@transcend-io/mcp-server-admin 0.3.19 → 0.4.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.
@@ -0,0 +1,1136 @@
1
+ import { EmptySchema, TranscendGraphQLBase, createListResult, createToolResult, defineTool, z } from "@transcend-io/mcp-server-base";
2
+ import { ScopeName, TRANSCEND_SCOPES } from "@transcend-io/privacy-types";
3
+ //#region src/tools/admin_create_api_key.ts
4
+ const scopeSummary = Object.entries(TRANSCEND_SCOPES).map(([name, def]) => {
5
+ const deps = def.dependencies.length > 0 ? ` (requires: ${def.dependencies.join(", ")})` : "";
6
+ return `- ${name}: ${def.title} — ${def.description}${deps}`;
7
+ }).join("\n");
8
+ const CreateApiKeySchema = z.object({
9
+ title: z.string().describe("Name/title for the API key"),
10
+ scopes: z.array(z.nativeEnum(ScopeName)).describe("Array of permission scopes for the key"),
11
+ dataSilos: z.array(z.string()).optional().describe("Array of data silo IDs to assign the key to (optional)")
12
+ });
13
+ function createAdminCreateApiKeyTool(clients) {
14
+ const graphql = clients.graphql;
15
+ return defineTool({
16
+ name: "admin_create_api_key",
17
+ description: "Create a new API key with specified scopes. WARNING: The token is only shown once! Scopes control what the key can access. Some scopes inherit dependencies — for example, manageDataMap requires viewDataMap. Use \"readOnly\" for view-only access to all resources, or \"fullAdmin\" for unrestricted access. Common scopes: manageApiKeys, manageDataMap, manageConsentManager, makeDataSubjectRequest, connectDataSilos, manageAssessments, manageDataInventory.\n\nAvailable scopes:\n" + scopeSummary,
18
+ category: "Admin",
19
+ readOnly: false,
20
+ confirmationHint: "Creates a new API key with the specified scopes",
21
+ annotations: {
22
+ readOnlyHint: false,
23
+ destructiveHint: true,
24
+ idempotentHint: false
25
+ },
26
+ zodSchema: CreateApiKeySchema,
27
+ handler: async ({ title, scopes, dataSilos }) => {
28
+ const { token, ...apiKey } = await graphql.createApiKey({
29
+ title,
30
+ scopes,
31
+ dataSilos
32
+ });
33
+ return createToolResult(true, {
34
+ apiKey,
35
+ token,
36
+ warning: "IMPORTANT: Save this token now! It will not be shown again.",
37
+ message: `API key "${title}" created successfully`
38
+ });
39
+ }
40
+ });
41
+ }
42
+ //#endregion
43
+ //#region src/tools/admin_get_current_user.ts
44
+ function createAdminGetCurrentUserTool(clients) {
45
+ const graphql = clients.graphql;
46
+ return defineTool({
47
+ name: "admin_get_current_user",
48
+ description: "Get information about the currently authenticated user (the API key owner)",
49
+ category: "Admin",
50
+ readOnly: true,
51
+ annotations: {
52
+ readOnlyHint: true,
53
+ destructiveHint: false,
54
+ idempotentHint: true
55
+ },
56
+ zodSchema: EmptySchema,
57
+ handler: async (_args) => {
58
+ return createToolResult(true, await graphql.getCurrentUser());
59
+ }
60
+ });
61
+ }
62
+ //#endregion
63
+ //#region src/tools/admin_get_organization.ts
64
+ function createAdminGetOrganizationTool(clients) {
65
+ const graphql = clients.graphql;
66
+ return defineTool({
67
+ name: "admin_get_organization",
68
+ description: "Get information about your Transcend organization",
69
+ category: "Admin",
70
+ readOnly: true,
71
+ annotations: {
72
+ readOnlyHint: true,
73
+ destructiveHint: false,
74
+ idempotentHint: true
75
+ },
76
+ zodSchema: EmptySchema,
77
+ handler: async (_args) => {
78
+ return createToolResult(true, await graphql.getOrganization());
79
+ }
80
+ });
81
+ }
82
+ //#endregion
83
+ //#region src/tools/admin_get_privacy_center.ts
84
+ function createAdminGetPrivacyCenterTool(clients) {
85
+ const graphql = clients.graphql;
86
+ return defineTool({
87
+ name: "admin_get_privacy_center",
88
+ description: "Get privacy center configuration for your organization",
89
+ category: "Admin",
90
+ readOnly: true,
91
+ annotations: {
92
+ readOnlyHint: true,
93
+ destructiveHint: false,
94
+ idempotentHint: true
95
+ },
96
+ zodSchema: EmptySchema,
97
+ handler: async (_args) => {
98
+ const result = await graphql.getPrivacyCenter();
99
+ if (!result) return createToolResult(true, {
100
+ found: false,
101
+ message: "No privacy center configured for this organization"
102
+ });
103
+ return createToolResult(true, {
104
+ found: true,
105
+ privacyCenter: result
106
+ });
107
+ }
108
+ });
109
+ }
110
+ //#endregion
111
+ //#region src/tools/admin_list_api_keys.ts
112
+ const ListApiKeysSchema = z.object({
113
+ limit: z.coerce.number().min(1).max(100).optional().default(50).describe("Results per page (1-100, default: 50)"),
114
+ cursor: z.string().optional().describe("Pagination cursor from previous response (where supported)"),
115
+ offset: z.coerce.number().min(0).optional().default(0).describe("Number of results to skip (default: 0)")
116
+ });
117
+ function createAdminListApiKeysTool(clients) {
118
+ const graphql = clients.graphql;
119
+ return defineTool({
120
+ name: "admin_list_api_keys",
121
+ description: "List all API keys configured for your organization (tokens are not shown). Note: API does not support cursor pagination (max ~100 results).",
122
+ category: "Admin",
123
+ readOnly: true,
124
+ annotations: {
125
+ readOnlyHint: true,
126
+ destructiveHint: false,
127
+ idempotentHint: true
128
+ },
129
+ zodSchema: ListApiKeysSchema,
130
+ handler: async ({ limit, offset }) => {
131
+ const result = await graphql.listApiKeys({
132
+ first: limit,
133
+ offset
134
+ });
135
+ return createListResult(result.nodes, {
136
+ totalCount: result.totalCount,
137
+ hasNextPage: result.pageInfo?.hasNextPage
138
+ });
139
+ }
140
+ });
141
+ }
142
+ //#endregion
143
+ //#region src/tools/admin_list_teams.ts
144
+ const ListTeamsSchema = z.object({
145
+ limit: z.coerce.number().min(1).max(100).optional().default(50).describe("Results per page (1-100, default: 50)"),
146
+ cursor: z.string().optional().describe("Pagination cursor from previous response (where supported)")
147
+ });
148
+ function createAdminListTeamsTool(clients) {
149
+ const graphql = clients.graphql;
150
+ return defineTool({
151
+ name: "admin_list_teams",
152
+ description: "List all teams in your Transcend organization. Note: API does not support cursor pagination (max ~100 results).",
153
+ category: "Admin",
154
+ readOnly: true,
155
+ annotations: {
156
+ readOnlyHint: true,
157
+ destructiveHint: false,
158
+ idempotentHint: true
159
+ },
160
+ zodSchema: ListTeamsSchema,
161
+ handler: async ({ limit, cursor }) => {
162
+ const result = await graphql.listTeams({
163
+ first: limit,
164
+ after: cursor
165
+ });
166
+ return createListResult(result.nodes, {
167
+ totalCount: result.totalCount,
168
+ hasNextPage: result.pageInfo?.hasNextPage
169
+ });
170
+ }
171
+ });
172
+ }
173
+ //#endregion
174
+ //#region src/tools/admin_list_users.ts
175
+ const ListUsersSchema = z.object({
176
+ limit: z.coerce.number().min(1).max(100).optional().default(50).describe("Results per page (1-100, default: 50)"),
177
+ cursor: z.string().optional().describe("Pagination cursor from previous response (where supported)")
178
+ });
179
+ function createAdminListUsersTool(clients) {
180
+ const graphql = clients.graphql;
181
+ return defineTool({
182
+ name: "admin_list_users",
183
+ description: "List all users in your Transcend organization. Note: API does not support cursor pagination (max ~100 results).",
184
+ category: "Admin",
185
+ readOnly: true,
186
+ annotations: {
187
+ readOnlyHint: true,
188
+ destructiveHint: false,
189
+ idempotentHint: true
190
+ },
191
+ zodSchema: ListUsersSchema,
192
+ handler: async ({ limit, cursor }) => {
193
+ const result = await graphql.listUsers({
194
+ first: limit,
195
+ after: cursor
196
+ });
197
+ return createListResult(result.nodes, {
198
+ totalCount: result.totalCount,
199
+ hasNextPage: result.pageInfo?.hasNextPage
200
+ });
201
+ }
202
+ });
203
+ }
204
+ //#endregion
205
+ //#region src/tools/admin_test_connection.ts
206
+ function createAdminTestConnectionTool(clients) {
207
+ const { rest } = clients;
208
+ const graphql = clients.graphql;
209
+ return defineTool({
210
+ name: "admin_test_connection",
211
+ description: "Test connectivity to both Transcend REST and GraphQL APIs",
212
+ category: "Admin",
213
+ readOnly: true,
214
+ annotations: {
215
+ readOnlyHint: true,
216
+ destructiveHint: false,
217
+ idempotentHint: true
218
+ },
219
+ zodSchema: EmptySchema,
220
+ handler: async (_args) => {
221
+ const [graphqlConnected, restConnected] = await Promise.all([graphql.testConnection(), rest.testConnection()]);
222
+ const allConnected = graphqlConnected && restConnected;
223
+ return createToolResult(true, {
224
+ connected: allConnected,
225
+ details: {
226
+ graphql: {
227
+ connected: graphqlConnected,
228
+ url: graphql.getBaseUrl()
229
+ },
230
+ rest: {
231
+ connected: restConnected,
232
+ url: rest.getBaseUrl()
233
+ }
234
+ },
235
+ message: allConnected ? "Successfully connected to all Transcend APIs" : "Some API connections failed - check details",
236
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
237
+ });
238
+ }
239
+ });
240
+ }
241
+ //#endregion
242
+ //#region src/tools/index.ts
243
+ function getAdminTools(clients) {
244
+ return [
245
+ createAdminGetOrganizationTool(clients),
246
+ createAdminGetCurrentUserTool(clients),
247
+ createAdminListUsersTool(clients),
248
+ createAdminListTeamsTool(clients),
249
+ createAdminListApiKeysTool(clients),
250
+ createAdminCreateApiKeyTool(clients),
251
+ createAdminGetPrivacyCenterTool(clients),
252
+ createAdminTestConnectionTool(clients)
253
+ ];
254
+ }
255
+ //#endregion
256
+ //#region src/scopes.ts
257
+ /** OAuth scopes required for Admin MCP tools (offline_access added by base). */
258
+ const ADMIN_OAUTH_SCOPES = [
259
+ ScopeName.ViewEmployees,
260
+ ScopeName.ViewApiKeys,
261
+ ScopeName.ManageApiKeys
262
+ ];
263
+ //#endregion
264
+ //#region src/__generated__/gql.ts
265
+ const documents = {
266
+ "\n query AdminGetOrganization {\n organization {\n id\n name\n uri\n createdAt\n }\n }\n": {
267
+ "kind": "Document",
268
+ "definitions": [{
269
+ "kind": "OperationDefinition",
270
+ "operation": "query",
271
+ "name": {
272
+ "kind": "Name",
273
+ "value": "AdminGetOrganization"
274
+ },
275
+ "selectionSet": {
276
+ "kind": "SelectionSet",
277
+ "selections": [{
278
+ "kind": "Field",
279
+ "name": {
280
+ "kind": "Name",
281
+ "value": "organization"
282
+ },
283
+ "selectionSet": {
284
+ "kind": "SelectionSet",
285
+ "selections": [
286
+ {
287
+ "kind": "Field",
288
+ "name": {
289
+ "kind": "Name",
290
+ "value": "id"
291
+ }
292
+ },
293
+ {
294
+ "kind": "Field",
295
+ "name": {
296
+ "kind": "Name",
297
+ "value": "name"
298
+ }
299
+ },
300
+ {
301
+ "kind": "Field",
302
+ "name": {
303
+ "kind": "Name",
304
+ "value": "uri"
305
+ }
306
+ },
307
+ {
308
+ "kind": "Field",
309
+ "name": {
310
+ "kind": "Name",
311
+ "value": "createdAt"
312
+ }
313
+ }
314
+ ]
315
+ }
316
+ }]
317
+ }
318
+ }]
319
+ },
320
+ "\n query AdminGetCurrentUser {\n user {\n id\n email\n name\n createdAt\n }\n }\n": {
321
+ "kind": "Document",
322
+ "definitions": [{
323
+ "kind": "OperationDefinition",
324
+ "operation": "query",
325
+ "name": {
326
+ "kind": "Name",
327
+ "value": "AdminGetCurrentUser"
328
+ },
329
+ "selectionSet": {
330
+ "kind": "SelectionSet",
331
+ "selections": [{
332
+ "kind": "Field",
333
+ "name": {
334
+ "kind": "Name",
335
+ "value": "user"
336
+ },
337
+ "selectionSet": {
338
+ "kind": "SelectionSet",
339
+ "selections": [
340
+ {
341
+ "kind": "Field",
342
+ "name": {
343
+ "kind": "Name",
344
+ "value": "id"
345
+ }
346
+ },
347
+ {
348
+ "kind": "Field",
349
+ "name": {
350
+ "kind": "Name",
351
+ "value": "email"
352
+ }
353
+ },
354
+ {
355
+ "kind": "Field",
356
+ "name": {
357
+ "kind": "Name",
358
+ "value": "name"
359
+ }
360
+ },
361
+ {
362
+ "kind": "Field",
363
+ "name": {
364
+ "kind": "Name",
365
+ "value": "createdAt"
366
+ }
367
+ }
368
+ ]
369
+ }
370
+ }]
371
+ }
372
+ }]
373
+ },
374
+ "\n query AdminListUsers($first: Int, $filterBy: UserFiltersInput) {\n users(first: $first, filterBy: $filterBy) {\n nodes {\n id\n email\n name\n }\n totalCount\n }\n }\n": {
375
+ "kind": "Document",
376
+ "definitions": [{
377
+ "kind": "OperationDefinition",
378
+ "operation": "query",
379
+ "name": {
380
+ "kind": "Name",
381
+ "value": "AdminListUsers"
382
+ },
383
+ "variableDefinitions": [{
384
+ "kind": "VariableDefinition",
385
+ "variable": {
386
+ "kind": "Variable",
387
+ "name": {
388
+ "kind": "Name",
389
+ "value": "first"
390
+ }
391
+ },
392
+ "type": {
393
+ "kind": "NamedType",
394
+ "name": {
395
+ "kind": "Name",
396
+ "value": "Int"
397
+ }
398
+ }
399
+ }, {
400
+ "kind": "VariableDefinition",
401
+ "variable": {
402
+ "kind": "Variable",
403
+ "name": {
404
+ "kind": "Name",
405
+ "value": "filterBy"
406
+ }
407
+ },
408
+ "type": {
409
+ "kind": "NamedType",
410
+ "name": {
411
+ "kind": "Name",
412
+ "value": "UserFiltersInput"
413
+ }
414
+ }
415
+ }],
416
+ "selectionSet": {
417
+ "kind": "SelectionSet",
418
+ "selections": [{
419
+ "kind": "Field",
420
+ "name": {
421
+ "kind": "Name",
422
+ "value": "users"
423
+ },
424
+ "arguments": [{
425
+ "kind": "Argument",
426
+ "name": {
427
+ "kind": "Name",
428
+ "value": "first"
429
+ },
430
+ "value": {
431
+ "kind": "Variable",
432
+ "name": {
433
+ "kind": "Name",
434
+ "value": "first"
435
+ }
436
+ }
437
+ }, {
438
+ "kind": "Argument",
439
+ "name": {
440
+ "kind": "Name",
441
+ "value": "filterBy"
442
+ },
443
+ "value": {
444
+ "kind": "Variable",
445
+ "name": {
446
+ "kind": "Name",
447
+ "value": "filterBy"
448
+ }
449
+ }
450
+ }],
451
+ "selectionSet": {
452
+ "kind": "SelectionSet",
453
+ "selections": [{
454
+ "kind": "Field",
455
+ "name": {
456
+ "kind": "Name",
457
+ "value": "nodes"
458
+ },
459
+ "selectionSet": {
460
+ "kind": "SelectionSet",
461
+ "selections": [
462
+ {
463
+ "kind": "Field",
464
+ "name": {
465
+ "kind": "Name",
466
+ "value": "id"
467
+ }
468
+ },
469
+ {
470
+ "kind": "Field",
471
+ "name": {
472
+ "kind": "Name",
473
+ "value": "email"
474
+ }
475
+ },
476
+ {
477
+ "kind": "Field",
478
+ "name": {
479
+ "kind": "Name",
480
+ "value": "name"
481
+ }
482
+ }
483
+ ]
484
+ }
485
+ }, {
486
+ "kind": "Field",
487
+ "name": {
488
+ "kind": "Name",
489
+ "value": "totalCount"
490
+ }
491
+ }]
492
+ }
493
+ }]
494
+ }
495
+ }]
496
+ },
497
+ "\n query AdminListTeams($first: Int) {\n teams(first: $first) {\n nodes {\n id\n name\n }\n totalCount\n }\n }\n": {
498
+ "kind": "Document",
499
+ "definitions": [{
500
+ "kind": "OperationDefinition",
501
+ "operation": "query",
502
+ "name": {
503
+ "kind": "Name",
504
+ "value": "AdminListTeams"
505
+ },
506
+ "variableDefinitions": [{
507
+ "kind": "VariableDefinition",
508
+ "variable": {
509
+ "kind": "Variable",
510
+ "name": {
511
+ "kind": "Name",
512
+ "value": "first"
513
+ }
514
+ },
515
+ "type": {
516
+ "kind": "NamedType",
517
+ "name": {
518
+ "kind": "Name",
519
+ "value": "Int"
520
+ }
521
+ }
522
+ }],
523
+ "selectionSet": {
524
+ "kind": "SelectionSet",
525
+ "selections": [{
526
+ "kind": "Field",
527
+ "name": {
528
+ "kind": "Name",
529
+ "value": "teams"
530
+ },
531
+ "arguments": [{
532
+ "kind": "Argument",
533
+ "name": {
534
+ "kind": "Name",
535
+ "value": "first"
536
+ },
537
+ "value": {
538
+ "kind": "Variable",
539
+ "name": {
540
+ "kind": "Name",
541
+ "value": "first"
542
+ }
543
+ }
544
+ }],
545
+ "selectionSet": {
546
+ "kind": "SelectionSet",
547
+ "selections": [{
548
+ "kind": "Field",
549
+ "name": {
550
+ "kind": "Name",
551
+ "value": "nodes"
552
+ },
553
+ "selectionSet": {
554
+ "kind": "SelectionSet",
555
+ "selections": [{
556
+ "kind": "Field",
557
+ "name": {
558
+ "kind": "Name",
559
+ "value": "id"
560
+ }
561
+ }, {
562
+ "kind": "Field",
563
+ "name": {
564
+ "kind": "Name",
565
+ "value": "name"
566
+ }
567
+ }]
568
+ }
569
+ }, {
570
+ "kind": "Field",
571
+ "name": {
572
+ "kind": "Name",
573
+ "value": "totalCount"
574
+ }
575
+ }]
576
+ }
577
+ }]
578
+ }
579
+ }]
580
+ },
581
+ "\n query AdminListApiKeys($first: Int, $offset: Int) {\n apiKeys(first: $first, offset: $offset) {\n nodes {\n id\n title\n scopes {\n id\n name\n }\n lastUsedAt\n createdAt\n }\n totalCount\n }\n }\n": {
582
+ "kind": "Document",
583
+ "definitions": [{
584
+ "kind": "OperationDefinition",
585
+ "operation": "query",
586
+ "name": {
587
+ "kind": "Name",
588
+ "value": "AdminListApiKeys"
589
+ },
590
+ "variableDefinitions": [{
591
+ "kind": "VariableDefinition",
592
+ "variable": {
593
+ "kind": "Variable",
594
+ "name": {
595
+ "kind": "Name",
596
+ "value": "first"
597
+ }
598
+ },
599
+ "type": {
600
+ "kind": "NamedType",
601
+ "name": {
602
+ "kind": "Name",
603
+ "value": "Int"
604
+ }
605
+ }
606
+ }, {
607
+ "kind": "VariableDefinition",
608
+ "variable": {
609
+ "kind": "Variable",
610
+ "name": {
611
+ "kind": "Name",
612
+ "value": "offset"
613
+ }
614
+ },
615
+ "type": {
616
+ "kind": "NamedType",
617
+ "name": {
618
+ "kind": "Name",
619
+ "value": "Int"
620
+ }
621
+ }
622
+ }],
623
+ "selectionSet": {
624
+ "kind": "SelectionSet",
625
+ "selections": [{
626
+ "kind": "Field",
627
+ "name": {
628
+ "kind": "Name",
629
+ "value": "apiKeys"
630
+ },
631
+ "arguments": [{
632
+ "kind": "Argument",
633
+ "name": {
634
+ "kind": "Name",
635
+ "value": "first"
636
+ },
637
+ "value": {
638
+ "kind": "Variable",
639
+ "name": {
640
+ "kind": "Name",
641
+ "value": "first"
642
+ }
643
+ }
644
+ }, {
645
+ "kind": "Argument",
646
+ "name": {
647
+ "kind": "Name",
648
+ "value": "offset"
649
+ },
650
+ "value": {
651
+ "kind": "Variable",
652
+ "name": {
653
+ "kind": "Name",
654
+ "value": "offset"
655
+ }
656
+ }
657
+ }],
658
+ "selectionSet": {
659
+ "kind": "SelectionSet",
660
+ "selections": [{
661
+ "kind": "Field",
662
+ "name": {
663
+ "kind": "Name",
664
+ "value": "nodes"
665
+ },
666
+ "selectionSet": {
667
+ "kind": "SelectionSet",
668
+ "selections": [
669
+ {
670
+ "kind": "Field",
671
+ "name": {
672
+ "kind": "Name",
673
+ "value": "id"
674
+ }
675
+ },
676
+ {
677
+ "kind": "Field",
678
+ "name": {
679
+ "kind": "Name",
680
+ "value": "title"
681
+ }
682
+ },
683
+ {
684
+ "kind": "Field",
685
+ "name": {
686
+ "kind": "Name",
687
+ "value": "scopes"
688
+ },
689
+ "selectionSet": {
690
+ "kind": "SelectionSet",
691
+ "selections": [{
692
+ "kind": "Field",
693
+ "name": {
694
+ "kind": "Name",
695
+ "value": "id"
696
+ }
697
+ }, {
698
+ "kind": "Field",
699
+ "name": {
700
+ "kind": "Name",
701
+ "value": "name"
702
+ }
703
+ }]
704
+ }
705
+ },
706
+ {
707
+ "kind": "Field",
708
+ "name": {
709
+ "kind": "Name",
710
+ "value": "lastUsedAt"
711
+ }
712
+ },
713
+ {
714
+ "kind": "Field",
715
+ "name": {
716
+ "kind": "Name",
717
+ "value": "createdAt"
718
+ }
719
+ }
720
+ ]
721
+ }
722
+ }, {
723
+ "kind": "Field",
724
+ "name": {
725
+ "kind": "Name",
726
+ "value": "totalCount"
727
+ }
728
+ }]
729
+ }
730
+ }]
731
+ }
732
+ }]
733
+ },
734
+ "\n mutation AdminCreateApiKey($input: ApiKeyInput!) {\n createApiKey(input: $input) {\n apiKey {\n id\n title\n apiKey\n preview\n scopes {\n id\n name\n }\n createdAt\n }\n }\n }\n": {
735
+ "kind": "Document",
736
+ "definitions": [{
737
+ "kind": "OperationDefinition",
738
+ "operation": "mutation",
739
+ "name": {
740
+ "kind": "Name",
741
+ "value": "AdminCreateApiKey"
742
+ },
743
+ "variableDefinitions": [{
744
+ "kind": "VariableDefinition",
745
+ "variable": {
746
+ "kind": "Variable",
747
+ "name": {
748
+ "kind": "Name",
749
+ "value": "input"
750
+ }
751
+ },
752
+ "type": {
753
+ "kind": "NonNullType",
754
+ "type": {
755
+ "kind": "NamedType",
756
+ "name": {
757
+ "kind": "Name",
758
+ "value": "ApiKeyInput"
759
+ }
760
+ }
761
+ }
762
+ }],
763
+ "selectionSet": {
764
+ "kind": "SelectionSet",
765
+ "selections": [{
766
+ "kind": "Field",
767
+ "name": {
768
+ "kind": "Name",
769
+ "value": "createApiKey"
770
+ },
771
+ "arguments": [{
772
+ "kind": "Argument",
773
+ "name": {
774
+ "kind": "Name",
775
+ "value": "input"
776
+ },
777
+ "value": {
778
+ "kind": "Variable",
779
+ "name": {
780
+ "kind": "Name",
781
+ "value": "input"
782
+ }
783
+ }
784
+ }],
785
+ "selectionSet": {
786
+ "kind": "SelectionSet",
787
+ "selections": [{
788
+ "kind": "Field",
789
+ "name": {
790
+ "kind": "Name",
791
+ "value": "apiKey"
792
+ },
793
+ "selectionSet": {
794
+ "kind": "SelectionSet",
795
+ "selections": [
796
+ {
797
+ "kind": "Field",
798
+ "name": {
799
+ "kind": "Name",
800
+ "value": "id"
801
+ }
802
+ },
803
+ {
804
+ "kind": "Field",
805
+ "name": {
806
+ "kind": "Name",
807
+ "value": "title"
808
+ }
809
+ },
810
+ {
811
+ "kind": "Field",
812
+ "name": {
813
+ "kind": "Name",
814
+ "value": "apiKey"
815
+ }
816
+ },
817
+ {
818
+ "kind": "Field",
819
+ "name": {
820
+ "kind": "Name",
821
+ "value": "preview"
822
+ }
823
+ },
824
+ {
825
+ "kind": "Field",
826
+ "name": {
827
+ "kind": "Name",
828
+ "value": "scopes"
829
+ },
830
+ "selectionSet": {
831
+ "kind": "SelectionSet",
832
+ "selections": [{
833
+ "kind": "Field",
834
+ "name": {
835
+ "kind": "Name",
836
+ "value": "id"
837
+ }
838
+ }, {
839
+ "kind": "Field",
840
+ "name": {
841
+ "kind": "Name",
842
+ "value": "name"
843
+ }
844
+ }]
845
+ }
846
+ },
847
+ {
848
+ "kind": "Field",
849
+ "name": {
850
+ "kind": "Name",
851
+ "value": "createdAt"
852
+ }
853
+ }
854
+ ]
855
+ }
856
+ }]
857
+ }
858
+ }]
859
+ }
860
+ }]
861
+ },
862
+ "\n query AdminGetPrivacyCenter($lookup: PrivacyCenterLookupInput) {\n privacyCenter(lookup: $lookup) {\n id\n }\n }\n": {
863
+ "kind": "Document",
864
+ "definitions": [{
865
+ "kind": "OperationDefinition",
866
+ "operation": "query",
867
+ "name": {
868
+ "kind": "Name",
869
+ "value": "AdminGetPrivacyCenter"
870
+ },
871
+ "variableDefinitions": [{
872
+ "kind": "VariableDefinition",
873
+ "variable": {
874
+ "kind": "Variable",
875
+ "name": {
876
+ "kind": "Name",
877
+ "value": "lookup"
878
+ }
879
+ },
880
+ "type": {
881
+ "kind": "NamedType",
882
+ "name": {
883
+ "kind": "Name",
884
+ "value": "PrivacyCenterLookupInput"
885
+ }
886
+ }
887
+ }],
888
+ "selectionSet": {
889
+ "kind": "SelectionSet",
890
+ "selections": [{
891
+ "kind": "Field",
892
+ "name": {
893
+ "kind": "Name",
894
+ "value": "privacyCenter"
895
+ },
896
+ "arguments": [{
897
+ "kind": "Argument",
898
+ "name": {
899
+ "kind": "Name",
900
+ "value": "lookup"
901
+ },
902
+ "value": {
903
+ "kind": "Variable",
904
+ "name": {
905
+ "kind": "Name",
906
+ "value": "lookup"
907
+ }
908
+ }
909
+ }],
910
+ "selectionSet": {
911
+ "kind": "SelectionSet",
912
+ "selections": [{
913
+ "kind": "Field",
914
+ "name": {
915
+ "kind": "Name",
916
+ "value": "id"
917
+ }
918
+ }]
919
+ }
920
+ }]
921
+ }
922
+ }]
923
+ }
924
+ };
925
+ function graphql(source) {
926
+ return documents[source] ?? {};
927
+ }
928
+ //#endregion
929
+ //#region src/graphql.ts
930
+ const GetOrganizationDoc = graphql(`
931
+ query AdminGetOrganization {
932
+ organization {
933
+ id
934
+ name
935
+ uri
936
+ createdAt
937
+ }
938
+ }
939
+ `);
940
+ const GetCurrentUserDoc = graphql(`
941
+ query AdminGetCurrentUser {
942
+ user {
943
+ id
944
+ email
945
+ name
946
+ createdAt
947
+ }
948
+ }
949
+ `);
950
+ const ListUsersDoc = graphql(`
951
+ query AdminListUsers($first: Int, $filterBy: UserFiltersInput) {
952
+ users(first: $first, filterBy: $filterBy) {
953
+ nodes {
954
+ id
955
+ email
956
+ name
957
+ }
958
+ totalCount
959
+ }
960
+ }
961
+ `);
962
+ const ListTeamsDoc = graphql(`
963
+ query AdminListTeams($first: Int) {
964
+ teams(first: $first) {
965
+ nodes {
966
+ id
967
+ name
968
+ }
969
+ totalCount
970
+ }
971
+ }
972
+ `);
973
+ const ListApiKeysDoc = graphql(`
974
+ query AdminListApiKeys($first: Int, $offset: Int) {
975
+ apiKeys(first: $first, offset: $offset) {
976
+ nodes {
977
+ id
978
+ title
979
+ scopes {
980
+ id
981
+ name
982
+ }
983
+ lastUsedAt
984
+ createdAt
985
+ }
986
+ totalCount
987
+ }
988
+ }
989
+ `);
990
+ const CreateApiKeyDoc = graphql(`
991
+ mutation AdminCreateApiKey($input: ApiKeyInput!) {
992
+ createApiKey(input: $input) {
993
+ apiKey {
994
+ id
995
+ title
996
+ apiKey
997
+ preview
998
+ scopes {
999
+ id
1000
+ name
1001
+ }
1002
+ createdAt
1003
+ }
1004
+ }
1005
+ }
1006
+ `);
1007
+ const GetPrivacyCenterDoc = graphql(`
1008
+ query AdminGetPrivacyCenter($lookup: PrivacyCenterLookupInput) {
1009
+ privacyCenter(lookup: $lookup) {
1010
+ id
1011
+ }
1012
+ }
1013
+ `);
1014
+ var AdminMixin = class extends TranscendGraphQLBase {
1015
+ async getOrganization() {
1016
+ const data = await this.makeRequest(GetOrganizationDoc);
1017
+ return {
1018
+ id: data.organization.id,
1019
+ name: data.organization.name,
1020
+ uri: data.organization.uri,
1021
+ createdAt: data.organization.createdAt
1022
+ };
1023
+ }
1024
+ async getCurrentUser() {
1025
+ const data = await this.makeRequest(GetCurrentUserDoc);
1026
+ if (!data.user) throw new Error("No user is currently authenticated for this API key.");
1027
+ return {
1028
+ id: data.user.id,
1029
+ email: data.user.email,
1030
+ name: data.user.name,
1031
+ isActive: true,
1032
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString()
1033
+ };
1034
+ }
1035
+ async listUsers(options) {
1036
+ const data = await this.makeRequest(ListUsersDoc, {
1037
+ first: Math.min(options?.first ?? 50, 100),
1038
+ filterBy: options?.filterBy ?? null
1039
+ });
1040
+ return {
1041
+ nodes: data.users.nodes.map((node) => ({
1042
+ id: node.id,
1043
+ email: node.email,
1044
+ name: node.name,
1045
+ isActive: true,
1046
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString()
1047
+ })),
1048
+ pageInfo: {
1049
+ hasNextPage: data.users.nodes.length < data.users.totalCount,
1050
+ hasPreviousPage: false
1051
+ },
1052
+ totalCount: data.users.totalCount
1053
+ };
1054
+ }
1055
+ async listTeams(options) {
1056
+ const data = await this.makeRequest(ListTeamsDoc, { first: Math.min(options?.first ?? 50, 100) });
1057
+ return {
1058
+ nodes: data.teams.nodes.map((node) => ({
1059
+ id: node.id,
1060
+ name: node.name,
1061
+ createdAt: (/* @__PURE__ */ new Date(0)).toISOString()
1062
+ })),
1063
+ pageInfo: {
1064
+ hasNextPage: data.teams.nodes.length < data.teams.totalCount,
1065
+ hasPreviousPage: false
1066
+ },
1067
+ totalCount: data.teams.totalCount
1068
+ };
1069
+ }
1070
+ async listApiKeys(options) {
1071
+ const data = await this.makeRequest(ListApiKeysDoc, {
1072
+ first: Math.min(options?.first ?? 50, 100),
1073
+ offset: options?.offset ?? 0
1074
+ });
1075
+ return {
1076
+ nodes: data.apiKeys.nodes.map((node) => ({
1077
+ id: node.id,
1078
+ title: node.title,
1079
+ scopes: node.scopes.map((scope) => ({
1080
+ id: scope.id,
1081
+ name: scope.name
1082
+ })),
1083
+ lastUsedAt: node.lastUsedAt ?? void 0,
1084
+ createdAt: node.createdAt
1085
+ })),
1086
+ pageInfo: {
1087
+ hasNextPage: data.apiKeys.nodes.length < data.apiKeys.totalCount,
1088
+ hasPreviousPage: false
1089
+ },
1090
+ totalCount: data.apiKeys.totalCount
1091
+ };
1092
+ }
1093
+ /**
1094
+ * Create a new API key. The returned `token` is the plain-text bearer the
1095
+ * caller must surface to the user immediately -- the API key endpoint never
1096
+ * returns it again. The token is on `createApiKey.apiKey.apiKey` (a sibling
1097
+ * of `id`/`title`/`scopes`), not a top-level `token` field.
1098
+ */
1099
+ async createApiKey(input) {
1100
+ const created = (await this.makeRequest(CreateApiKeyDoc, { input: {
1101
+ title: input.title,
1102
+ scopes: input.scopes,
1103
+ dataSilos: input.dataSilos ?? null
1104
+ } })).createApiKey.apiKey;
1105
+ return {
1106
+ id: created.id,
1107
+ title: created.title,
1108
+ scopes: created.scopes.map((scope) => ({
1109
+ id: scope.id,
1110
+ name: scope.name
1111
+ })),
1112
+ createdAt: created.createdAt,
1113
+ token: created.apiKey
1114
+ };
1115
+ }
1116
+ async getPrivacyCenter(lookup) {
1117
+ try {
1118
+ const data = await this.makeRequest(GetPrivacyCenterDoc, { lookup: lookup ?? null });
1119
+ if (data.privacyCenter) return {
1120
+ id: data.privacyCenter.id,
1121
+ name: "Privacy Center",
1122
+ url: lookup?.url ?? "",
1123
+ isActive: true,
1124
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1125
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1126
+ };
1127
+ return null;
1128
+ } catch {
1129
+ return null;
1130
+ }
1131
+ }
1132
+ };
1133
+ //#endregion
1134
+ export { ListTeamsSchema as a, ListUsersSchema as i, ADMIN_OAUTH_SCOPES as n, ListApiKeysSchema as o, getAdminTools as r, CreateApiKeySchema as s, AdminMixin as t };
1135
+
1136
+ //# sourceMappingURL=graphql-C1RNzXVj.mjs.map