@superblocksteam/shared 0.9598.1 → 0.9599.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 (56) hide show
  1. package/dist/database-lifecycle/index.d.ts +26 -2
  2. package/dist/database-lifecycle/index.d.ts.map +1 -1
  3. package/dist/database-lifecycle/index.js +122 -3
  4. package/dist/database-lifecycle/index.js.map +1 -1
  5. package/dist/database-lifecycle/index.test.js +90 -6
  6. package/dist/database-lifecycle/index.test.js.map +1 -1
  7. package/dist/plugins/templates/postgres.d.ts.map +1 -1
  8. package/dist/plugins/templates/postgres.js +164 -1
  9. package/dist/plugins/templates/postgres.js.map +1 -1
  10. package/dist/plugins/templates/postgres.test.d.ts +2 -0
  11. package/dist/plugins/templates/postgres.test.d.ts.map +1 -0
  12. package/dist/plugins/templates/postgres.test.js +224 -0
  13. package/dist/plugins/templates/postgres.test.js.map +1 -0
  14. package/dist/types/datasource/auth.d.ts +4 -0
  15. package/dist/types/datasource/auth.d.ts.map +1 -1
  16. package/dist/types/datasource/auth.js +6 -1
  17. package/dist/types/datasource/auth.js.map +1 -1
  18. package/dist/types/datasource/index.d.ts +104 -3
  19. package/dist/types/datasource/index.d.ts.map +1 -1
  20. package/dist/types/datasource/index.js.map +1 -1
  21. package/dist/types/deployment/deployQueueStatus.d.ts +3 -1
  22. package/dist/types/deployment/deployQueueStatus.d.ts.map +1 -1
  23. package/dist/types/deployment/deployQueueStatus.js +2 -0
  24. package/dist/types/deployment/deployQueueStatus.js.map +1 -1
  25. package/dist-esm/database-lifecycle/index.d.ts +26 -2
  26. package/dist-esm/database-lifecycle/index.d.ts.map +1 -1
  27. package/dist-esm/database-lifecycle/index.js +117 -2
  28. package/dist-esm/database-lifecycle/index.js.map +1 -1
  29. package/dist-esm/database-lifecycle/index.test.js +91 -7
  30. package/dist-esm/database-lifecycle/index.test.js.map +1 -1
  31. package/dist-esm/plugins/templates/postgres.d.ts.map +1 -1
  32. package/dist-esm/plugins/templates/postgres.js +165 -2
  33. package/dist-esm/plugins/templates/postgres.js.map +1 -1
  34. package/dist-esm/plugins/templates/postgres.test.d.ts +2 -0
  35. package/dist-esm/plugins/templates/postgres.test.d.ts.map +1 -0
  36. package/dist-esm/plugins/templates/postgres.test.js +222 -0
  37. package/dist-esm/plugins/templates/postgres.test.js.map +1 -0
  38. package/dist-esm/types/datasource/auth.d.ts +4 -0
  39. package/dist-esm/types/datasource/auth.d.ts.map +1 -1
  40. package/dist-esm/types/datasource/auth.js +5 -0
  41. package/dist-esm/types/datasource/auth.js.map +1 -1
  42. package/dist-esm/types/datasource/index.d.ts +104 -3
  43. package/dist-esm/types/datasource/index.d.ts.map +1 -1
  44. package/dist-esm/types/datasource/index.js.map +1 -1
  45. package/dist-esm/types/deployment/deployQueueStatus.d.ts +3 -1
  46. package/dist-esm/types/deployment/deployQueueStatus.d.ts.map +1 -1
  47. package/dist-esm/types/deployment/deployQueueStatus.js +2 -0
  48. package/dist-esm/types/deployment/deployQueueStatus.js.map +1 -1
  49. package/package.json +1 -1
  50. package/src/database-lifecycle/index.test.ts +107 -6
  51. package/src/database-lifecycle/index.ts +153 -10
  52. package/src/plugins/templates/postgres.test.ts +231 -0
  53. package/src/plugins/templates/postgres.ts +166 -2
  54. package/src/types/datasource/auth.ts +5 -0
  55. package/src/types/datasource/index.ts +115 -3
  56. package/src/types/deployment/deployQueueStatus.ts +3 -1
@@ -6,7 +6,8 @@ import {
6
6
  InputDataType,
7
7
  Plugin,
8
8
  PluginResponseType,
9
- PluginType
9
+ PluginType,
10
+ PostgresAuthType
10
11
  } from '../../types/index.js';
11
12
  import { PARAMETERIZED_SQL_DESCRIPTION, PUBLIC_INTEGRATIONS_LOGO_URL, DOCS_BASE_URL } from './constants.js';
12
13
  import { CONNECTION_METHODS_AND_DISPLAY_NAMES, makeDropdownItem } from './shared/db.js';
@@ -20,7 +21,8 @@ const PostgresPluginVersions = {
20
21
  V9: '0.0.9',
21
22
  V10: '0.0.10',
22
23
  V11: '0.0.11',
23
- V12: '0.0.12'
24
+ V12: '0.0.12',
25
+ V13: '0.0.13'
24
26
  };
25
27
 
26
28
  const BASE_HOST = {
@@ -191,45 +193,207 @@ export const PostgresPlugin: Plugin = {
191
193
  {
192
194
  ...BASE_DATABASE_NAME,
193
195
  startVersion: PostgresPluginVersions.V11,
196
+ endVersion: PostgresPluginVersions.V12,
194
197
  display: {
195
198
  show: {
196
199
  connectionType: ['fields']
197
200
  }
198
201
  }
199
202
  } as FormItem,
203
+ {
204
+ label: 'Database name',
205
+ name: 'authentication.custom.databaseName.value',
206
+ startVersion: PostgresPluginVersions.V13,
207
+ componentType: FormComponentType.INPUT_TEXT,
208
+ display: {
209
+ show: {
210
+ 'authentication.authType': ['', 'undefined', PostgresAuthType.PASSWORD],
211
+ connectionType: ['fields']
212
+ }
213
+ }
214
+ },
215
+ {
216
+ label: 'Database name',
217
+ name: 'authentication.custom.databaseName.value',
218
+ startVersion: PostgresPluginVersions.V13,
219
+ componentType: FormComponentType.INPUT_TEXT,
220
+ rules: [{ required: true, message: 'Database name is required' }],
221
+ display: {
222
+ show: {
223
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
224
+ connectionType: ['fields']
225
+ }
226
+ }
227
+ },
228
+ {
229
+ label: 'Authentication method',
230
+ name: 'authentication.authType',
231
+ startVersion: PostgresPluginVersions.V13,
232
+ componentType: FormComponentType.DROPDOWN,
233
+ initialValue: PostgresAuthType.PASSWORD,
234
+ options: [
235
+ {
236
+ displayName: 'Username & password',
237
+ key: PostgresAuthType.PASSWORD,
238
+ value: PostgresAuthType.PASSWORD
239
+ },
240
+ {
241
+ displayName: 'AWS IAM Role',
242
+ key: PostgresAuthType.AWS_IAM_ROLE,
243
+ value: PostgresAuthType.AWS_IAM_ROLE
244
+ }
245
+ ],
246
+ display: {
247
+ show: {
248
+ connectionType: ['fields']
249
+ }
250
+ }
251
+ },
252
+ {
253
+ label: 'Role ARN',
254
+ name: 'authentication.custom.iamRoleArn.value',
255
+ startVersion: PostgresPluginVersions.V13,
256
+ componentType: FormComponentType.INPUT_TEXT,
257
+ placeholder: 'arn:aws:iam::<account-id>:role/<role-name>',
258
+ rules: [{ required: true, message: 'Role ARN is required' }],
259
+ display: {
260
+ show: {
261
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
262
+ connectionType: ['fields']
263
+ }
264
+ }
265
+ },
266
+ {
267
+ label: 'Region',
268
+ name: 'authentication.custom.region.value',
269
+ startVersion: PostgresPluginVersions.V13,
270
+ componentType: FormComponentType.INPUT_TEXT,
271
+ placeholder: 'us-east-1',
272
+ rules: [{ required: true, message: 'Region is required' }],
273
+ display: {
274
+ show: {
275
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
276
+ connectionType: ['fields']
277
+ }
278
+ }
279
+ },
280
+ {
281
+ label: 'Session policy JSON (optional)',
282
+ name: 'authentication.custom.sessionPolicy.value',
283
+ startVersion: PostgresPluginVersions.V13,
284
+ componentType: FormComponentType.CODE_EDITOR,
285
+ language: EditorLanguage.JSON,
286
+ rules: [{ required: false }],
287
+ display: {
288
+ show: {
289
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
290
+ connectionType: ['fields']
291
+ }
292
+ }
293
+ },
200
294
  // DATABASE USERNAME
201
295
  { ...BASE_DATABASE_USERNAME, startVersion: PostgresPluginVersions.V1, endVersion: PostgresPluginVersions.V10 } as FormItem,
202
296
  {
203
297
  ...BASE_DATABASE_USERNAME,
204
298
  startVersion: PostgresPluginVersions.V11,
299
+ endVersion: PostgresPluginVersions.V12,
205
300
  display: {
206
301
  show: {
207
302
  connectionType: ['fields']
208
303
  }
209
304
  }
210
305
  } as FormItem,
306
+ {
307
+ label: 'Database username',
308
+ name: 'authentication.username',
309
+ startVersion: PostgresPluginVersions.V13,
310
+ componentType: FormComponentType.INPUT_TEXT,
311
+ display: {
312
+ show: {
313
+ 'authentication.authType': ['', 'undefined', PostgresAuthType.PASSWORD],
314
+ connectionType: ['fields']
315
+ }
316
+ }
317
+ },
318
+ {
319
+ label: 'Database username',
320
+ name: 'authentication.username',
321
+ startVersion: PostgresPluginVersions.V13,
322
+ componentType: FormComponentType.INPUT_TEXT,
323
+ rules: [{ required: true, message: 'Database username is required' }],
324
+ display: {
325
+ show: {
326
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
327
+ connectionType: ['fields']
328
+ }
329
+ }
330
+ },
211
331
  // DATABASE PASSWORD
212
332
  { ...BASE_DATABASE_PASSWORD, startVersion: PostgresPluginVersions.V1, endVersion: PostgresPluginVersions.V10 } as FormItem,
213
333
  {
214
334
  ...BASE_DATABASE_PASSWORD,
215
335
  startVersion: PostgresPluginVersions.V11,
336
+ endVersion: PostgresPluginVersions.V12,
216
337
  display: {
217
338
  show: {
218
339
  connectionType: ['fields']
219
340
  }
220
341
  }
221
342
  } as FormItem,
343
+ {
344
+ label: 'Database password',
345
+ name: 'authentication.password',
346
+ startVersion: PostgresPluginVersions.V13,
347
+ componentType: FormComponentType.INPUT_TEXT,
348
+ dataType: InputDataType.PASSWORD,
349
+ display: {
350
+ show: {
351
+ 'authentication.authType': ['', 'undefined', PostgresAuthType.PASSWORD],
352
+ connectionType: ['fields']
353
+ }
354
+ }
355
+ },
222
356
  // ENABLE SSL
223
357
  { ...BASE_ENABLE_SSL, startVersion: PostgresPluginVersions.V1, endVersion: PostgresPluginVersions.V10 } as FormItem,
224
358
  {
225
359
  ...BASE_ENABLE_SSL,
226
360
  startVersion: PostgresPluginVersions.V11,
361
+ endVersion: PostgresPluginVersions.V12,
227
362
  display: {
228
363
  show: {
229
364
  connectionType: ['fields']
230
365
  }
231
366
  }
232
367
  } as FormItem,
368
+ {
369
+ label: 'Enable SSL',
370
+ name: 'connection.useSsl',
371
+ startVersion: PostgresPluginVersions.V13,
372
+ componentType: FormComponentType.CHECKBOX,
373
+ initialValue: true,
374
+ disabled: false,
375
+ display: {
376
+ show: {
377
+ 'authentication.authType': ['', 'undefined', PostgresAuthType.PASSWORD],
378
+ connectionType: ['fields']
379
+ }
380
+ }
381
+ },
382
+ {
383
+ label: 'Enable SSL',
384
+ name: 'connection.useSsl',
385
+ startVersion: PostgresPluginVersions.V13,
386
+ componentType: FormComponentType.CHECKBOX,
387
+ initialValue: true,
388
+ disabled: true,
389
+ rules: [{ enum: [true], message: 'SSL is required for AWS IAM role authentication' }],
390
+ display: {
391
+ show: {
392
+ 'authentication.authType': [PostgresAuthType.AWS_IAM_ROLE],
393
+ connectionType: ['fields']
394
+ }
395
+ }
396
+ },
233
397
  // USE SELF-SIGNED SSL
234
398
  { ...BASE_SELFSIGNED_SSL, startVersion: PostgresPluginVersions.V1, endVersion: PostgresPluginVersions.V10 } as FormItem,
235
399
  {
@@ -173,6 +173,11 @@ export enum AWSAuthType {
173
173
  EC2_INSTANCE_METADATA = 'ec2-instance-metadata'
174
174
  }
175
175
 
176
+ export enum PostgresAuthType {
177
+ AWS_IAM_ROLE = 'aws_iam_role',
178
+ PASSWORD = 'password'
179
+ }
180
+
176
181
  const awsAuthTypeDisplayName = new Map([
177
182
  [AWSAuthType.ACCESS_KEY, 'Access Key'],
178
183
  [AWSAuthType.TOKEN_FILE, 'Token File'],
@@ -17,7 +17,7 @@ import { SecretsV1 as Secrets } from '@superblocksteam/types';
17
17
  import { Property } from '../common/property.js';
18
18
  import { Plugin, PluginMetadata } from '../plugin/index.js';
19
19
  import { CreatorDto } from '../rbac/index.js';
20
- import { AWSAuthType, AuthConfig, AuthId, AuthType, IntegrationAuthType, getAuthId } from './auth.js';
20
+ import { AWSAuthType, AuthConfig, AuthId, AuthType, IntegrationAuthType, PostgresAuthType, getAuthId } from './auth.js';
21
21
  export { PluginCommonV1 as PluginCommon } from '@superblocksteam/types';
22
22
 
23
23
  // The DTO for the full datasource (ie all fields). This should only be visible
@@ -304,7 +304,79 @@ type MySQLDatasourceConfiguration = DBDatasourceConfiguration &
304
304
  // 2. Our schema generator requires a named type for unions like this
305
305
  type FakeBoolean = boolean | string;
306
306
 
307
- export type PostgresDatasourceConfiguration = DBDatasourceConfiguration &
307
+ // These types are self-contained because ts-json-schema-generator drops value
308
+ // annotations when the field is composed through a Property intersection.
309
+ type PostgresDatabaseNameProperty = {
310
+ key?: string;
311
+ /** @minLength 1 */
312
+ value: string;
313
+ editable?: boolean;
314
+ internal?: boolean;
315
+ system?: boolean;
316
+ description?: string;
317
+ mandatory?: boolean;
318
+ type?: string;
319
+ defaultValue?: string;
320
+ minRange?: string;
321
+ maxRange?: string;
322
+ valueOptions?: string[];
323
+ };
324
+
325
+ type PostgresIamRoleArnProperty = {
326
+ key?: string;
327
+ /**
328
+ * Validates stable IAM role ARN wire syntax. Role authorization and allowlist
329
+ * checks remain runtime concerns. The 510-character ARN interior accounts
330
+ * for the path's leading and trailing slashes within IAM's 512-character max.
331
+ * @minLength 1
332
+ * @pattern ^arn:[a-z0-9-]+:iam::[0-9]{12}:role/(?:[!-~]{1,510}/)?[A-Za-z0-9_+=,.@-]{1,64}$
333
+ */
334
+ value: string;
335
+ editable?: boolean;
336
+ internal?: boolean;
337
+ system?: boolean;
338
+ description?: string;
339
+ mandatory?: boolean;
340
+ type?: string;
341
+ defaultValue?: string;
342
+ minRange?: string;
343
+ maxRange?: string;
344
+ valueOptions?: string[];
345
+ };
346
+
347
+ type PostgresIamRegionProperty = {
348
+ key?: string;
349
+ /**
350
+ * Validates region identifier syntax without freezing the set of AWS regions.
351
+ * Region existence and availability remain runtime concerns.
352
+ * @minLength 1
353
+ * @pattern ^[a-z]{2,}(?:-[a-z0-9]+)+-[0-9]+$
354
+ */
355
+ value: string;
356
+ editable?: boolean;
357
+ internal?: boolean;
358
+ system?: boolean;
359
+ description?: string;
360
+ mandatory?: boolean;
361
+ type?: string;
362
+ defaultValue?: string;
363
+ minRange?: string;
364
+ maxRange?: string;
365
+ valueOptions?: string[];
366
+ };
367
+
368
+ type PostgresIamEndpoint = {
369
+ /** @minLength 1 */
370
+ host: string;
371
+ /**
372
+ * @type integer
373
+ * @minimum 1
374
+ * @maximum 65535
375
+ */
376
+ port: number;
377
+ };
378
+
379
+ type CockroachDBDatasourceConfiguration = DBDatasourceConfiguration &
308
380
  DBConnection &
309
381
  DBAuthentication &
310
382
  SSHTunnel & {
@@ -312,7 +384,47 @@ export type PostgresDatasourceConfiguration = DBDatasourceConfiguration &
312
384
  connectionUrl?: string;
313
385
  };
314
386
 
315
- type CockroachDBDatasourceConfiguration = PostgresDatasourceConfiguration;
387
+ type PostgresPasswordDatasourceConfiguration = DBDatasourceConfiguration &
388
+ DBConnection &
389
+ SSHTunnel & {
390
+ authentication?: {
391
+ authType?: PostgresAuthType.PASSWORD;
392
+ custom?: {
393
+ databaseName?: Property;
394
+ };
395
+ password?: string;
396
+ username?: string;
397
+ };
398
+ connectionType?: 'fields' | 'url';
399
+ connectionUrl?: string;
400
+ };
401
+
402
+ type PostgresIamRoleDatasourceConfiguration = BaseDatasourceConfiguration &
403
+ SSHTunnel & {
404
+ authentication: {
405
+ authType: PostgresAuthType.AWS_IAM_ROLE;
406
+ custom: {
407
+ databaseName: PostgresDatabaseNameProperty;
408
+ iamRoleArn: PostgresIamRoleArnProperty;
409
+ region: PostgresIamRegionProperty;
410
+ sessionPolicy?: Property;
411
+ };
412
+ /** @minLength 1 */
413
+ username: string;
414
+ };
415
+ connection: {
416
+ useSsl: true;
417
+ useSelfSignedSsl?: FakeBoolean;
418
+ ca?: string;
419
+ key?: string;
420
+ cert?: string;
421
+ mode?: 0;
422
+ };
423
+ connectionType: 'fields';
424
+ endpoint: PostgresIamEndpoint;
425
+ };
426
+
427
+ export type PostgresDatasourceConfiguration = PostgresPasswordDatasourceConfiguration | PostgresIamRoleDatasourceConfiguration;
316
428
 
317
429
  type PythonDatasourceConfiguration = LanguageDatasourceConfiguration;
318
430
 
@@ -2,7 +2,9 @@ export enum DeployQueueStatus {
2
2
  QUEUED = 'QUEUED',
3
3
  DEPLOYING = 'DEPLOYING',
4
4
  DEPLOYED = 'DEPLOYED',
5
- FAILED = 'FAILED'
5
+ FAILED = 'FAILED',
6
+ /** Build + gates done, advisory-only findings present, waiting for explicit "Publish anyway". */
7
+ AWAITING_ACK = 'AWAITING_ACK'
6
8
  }
7
9
 
8
10
  /** Status returned by the deploy-status polling endpoint. "none" means no queue entry exists. */