@terrantula/sdk 0.0.1 → 0.1.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.
package/dist/index.js CHANGED
@@ -1018,7 +1018,7 @@ var SERVER_FIELDS = /* @__PURE__ */ new Set(["id", "projectId", "envId", "create
1018
1018
  function stripServerFields(row) {
1019
1019
  const out = {};
1020
1020
  for (const [key, value] of Object.entries(row)) {
1021
- if (!SERVER_FIELDS.has(key)) out[key] = value;
1021
+ if (!SERVER_FIELDS.has(key) && value !== null) out[key] = value;
1022
1022
  }
1023
1023
  return out;
1024
1024
  }
@@ -1045,9 +1045,13 @@ function createExportCatalogFn(proj, projEnv) {
1045
1045
  ...cells.map(
1046
1046
  (r) => ({ kind: "Cell", ...stripServerFields(r) })
1047
1047
  ),
1048
- ...relationshipTypes.map(
1049
- (r) => ({ kind: "RelationshipType", ...stripServerFields(r) })
1050
- ),
1048
+ ...relationshipTypes.map((r) => {
1049
+ const { fromEntityTypeName, toEntityTypeName, ...rest } = r;
1050
+ const stripped = stripServerFields(rest);
1051
+ if (fromEntityTypeName != null) stripped.from = fromEntityTypeName;
1052
+ if (toEntityTypeName != null) stripped.to = toEntityTypeName;
1053
+ return { kind: "RelationshipType", ...stripped };
1054
+ }),
1051
1055
  ...actions.map(
1052
1056
  (r) => ({ kind: "Action", ...stripServerFields(r) })
1053
1057
  ),
@@ -1449,6 +1453,91 @@ function createUserPreferencesClient(baseUrl, hcOpts) {
1449
1453
  };
1450
1454
  }
1451
1455
 
1456
+ // src/import-sources.ts
1457
+ var import_zod17 = require("zod");
1458
+ var SourceKindEnum = import_zod17.z.enum(["tf-state", "atmos-manifests"]);
1459
+ var PolicyEnum = import_zod17.z.enum(["auto-update", "human-approval"]);
1460
+ function createImportSourcesClient(proj) {
1461
+ return {
1462
+ list: withSchema(
1463
+ import_zod17.z.object({ projectId: import_zod17.z.string().describe("Project ID") }),
1464
+ (params) => call(proj(params.projectId)["import-sources"].$get())
1465
+ ),
1466
+ get: withSchema(
1467
+ import_zod17.z.object({
1468
+ projectId: import_zod17.z.string().describe("Project ID"),
1469
+ id: import_zod17.z.string().uuid().describe("ImportSource ID")
1470
+ }),
1471
+ (params) => call(proj(params.projectId)["import-sources"][":id"].$get({ param: { id: params.id } }))
1472
+ ),
1473
+ registerOrUpdate: withSchema(
1474
+ import_zod17.z.object({
1475
+ projectId: import_zod17.z.string().describe("Project ID"),
1476
+ envName: import_zod17.z.string().describe("Env name the source belongs to"),
1477
+ sourceKind: SourceKindEnum,
1478
+ sourceUri: import_zod17.z.string().describe("Stable URI identifying the source"),
1479
+ reconciliationPolicy: PolicyEnum.optional()
1480
+ }),
1481
+ (params) => {
1482
+ const { projectId, ...body } = params;
1483
+ return call(proj(projectId)["import-sources"].$post({ json: body }));
1484
+ }
1485
+ ),
1486
+ rescan: withSchema(
1487
+ import_zod17.z.object({
1488
+ projectId: import_zod17.z.string(),
1489
+ id: import_zod17.z.string().uuid(),
1490
+ envName: import_zod17.z.string(),
1491
+ items: import_zod17.z.array(import_zod17.z.unknown()),
1492
+ deletions: import_zod17.z.array(import_zod17.z.object({ kind: import_zod17.z.string(), name: import_zod17.z.string() })).optional()
1493
+ }),
1494
+ (params) => {
1495
+ const { projectId, id, ...body } = params;
1496
+ return call(
1497
+ proj(projectId)["import-sources"][":id"].rescan.$post({
1498
+ param: { id },
1499
+ // why: the Hono RPC type for the body is the AnyKindSchema union;
1500
+ // the SDK accepts `unknown[]` so callers don't have to re-import the
1501
+ // entire schema graph just to construct an apply bundle.
1502
+ json: body
1503
+ })
1504
+ );
1505
+ }
1506
+ ),
1507
+ drift: withSchema(
1508
+ import_zod17.z.object({
1509
+ projectId: import_zod17.z.string(),
1510
+ id: import_zod17.z.string().uuid()
1511
+ }),
1512
+ (params) => call(proj(params.projectId)["import-sources"][":id"].drift.$get({ param: { id: params.id } }))
1513
+ ),
1514
+ approveProposal: withSchema(
1515
+ import_zod17.z.object({
1516
+ projectId: import_zod17.z.string(),
1517
+ id: import_zod17.z.string().uuid(),
1518
+ proposalId: import_zod17.z.string().uuid()
1519
+ }),
1520
+ (params) => call(
1521
+ proj(params.projectId)["import-sources"][":id"]["drift-proposals"][":proposalId"].approve.$post({
1522
+ param: { id: params.id, proposalId: params.proposalId }
1523
+ })
1524
+ )
1525
+ ),
1526
+ rejectProposal: withSchema(
1527
+ import_zod17.z.object({
1528
+ projectId: import_zod17.z.string(),
1529
+ id: import_zod17.z.string().uuid(),
1530
+ proposalId: import_zod17.z.string().uuid()
1531
+ }),
1532
+ (params) => call(
1533
+ proj(params.projectId)["import-sources"][":id"]["drift-proposals"][":proposalId"].reject.$post({
1534
+ param: { id: params.id, proposalId: params.proposalId }
1535
+ })
1536
+ )
1537
+ )
1538
+ };
1539
+ }
1540
+
1452
1541
  // src/index.ts
1453
1542
  var createClient = (baseUrl, options = {}) => {
1454
1543
  const opts = typeof options === "string" || typeof options === "function" ? { token: options } : options;
@@ -1482,6 +1571,7 @@ var createClient = (baseUrl, options = {}) => {
1482
1571
  notifications: createNotificationsClient(baseUrl, hcOpts),
1483
1572
  auditExport: createAuditExportClient(baseUrl, hcOpts),
1484
1573
  userPreferences: createUserPreferencesClient(baseUrl, hcOpts),
1574
+ importSources: createImportSourcesClient(proj),
1485
1575
  exportCatalog
1486
1576
  };
1487
1577
  let warnedPools = false;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  TerrantulaError,
3
3
  createClient,
4
4
  withSchema
5
- } from "./chunk-NTU2AEMP.mjs";
5
+ } from "./chunk-KOGEUSRZ.mjs";
6
6
  export {
7
7
  TerrantulaError,
8
8
  createClient,
package/dist/local.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { a as SchemaFn, S as SnapshotOp, A as AuditExportConfigResponse, b as TestConnectionResponse, c as AuditExportRunResponse, E as ExportCatalogResult } from './audit-export-BJSNZ9ic.mjs';
2
+ import * as _terrantula_types from '@terrantula/types';
2
3
  import * as hono_utils_types from 'hono/utils/types';
3
4
  import * as zod from 'zod';
4
5
 
@@ -1606,6 +1607,8 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
1606
1607
  updatedAt: string;
1607
1608
  projectId: string | null;
1608
1609
  envId: string;
1610
+ deletionScheduledAt: string | null;
1611
+ deletionGracePeriodSeconds: number | null;
1609
1612
  }[]>;
1610
1613
  syncStamp: SchemaFn<zod.ZodObject<{
1611
1614
  projectId: zod.ZodString;
@@ -2234,6 +2237,8 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
2234
2237
  updatedAt: string;
2235
2238
  projectId: string | null;
2236
2239
  envId: string;
2240
+ deletionScheduledAt: string | null;
2241
+ deletionGracePeriodSeconds: number | null;
2237
2242
  }[]>;
2238
2243
  get: SchemaFn<zod.ZodObject<{
2239
2244
  projectId: zod.ZodString;
@@ -2259,6 +2264,8 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
2259
2264
  updatedAt: string;
2260
2265
  projectId: string | null;
2261
2266
  envId: string;
2267
+ deletionScheduledAt: string | null;
2268
+ deletionGracePeriodSeconds: number | null;
2262
2269
  }>;
2263
2270
  create: SchemaFn<zod.ZodObject<{
2264
2271
  kind: zod.ZodLiteral<"Relationship">;
@@ -2305,6 +2312,8 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
2305
2312
  relationshipTypeName: string;
2306
2313
  fromEntityId: string;
2307
2314
  toEntityId: string;
2315
+ deletionScheduledAt: string | null;
2316
+ deletionGracePeriodSeconds: number | null;
2308
2317
  }>;
2309
2318
  delete: SchemaFn<zod.ZodObject<{
2310
2319
  projectId: zod.ZodString;
@@ -15953,6 +15962,7 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
15953
15962
  itemCount: number;
15954
15963
  deletionCount: number;
15955
15964
  force: boolean;
15965
+ version: number;
15956
15966
  }[]>;
15957
15967
  get: SchemaFn<zod.ZodObject<{
15958
15968
  projectId: zod.ZodString;
@@ -16435,6 +16445,242 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
16435
16445
  }>;
16436
16446
  delete: (key: string) => Promise<unknown>;
16437
16447
  };
16448
+ importSources: {
16449
+ list: SchemaFn<zod.ZodObject<{
16450
+ projectId: zod.ZodString;
16451
+ }, "strip", zod.ZodTypeAny, {
16452
+ projectId: string;
16453
+ }, {
16454
+ projectId: string;
16455
+ }>, {
16456
+ id: string;
16457
+ projectId: string | null;
16458
+ envId: string;
16459
+ sourceKind: string;
16460
+ sourceUri: string;
16461
+ reconciliationPolicy: string;
16462
+ lastScannedAt: string | null;
16463
+ lastScanStatus: string | null;
16464
+ lastScanSummary: hono_utils_types.JSONValue;
16465
+ createdAt: string;
16466
+ updatedAt: string;
16467
+ }[]>;
16468
+ get: SchemaFn<zod.ZodObject<{
16469
+ projectId: zod.ZodString;
16470
+ id: zod.ZodString;
16471
+ }, "strip", zod.ZodTypeAny, {
16472
+ id: string;
16473
+ projectId: string;
16474
+ }, {
16475
+ id: string;
16476
+ projectId: string;
16477
+ }>, {
16478
+ id: string;
16479
+ projectId: string | null;
16480
+ envId: string;
16481
+ sourceKind: string;
16482
+ sourceUri: string;
16483
+ reconciliationPolicy: string;
16484
+ lastScannedAt: string | null;
16485
+ lastScanStatus: string | null;
16486
+ lastScanSummary: hono_utils_types.JSONValue;
16487
+ createdAt: string;
16488
+ updatedAt: string;
16489
+ }>;
16490
+ registerOrUpdate: SchemaFn<zod.ZodObject<{
16491
+ projectId: zod.ZodString;
16492
+ envName: zod.ZodString;
16493
+ sourceKind: zod.ZodEnum<["tf-state", "atmos-manifests"]>;
16494
+ sourceUri: zod.ZodString;
16495
+ reconciliationPolicy: zod.ZodOptional<zod.ZodEnum<["auto-update", "human-approval"]>>;
16496
+ }, "strip", zod.ZodTypeAny, {
16497
+ projectId: string;
16498
+ envName: string;
16499
+ sourceKind: "tf-state" | "atmos-manifests";
16500
+ sourceUri: string;
16501
+ reconciliationPolicy?: "auto-update" | "human-approval" | undefined;
16502
+ }, {
16503
+ projectId: string;
16504
+ envName: string;
16505
+ sourceKind: "tf-state" | "atmos-manifests";
16506
+ sourceUri: string;
16507
+ reconciliationPolicy?: "auto-update" | "human-approval" | undefined;
16508
+ }>, {
16509
+ id: string;
16510
+ projectId: string | null;
16511
+ envId: string;
16512
+ sourceKind: string;
16513
+ sourceUri: string;
16514
+ reconciliationPolicy: string;
16515
+ lastScannedAt: string | null;
16516
+ lastScanStatus: string | null;
16517
+ lastScanSummary: hono_utils_types.JSONValue;
16518
+ createdAt: string;
16519
+ updatedAt: string;
16520
+ } | {
16521
+ id: string;
16522
+ createdAt: string;
16523
+ updatedAt: string;
16524
+ projectId: string | null;
16525
+ envId: string;
16526
+ sourceKind: string;
16527
+ sourceUri: string;
16528
+ reconciliationPolicy: string;
16529
+ lastScannedAt: string | null;
16530
+ lastScanStatus: string | null;
16531
+ lastScanSummary: hono_utils_types.JSONValue;
16532
+ }>;
16533
+ rescan: SchemaFn<zod.ZodObject<{
16534
+ projectId: zod.ZodString;
16535
+ id: zod.ZodString;
16536
+ envName: zod.ZodString;
16537
+ items: zod.ZodArray<zod.ZodUnknown, "many">;
16538
+ deletions: zod.ZodOptional<zod.ZodArray<zod.ZodObject<{
16539
+ kind: zod.ZodString;
16540
+ name: zod.ZodString;
16541
+ }, "strip", zod.ZodTypeAny, {
16542
+ name: string;
16543
+ kind: string;
16544
+ }, {
16545
+ name: string;
16546
+ kind: string;
16547
+ }>, "many">>;
16548
+ }, "strip", zod.ZodTypeAny, {
16549
+ id: string;
16550
+ projectId: string;
16551
+ envName: string;
16552
+ items: unknown[];
16553
+ deletions?: {
16554
+ name: string;
16555
+ kind: string;
16556
+ }[] | undefined;
16557
+ }, {
16558
+ id: string;
16559
+ projectId: string;
16560
+ envName: string;
16561
+ items: unknown[];
16562
+ deletions?: {
16563
+ name: string;
16564
+ kind: string;
16565
+ }[] | undefined;
16566
+ }>, {
16567
+ scan: {
16568
+ scanned: any;
16569
+ succeeded: number;
16570
+ failed: number;
16571
+ proposalsCreated: number;
16572
+ };
16573
+ lastScannedAt: string;
16574
+ lastScanStatus: string;
16575
+ } | {
16576
+ scan: {
16577
+ scanned: any;
16578
+ created: number;
16579
+ failed: number;
16580
+ proposalsCreated: number;
16581
+ };
16582
+ lastScannedAt: string;
16583
+ lastScanStatus: string;
16584
+ }>;
16585
+ drift: SchemaFn<zod.ZodObject<{
16586
+ projectId: zod.ZodString;
16587
+ id: zod.ZodString;
16588
+ }, "strip", zod.ZodTypeAny, {
16589
+ id: string;
16590
+ projectId: string;
16591
+ }, {
16592
+ id: string;
16593
+ projectId: string;
16594
+ }>, {
16595
+ source: {
16596
+ id: string;
16597
+ projectId: string | null;
16598
+ envId: string;
16599
+ sourceKind: string;
16600
+ sourceUri: string;
16601
+ reconciliationPolicy: string;
16602
+ lastScannedAt: string | null;
16603
+ lastScanStatus: string | null;
16604
+ lastScanSummary: hono_utils_types.JSONValue;
16605
+ createdAt: string;
16606
+ updatedAt: string;
16607
+ };
16608
+ totals: {
16609
+ entities: number;
16610
+ current: number;
16611
+ stale: number;
16612
+ missing: number;
16613
+ pendingProposals: number;
16614
+ };
16615
+ entities: {
16616
+ id: string;
16617
+ name: string;
16618
+ entityType: string;
16619
+ lastSyncedAt: string | null;
16620
+ driftStatus: _terrantula_types.DriftStatus | null;
16621
+ }[];
16622
+ pendingProposals: {
16623
+ id: string;
16624
+ importSourceId: string;
16625
+ projectId: string | null;
16626
+ envId: string;
16627
+ entityId: string;
16628
+ proposedChanges: hono_utils_types.JSONValue;
16629
+ status: string;
16630
+ createdAt: string;
16631
+ decidedAt: string | null;
16632
+ decidedBy: string | null;
16633
+ }[];
16634
+ }>;
16635
+ approveProposal: SchemaFn<zod.ZodObject<{
16636
+ projectId: zod.ZodString;
16637
+ id: zod.ZodString;
16638
+ proposalId: zod.ZodString;
16639
+ }, "strip", zod.ZodTypeAny, {
16640
+ id: string;
16641
+ projectId: string;
16642
+ proposalId: string;
16643
+ }, {
16644
+ id: string;
16645
+ projectId: string;
16646
+ proposalId: string;
16647
+ }>, {
16648
+ id: string;
16649
+ importSourceId: string;
16650
+ projectId: string | null;
16651
+ envId: string;
16652
+ entityId: string;
16653
+ proposedChanges: hono_utils_types.JSONValue;
16654
+ status: string;
16655
+ createdAt: string;
16656
+ decidedAt: string | null;
16657
+ decidedBy: string | null;
16658
+ }>;
16659
+ rejectProposal: SchemaFn<zod.ZodObject<{
16660
+ projectId: zod.ZodString;
16661
+ id: zod.ZodString;
16662
+ proposalId: zod.ZodString;
16663
+ }, "strip", zod.ZodTypeAny, {
16664
+ id: string;
16665
+ projectId: string;
16666
+ proposalId: string;
16667
+ }, {
16668
+ id: string;
16669
+ projectId: string;
16670
+ proposalId: string;
16671
+ }>, {
16672
+ id: string;
16673
+ importSourceId: string;
16674
+ projectId: string | null;
16675
+ envId: string;
16676
+ entityId: string;
16677
+ proposedChanges: hono_utils_types.JSONValue;
16678
+ status: string;
16679
+ createdAt: string;
16680
+ decidedAt: string | null;
16681
+ decidedBy: string | null;
16682
+ }>;
16683
+ };
16438
16684
  exportCatalog: SchemaFn<zod.ZodObject<{
16439
16685
  projectId: zod.ZodString;
16440
16686
  envName: zod.ZodString;
@@ -16706,6 +16952,7 @@ declare const createLocalClient: (options?: CreateLocalClientOptions) => {
16706
16952
  itemCount: number;
16707
16953
  deletionCount: number;
16708
16954
  force: boolean;
16955
+ version: number;
16709
16956
  }[]>;
16710
16957
  get: SchemaFn<zod.ZodObject<{
16711
16958
  projectId: zod.ZodString;