@itm-studio/partner-sdk 0.6.8 → 0.6.10

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
@@ -675,7 +675,16 @@ var types_default = {
675
675
  282,
676
676
  289,
677
677
  290,
678
- 291
678
+ 291,
679
+ 305,
680
+ 309,
681
+ 313,
682
+ 314,
683
+ 315,
684
+ 316,
685
+ 317,
686
+ 318,
687
+ 319
679
688
  ],
680
689
  "types": {
681
690
  "DateTime": {},
@@ -3629,6 +3638,85 @@ var types_default = {
3629
3638
  ]
3630
3639
  },
3631
3640
  "Query": {
3641
+ "getPartnerWalletOperation": [
3642
+ 306,
3643
+ {
3644
+ "brandUid": [
3645
+ 36,
3646
+ "String!"
3647
+ ],
3648
+ "operationUid": [
3649
+ 36,
3650
+ "String!"
3651
+ ],
3652
+ "walletUid": [
3653
+ 36,
3654
+ "String!"
3655
+ ]
3656
+ }
3657
+ ],
3658
+ "listPartnerWalletActivity": [
3659
+ 300,
3660
+ {
3661
+ "brandUid": [
3662
+ 36,
3663
+ "String!"
3664
+ ],
3665
+ "cursor": [
3666
+ 36
3667
+ ],
3668
+ "take": [
3669
+ 38
3670
+ ],
3671
+ "walletUid": [
3672
+ 36,
3673
+ "String!"
3674
+ ]
3675
+ }
3676
+ ],
3677
+ "listPartnerWalletOperations": [
3678
+ 308,
3679
+ {
3680
+ "brandUid": [
3681
+ 36,
3682
+ "String!"
3683
+ ],
3684
+ "cursor": [
3685
+ 36
3686
+ ],
3687
+ "excludeUnconfirmed": [
3688
+ 39
3689
+ ],
3690
+ "kind": [
3691
+ 313
3692
+ ],
3693
+ "statuses": [
3694
+ 314,
3695
+ "[WalletOperationStatus!]"
3696
+ ],
3697
+ "take": [
3698
+ 38
3699
+ ],
3700
+ "walletUid": [
3701
+ 36
3702
+ ]
3703
+ }
3704
+ ],
3705
+ "listPartnerWallets": [
3706
+ 310,
3707
+ {
3708
+ "brandUid": [
3709
+ 36,
3710
+ "String!"
3711
+ ],
3712
+ "cursor": [
3713
+ 36
3714
+ ],
3715
+ "take": [
3716
+ 38
3717
+ ]
3718
+ }
3719
+ ],
3632
3720
  "getPartnerForms": [
3633
3721
  292,
3634
3722
  {
@@ -4128,6 +4216,35 @@ var types_default = {
4128
4216
  ]
4129
4217
  }
4130
4218
  ],
4219
+ "getPartnerSpaceLocations": [
4220
+ 322,
4221
+ {
4222
+ "cursor": [
4223
+ 36
4224
+ ],
4225
+ "take": [
4226
+ 38
4227
+ ]
4228
+ }
4229
+ ],
4230
+ "getPartnerSpaceCalendar": [
4231
+ 327,
4232
+ {
4233
+ "input": [
4234
+ 332,
4235
+ "SpaceCalendarInput!"
4236
+ ]
4237
+ }
4238
+ ],
4239
+ "getPartnerSpaceAvailability": [
4240
+ 331,
4241
+ {
4242
+ "input": [
4243
+ 333,
4244
+ "SpaceAvailabilityInput!"
4245
+ ]
4246
+ }
4247
+ ],
4131
4248
  "__typename": [
4132
4249
  36
4133
4250
  ]
@@ -4829,6 +4946,57 @@ var types_default = {
4829
4946
  ]
4830
4947
  },
4831
4948
  "Mutation": {
4949
+ "confirmPartnerWalletOperation": [
4950
+ 306,
4951
+ {
4952
+ "brandUid": [
4953
+ 36,
4954
+ "String!"
4955
+ ],
4956
+ "operationUid": [
4957
+ 36,
4958
+ "String!"
4959
+ ],
4960
+ "walletUid": [
4961
+ 36,
4962
+ "String!"
4963
+ ]
4964
+ }
4965
+ ],
4966
+ "createPartnerWalletPaymentRequest": [
4967
+ 306,
4968
+ {
4969
+ "brandUid": [
4970
+ 36,
4971
+ "String!"
4972
+ ],
4973
+ "input": [
4974
+ 311,
4975
+ "CreateBrandWalletPaymentRequestInput!"
4976
+ ],
4977
+ "walletUid": [
4978
+ 36,
4979
+ "String!"
4980
+ ]
4981
+ }
4982
+ ],
4983
+ "preparePartnerWalletPayment": [
4984
+ 306,
4985
+ {
4986
+ "brandUid": [
4987
+ 36,
4988
+ "String!"
4989
+ ],
4990
+ "input": [
4991
+ 312,
4992
+ "PrepareBrandWalletPaymentInput!"
4993
+ ],
4994
+ "walletUid": [
4995
+ 36,
4996
+ "String!"
4997
+ ]
4998
+ }
4999
+ ],
4832
5000
  "createPartnerBrandApp": [
4833
5001
  154,
4834
5002
  {
@@ -7173,151 +7341,787 @@ var types_default = {
7173
7341
  "__typename": [
7174
7342
  36
7175
7343
  ]
7176
- }
7177
- }
7178
- };
7179
-
7180
- // src/generated/index.ts
7181
- var typeMap = linkTypeMap(types_default);
7182
- var createClient2 = function(options) {
7183
- return createClient({
7184
- url: void 0,
7185
- ...options,
7186
- queryRoot: typeMap.Query,
7187
- mutationRoot: typeMap.Mutation,
7188
- subscriptionRoot: typeMap.Subscription
7189
- });
7190
- };
7191
- var everything = {
7192
- __scalar: true
7193
- };
7194
- var generateQueryOp = function(fields) {
7195
- return generateGraphqlOperation("query", typeMap.Query, fields);
7196
- };
7197
- var generateMutationOp = function(fields) {
7198
- return generateGraphqlOperation("mutation", typeMap.Mutation, fields);
7199
- };
7200
-
7201
- // src/runtime.ts
7202
- var NODE_SERVER_ONLY_ERROR = "ITM Partner SDK is Node-server-only. Do not import it in browser, React Native, worker, edge, or Electron process code. Call it from a Node backend and return only the data the client needs.";
7203
- function assertNodeServerRuntime(runtime = globalThis) {
7204
- const runtimeProcess = runtime.process;
7205
- const isNode = runtimeProcess?.release?.name === "node" && typeof runtimeProcess.versions?.node === "string";
7206
- const isBrowserWindow = typeof runtime.window !== "undefined";
7207
- const isReactNative = runtime.navigator?.product === "ReactNative";
7208
- const isElectron = typeof runtimeProcess?.versions?.electron === "string" || typeof runtimeProcess?.type === "string";
7209
- if (!isNode || isBrowserWindow || isReactNative || isElectron) {
7210
- throw new Error(NODE_SERVER_ONLY_ERROR);
7211
- }
7212
- }
7213
-
7214
- // src/client.ts
7215
- assertNodeServerRuntime();
7216
- var DEFAULT_API_URL = "https://itm-backend-production.up.railway.app/graphql";
7217
- var RESERVED_AGENT_HEADERS = /* @__PURE__ */ new Set([
7218
- "authorization",
7219
- "x-itm-integration-access-token",
7220
- "x-itm-agent-session-id",
7221
- "x-itm-agent-bootstrap-token",
7222
- "x-itm-agent-access-token",
7223
- "x-partner-api-key"
7224
- ]);
7225
- function createITMPartnerClient(config) {
7226
- const { baseUrl, headers: extraHeaders, signal } = config;
7227
- const token = "token" in config ? config.token : void 0;
7228
- const agentSession = "agentSession" in config ? config.agentSession : void 0;
7229
- const agentAccess = "agentAccess" in config ? config.agentAccess : void 0;
7230
- const integration = "integration" in config ? config.integration : void 0;
7231
- const providedModes = [token, agentSession, agentAccess, integration].filter(
7232
- (mode) => mode !== void 0
7233
- );
7234
- if (providedModes.length > 1) {
7235
- throw new Error(
7236
- "ITM Partner SDK: provide exactly one of token, agentSession, agentAccess, or integration authentication."
7237
- );
7238
- }
7239
- if (integration !== void 0) {
7240
- if (typeof integration.accessToken !== "function" && (typeof integration.accessToken !== "string" || !integration.accessToken.trim())) {
7241
- throw new Error("ITM Partner SDK: integration.accessToken is required.");
7242
- }
7243
- return createSafeClient({
7244
- url: baseUrl ?? DEFAULT_API_URL,
7245
- signal,
7246
- headers: async () => {
7247
- const extra = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
7248
- let credential;
7249
- try {
7250
- credential = typeof integration.accessToken === "function" ? await integration.accessToken() : integration.accessToken;
7251
- } catch {
7252
- throw new Error("ITM Partner SDK: integration credential is unavailable.");
7253
- }
7254
- if (typeof credential !== "string" || !credential.trim()) throw new Error("ITM Partner SDK: integration credential is unavailable.");
7255
- return { ...sanitizeHeaders(extra), "x-itm-integration-access-token": credential, "Content-Type": "application/json" };
7256
- }
7257
- });
7258
- }
7259
- if (agentAccess !== void 0) {
7260
- if (typeof agentAccess.workloadToken !== "function") {
7261
- throw new Error(
7262
- "ITM Partner SDK: agentAccess.workloadToken must be a function returning a workload identity bearer."
7263
- );
7264
- }
7265
- if (!agentAccess.accessToken) {
7266
- throw new Error("ITM Partner SDK: agentAccess.accessToken is required.");
7267
- }
7268
- return createSafeClient({
7269
- url: baseUrl ?? DEFAULT_API_URL,
7270
- signal,
7271
- headers: async () => {
7272
- const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
7273
- const sanitizedExtraHeaders = Object.fromEntries(
7274
- Object.entries(resolvedExtraHeaders ?? {}).filter(
7275
- ([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())
7276
- )
7277
- );
7278
- const workloadToken = (await agentAccess.workloadToken()).trim();
7279
- if (!workloadToken) {
7280
- throw new Error(
7281
- "ITM Partner SDK: agent workload identity is unavailable."
7282
- );
7283
- }
7284
- return {
7285
- ...sanitizedExtraHeaders,
7286
- authorization: `Bearer ${workloadToken}`,
7287
- "x-itm-agent-access-token": agentAccess.accessToken,
7288
- "Content-Type": "application/json"
7289
- };
7290
- }
7291
- });
7292
- }
7293
- if (agentSession !== void 0) {
7294
- if (typeof agentSession.workloadToken !== "function") {
7295
- throw new Error(
7296
- "ITM Partner SDK: agentSession.workloadToken must be a function returning a workload identity bearer."
7297
- );
7298
- }
7299
- if (!agentSession.sessionUid) {
7300
- throw new Error("ITM Partner SDK: agentSession.sessionUid is required.");
7301
- }
7302
- return createSafeClient({
7303
- url: baseUrl ?? DEFAULT_API_URL,
7304
- signal,
7305
- headers: async () => {
7306
- const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
7307
- const sanitizedExtraHeaders = Object.fromEntries(
7308
- Object.entries(resolvedExtraHeaders ?? {}).filter(
7309
- ([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())
7310
- )
7311
- );
7312
- const workloadToken = (await agentSession.workloadToken()).trim();
7313
- if (!workloadToken) {
7314
- throw new Error(
7315
- "ITM Partner SDK: agent workload identity is unavailable."
7316
- );
7317
- }
7318
- return {
7319
- ...sanitizedExtraHeaders,
7320
- authorization: `Bearer ${workloadToken}`,
7344
+ },
7345
+ "BrandWallet": {
7346
+ "accessReady": [
7347
+ 39
7348
+ ],
7349
+ "balance": [
7350
+ 301
7351
+ ],
7352
+ "balanceStale": [
7353
+ 39
7354
+ ],
7355
+ "capabilities": [
7356
+ 302
7357
+ ],
7358
+ "displayName": [
7359
+ 36
7360
+ ],
7361
+ "status": [
7362
+ 36
7363
+ ],
7364
+ "uid": [
7365
+ 36
7366
+ ],
7367
+ "__typename": [
7368
+ 36
7369
+ ]
7370
+ },
7371
+ "BrandWalletActivity": {
7372
+ "amountMinor": [
7373
+ 36
7374
+ ],
7375
+ "counterparty": [
7376
+ 303
7377
+ ],
7378
+ "currency": [
7379
+ 36
7380
+ ],
7381
+ "description": [
7382
+ 36
7383
+ ],
7384
+ "direction": [
7385
+ 36
7386
+ ],
7387
+ "feeMinor": [
7388
+ 36
7389
+ ],
7390
+ "occurredAt": [
7391
+ 0
7392
+ ],
7393
+ "operationKind": [
7394
+ 313
7395
+ ],
7396
+ "operationUid": [
7397
+ 36
7398
+ ],
7399
+ "status": [
7400
+ 36
7401
+ ],
7402
+ "uid": [
7403
+ 36
7404
+ ],
7405
+ "__typename": [
7406
+ 36
7407
+ ]
7408
+ },
7409
+ "BrandWalletActivityResponse": {
7410
+ "activity": [
7411
+ 299
7412
+ ],
7413
+ "activityStale": [
7414
+ 39
7415
+ ],
7416
+ "hasNextPage": [
7417
+ 39
7418
+ ],
7419
+ "ledgerCheckedAt": [
7420
+ 0
7421
+ ],
7422
+ "nextCursor": [
7423
+ 36
7424
+ ],
7425
+ "totalCount": [
7426
+ 38
7427
+ ],
7428
+ "__typename": [
7429
+ 36
7430
+ ]
7431
+ },
7432
+ "BrandWalletBalance": {
7433
+ "availableMinor": [
7434
+ 36
7435
+ ],
7436
+ "currency": [
7437
+ 36
7438
+ ],
7439
+ "refreshedAt": [
7440
+ 0
7441
+ ],
7442
+ "totalMinor": [
7443
+ 36
7444
+ ],
7445
+ "__typename": [
7446
+ 36
7447
+ ]
7448
+ },
7449
+ "BrandWalletCapabilities": {
7450
+ "canRequest": [
7451
+ 39
7452
+ ],
7453
+ "canSend": [
7454
+ 39
7455
+ ],
7456
+ "canTransfer": [
7457
+ 39
7458
+ ],
7459
+ "missingPermissions": [
7460
+ 36
7461
+ ],
7462
+ "__typename": [
7463
+ 36
7464
+ ]
7465
+ },
7466
+ "BrandWalletCounterparty": {
7467
+ "type": [
7468
+ 305
7469
+ ],
7470
+ "value": [
7471
+ 36
7472
+ ],
7473
+ "__typename": [
7474
+ 36
7475
+ ]
7476
+ },
7477
+ "BrandWalletCounterpartyInput": {
7478
+ "type": [
7479
+ 305
7480
+ ],
7481
+ "value": [
7482
+ 36
7483
+ ],
7484
+ "__typename": [
7485
+ 36
7486
+ ]
7487
+ },
7488
+ "BrandWalletCounterpartyType": {},
7489
+ "BrandWalletOperation": {
7490
+ "amountMinor": [
7491
+ 36
7492
+ ],
7493
+ "clientRequestKey": [
7494
+ 36
7495
+ ],
7496
+ "confirmedAt": [
7497
+ 0
7498
+ ],
7499
+ "counterparty": [
7500
+ 303
7501
+ ],
7502
+ "createdAt": [
7503
+ 0
7504
+ ],
7505
+ "createdBy": [
7506
+ 307
7507
+ ],
7508
+ "currency": [
7509
+ 36
7510
+ ],
7511
+ "description": [
7512
+ 36
7513
+ ],
7514
+ "destinationWalletUid": [
7515
+ 36
7516
+ ],
7517
+ "feeMinor": [
7518
+ 36
7519
+ ],
7520
+ "hasLink": [
7521
+ 39
7522
+ ],
7523
+ "kind": [
7524
+ 313
7525
+ ],
7526
+ "lastErrorCode": [
7527
+ 36
7528
+ ],
7529
+ "link": [
7530
+ 36
7531
+ ],
7532
+ "linkExpiresAt": [
7533
+ 0
7534
+ ],
7535
+ "netMinor": [
7536
+ 36
7537
+ ],
7538
+ "pendingCancelOperationUid": [
7539
+ 36
7540
+ ],
7541
+ "preparedExpiresAt": [
7542
+ 0
7543
+ ],
7544
+ "provider": [
7545
+ 309
7546
+ ],
7547
+ "providerResourceId": [
7548
+ 36
7549
+ ],
7550
+ "providerStatus": [
7551
+ 36
7552
+ ],
7553
+ "settledAt": [
7554
+ 0
7555
+ ],
7556
+ "status": [
7557
+ 314
7558
+ ],
7559
+ "submittedAt": [
7560
+ 0
7561
+ ],
7562
+ "uid": [
7563
+ 36
7564
+ ],
7565
+ "updatedAt": [
7566
+ 0
7567
+ ],
7568
+ "walletUid": [
7569
+ 36
7570
+ ],
7571
+ "__typename": [
7572
+ 36
7573
+ ]
7574
+ },
7575
+ "BrandWalletOperationCreator": {
7576
+ "email": [
7577
+ 36
7578
+ ],
7579
+ "uid": [
7580
+ 36
7581
+ ],
7582
+ "__typename": [
7583
+ 36
7584
+ ]
7585
+ },
7586
+ "BrandWalletOperationsResponse": {
7587
+ "hasNextPage": [
7588
+ 39
7589
+ ],
7590
+ "nextCursor": [
7591
+ 36
7592
+ ],
7593
+ "operations": [
7594
+ 306
7595
+ ],
7596
+ "totalCount": [
7597
+ 38
7598
+ ],
7599
+ "__typename": [
7600
+ 36
7601
+ ]
7602
+ },
7603
+ "BrandWalletProvider": {},
7604
+ "BrandWalletsResponse": {
7605
+ "hasNextPage": [
7606
+ 39
7607
+ ],
7608
+ "nextCursor": [
7609
+ 36
7610
+ ],
7611
+ "totalCount": [
7612
+ 38
7613
+ ],
7614
+ "wallets": [
7615
+ 298
7616
+ ],
7617
+ "__typename": [
7618
+ 36
7619
+ ]
7620
+ },
7621
+ "CreateBrandWalletPaymentRequestInput": {
7622
+ "amountMinor": [
7623
+ 36
7624
+ ],
7625
+ "clientRequestKey": [
7626
+ 36
7627
+ ],
7628
+ "currency": [
7629
+ 36
7630
+ ],
7631
+ "description": [
7632
+ 36
7633
+ ],
7634
+ "payer": [
7635
+ 304
7636
+ ],
7637
+ "__typename": [
7638
+ 36
7639
+ ]
7640
+ },
7641
+ "PrepareBrandWalletPaymentInput": {
7642
+ "amountMinor": [
7643
+ 36
7644
+ ],
7645
+ "clientRequestKey": [
7646
+ 36
7647
+ ],
7648
+ "counterparty": [
7649
+ 304
7650
+ ],
7651
+ "currency": [
7652
+ 36
7653
+ ],
7654
+ "description": [
7655
+ 36
7656
+ ],
7657
+ "__typename": [
7658
+ 36
7659
+ ]
7660
+ },
7661
+ "WalletOperationKind": {},
7662
+ "WalletOperationStatus": {},
7663
+ "SpaceKind": {},
7664
+ "SpaceHoldStatus": {},
7665
+ "SpaceRequestKind": {},
7666
+ "SpaceHoldPreviewOutcome": {},
7667
+ "SpaceCalendarConflictKind": {},
7668
+ "PartnerSpace": {
7669
+ "capacity": [
7670
+ 38
7671
+ ],
7672
+ "kind": [
7673
+ 315
7674
+ ],
7675
+ "name": [
7676
+ 36
7677
+ ],
7678
+ "parts": [
7679
+ 320
7680
+ ],
7681
+ "setupMinutes": [
7682
+ 38
7683
+ ],
7684
+ "teardownMinutes": [
7685
+ 38
7686
+ ],
7687
+ "uid": [
7688
+ 35
7689
+ ],
7690
+ "__typename": [
7691
+ 36
7692
+ ]
7693
+ },
7694
+ "PartnerSpaceLocation": {
7695
+ "city": [
7696
+ 36
7697
+ ],
7698
+ "country": [
7699
+ 36
7700
+ ],
7701
+ "name": [
7702
+ 36
7703
+ ],
7704
+ "spaces": [
7705
+ 320
7706
+ ],
7707
+ "timezone": [
7708
+ 36
7709
+ ],
7710
+ "uid": [
7711
+ 35
7712
+ ],
7713
+ "__typename": [
7714
+ 36
7715
+ ]
7716
+ },
7717
+ "PartnerSpaceLocationsPage": {
7718
+ "hasNextPage": [
7719
+ 39
7720
+ ],
7721
+ "locations": [
7722
+ 321
7723
+ ],
7724
+ "nextCursor": [
7725
+ 36
7726
+ ],
7727
+ "totalCount": [
7728
+ 38
7729
+ ],
7730
+ "__typename": [
7731
+ 36
7732
+ ]
7733
+ },
7734
+ "PartnerSpaceRequest": {
7735
+ "headcount": [
7736
+ 38
7737
+ ],
7738
+ "organization": [
7739
+ 36
7740
+ ],
7741
+ "requesterKind": [
7742
+ 317
7743
+ ],
7744
+ "title": [
7745
+ 36
7746
+ ],
7747
+ "uid": [
7748
+ 35
7749
+ ],
7750
+ "__typename": [
7751
+ 36
7752
+ ]
7753
+ },
7754
+ "PartnerSpaceHold": {
7755
+ "aheadCount": [
7756
+ 38
7757
+ ],
7758
+ "endsAt": [
7759
+ 0
7760
+ ],
7761
+ "expiresAt": [
7762
+ 0
7763
+ ],
7764
+ "isChallengeOverdue": [
7765
+ 39
7766
+ ],
7767
+ "isLapsed": [
7768
+ 39
7769
+ ],
7770
+ "localDate": [
7771
+ 36
7772
+ ],
7773
+ "occupiedEndsAt": [
7774
+ 0
7775
+ ],
7776
+ "occupiedStartsAt": [
7777
+ 0
7778
+ ],
7779
+ "position": [
7780
+ 38
7781
+ ],
7782
+ "request": [
7783
+ 323
7784
+ ],
7785
+ "requestUid": [
7786
+ 35
7787
+ ],
7788
+ "respondBy": [
7789
+ 0
7790
+ ],
7791
+ "spaceUid": [
7792
+ 35
7793
+ ],
7794
+ "startsAt": [
7795
+ 0
7796
+ ],
7797
+ "status": [
7798
+ 316
7799
+ ],
7800
+ "uid": [
7801
+ 35
7802
+ ],
7803
+ "__typename": [
7804
+ 36
7805
+ ]
7806
+ },
7807
+ "PartnerSpaceBlock": {
7808
+ "endsAt": [
7809
+ 0
7810
+ ],
7811
+ "reason": [
7812
+ 36
7813
+ ],
7814
+ "spaceUid": [
7815
+ 35
7816
+ ],
7817
+ "startsAt": [
7818
+ 0
7819
+ ],
7820
+ "uid": [
7821
+ 35
7822
+ ],
7823
+ "__typename": [
7824
+ 36
7825
+ ]
7826
+ },
7827
+ "SpaceCalendarClosure": {
7828
+ "endsAt": [
7829
+ 0
7830
+ ],
7831
+ "localDate": [
7832
+ 36
7833
+ ],
7834
+ "note": [
7835
+ 36
7836
+ ],
7837
+ "spaceUid": [
7838
+ 35
7839
+ ],
7840
+ "startsAt": [
7841
+ 0
7842
+ ],
7843
+ "__typename": [
7844
+ 36
7845
+ ]
7846
+ },
7847
+ "PartnerSpaceCalendar": {
7848
+ "blocks": [
7849
+ 325
7850
+ ],
7851
+ "closures": [
7852
+ 326
7853
+ ],
7854
+ "holds": [
7855
+ 324
7856
+ ],
7857
+ "locationName": [
7858
+ 36
7859
+ ],
7860
+ "locationUid": [
7861
+ 35
7862
+ ],
7863
+ "spaces": [
7864
+ 320
7865
+ ],
7866
+ "timezone": [
7867
+ 36
7868
+ ],
7869
+ "__typename": [
7870
+ 36
7871
+ ]
7872
+ },
7873
+ "SpaceCalendarConflict": {
7874
+ "endsAt": [
7875
+ 0
7876
+ ],
7877
+ "kind": [
7878
+ 319
7879
+ ],
7880
+ "label": [
7881
+ 36
7882
+ ],
7883
+ "startsAt": [
7884
+ 0
7885
+ ],
7886
+ "uid": [
7887
+ 35
7888
+ ],
7889
+ "__typename": [
7890
+ 36
7891
+ ]
7892
+ },
7893
+ "SpaceAvailabilityDate": {
7894
+ "closed": [
7895
+ 39
7896
+ ],
7897
+ "conflicts": [
7898
+ 328
7899
+ ],
7900
+ "lineSize": [
7901
+ 38
7902
+ ],
7903
+ "localDate": [
7904
+ 36
7905
+ ],
7906
+ "outcome": [
7907
+ 318
7908
+ ],
7909
+ "__typename": [
7910
+ 36
7911
+ ]
7912
+ },
7913
+ "SpaceAvailabilitySpace": {
7914
+ "dates": [
7915
+ 329
7916
+ ],
7917
+ "name": [
7918
+ 36
7919
+ ],
7920
+ "spaceUid": [
7921
+ 35
7922
+ ],
7923
+ "__typename": [
7924
+ 36
7925
+ ]
7926
+ },
7927
+ "SpaceAvailability": {
7928
+ "spaces": [
7929
+ 330
7930
+ ],
7931
+ "timezone": [
7932
+ 36
7933
+ ],
7934
+ "__typename": [
7935
+ 36
7936
+ ]
7937
+ },
7938
+ "SpaceCalendarInput": {
7939
+ "endsOn": [
7940
+ 36
7941
+ ],
7942
+ "includeReleased": [
7943
+ 39
7944
+ ],
7945
+ "locationUid": [
7946
+ 35
7947
+ ],
7948
+ "spaceUids": [
7949
+ 35
7950
+ ],
7951
+ "startsOn": [
7952
+ 36
7953
+ ],
7954
+ "__typename": [
7955
+ 36
7956
+ ]
7957
+ },
7958
+ "SpaceAvailabilityInput": {
7959
+ "endTime": [
7960
+ 36
7961
+ ],
7962
+ "endsOn": [
7963
+ 36
7964
+ ],
7965
+ "locationUid": [
7966
+ 35
7967
+ ],
7968
+ "spaceUids": [
7969
+ 35
7970
+ ],
7971
+ "startTime": [
7972
+ 36
7973
+ ],
7974
+ "startsOn": [
7975
+ 36
7976
+ ],
7977
+ "__typename": [
7978
+ 36
7979
+ ]
7980
+ }
7981
+ }
7982
+ };
7983
+
7984
+ // src/generated/index.ts
7985
+ var typeMap = linkTypeMap(types_default);
7986
+ var createClient2 = function(options) {
7987
+ return createClient({
7988
+ url: void 0,
7989
+ ...options,
7990
+ queryRoot: typeMap.Query,
7991
+ mutationRoot: typeMap.Mutation,
7992
+ subscriptionRoot: typeMap.Subscription
7993
+ });
7994
+ };
7995
+ var everything = {
7996
+ __scalar: true
7997
+ };
7998
+ var generateQueryOp = function(fields) {
7999
+ return generateGraphqlOperation("query", typeMap.Query, fields);
8000
+ };
8001
+ var generateMutationOp = function(fields) {
8002
+ return generateGraphqlOperation("mutation", typeMap.Mutation, fields);
8003
+ };
8004
+
8005
+ // src/runtime.ts
8006
+ var NODE_SERVER_ONLY_ERROR = "ITM Partner SDK is Node-server-only. Do not import it in browser, React Native, worker, edge, or Electron process code. Call it from a Node backend and return only the data the client needs.";
8007
+ function assertNodeServerRuntime(runtime = globalThis) {
8008
+ const runtimeProcess = runtime.process;
8009
+ const isNode = runtimeProcess?.release?.name === "node" && typeof runtimeProcess.versions?.node === "string";
8010
+ const isBrowserWindow = typeof runtime.window !== "undefined";
8011
+ const isReactNative = runtime.navigator?.product === "ReactNative";
8012
+ const isElectron = typeof runtimeProcess?.versions?.electron === "string" || typeof runtimeProcess?.type === "string";
8013
+ if (!isNode || isBrowserWindow || isReactNative || isElectron) {
8014
+ throw new Error(NODE_SERVER_ONLY_ERROR);
8015
+ }
8016
+ }
8017
+
8018
+ // src/client.ts
8019
+ assertNodeServerRuntime();
8020
+ var DEFAULT_API_URL = "https://itm-backend-production.up.railway.app/graphql";
8021
+ var RESERVED_AGENT_HEADERS = /* @__PURE__ */ new Set([
8022
+ "authorization",
8023
+ "x-itm-integration-access-token",
8024
+ "x-itm-agent-session-id",
8025
+ "x-itm-agent-bootstrap-token",
8026
+ "x-itm-agent-access-token",
8027
+ "x-partner-api-key"
8028
+ ]);
8029
+ function createITMPartnerClient(config) {
8030
+ const { baseUrl, headers: extraHeaders, signal } = config;
8031
+ const token = "token" in config ? config.token : void 0;
8032
+ const agentSession = "agentSession" in config ? config.agentSession : void 0;
8033
+ const agentAccess = "agentAccess" in config ? config.agentAccess : void 0;
8034
+ const integration = "integration" in config ? config.integration : void 0;
8035
+ const providedModes = [token, agentSession, agentAccess, integration].filter(
8036
+ (mode) => mode !== void 0
8037
+ );
8038
+ if (providedModes.length > 1) {
8039
+ throw new Error(
8040
+ "ITM Partner SDK: provide exactly one of token, agentSession, agentAccess, or integration authentication."
8041
+ );
8042
+ }
8043
+ if (integration !== void 0) {
8044
+ if (typeof integration.accessToken !== "function" && (typeof integration.accessToken !== "string" || !integration.accessToken.trim())) {
8045
+ throw new Error("ITM Partner SDK: integration.accessToken is required.");
8046
+ }
8047
+ return createSafeClient({
8048
+ url: baseUrl ?? DEFAULT_API_URL,
8049
+ signal,
8050
+ headers: async () => {
8051
+ const extra = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
8052
+ let credential;
8053
+ try {
8054
+ credential = typeof integration.accessToken === "function" ? await integration.accessToken() : integration.accessToken;
8055
+ } catch {
8056
+ throw new Error("ITM Partner SDK: integration credential is unavailable.");
8057
+ }
8058
+ if (typeof credential !== "string" || !credential.trim()) throw new Error("ITM Partner SDK: integration credential is unavailable.");
8059
+ return { ...sanitizeHeaders(extra), "x-itm-integration-access-token": credential, "Content-Type": "application/json" };
8060
+ }
8061
+ });
8062
+ }
8063
+ if (agentAccess !== void 0) {
8064
+ if (typeof agentAccess.workloadToken !== "function") {
8065
+ throw new Error(
8066
+ "ITM Partner SDK: agentAccess.workloadToken must be a function returning a workload identity bearer."
8067
+ );
8068
+ }
8069
+ if (!agentAccess.accessToken) {
8070
+ throw new Error("ITM Partner SDK: agentAccess.accessToken is required.");
8071
+ }
8072
+ return createSafeClient({
8073
+ url: baseUrl ?? DEFAULT_API_URL,
8074
+ signal,
8075
+ headers: async () => {
8076
+ const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
8077
+ const sanitizedExtraHeaders = Object.fromEntries(
8078
+ Object.entries(resolvedExtraHeaders ?? {}).filter(
8079
+ ([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())
8080
+ )
8081
+ );
8082
+ const workloadToken = (await agentAccess.workloadToken()).trim();
8083
+ if (!workloadToken) {
8084
+ throw new Error(
8085
+ "ITM Partner SDK: agent workload identity is unavailable."
8086
+ );
8087
+ }
8088
+ return {
8089
+ ...sanitizedExtraHeaders,
8090
+ authorization: `Bearer ${workloadToken}`,
8091
+ "x-itm-agent-access-token": agentAccess.accessToken,
8092
+ "Content-Type": "application/json"
8093
+ };
8094
+ }
8095
+ });
8096
+ }
8097
+ if (agentSession !== void 0) {
8098
+ if (typeof agentSession.workloadToken !== "function") {
8099
+ throw new Error(
8100
+ "ITM Partner SDK: agentSession.workloadToken must be a function returning a workload identity bearer."
8101
+ );
8102
+ }
8103
+ if (!agentSession.sessionUid) {
8104
+ throw new Error("ITM Partner SDK: agentSession.sessionUid is required.");
8105
+ }
8106
+ return createSafeClient({
8107
+ url: baseUrl ?? DEFAULT_API_URL,
8108
+ signal,
8109
+ headers: async () => {
8110
+ const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
8111
+ const sanitizedExtraHeaders = Object.fromEntries(
8112
+ Object.entries(resolvedExtraHeaders ?? {}).filter(
8113
+ ([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())
8114
+ )
8115
+ );
8116
+ const workloadToken = (await agentSession.workloadToken()).trim();
8117
+ if (!workloadToken) {
8118
+ throw new Error(
8119
+ "ITM Partner SDK: agent workload identity is unavailable."
8120
+ );
8121
+ }
8122
+ return {
8123
+ ...sanitizedExtraHeaders,
8124
+ authorization: `Bearer ${workloadToken}`,
7321
8125
  "x-itm-agent-session-id": agentSession.sessionUid,
7322
8126
  ...agentSession.bootstrapToken ? { "x-itm-agent-bootstrap-token": agentSession.bootstrapToken } : {},
7323
8127
  "Content-Type": "application/json"
@@ -7330,18 +8134,40 @@ function createITMPartnerClient(config) {
7330
8134
  "ITM Partner SDK: token is required. Get one from backstage: Settings > Partner API."
7331
8135
  );
7332
8136
  }
7333
- return createSafeClient({
8137
+ const adminSession = "adminSession" in config ? config.adminSession : void 0;
8138
+ if (adminSession !== void 0 && typeof adminSession !== "function" && (typeof adminSession !== "string" || !adminSession.trim())) {
8139
+ throw new Error("ITM Partner SDK: adminSession must be a non-empty string or a function.");
8140
+ }
8141
+ const tokenClient = (withSession) => createSafeClient({
7334
8142
  url: baseUrl ?? DEFAULT_API_URL,
7335
8143
  signal,
7336
8144
  headers: async () => {
7337
8145
  const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
8146
+ let session;
8147
+ if (withSession && adminSession !== void 0) {
8148
+ try {
8149
+ session = typeof adminSession === "function" ? await adminSession() : adminSession;
8150
+ } catch {
8151
+ throw new Error("ITM Partner SDK: admin session is unavailable.");
8152
+ }
8153
+ if (typeof session !== "string" || !session.trim()) throw new Error("ITM Partner SDK: admin session is unavailable.");
8154
+ if (session.trim() === token.trim()) throw new Error("ITM Partner SDK: adminSession must be an admin session, not the partner key.");
8155
+ }
7338
8156
  return {
7339
8157
  ...sanitizeHeaders(resolvedExtraHeaders),
8158
+ ...session ? { authorization: `Bearer ${session.trim()}` } : {},
7340
8159
  "x-partner-api-key": token,
7341
8160
  "Content-Type": "application/json"
7342
8161
  };
7343
8162
  }
7344
8163
  });
8164
+ const ordinary = tokenClient(false);
8165
+ if (adminSession === void 0) return ordinary;
8166
+ const wallet = tokenClient(true);
8167
+ return {
8168
+ query: (request) => (request.listPartnerWallets || request.getPartnerWalletOperation || request.listPartnerWalletOperations || request.listPartnerWalletActivity ? wallet : ordinary).query(request),
8169
+ mutation: (request) => (request.preparePartnerWalletPayment || request.confirmPartnerWalletOperation || request.createPartnerWalletPaymentRequest ? wallet : ordinary).mutation(request)
8170
+ };
7345
8171
  }
7346
8172
  function sanitizeHeaders(headers) {
7347
8173
  return Object.fromEntries(Object.entries(headers ?? {}).filter(([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())));