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