@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.
@@ -995,7 +995,7 @@ var SERVER_FIELDS = /* @__PURE__ */ new Set(["id", "projectId", "envId", "create
995
995
  function stripServerFields(row) {
996
996
  const out = {};
997
997
  for (const [key, value] of Object.entries(row)) {
998
- if (!SERVER_FIELDS.has(key)) out[key] = value;
998
+ if (!SERVER_FIELDS.has(key) && value !== null) out[key] = value;
999
999
  }
1000
1000
  return out;
1001
1001
  }
@@ -1022,9 +1022,13 @@ function createExportCatalogFn(proj, projEnv) {
1022
1022
  ...cells.map(
1023
1023
  (r) => ({ kind: "Cell", ...stripServerFields(r) })
1024
1024
  ),
1025
- ...relationshipTypes.map(
1026
- (r) => ({ kind: "RelationshipType", ...stripServerFields(r) })
1027
- ),
1025
+ ...relationshipTypes.map((r) => {
1026
+ const { fromEntityTypeName, toEntityTypeName, ...rest } = r;
1027
+ const stripped = stripServerFields(rest);
1028
+ if (fromEntityTypeName != null) stripped.from = fromEntityTypeName;
1029
+ if (toEntityTypeName != null) stripped.to = toEntityTypeName;
1030
+ return { kind: "RelationshipType", ...stripped };
1031
+ }),
1028
1032
  ...actions.map(
1029
1033
  (r) => ({ kind: "Action", ...stripServerFields(r) })
1030
1034
  ),
@@ -1426,6 +1430,91 @@ function createUserPreferencesClient(baseUrl, hcOpts) {
1426
1430
  };
1427
1431
  }
1428
1432
 
1433
+ // src/import-sources.ts
1434
+ import { z as z17 } from "zod";
1435
+ var SourceKindEnum = z17.enum(["tf-state", "atmos-manifests"]);
1436
+ var PolicyEnum = z17.enum(["auto-update", "human-approval"]);
1437
+ function createImportSourcesClient(proj) {
1438
+ return {
1439
+ list: withSchema(
1440
+ z17.object({ projectId: z17.string().describe("Project ID") }),
1441
+ (params) => call(proj(params.projectId)["import-sources"].$get())
1442
+ ),
1443
+ get: withSchema(
1444
+ z17.object({
1445
+ projectId: z17.string().describe("Project ID"),
1446
+ id: z17.string().uuid().describe("ImportSource ID")
1447
+ }),
1448
+ (params) => call(proj(params.projectId)["import-sources"][":id"].$get({ param: { id: params.id } }))
1449
+ ),
1450
+ registerOrUpdate: withSchema(
1451
+ z17.object({
1452
+ projectId: z17.string().describe("Project ID"),
1453
+ envName: z17.string().describe("Env name the source belongs to"),
1454
+ sourceKind: SourceKindEnum,
1455
+ sourceUri: z17.string().describe("Stable URI identifying the source"),
1456
+ reconciliationPolicy: PolicyEnum.optional()
1457
+ }),
1458
+ (params) => {
1459
+ const { projectId, ...body } = params;
1460
+ return call(proj(projectId)["import-sources"].$post({ json: body }));
1461
+ }
1462
+ ),
1463
+ rescan: withSchema(
1464
+ z17.object({
1465
+ projectId: z17.string(),
1466
+ id: z17.string().uuid(),
1467
+ envName: z17.string(),
1468
+ items: z17.array(z17.unknown()),
1469
+ deletions: z17.array(z17.object({ kind: z17.string(), name: z17.string() })).optional()
1470
+ }),
1471
+ (params) => {
1472
+ const { projectId, id, ...body } = params;
1473
+ return call(
1474
+ proj(projectId)["import-sources"][":id"].rescan.$post({
1475
+ param: { id },
1476
+ // why: the Hono RPC type for the body is the AnyKindSchema union;
1477
+ // the SDK accepts `unknown[]` so callers don't have to re-import the
1478
+ // entire schema graph just to construct an apply bundle.
1479
+ json: body
1480
+ })
1481
+ );
1482
+ }
1483
+ ),
1484
+ drift: withSchema(
1485
+ z17.object({
1486
+ projectId: z17.string(),
1487
+ id: z17.string().uuid()
1488
+ }),
1489
+ (params) => call(proj(params.projectId)["import-sources"][":id"].drift.$get({ param: { id: params.id } }))
1490
+ ),
1491
+ approveProposal: withSchema(
1492
+ z17.object({
1493
+ projectId: z17.string(),
1494
+ id: z17.string().uuid(),
1495
+ proposalId: z17.string().uuid()
1496
+ }),
1497
+ (params) => call(
1498
+ proj(params.projectId)["import-sources"][":id"]["drift-proposals"][":proposalId"].approve.$post({
1499
+ param: { id: params.id, proposalId: params.proposalId }
1500
+ })
1501
+ )
1502
+ ),
1503
+ rejectProposal: withSchema(
1504
+ z17.object({
1505
+ projectId: z17.string(),
1506
+ id: z17.string().uuid(),
1507
+ proposalId: z17.string().uuid()
1508
+ }),
1509
+ (params) => call(
1510
+ proj(params.projectId)["import-sources"][":id"]["drift-proposals"][":proposalId"].reject.$post({
1511
+ param: { id: params.id, proposalId: params.proposalId }
1512
+ })
1513
+ )
1514
+ )
1515
+ };
1516
+ }
1517
+
1429
1518
  // src/index.ts
1430
1519
  var createClient = (baseUrl, options = {}) => {
1431
1520
  const opts = typeof options === "string" || typeof options === "function" ? { token: options } : options;
@@ -1459,6 +1548,7 @@ var createClient = (baseUrl, options = {}) => {
1459
1548
  notifications: createNotificationsClient(baseUrl, hcOpts),
1460
1549
  auditExport: createAuditExportClient(baseUrl, hcOpts),
1461
1550
  userPreferences: createUserPreferencesClient(baseUrl, hcOpts),
1551
+ importSources: createImportSourcesClient(proj),
1462
1552
  exportCatalog
1463
1553
  };
1464
1554
  let warnedPools = false;