@terrantula/sdk 0.0.2 → 0.2.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/{audit-export-BJSNZ9ic.d.mts → audit-export-BtZTnt8a.d.mts} +51 -1
- package/dist/{audit-export-BJSNZ9ic.d.ts → audit-export-BtZTnt8a.d.ts} +51 -1
- package/dist/{chunk-NTU2AEMP.mjs → chunk-WYOV3M2X.mjs} +204 -5
- package/dist/index.d.mts +615 -6
- package/dist/index.d.ts +615 -6
- package/dist/index.js +204 -5
- package/dist/index.mjs +1 -1
- package/dist/local.d.mts +308 -3
- package/dist/local.d.ts +308 -3
- package/dist/local.js +204 -5
- package/dist/local.mjs +1 -1
- package/package.json +3 -3
|
@@ -13,6 +13,56 @@ declare function withSchema<S extends z.ZodObject<z.ZodRawShape>, R>(schema: S,
|
|
|
13
13
|
/** A static token string or a (possibly async) factory that returns one. */
|
|
14
14
|
type TokenSource = string | (() => string | Promise<string>);
|
|
15
15
|
|
|
16
|
+
interface AdminAuditEvent {
|
|
17
|
+
id: string;
|
|
18
|
+
actorUserId: string;
|
|
19
|
+
action: string;
|
|
20
|
+
resourceKind: string;
|
|
21
|
+
resourceId: string | null;
|
|
22
|
+
metadata: unknown;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}
|
|
25
|
+
interface AdminAuditListResponse {
|
|
26
|
+
data: AdminAuditEvent[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}
|
|
31
|
+
interface AdminOrgSummary {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
slug: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
suspendedAt: string | null;
|
|
37
|
+
memberCount: number;
|
|
38
|
+
projectCount: number;
|
|
39
|
+
}
|
|
40
|
+
interface AdminOrgMember {
|
|
41
|
+
userId: string;
|
|
42
|
+
email: string;
|
|
43
|
+
username: string | null;
|
|
44
|
+
name: string | null;
|
|
45
|
+
role: string;
|
|
46
|
+
joinedAt: string;
|
|
47
|
+
}
|
|
48
|
+
interface AdminOrgProject {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
}
|
|
54
|
+
interface AdminOrgDetail extends AdminOrgSummary {
|
|
55
|
+
members: AdminOrgMember[];
|
|
56
|
+
projects: AdminOrgProject[];
|
|
57
|
+
}
|
|
58
|
+
interface AdminOrgListResponse {
|
|
59
|
+
data: AdminOrgSummary[];
|
|
60
|
+
}
|
|
61
|
+
interface AdminSuspendResponse {
|
|
62
|
+
id: string;
|
|
63
|
+
suspendedAt: string | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
16
66
|
type SnapshotOp = 'created' | 'updated' | 'deleted' | 'unchanged' | 'failed';
|
|
17
67
|
|
|
18
68
|
interface ExportedItem {
|
|
@@ -53,4 +103,4 @@ interface TestConnectionResponse {
|
|
|
53
103
|
error?: string;
|
|
54
104
|
}
|
|
55
105
|
|
|
56
|
-
export { type AuditExportConfigResponse as A, type ExportCatalogResult as E, type SnapshotOp as S, type TokenSource as T, type SchemaFn as a, type TestConnectionResponse as b, type AuditExportRunResponse as c,
|
|
106
|
+
export { type AuditExportConfigResponse as A, type ExportCatalogResult as E, type SnapshotOp as S, type TokenSource as T, type SchemaFn as a, type TestConnectionResponse as b, type AuditExportRunResponse as c, type AdminAuditListResponse as d, type AdminOrgListResponse as e, type AdminOrgDetail as f, type AdminSuspendResponse as g, type AdminAuditEvent as h, type AdminOrgMember as i, type AdminOrgProject as j, type AdminOrgSummary as k, TerrantulaError as l, withSchema as w };
|
|
@@ -13,6 +13,56 @@ declare function withSchema<S extends z.ZodObject<z.ZodRawShape>, R>(schema: S,
|
|
|
13
13
|
/** A static token string or a (possibly async) factory that returns one. */
|
|
14
14
|
type TokenSource = string | (() => string | Promise<string>);
|
|
15
15
|
|
|
16
|
+
interface AdminAuditEvent {
|
|
17
|
+
id: string;
|
|
18
|
+
actorUserId: string;
|
|
19
|
+
action: string;
|
|
20
|
+
resourceKind: string;
|
|
21
|
+
resourceId: string | null;
|
|
22
|
+
metadata: unknown;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}
|
|
25
|
+
interface AdminAuditListResponse {
|
|
26
|
+
data: AdminAuditEvent[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}
|
|
31
|
+
interface AdminOrgSummary {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
slug: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
suspendedAt: string | null;
|
|
37
|
+
memberCount: number;
|
|
38
|
+
projectCount: number;
|
|
39
|
+
}
|
|
40
|
+
interface AdminOrgMember {
|
|
41
|
+
userId: string;
|
|
42
|
+
email: string;
|
|
43
|
+
username: string | null;
|
|
44
|
+
name: string | null;
|
|
45
|
+
role: string;
|
|
46
|
+
joinedAt: string;
|
|
47
|
+
}
|
|
48
|
+
interface AdminOrgProject {
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
slug: string;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
}
|
|
54
|
+
interface AdminOrgDetail extends AdminOrgSummary {
|
|
55
|
+
members: AdminOrgMember[];
|
|
56
|
+
projects: AdminOrgProject[];
|
|
57
|
+
}
|
|
58
|
+
interface AdminOrgListResponse {
|
|
59
|
+
data: AdminOrgSummary[];
|
|
60
|
+
}
|
|
61
|
+
interface AdminSuspendResponse {
|
|
62
|
+
id: string;
|
|
63
|
+
suspendedAt: string | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
16
66
|
type SnapshotOp = 'created' | 'updated' | 'deleted' | 'unchanged' | 'failed';
|
|
17
67
|
|
|
18
68
|
interface ExportedItem {
|
|
@@ -53,4 +103,4 @@ interface TestConnectionResponse {
|
|
|
53
103
|
error?: string;
|
|
54
104
|
}
|
|
55
105
|
|
|
56
|
-
export { type AuditExportConfigResponse as A, type ExportCatalogResult as E, type SnapshotOp as S, type TokenSource as T, type SchemaFn as a, type TestConnectionResponse as b, type AuditExportRunResponse as c,
|
|
106
|
+
export { type AuditExportConfigResponse as A, type ExportCatalogResult as E, type SnapshotOp as S, type TokenSource as T, type SchemaFn as a, type TestConnectionResponse as b, type AuditExportRunResponse as c, type AdminAuditListResponse as d, type AdminOrgListResponse as e, type AdminOrgDetail as f, type AdminSuspendResponse as g, type AdminAuditEvent as h, type AdminOrgMember as i, type AdminOrgProject as j, type AdminOrgSummary as k, TerrantulaError as l, withSchema as w };
|
|
@@ -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
|
-
|
|
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,199 @@ 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
|
+
|
|
1518
|
+
// src/admin.ts
|
|
1519
|
+
import { z as z18 } from "zod";
|
|
1520
|
+
async function rawRequest2(baseUrl, hcOpts, path, init = {}) {
|
|
1521
|
+
const fetchImpl = hcOpts?.fetch ?? fetch;
|
|
1522
|
+
const rawHeaders = hcOpts?.headers;
|
|
1523
|
+
const resolvedHeaders = typeof rawHeaders === "function" ? await rawHeaders() : rawHeaders ?? {};
|
|
1524
|
+
return fetchImpl(`${baseUrl}${path}`, {
|
|
1525
|
+
...init,
|
|
1526
|
+
headers: {
|
|
1527
|
+
...resolvedHeaders,
|
|
1528
|
+
...init.headers
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
async function callRaw2(res) {
|
|
1533
|
+
if (!res.ok) {
|
|
1534
|
+
let message = fallbackMessage(res.status);
|
|
1535
|
+
try {
|
|
1536
|
+
const body = await res.json();
|
|
1537
|
+
if (body.error) message = body.error;
|
|
1538
|
+
} catch {
|
|
1539
|
+
}
|
|
1540
|
+
throw new TerrantulaError(res.status, { error: message });
|
|
1541
|
+
}
|
|
1542
|
+
return res.json();
|
|
1543
|
+
}
|
|
1544
|
+
function createAdminClient(baseUrl, hcOpts) {
|
|
1545
|
+
return {
|
|
1546
|
+
audit: {
|
|
1547
|
+
/**
|
|
1548
|
+
* GET /admin/audit
|
|
1549
|
+
* List super-admin audit events with optional filters.
|
|
1550
|
+
*/
|
|
1551
|
+
list: withSchema(
|
|
1552
|
+
z18.object({
|
|
1553
|
+
actor: z18.string().optional().describe("Filter by actor user ID"),
|
|
1554
|
+
action: z18.string().optional().describe("Filter by action name"),
|
|
1555
|
+
resourceKind: z18.string().optional().describe("Filter by resource kind"),
|
|
1556
|
+
since: z18.string().optional().describe("ISO 8601 datetime lower bound"),
|
|
1557
|
+
until: z18.string().optional().describe("ISO 8601 datetime upper bound"),
|
|
1558
|
+
limit: z18.coerce.number().int().min(1).max(200).optional().describe("Max results (1-200)"),
|
|
1559
|
+
offset: z18.coerce.number().int().min(0).optional().describe("Pagination offset")
|
|
1560
|
+
}),
|
|
1561
|
+
async (params) => {
|
|
1562
|
+
const qs = new URLSearchParams();
|
|
1563
|
+
if (params.actor !== void 0) qs.set("actor", params.actor);
|
|
1564
|
+
if (params.action !== void 0) qs.set("action", params.action);
|
|
1565
|
+
if (params.resourceKind !== void 0) qs.set("resourceKind", params.resourceKind);
|
|
1566
|
+
if (params.since !== void 0) qs.set("since", params.since);
|
|
1567
|
+
if (params.until !== void 0) qs.set("until", params.until);
|
|
1568
|
+
if (params.limit !== void 0) qs.set("limit", String(params.limit));
|
|
1569
|
+
if (params.offset !== void 0) qs.set("offset", String(params.offset));
|
|
1570
|
+
const search = qs.toString();
|
|
1571
|
+
return callRaw2(
|
|
1572
|
+
await rawRequest2(baseUrl, hcOpts, `/admin/audit${search ? `?${search}` : ""}`)
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
},
|
|
1577
|
+
orgs: {
|
|
1578
|
+
/**
|
|
1579
|
+
* GET /admin/orgs
|
|
1580
|
+
* List all organizations across tenants with member + project counts.
|
|
1581
|
+
*/
|
|
1582
|
+
list: withSchema(
|
|
1583
|
+
z18.object({}),
|
|
1584
|
+
async () => callRaw2(
|
|
1585
|
+
await rawRequest2(baseUrl, hcOpts, "/admin/orgs")
|
|
1586
|
+
)
|
|
1587
|
+
),
|
|
1588
|
+
/**
|
|
1589
|
+
* GET /admin/orgs/:id
|
|
1590
|
+
* Detail view: org fields + member list + project list.
|
|
1591
|
+
*/
|
|
1592
|
+
get: withSchema(
|
|
1593
|
+
z18.object({ id: z18.string().describe("Organization ID") }),
|
|
1594
|
+
async (params) => callRaw2(
|
|
1595
|
+
await rawRequest2(baseUrl, hcOpts, `/admin/orgs/${params.id}`)
|
|
1596
|
+
)
|
|
1597
|
+
),
|
|
1598
|
+
/**
|
|
1599
|
+
* POST /admin/orgs/:id/suspend
|
|
1600
|
+
* Set suspended_at = now(). Idempotent.
|
|
1601
|
+
*/
|
|
1602
|
+
suspend: withSchema(
|
|
1603
|
+
z18.object({ id: z18.string().describe("Organization ID") }),
|
|
1604
|
+
async (params) => callRaw2(
|
|
1605
|
+
await rawRequest2(baseUrl, hcOpts, `/admin/orgs/${params.id}/suspend`, {
|
|
1606
|
+
method: "POST"
|
|
1607
|
+
})
|
|
1608
|
+
)
|
|
1609
|
+
),
|
|
1610
|
+
/**
|
|
1611
|
+
* POST /admin/orgs/:id/unsuspend
|
|
1612
|
+
* Clear suspended_at.
|
|
1613
|
+
*/
|
|
1614
|
+
unsuspend: withSchema(
|
|
1615
|
+
z18.object({ id: z18.string().describe("Organization ID") }),
|
|
1616
|
+
async (params) => callRaw2(
|
|
1617
|
+
await rawRequest2(baseUrl, hcOpts, `/admin/orgs/${params.id}/unsuspend`, {
|
|
1618
|
+
method: "POST"
|
|
1619
|
+
})
|
|
1620
|
+
)
|
|
1621
|
+
)
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1429
1626
|
// src/index.ts
|
|
1430
1627
|
var createClient = (baseUrl, options = {}) => {
|
|
1431
1628
|
const opts = typeof options === "string" || typeof options === "function" ? { token: options } : options;
|
|
@@ -1459,7 +1656,9 @@ var createClient = (baseUrl, options = {}) => {
|
|
|
1459
1656
|
notifications: createNotificationsClient(baseUrl, hcOpts),
|
|
1460
1657
|
auditExport: createAuditExportClient(baseUrl, hcOpts),
|
|
1461
1658
|
userPreferences: createUserPreferencesClient(baseUrl, hcOpts),
|
|
1462
|
-
|
|
1659
|
+
importSources: createImportSourcesClient(proj),
|
|
1660
|
+
exportCatalog,
|
|
1661
|
+
admin: createAdminClient(baseUrl, hcOpts)
|
|
1463
1662
|
};
|
|
1464
1663
|
let warnedPools = false;
|
|
1465
1664
|
let warnedApplyRevisions = false;
|