@itm-studio/partner-sdk 0.6.7 → 0.6.9

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,11 @@ var types_default = {
675
675
  282,
676
676
  289,
677
677
  290,
678
- 291
678
+ 291,
679
+ 305,
680
+ 309,
681
+ 313,
682
+ 314
679
683
  ],
680
684
  "types": {
681
685
  "DateTime": {},
@@ -3629,6 +3633,85 @@ var types_default = {
3629
3633
  ]
3630
3634
  },
3631
3635
  "Query": {
3636
+ "getPartnerWalletOperation": [
3637
+ 306,
3638
+ {
3639
+ "brandUid": [
3640
+ 36,
3641
+ "String!"
3642
+ ],
3643
+ "operationUid": [
3644
+ 36,
3645
+ "String!"
3646
+ ],
3647
+ "walletUid": [
3648
+ 36,
3649
+ "String!"
3650
+ ]
3651
+ }
3652
+ ],
3653
+ "listPartnerWalletActivity": [
3654
+ 300,
3655
+ {
3656
+ "brandUid": [
3657
+ 36,
3658
+ "String!"
3659
+ ],
3660
+ "cursor": [
3661
+ 36
3662
+ ],
3663
+ "take": [
3664
+ 38
3665
+ ],
3666
+ "walletUid": [
3667
+ 36,
3668
+ "String!"
3669
+ ]
3670
+ }
3671
+ ],
3672
+ "listPartnerWalletOperations": [
3673
+ 308,
3674
+ {
3675
+ "brandUid": [
3676
+ 36,
3677
+ "String!"
3678
+ ],
3679
+ "cursor": [
3680
+ 36
3681
+ ],
3682
+ "excludeUnconfirmed": [
3683
+ 39
3684
+ ],
3685
+ "kind": [
3686
+ 313
3687
+ ],
3688
+ "statuses": [
3689
+ 314,
3690
+ "[WalletOperationStatus!]"
3691
+ ],
3692
+ "take": [
3693
+ 38
3694
+ ],
3695
+ "walletUid": [
3696
+ 36
3697
+ ]
3698
+ }
3699
+ ],
3700
+ "listPartnerWallets": [
3701
+ 310,
3702
+ {
3703
+ "brandUid": [
3704
+ 36,
3705
+ "String!"
3706
+ ],
3707
+ "cursor": [
3708
+ 36
3709
+ ],
3710
+ "take": [
3711
+ 38
3712
+ ]
3713
+ }
3714
+ ],
3632
3715
  "getPartnerForms": [
3633
3716
  292,
3634
3717
  {
@@ -4829,6 +4912,57 @@ var types_default = {
4829
4912
  ]
4830
4913
  },
4831
4914
  "Mutation": {
4915
+ "confirmPartnerWalletOperation": [
4916
+ 306,
4917
+ {
4918
+ "brandUid": [
4919
+ 36,
4920
+ "String!"
4921
+ ],
4922
+ "operationUid": [
4923
+ 36,
4924
+ "String!"
4925
+ ],
4926
+ "walletUid": [
4927
+ 36,
4928
+ "String!"
4929
+ ]
4930
+ }
4931
+ ],
4932
+ "createPartnerWalletPaymentRequest": [
4933
+ 306,
4934
+ {
4935
+ "brandUid": [
4936
+ 36,
4937
+ "String!"
4938
+ ],
4939
+ "input": [
4940
+ 311,
4941
+ "CreateBrandWalletPaymentRequestInput!"
4942
+ ],
4943
+ "walletUid": [
4944
+ 36,
4945
+ "String!"
4946
+ ]
4947
+ }
4948
+ ],
4949
+ "preparePartnerWalletPayment": [
4950
+ 306,
4951
+ {
4952
+ "brandUid": [
4953
+ 36,
4954
+ "String!"
4955
+ ],
4956
+ "input": [
4957
+ 312,
4958
+ "PrepareBrandWalletPaymentInput!"
4959
+ ],
4960
+ "walletUid": [
4961
+ 36,
4962
+ "String!"
4963
+ ]
4964
+ }
4965
+ ],
4832
4966
  "createPartnerBrandApp": [
4833
4967
  154,
4834
4968
  {
@@ -7173,7 +7307,325 @@ var types_default = {
7173
7307
  "__typename": [
7174
7308
  36
7175
7309
  ]
7176
- }
7310
+ },
7311
+ "BrandWallet": {
7312
+ "accessReady": [
7313
+ 39
7314
+ ],
7315
+ "balance": [
7316
+ 301
7317
+ ],
7318
+ "balanceStale": [
7319
+ 39
7320
+ ],
7321
+ "capabilities": [
7322
+ 302
7323
+ ],
7324
+ "displayName": [
7325
+ 36
7326
+ ],
7327
+ "status": [
7328
+ 36
7329
+ ],
7330
+ "uid": [
7331
+ 36
7332
+ ],
7333
+ "__typename": [
7334
+ 36
7335
+ ]
7336
+ },
7337
+ "BrandWalletActivity": {
7338
+ "amountMinor": [
7339
+ 36
7340
+ ],
7341
+ "counterparty": [
7342
+ 303
7343
+ ],
7344
+ "currency": [
7345
+ 36
7346
+ ],
7347
+ "description": [
7348
+ 36
7349
+ ],
7350
+ "direction": [
7351
+ 36
7352
+ ],
7353
+ "feeMinor": [
7354
+ 36
7355
+ ],
7356
+ "occurredAt": [
7357
+ 0
7358
+ ],
7359
+ "operationKind": [
7360
+ 313
7361
+ ],
7362
+ "operationUid": [
7363
+ 36
7364
+ ],
7365
+ "status": [
7366
+ 36
7367
+ ],
7368
+ "uid": [
7369
+ 36
7370
+ ],
7371
+ "__typename": [
7372
+ 36
7373
+ ]
7374
+ },
7375
+ "BrandWalletActivityResponse": {
7376
+ "activity": [
7377
+ 299
7378
+ ],
7379
+ "activityStale": [
7380
+ 39
7381
+ ],
7382
+ "hasNextPage": [
7383
+ 39
7384
+ ],
7385
+ "ledgerCheckedAt": [
7386
+ 0
7387
+ ],
7388
+ "nextCursor": [
7389
+ 36
7390
+ ],
7391
+ "totalCount": [
7392
+ 38
7393
+ ],
7394
+ "__typename": [
7395
+ 36
7396
+ ]
7397
+ },
7398
+ "BrandWalletBalance": {
7399
+ "availableMinor": [
7400
+ 36
7401
+ ],
7402
+ "currency": [
7403
+ 36
7404
+ ],
7405
+ "refreshedAt": [
7406
+ 0
7407
+ ],
7408
+ "totalMinor": [
7409
+ 36
7410
+ ],
7411
+ "__typename": [
7412
+ 36
7413
+ ]
7414
+ },
7415
+ "BrandWalletCapabilities": {
7416
+ "canRequest": [
7417
+ 39
7418
+ ],
7419
+ "canSend": [
7420
+ 39
7421
+ ],
7422
+ "canTransfer": [
7423
+ 39
7424
+ ],
7425
+ "missingPermissions": [
7426
+ 36
7427
+ ],
7428
+ "__typename": [
7429
+ 36
7430
+ ]
7431
+ },
7432
+ "BrandWalletCounterparty": {
7433
+ "type": [
7434
+ 305
7435
+ ],
7436
+ "value": [
7437
+ 36
7438
+ ],
7439
+ "__typename": [
7440
+ 36
7441
+ ]
7442
+ },
7443
+ "BrandWalletCounterpartyInput": {
7444
+ "type": [
7445
+ 305
7446
+ ],
7447
+ "value": [
7448
+ 36
7449
+ ],
7450
+ "__typename": [
7451
+ 36
7452
+ ]
7453
+ },
7454
+ "BrandWalletCounterpartyType": {},
7455
+ "BrandWalletOperation": {
7456
+ "amountMinor": [
7457
+ 36
7458
+ ],
7459
+ "clientRequestKey": [
7460
+ 36
7461
+ ],
7462
+ "confirmedAt": [
7463
+ 0
7464
+ ],
7465
+ "counterparty": [
7466
+ 303
7467
+ ],
7468
+ "createdAt": [
7469
+ 0
7470
+ ],
7471
+ "createdBy": [
7472
+ 307
7473
+ ],
7474
+ "currency": [
7475
+ 36
7476
+ ],
7477
+ "description": [
7478
+ 36
7479
+ ],
7480
+ "destinationWalletUid": [
7481
+ 36
7482
+ ],
7483
+ "feeMinor": [
7484
+ 36
7485
+ ],
7486
+ "hasLink": [
7487
+ 39
7488
+ ],
7489
+ "kind": [
7490
+ 313
7491
+ ],
7492
+ "lastErrorCode": [
7493
+ 36
7494
+ ],
7495
+ "link": [
7496
+ 36
7497
+ ],
7498
+ "linkExpiresAt": [
7499
+ 0
7500
+ ],
7501
+ "netMinor": [
7502
+ 36
7503
+ ],
7504
+ "pendingCancelOperationUid": [
7505
+ 36
7506
+ ],
7507
+ "preparedExpiresAt": [
7508
+ 0
7509
+ ],
7510
+ "provider": [
7511
+ 309
7512
+ ],
7513
+ "providerResourceId": [
7514
+ 36
7515
+ ],
7516
+ "providerStatus": [
7517
+ 36
7518
+ ],
7519
+ "settledAt": [
7520
+ 0
7521
+ ],
7522
+ "status": [
7523
+ 314
7524
+ ],
7525
+ "submittedAt": [
7526
+ 0
7527
+ ],
7528
+ "uid": [
7529
+ 36
7530
+ ],
7531
+ "updatedAt": [
7532
+ 0
7533
+ ],
7534
+ "walletUid": [
7535
+ 36
7536
+ ],
7537
+ "__typename": [
7538
+ 36
7539
+ ]
7540
+ },
7541
+ "BrandWalletOperationCreator": {
7542
+ "email": [
7543
+ 36
7544
+ ],
7545
+ "uid": [
7546
+ 36
7547
+ ],
7548
+ "__typename": [
7549
+ 36
7550
+ ]
7551
+ },
7552
+ "BrandWalletOperationsResponse": {
7553
+ "hasNextPage": [
7554
+ 39
7555
+ ],
7556
+ "nextCursor": [
7557
+ 36
7558
+ ],
7559
+ "operations": [
7560
+ 306
7561
+ ],
7562
+ "totalCount": [
7563
+ 38
7564
+ ],
7565
+ "__typename": [
7566
+ 36
7567
+ ]
7568
+ },
7569
+ "BrandWalletProvider": {},
7570
+ "BrandWalletsResponse": {
7571
+ "hasNextPage": [
7572
+ 39
7573
+ ],
7574
+ "nextCursor": [
7575
+ 36
7576
+ ],
7577
+ "totalCount": [
7578
+ 38
7579
+ ],
7580
+ "wallets": [
7581
+ 298
7582
+ ],
7583
+ "__typename": [
7584
+ 36
7585
+ ]
7586
+ },
7587
+ "CreateBrandWalletPaymentRequestInput": {
7588
+ "amountMinor": [
7589
+ 36
7590
+ ],
7591
+ "clientRequestKey": [
7592
+ 36
7593
+ ],
7594
+ "currency": [
7595
+ 36
7596
+ ],
7597
+ "description": [
7598
+ 36
7599
+ ],
7600
+ "payer": [
7601
+ 304
7602
+ ],
7603
+ "__typename": [
7604
+ 36
7605
+ ]
7606
+ },
7607
+ "PrepareBrandWalletPaymentInput": {
7608
+ "amountMinor": [
7609
+ 36
7610
+ ],
7611
+ "clientRequestKey": [
7612
+ 36
7613
+ ],
7614
+ "counterparty": [
7615
+ 304
7616
+ ],
7617
+ "currency": [
7618
+ 36
7619
+ ],
7620
+ "description": [
7621
+ 36
7622
+ ],
7623
+ "__typename": [
7624
+ 36
7625
+ ]
7626
+ },
7627
+ "WalletOperationKind": {},
7628
+ "WalletOperationStatus": {}
7177
7629
  }
7178
7630
  };
7179
7631
 
@@ -7330,18 +7782,40 @@ function createITMPartnerClient(config) {
7330
7782
  "ITM Partner SDK: token is required. Get one from backstage: Settings > Partner API."
7331
7783
  );
7332
7784
  }
7333
- return createSafeClient({
7785
+ const adminSession = "adminSession" in config ? config.adminSession : void 0;
7786
+ if (adminSession !== void 0 && typeof adminSession !== "function" && (typeof adminSession !== "string" || !adminSession.trim())) {
7787
+ throw new Error("ITM Partner SDK: adminSession must be a non-empty string or a function.");
7788
+ }
7789
+ const tokenClient = (withSession) => createSafeClient({
7334
7790
  url: baseUrl ?? DEFAULT_API_URL,
7335
7791
  signal,
7336
7792
  headers: async () => {
7337
7793
  const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
7794
+ let session;
7795
+ if (withSession && adminSession !== void 0) {
7796
+ try {
7797
+ session = typeof adminSession === "function" ? await adminSession() : adminSession;
7798
+ } catch {
7799
+ throw new Error("ITM Partner SDK: admin session is unavailable.");
7800
+ }
7801
+ if (typeof session !== "string" || !session.trim()) throw new Error("ITM Partner SDK: admin session is unavailable.");
7802
+ if (session.trim() === token.trim()) throw new Error("ITM Partner SDK: adminSession must be an admin session, not the partner key.");
7803
+ }
7338
7804
  return {
7339
7805
  ...sanitizeHeaders(resolvedExtraHeaders),
7806
+ ...session ? { authorization: `Bearer ${session.trim()}` } : {},
7340
7807
  "x-partner-api-key": token,
7341
7808
  "Content-Type": "application/json"
7342
7809
  };
7343
7810
  }
7344
7811
  });
7812
+ const ordinary = tokenClient(false);
7813
+ if (adminSession === void 0) return ordinary;
7814
+ const wallet = tokenClient(true);
7815
+ return {
7816
+ query: (request) => (request.listPartnerWallets || request.getPartnerWalletOperation || request.listPartnerWalletOperations || request.listPartnerWalletActivity ? wallet : ordinary).query(request),
7817
+ mutation: (request) => (request.preparePartnerWalletPayment || request.confirmPartnerWalletOperation || request.createPartnerWalletPaymentRequest ? wallet : ordinary).mutation(request)
7818
+ };
7345
7819
  }
7346
7820
  function sanitizeHeaders(headers) {
7347
7821
  return Object.fromEntries(Object.entries(headers ?? {}).filter(([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())));