indraq_cli 1.5.8 → 1.9.1

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 (274) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1517 -1686
  3. package/cloud-api/.dockerignore +18 -0
  4. package/cloud-api/.env.example +14 -0
  5. package/cloud-api/Dockerfile +19 -0
  6. package/cloud-api/README.md +141 -0
  7. package/cloud-api/package-lock.json +2250 -0
  8. package/cloud-api/package.json +29 -0
  9. package/cloud-api/sql/001_init.sql +8 -0
  10. package/cloud-api/sql/002_user_providers_and_project_resources.sql +40 -0
  11. package/cloud-api/sql/003_environment_infrastructure.sql +19 -0
  12. package/cloud-api/sql/004_managed_aws_credentials.sql +20 -0
  13. package/cloud-api/sql/005_project_members_and_resource_grants.sql +22 -0
  14. package/cloud-api/sql/006_catalog_identity_password_security.sql +96 -0
  15. package/cloud-api/sql/007_aws_access_key_rotation.sql +16 -0
  16. package/cloud-api/src/index.ts +1254 -0
  17. package/cloud-api/tsconfig.json +18 -0
  18. package/dist/cli/create-program.d.ts.map +1 -1
  19. package/dist/cli/create-program.js +21 -3
  20. package/dist/cli/create-program.js.map +1 -1
  21. package/dist/cli/doctor.command.d.ts +1 -1
  22. package/dist/cli/doctor.command.d.ts.map +1 -1
  23. package/dist/cli/doctor.command.js +70 -12
  24. package/dist/cli/doctor.command.js.map +1 -1
  25. package/dist/cli/help-content.d.ts +1 -1
  26. package/dist/cli/help-content.d.ts.map +1 -1
  27. package/dist/cli/help-content.js +256 -177
  28. package/dist/cli/help-content.js.map +1 -1
  29. package/dist/modules/access/commands/access.command.d.ts +3 -0
  30. package/dist/modules/access/commands/access.command.d.ts.map +1 -0
  31. package/dist/modules/access/commands/access.command.js +226 -0
  32. package/dist/modules/access/commands/access.command.js.map +1 -0
  33. package/dist/modules/access/index.d.ts +3 -0
  34. package/dist/modules/access/index.d.ts.map +1 -0
  35. package/dist/modules/access/index.js +11 -0
  36. package/dist/modules/access/index.js.map +1 -0
  37. package/dist/modules/aws/commands/configure-aws.command.d.ts +2 -0
  38. package/dist/modules/aws/commands/configure-aws.command.d.ts.map +1 -0
  39. package/dist/modules/aws/commands/configure-aws.command.js +7 -0
  40. package/dist/modules/aws/commands/configure-aws.command.js.map +1 -0
  41. package/dist/modules/aws/commands/dns.command.d.ts +22 -0
  42. package/dist/modules/aws/commands/dns.command.d.ts.map +1 -0
  43. package/dist/modules/aws/commands/dns.command.js +229 -0
  44. package/dist/modules/aws/commands/dns.command.js.map +1 -0
  45. package/dist/modules/aws/commands/healthcheck.command.d.ts +22 -0
  46. package/dist/modules/aws/commands/healthcheck.command.d.ts.map +1 -0
  47. package/dist/modules/aws/commands/healthcheck.command.js +125 -0
  48. package/dist/modules/aws/commands/healthcheck.command.js.map +1 -0
  49. package/dist/modules/aws/commands/iam.command.d.ts +24 -0
  50. package/dist/modules/aws/commands/iam.command.d.ts.map +1 -0
  51. package/dist/modules/aws/commands/iam.command.js +219 -0
  52. package/dist/modules/aws/commands/iam.command.js.map +1 -0
  53. package/dist/modules/aws/config/aws-config.d.ts +23 -0
  54. package/dist/modules/aws/config/aws-config.d.ts.map +1 -0
  55. package/dist/modules/aws/config/aws-config.js +72 -0
  56. package/dist/modules/aws/config/aws-config.js.map +1 -0
  57. package/dist/modules/aws/index.d.ts +3 -0
  58. package/dist/modules/aws/index.d.ts.map +1 -0
  59. package/dist/modules/aws/index.js +54 -0
  60. package/dist/modules/aws/index.js.map +1 -0
  61. package/dist/modules/aws/services/aws-clients.d.ts +9 -0
  62. package/dist/modules/aws/services/aws-clients.d.ts.map +1 -0
  63. package/dist/modules/aws/services/aws-clients.js +43 -0
  64. package/dist/modules/aws/services/aws-clients.js.map +1 -0
  65. package/dist/modules/aws/services/route53-lookup.service.d.ts +9 -0
  66. package/dist/modules/aws/services/route53-lookup.service.d.ts.map +1 -0
  67. package/dist/modules/aws/services/route53-lookup.service.js +57 -0
  68. package/dist/modules/aws/services/route53-lookup.service.js.map +1 -0
  69. package/dist/modules/cloud/commands/cloud.command.d.ts +38 -0
  70. package/dist/modules/cloud/commands/cloud.command.d.ts.map +1 -0
  71. package/dist/modules/cloud/commands/cloud.command.js +443 -0
  72. package/dist/modules/cloud/commands/cloud.command.js.map +1 -0
  73. package/dist/modules/cloud/commands/credentials.command.d.ts +5 -0
  74. package/dist/modules/cloud/commands/credentials.command.d.ts.map +1 -0
  75. package/dist/modules/cloud/commands/credentials.command.js +25 -0
  76. package/dist/modules/cloud/commands/credentials.command.js.map +1 -0
  77. package/dist/modules/cloud/commands/environment.command.d.ts +6 -0
  78. package/dist/modules/cloud/commands/environment.command.d.ts.map +1 -0
  79. package/dist/modules/cloud/commands/environment.command.js +75 -0
  80. package/dist/modules/cloud/commands/environment.command.js.map +1 -0
  81. package/dist/modules/cloud/commands/provider.command.d.ts +3 -0
  82. package/dist/modules/cloud/commands/provider.command.d.ts.map +1 -0
  83. package/dist/modules/cloud/commands/provider.command.js +193 -0
  84. package/dist/modules/cloud/commands/provider.command.js.map +1 -0
  85. package/dist/modules/cloud/config/cloud-config.d.ts +19 -0
  86. package/dist/modules/cloud/config/cloud-config.d.ts.map +1 -0
  87. package/dist/modules/cloud/config/cloud-config.js +53 -0
  88. package/dist/modules/cloud/config/cloud-config.js.map +1 -0
  89. package/dist/modules/cloud/index.d.ts +3 -0
  90. package/dist/modules/cloud/index.d.ts.map +1 -0
  91. package/dist/modules/cloud/index.js +62 -0
  92. package/dist/modules/cloud/index.js.map +1 -0
  93. package/dist/modules/cloud/services/cloud-api.service.d.ts +17 -0
  94. package/dist/modules/cloud/services/cloud-api.service.d.ts.map +1 -0
  95. package/dist/modules/cloud/services/cloud-api.service.js +61 -0
  96. package/dist/modules/cloud/services/cloud-api.service.js.map +1 -0
  97. package/dist/modules/cloud/services/cloud-aws.service.d.ts +23 -0
  98. package/dist/modules/cloud/services/cloud-aws.service.d.ts.map +1 -0
  99. package/dist/modules/cloud/services/cloud-aws.service.js +26 -0
  100. package/dist/modules/cloud/services/cloud-aws.service.js.map +1 -0
  101. package/dist/modules/cloud/services/cloud-ghcr.service.d.ts +12 -0
  102. package/dist/modules/cloud/services/cloud-ghcr.service.d.ts.map +1 -0
  103. package/dist/modules/cloud/services/cloud-ghcr.service.js +31 -0
  104. package/dist/modules/cloud/services/cloud-ghcr.service.js.map +1 -0
  105. package/dist/modules/cloud/services/cloud-jenkins.service.d.ts +29 -0
  106. package/dist/modules/cloud/services/cloud-jenkins.service.d.ts.map +1 -0
  107. package/dist/modules/cloud/services/cloud-jenkins.service.js +236 -0
  108. package/dist/modules/cloud/services/cloud-jenkins.service.js.map +1 -0
  109. package/dist/modules/cloud/services/cloud-npm.service.d.ts +3 -0
  110. package/dist/modules/cloud/services/cloud-npm.service.d.ts.map +1 -0
  111. package/dist/modules/cloud/services/cloud-npm.service.js +13 -0
  112. package/dist/modules/cloud/services/cloud-npm.service.js.map +1 -0
  113. package/dist/modules/cloud/services/environment.service.d.ts +25 -0
  114. package/dist/modules/cloud/services/environment.service.d.ts.map +1 -0
  115. package/dist/modules/cloud/services/environment.service.js +21 -0
  116. package/dist/modules/cloud/services/environment.service.js.map +1 -0
  117. package/dist/modules/cloud/services/managed-aws-credential.service.d.ts +36 -0
  118. package/dist/modules/cloud/services/managed-aws-credential.service.d.ts.map +1 -0
  119. package/dist/modules/cloud/services/managed-aws-credential.service.js +35 -0
  120. package/dist/modules/cloud/services/managed-aws-credential.service.js.map +1 -0
  121. package/dist/modules/cloud/services/project-cloud.service.d.ts +28 -0
  122. package/dist/modules/cloud/services/project-cloud.service.d.ts.map +1 -0
  123. package/dist/modules/cloud/services/project-cloud.service.js +50 -0
  124. package/dist/modules/cloud/services/project-cloud.service.js.map +1 -0
  125. package/dist/modules/cloud/services/user-provider.service.d.ts +17 -0
  126. package/dist/modules/cloud/services/user-provider.service.d.ts.map +1 -0
  127. package/dist/modules/cloud/services/user-provider.service.js +25 -0
  128. package/dist/modules/cloud/services/user-provider.service.js.map +1 -0
  129. package/dist/modules/configure/configure.command.d.ts.map +1 -1
  130. package/dist/modules/configure/configure.command.js +17 -94
  131. package/dist/modules/configure/configure.command.js.map +1 -1
  132. package/dist/modules/deploy/commands/build.command.d.ts +1 -2
  133. package/dist/modules/deploy/commands/build.command.d.ts.map +1 -1
  134. package/dist/modules/deploy/commands/build.command.js +82 -124
  135. package/dist/modules/deploy/commands/build.command.js.map +1 -1
  136. package/dist/modules/deploy/index.d.ts.map +1 -1
  137. package/dist/modules/deploy/index.js +10 -30
  138. package/dist/modules/deploy/index.js.map +1 -1
  139. package/dist/modules/deploy/services/docker.service.d.ts +6 -3
  140. package/dist/modules/deploy/services/docker.service.d.ts.map +1 -1
  141. package/dist/modules/deploy/services/docker.service.js +8 -11
  142. package/dist/modules/deploy/services/docker.service.js.map +1 -1
  143. package/dist/modules/dockerfile/commands/create-dockerfile.command.d.ts +13 -0
  144. package/dist/modules/dockerfile/commands/create-dockerfile.command.d.ts.map +1 -0
  145. package/dist/modules/dockerfile/commands/create-dockerfile.command.js +39 -0
  146. package/dist/modules/dockerfile/commands/create-dockerfile.command.js.map +1 -0
  147. package/dist/modules/dockerfile/index.d.ts +3 -0
  148. package/dist/modules/dockerfile/index.d.ts.map +1 -0
  149. package/dist/modules/dockerfile/index.js +7 -0
  150. package/dist/modules/dockerfile/index.js.map +1 -0
  151. package/dist/modules/jenkins/commands/admin.command.d.ts +22 -0
  152. package/dist/modules/jenkins/commands/admin.command.d.ts.map +1 -0
  153. package/dist/modules/jenkins/commands/admin.command.js +128 -0
  154. package/dist/modules/jenkins/commands/admin.command.js.map +1 -0
  155. package/dist/modules/jenkins/commands/create-deployment.command.d.ts +13 -0
  156. package/dist/modules/jenkins/commands/create-deployment.command.d.ts.map +1 -0
  157. package/dist/modules/jenkins/commands/create-deployment.command.js +115 -0
  158. package/dist/modules/jenkins/commands/create-deployment.command.js.map +1 -0
  159. package/dist/modules/jenkins/index.d.ts +3 -0
  160. package/dist/modules/jenkins/index.d.ts.map +1 -0
  161. package/dist/modules/jenkins/index.js +28 -0
  162. package/dist/modules/jenkins/index.js.map +1 -0
  163. package/dist/modules/mobile/commands/build-mobile.command.d.ts.map +1 -1
  164. package/dist/modules/mobile/commands/build-mobile.command.js +4 -22
  165. package/dist/modules/mobile/commands/build-mobile.command.js.map +1 -1
  166. package/dist/modules/mobile/commands/configure-mobile.command.d.ts +1 -1
  167. package/dist/modules/mobile/commands/configure-mobile.command.d.ts.map +1 -1
  168. package/dist/modules/mobile/commands/configure-mobile.command.js +11 -9
  169. package/dist/modules/mobile/commands/configure-mobile.command.js.map +1 -1
  170. package/dist/modules/mobile/services/jenkins-mobile.service.d.ts +2 -2
  171. package/dist/modules/mobile/services/jenkins-mobile.service.d.ts.map +1 -1
  172. package/dist/modules/mobile/services/jenkins-mobile.service.js +1 -2
  173. package/dist/modules/mobile/services/jenkins-mobile.service.js.map +1 -1
  174. package/dist/modules/mobile/services/project.service.d.ts +2 -2
  175. package/dist/modules/mobile/services/project.service.d.ts.map +1 -1
  176. package/dist/modules/prebuild/commands/prebuild.command.d.ts +13 -0
  177. package/dist/modules/prebuild/commands/prebuild.command.d.ts.map +1 -0
  178. package/dist/modules/prebuild/commands/prebuild.command.js +507 -0
  179. package/dist/modules/prebuild/commands/prebuild.command.js.map +1 -0
  180. package/dist/modules/prebuild/index.d.ts +3 -0
  181. package/dist/modules/prebuild/index.d.ts.map +1 -0
  182. package/dist/modules/prebuild/index.js +19 -0
  183. package/dist/modules/prebuild/index.js.map +1 -0
  184. package/dist/modules/proxy/commands/configure-proxy.command.d.ts +2 -0
  185. package/dist/modules/proxy/commands/configure-proxy.command.d.ts.map +1 -0
  186. package/dist/modules/proxy/commands/configure-proxy.command.js +7 -0
  187. package/dist/modules/proxy/commands/configure-proxy.command.js.map +1 -0
  188. package/dist/modules/proxy/commands/npm-user.command.d.ts +28 -0
  189. package/dist/modules/proxy/commands/npm-user.command.d.ts.map +1 -0
  190. package/dist/modules/proxy/commands/npm-user.command.js +77 -0
  191. package/dist/modules/proxy/commands/npm-user.command.js.map +1 -0
  192. package/dist/modules/proxy/commands/proxy.command.d.ts +22 -0
  193. package/dist/modules/proxy/commands/proxy.command.d.ts.map +1 -0
  194. package/dist/modules/proxy/commands/proxy.command.js +173 -0
  195. package/dist/modules/proxy/commands/proxy.command.js.map +1 -0
  196. package/dist/modules/proxy/config/npm-config.d.ts +17 -0
  197. package/dist/modules/proxy/config/npm-config.d.ts.map +1 -0
  198. package/dist/modules/proxy/config/npm-config.js +50 -0
  199. package/dist/modules/proxy/config/npm-config.js.map +1 -0
  200. package/dist/modules/proxy/index.d.ts +3 -0
  201. package/dist/modules/proxy/index.d.ts.map +1 -0
  202. package/dist/modules/proxy/index.js +21 -0
  203. package/dist/modules/proxy/index.js.map +1 -0
  204. package/dist/modules/proxy/services/npm-api.service.d.ts +76 -0
  205. package/dist/modules/proxy/services/npm-api.service.d.ts.map +1 -0
  206. package/dist/modules/proxy/services/npm-api.service.js +82 -0
  207. package/dist/modules/proxy/services/npm-api.service.js.map +1 -0
  208. package/dist/modules/scaffold/commands/init.command.d.ts +6 -0
  209. package/dist/modules/scaffold/commands/init.command.d.ts.map +1 -0
  210. package/dist/modules/scaffold/commands/init.command.js +193 -0
  211. package/dist/modules/scaffold/commands/init.command.js.map +1 -0
  212. package/dist/modules/scaffold/config/project-metadata.d.ts +9 -0
  213. package/dist/modules/scaffold/config/project-metadata.d.ts.map +1 -0
  214. package/dist/modules/scaffold/config/project-metadata.js +75 -0
  215. package/dist/modules/scaffold/config/project-metadata.js.map +1 -0
  216. package/dist/modules/scaffold/index.d.ts +3 -0
  217. package/dist/modules/scaffold/index.d.ts.map +1 -0
  218. package/dist/modules/scaffold/index.js +7 -0
  219. package/dist/modules/scaffold/index.js.map +1 -0
  220. package/dist/modules/scaffold/services/docker-template.service.d.ts +3 -0
  221. package/dist/modules/scaffold/services/docker-template.service.d.ts.map +1 -0
  222. package/dist/modules/scaffold/services/docker-template.service.js +131 -0
  223. package/dist/modules/scaffold/services/docker-template.service.js.map +1 -0
  224. package/dist/modules/scaffold/services/filesystem.service.d.ts +7 -0
  225. package/dist/modules/scaffold/services/filesystem.service.d.ts.map +1 -0
  226. package/dist/modules/scaffold/services/filesystem.service.js +97 -0
  227. package/dist/modules/scaffold/services/filesystem.service.js.map +1 -0
  228. package/dist/modules/scaffold/services/project-template.service.d.ts +4 -0
  229. package/dist/modules/scaffold/services/project-template.service.d.ts.map +1 -0
  230. package/dist/modules/scaffold/services/project-template.service.js +82 -0
  231. package/dist/modules/scaffold/services/project-template.service.js.map +1 -0
  232. package/dist/modules/scaffold/types.d.ts +65 -0
  233. package/dist/modules/scaffold/types.d.ts.map +1 -0
  234. package/dist/modules/scaffold/types.js +3 -0
  235. package/dist/modules/scaffold/types.js.map +1 -0
  236. package/dist/modules/users/commands/user.command.d.ts +22 -0
  237. package/dist/modules/users/commands/user.command.d.ts.map +1 -0
  238. package/dist/modules/users/commands/user.command.js +350 -0
  239. package/dist/modules/users/commands/user.command.js.map +1 -0
  240. package/dist/modules/users/index.d.ts +3 -0
  241. package/dist/modules/users/index.d.ts.map +1 -0
  242. package/dist/modules/users/index.js +34 -0
  243. package/dist/modules/users/index.js.map +1 -0
  244. package/dist/modules/users/providers/aws-user.provider.d.ts +11 -0
  245. package/dist/modules/users/providers/aws-user.provider.d.ts.map +1 -0
  246. package/dist/modules/users/providers/aws-user.provider.js +129 -0
  247. package/dist/modules/users/providers/aws-user.provider.js.map +1 -0
  248. package/dist/modules/users/providers/jenkins-user.provider.d.ts +6 -0
  249. package/dist/modules/users/providers/jenkins-user.provider.d.ts.map +1 -0
  250. package/dist/modules/users/providers/jenkins-user.provider.js +97 -0
  251. package/dist/modules/users/providers/jenkins-user.provider.js.map +1 -0
  252. package/dist/modules/users/providers/npm-user.provider.d.ts +4 -0
  253. package/dist/modules/users/providers/npm-user.provider.d.ts.map +1 -0
  254. package/dist/modules/users/providers/npm-user.provider.js +47 -0
  255. package/dist/modules/users/providers/npm-user.provider.js.map +1 -0
  256. package/dist/shared/config/config-files.d.ts.map +1 -1
  257. package/dist/shared/config/config-files.js +14 -10
  258. package/dist/shared/config/config-files.js.map +1 -1
  259. package/dist/shared/github/github-api.service.d.ts.map +1 -1
  260. package/dist/shared/github/github-api.service.js +25 -37
  261. package/dist/shared/github/github-api.service.js.map +1 -1
  262. package/dist/shared/jenkins/jenkins.service.d.ts +2 -0
  263. package/dist/shared/jenkins/jenkins.service.d.ts.map +1 -1
  264. package/dist/shared/jenkins/jenkins.service.js +30 -1
  265. package/dist/shared/jenkins/jenkins.service.js.map +1 -1
  266. package/dist/shared/listing.d.ts +9 -0
  267. package/dist/shared/listing.d.ts.map +1 -0
  268. package/dist/shared/listing.js +29 -0
  269. package/dist/shared/listing.js.map +1 -0
  270. package/docs/ARCHITECTURE.md +29 -0
  271. package/docs/CREATE-DEPLOYMENT-reference.groovy +1105 -0
  272. package/package.json +76 -59
  273. package/templates/jenkins/CREATE-DEPLOYMENT.groovy +1105 -0
  274. package/templates/jenkins/Jenkinsfile-Mobile-App +759 -759
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@indraq/cloud-api",
3
+ "private": true,
4
+ "version": "0.4.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "tsx watch src/index.ts",
8
+ "build": "tsc",
9
+ "start": "node dist/index.js"
10
+ },
11
+ "dependencies": {
12
+ "bcryptjs": "^3.0.2",
13
+ "dotenv": "^17.2.2",
14
+ "express": "^5.1.0",
15
+ "jsonwebtoken": "^9.0.2",
16
+ "pg": "^8.16.3",
17
+ "nodemailer": "^6.9.16",
18
+ "@aws-sdk/client-iam": "^3.1123.0"
19
+ },
20
+ "devDependencies": {
21
+ "@types/express": "^5.0.3",
22
+ "@types/jsonwebtoken": "^9.0.10",
23
+ "@types/node": "^24.3.0",
24
+ "@types/pg": "^8.15.5",
25
+ "tsx": "^4.20.5",
26
+ "typescript": "^5.9.2",
27
+ "@types/nodemailer": "^6.4.17"
28
+ }
29
+ }
@@ -0,0 +1,8 @@
1
+ CREATE EXTENSION IF NOT EXISTS pgcrypto;
2
+ CREATE TABLE IF NOT EXISTS users (id uuid PRIMARY KEY DEFAULT gen_random_uuid(), email text UNIQUE NOT NULL, name text NOT NULL, password_hash text NOT NULL, role text NOT NULL CHECK (role IN ('user','manager','admin')), is_active boolean NOT NULL DEFAULT true, created_by uuid REFERENCES users(id), created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now());
3
+ CREATE TABLE IF NOT EXISTS projects (id uuid PRIMARY KEY DEFAULT gen_random_uuid(), name text NOT NULL, kind text NOT NULL, config jsonb NOT NULL DEFAULT '{}'::jsonb, created_by uuid NOT NULL REFERENCES users(id), created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now());
4
+ CREATE TABLE IF NOT EXISTS project_members (project_id uuid REFERENCES projects(id) ON DELETE CASCADE, user_id uuid REFERENCES users(id) ON DELETE CASCADE, role text NOT NULL DEFAULT 'user', PRIMARY KEY(project_id,user_id));
5
+ CREATE TABLE IF NOT EXISTS servers (id uuid PRIMARY KEY DEFAULT gen_random_uuid(), name text NOT NULL UNIQUE, environment text NOT NULL, ipv4 inet NOT NULL, health_path text DEFAULT '/health', is_backup boolean NOT NULL DEFAULT false, created_by uuid NOT NULL REFERENCES users(id), created_at timestamptz NOT NULL DEFAULT now());
6
+ CREATE TABLE IF NOT EXISTS project_integrations (id uuid PRIMARY KEY DEFAULT gen_random_uuid(), project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE, provider text NOT NULL, config jsonb NOT NULL DEFAULT '{}'::jsonb, encrypted_secret text, UNIQUE(project_id,provider));
7
+ CREATE TABLE IF NOT EXISTS audit_logs (id bigserial PRIMARY KEY, actor_id uuid REFERENCES users(id), action text NOT NULL, resource_type text NOT NULL, resource_id text, reason text, metadata jsonb NOT NULL DEFAULT '{}'::jsonb, created_at timestamptz NOT NULL DEFAULT now());
8
+ CREATE INDEX IF NOT EXISTS audit_logs_created_at_idx ON audit_logs(created_at DESC);
@@ -0,0 +1,40 @@
1
+ CREATE TABLE IF NOT EXISTS user_integrations (
2
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
3
+ user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
4
+ provider text NOT NULL,
5
+ config jsonb NOT NULL DEFAULT '{}'::jsonb,
6
+ encrypted_secret text,
7
+ created_at timestamptz NOT NULL DEFAULT now(),
8
+ updated_at timestamptz NOT NULL DEFAULT now(),
9
+ UNIQUE(user_id, provider)
10
+ );
11
+
12
+ CREATE INDEX IF NOT EXISTS user_integrations_user_idx
13
+ ON user_integrations(user_id, provider);
14
+
15
+ CREATE TABLE IF NOT EXISTS project_resources (
16
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
17
+ project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
18
+ environment text NOT NULL DEFAULT 'dev',
19
+ resource_type text NOT NULL,
20
+ provider text NOT NULL,
21
+ provider_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
22
+ external_id text,
23
+ config jsonb NOT NULL DEFAULT '{}'::jsonb,
24
+ created_by uuid REFERENCES users(id),
25
+ updated_by uuid REFERENCES users(id),
26
+ created_at timestamptz NOT NULL DEFAULT now(),
27
+ updated_at timestamptz NOT NULL DEFAULT now(),
28
+ UNIQUE(project_id, environment, resource_type)
29
+ );
30
+
31
+ CREATE INDEX IF NOT EXISTS project_resources_project_idx
32
+ ON project_resources(project_id, environment, resource_type);
33
+
34
+ CREATE INDEX IF NOT EXISTS project_resources_provider_user_idx
35
+ ON project_resources(provider_user_id, provider);
36
+
37
+ -- provider credentials belong to an authenticated IndraQ user and are
38
+ -- reusable across every project that user can access. Project resources keep
39
+ -- only infrastructure associations plus the user whose provider profile last
40
+ -- reconciled the resource.
@@ -0,0 +1,19 @@
1
+ -- shared admin-managed named environments.
2
+ -- Environments are generic reusable targets. PRIMARY/SECONDARY is assigned only
3
+ -- when a project creates a FAILOVER Route53 record.
4
+ CREATE TABLE IF NOT EXISTS environments (
5
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
6
+ name text NOT NULL UNIQUE,
7
+ description text,
8
+ ipv4 inet NOT NULL,
9
+ region text,
10
+ health_path text NOT NULL DEFAULT '/health',
11
+ created_by uuid NOT NULL REFERENCES users(id),
12
+ created_at timestamptz NOT NULL DEFAULT now(),
13
+ updated_at timestamptz NOT NULL DEFAULT now()
14
+ );
15
+
16
+ CREATE INDEX IF NOT EXISTS environments_name_idx ON environments(name);
17
+
18
+ ALTER TABLE project_resources
19
+ ADD COLUMN IF NOT EXISTS environment_id uuid REFERENCES environments(id) ON DELETE SET NULL;
@@ -0,0 +1,20 @@
1
+ -- managed AWS IAM credentials.
2
+ -- AWS only returns SecretAccessKey when an access key is created. IndraQ stores
3
+ -- the generated secret encrypted in Cloud so the owning IndraQ user can resolve
4
+ -- it later without relying on AWS to recover it.
5
+ CREATE TABLE IF NOT EXISTS managed_aws_credentials (
6
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
7
+ cloud_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
8
+ aws_username text NOT NULL,
9
+ access_key_id text NOT NULL,
10
+ encrypted_secret_access_key text NOT NULL,
11
+ indraq_role text NOT NULL CHECK (indraq_role IN ('user','manager','admin')),
12
+ created_by uuid REFERENCES users(id) ON DELETE SET NULL,
13
+ created_at timestamptz NOT NULL DEFAULT now(),
14
+ updated_at timestamptz NOT NULL DEFAULT now(),
15
+ UNIQUE(cloud_user_id, aws_username),
16
+ UNIQUE(access_key_id)
17
+ );
18
+
19
+ CREATE INDEX IF NOT EXISTS managed_aws_credentials_user_idx
20
+ ON managed_aws_credentials(cloud_user_id, aws_username);
@@ -0,0 +1,22 @@
1
+ -- Project membership and per-resource access grants.
2
+ -- Project membership lets a user work with a project; resource grants control
3
+ -- which provider resources a normal user can read/update. Managers/admins can
4
+ -- manage membership and grants with audited reasons.
5
+ ALTER TABLE project_members
6
+ ADD COLUMN IF NOT EXISTS added_by uuid REFERENCES users(id) ON DELETE SET NULL,
7
+ ADD COLUMN IF NOT EXISTS added_at timestamptz NOT NULL DEFAULT now();
8
+
9
+ CREATE TABLE IF NOT EXISTS project_resource_grants (
10
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
11
+ project_resource_id uuid NOT NULL REFERENCES project_resources(id) ON DELETE CASCADE,
12
+ user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
13
+ permission text NOT NULL DEFAULT 'manage' CHECK (permission IN ('view','manage')),
14
+ created_by uuid REFERENCES users(id) ON DELETE SET NULL,
15
+ created_at timestamptz NOT NULL DEFAULT now(),
16
+ UNIQUE(project_resource_id, user_id)
17
+ );
18
+
19
+ CREATE INDEX IF NOT EXISTS project_resource_grants_user_idx
20
+ ON project_resource_grants(user_id, project_resource_id);
21
+ CREATE INDEX IF NOT EXISTS project_resource_grants_resource_idx
22
+ ON project_resource_grants(project_resource_id, user_id);
@@ -0,0 +1,96 @@
1
+ -- Organization-wide catalog constraints, project access levels, first-login
2
+ -- password changes, self-service OTP resets, and managed external identities.
3
+
4
+ ALTER TABLE users
5
+ ADD COLUMN IF NOT EXISTS must_change_password boolean NOT NULL DEFAULT false,
6
+ ADD COLUMN IF NOT EXISTS password_changed_at timestamptz,
7
+ ADD COLUMN IF NOT EXISTS last_login_at timestamptz;
8
+
9
+ ALTER TABLE project_members
10
+ ADD COLUMN IF NOT EXISTS access_level text NOT NULL DEFAULT 'write';
11
+
12
+ DO $$
13
+ BEGIN
14
+ IF NOT EXISTS (
15
+ SELECT 1 FROM pg_constraint WHERE conname = 'project_members_access_level_check'
16
+ ) THEN
17
+ ALTER TABLE project_members
18
+ ADD CONSTRAINT project_members_access_level_check
19
+ CHECK (access_level IN ('view','write'));
20
+ END IF;
21
+ END $$;
22
+
23
+ UPDATE project_members SET access_level='write' WHERE role='owner';
24
+
25
+ -- Resolve historical duplicate project names before enforcing organization-wide
26
+ -- case-insensitive uniqueness. The oldest row keeps the original display name.
27
+ WITH ranked AS (
28
+ SELECT id, name,
29
+ row_number() OVER (PARTITION BY lower(name) ORDER BY created_at, id) AS rn
30
+ FROM projects
31
+ )
32
+ UPDATE projects p
33
+ SET name = p.name || '-legacy-' || left(p.id::text, 8), updated_at=now()
34
+ FROM ranked r
35
+ WHERE p.id=r.id AND r.rn > 1;
36
+
37
+ CREATE UNIQUE INDEX IF NOT EXISTS projects_name_lower_unique_idx
38
+ ON projects (lower(name));
39
+
40
+ -- GHCR image names are organization-wide claims. Resolve historical duplicate
41
+ -- DB claims before adding the unique index; this does not mutate any registry.
42
+ WITH ranked AS (
43
+ SELECT id,
44
+ row_number() OVER (
45
+ PARTITION BY lower(config->>'fullImage')
46
+ ORDER BY created_at, id
47
+ ) AS rn
48
+ FROM project_resources
49
+ WHERE provider='ghcr'
50
+ AND config ? 'fullImage'
51
+ AND coalesce(config->>'fullImage','') <> ''
52
+ )
53
+ UPDATE project_resources pr
54
+ SET config = jsonb_set(
55
+ jsonb_set(pr.config, '{fullImage}', to_jsonb((pr.config->>'fullImage') || '-legacy-' || left(pr.id::text,8)), true),
56
+ '{imageName}', to_jsonb(coalesce(pr.config->>'imageName','image') || '-legacy-' || left(pr.id::text,8)), true
57
+ ),
58
+ updated_at=now()
59
+ FROM ranked r
60
+ WHERE pr.id=r.id AND r.rn > 1;
61
+
62
+ CREATE UNIQUE INDEX IF NOT EXISTS project_resources_ghcr_full_image_unique_idx
63
+ ON project_resources ((lower(config->>'fullImage')))
64
+ WHERE provider='ghcr'
65
+ AND config ? 'fullImage'
66
+ AND coalesce(config->>'fullImage','') <> '';
67
+
68
+ CREATE TABLE IF NOT EXISTS managed_external_accounts (
69
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
70
+ cloud_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
71
+ provider text NOT NULL CHECK (provider IN ('npm','jenkins-dev','jenkins-prod')),
72
+ external_username text NOT NULL,
73
+ external_email text,
74
+ managed_by_user_id uuid REFERENCES users(id) ON DELETE SET NULL,
75
+ config jsonb NOT NULL DEFAULT '{}'::jsonb,
76
+ created_at timestamptz NOT NULL DEFAULT now(),
77
+ updated_at timestamptz NOT NULL DEFAULT now(),
78
+ UNIQUE(cloud_user_id, provider)
79
+ );
80
+
81
+ CREATE INDEX IF NOT EXISTS managed_external_accounts_manager_idx
82
+ ON managed_external_accounts(managed_by_user_id, provider);
83
+
84
+ CREATE TABLE IF NOT EXISTS password_reset_otps (
85
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
86
+ user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
87
+ otp_hash text NOT NULL,
88
+ expires_at timestamptz NOT NULL,
89
+ attempts integer NOT NULL DEFAULT 0,
90
+ max_attempts integer NOT NULL DEFAULT 5,
91
+ used_at timestamptz,
92
+ created_at timestamptz NOT NULL DEFAULT now()
93
+ );
94
+
95
+ CREATE INDEX IF NOT EXISTS password_reset_otps_user_idx
96
+ ON password_reset_otps(user_id, created_at DESC);
@@ -0,0 +1,16 @@
1
+ -- AWS access-key rotation ownership.
2
+ -- The manager/admin provider that manages an IAM user's key is tracked so a
3
+ -- normal user can request self-service rotation without receiving broad IAM
4
+ -- permissions. Managers/admins can rotate keys for users they are allowed to
5
+ -- manage. Secret access keys remain encrypted at rest in IndraQ Cloud.
6
+
7
+ ALTER TABLE managed_aws_credentials
8
+ ADD COLUMN IF NOT EXISTS managed_by_user_id uuid REFERENCES users(id) ON DELETE SET NULL;
9
+
10
+ UPDATE managed_aws_credentials
11
+ SET managed_by_user_id = created_by
12
+ WHERE managed_by_user_id IS NULL
13
+ AND created_by IS NOT NULL;
14
+
15
+ CREATE INDEX IF NOT EXISTS managed_aws_credentials_manager_idx
16
+ ON managed_aws_credentials(managed_by_user_id, cloud_user_id);