@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/README.md +110 -3
- package/dist/index.d.mts +309 -1
- package/dist/index.d.ts +309 -1
- package/dist/index.js +477 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/schema/partner.graphql +172 -0
package/dist/index.mjs
CHANGED
|
@@ -653,7 +653,11 @@ var types_default = {
|
|
|
653
653
|
282,
|
|
654
654
|
289,
|
|
655
655
|
290,
|
|
656
|
-
291
|
|
656
|
+
291,
|
|
657
|
+
305,
|
|
658
|
+
309,
|
|
659
|
+
313,
|
|
660
|
+
314
|
|
657
661
|
],
|
|
658
662
|
"types": {
|
|
659
663
|
"DateTime": {},
|
|
@@ -3607,6 +3611,85 @@ var types_default = {
|
|
|
3607
3611
|
]
|
|
3608
3612
|
},
|
|
3609
3613
|
"Query": {
|
|
3614
|
+
"getPartnerWalletOperation": [
|
|
3615
|
+
306,
|
|
3616
|
+
{
|
|
3617
|
+
"brandUid": [
|
|
3618
|
+
36,
|
|
3619
|
+
"String!"
|
|
3620
|
+
],
|
|
3621
|
+
"operationUid": [
|
|
3622
|
+
36,
|
|
3623
|
+
"String!"
|
|
3624
|
+
],
|
|
3625
|
+
"walletUid": [
|
|
3626
|
+
36,
|
|
3627
|
+
"String!"
|
|
3628
|
+
]
|
|
3629
|
+
}
|
|
3630
|
+
],
|
|
3631
|
+
"listPartnerWalletActivity": [
|
|
3632
|
+
300,
|
|
3633
|
+
{
|
|
3634
|
+
"brandUid": [
|
|
3635
|
+
36,
|
|
3636
|
+
"String!"
|
|
3637
|
+
],
|
|
3638
|
+
"cursor": [
|
|
3639
|
+
36
|
|
3640
|
+
],
|
|
3641
|
+
"take": [
|
|
3642
|
+
38
|
|
3643
|
+
],
|
|
3644
|
+
"walletUid": [
|
|
3645
|
+
36,
|
|
3646
|
+
"String!"
|
|
3647
|
+
]
|
|
3648
|
+
}
|
|
3649
|
+
],
|
|
3650
|
+
"listPartnerWalletOperations": [
|
|
3651
|
+
308,
|
|
3652
|
+
{
|
|
3653
|
+
"brandUid": [
|
|
3654
|
+
36,
|
|
3655
|
+
"String!"
|
|
3656
|
+
],
|
|
3657
|
+
"cursor": [
|
|
3658
|
+
36
|
|
3659
|
+
],
|
|
3660
|
+
"excludeUnconfirmed": [
|
|
3661
|
+
39
|
|
3662
|
+
],
|
|
3663
|
+
"kind": [
|
|
3664
|
+
313
|
|
3665
|
+
],
|
|
3666
|
+
"statuses": [
|
|
3667
|
+
314,
|
|
3668
|
+
"[WalletOperationStatus!]"
|
|
3669
|
+
],
|
|
3670
|
+
"take": [
|
|
3671
|
+
38
|
|
3672
|
+
],
|
|
3673
|
+
"walletUid": [
|
|
3674
|
+
36
|
|
3675
|
+
]
|
|
3676
|
+
}
|
|
3677
|
+
],
|
|
3678
|
+
"listPartnerWallets": [
|
|
3679
|
+
310,
|
|
3680
|
+
{
|
|
3681
|
+
"brandUid": [
|
|
3682
|
+
36,
|
|
3683
|
+
"String!"
|
|
3684
|
+
],
|
|
3685
|
+
"cursor": [
|
|
3686
|
+
36
|
|
3687
|
+
],
|
|
3688
|
+
"take": [
|
|
3689
|
+
38
|
|
3690
|
+
]
|
|
3691
|
+
}
|
|
3692
|
+
],
|
|
3610
3693
|
"getPartnerForms": [
|
|
3611
3694
|
292,
|
|
3612
3695
|
{
|
|
@@ -4807,6 +4890,57 @@ var types_default = {
|
|
|
4807
4890
|
]
|
|
4808
4891
|
},
|
|
4809
4892
|
"Mutation": {
|
|
4893
|
+
"confirmPartnerWalletOperation": [
|
|
4894
|
+
306,
|
|
4895
|
+
{
|
|
4896
|
+
"brandUid": [
|
|
4897
|
+
36,
|
|
4898
|
+
"String!"
|
|
4899
|
+
],
|
|
4900
|
+
"operationUid": [
|
|
4901
|
+
36,
|
|
4902
|
+
"String!"
|
|
4903
|
+
],
|
|
4904
|
+
"walletUid": [
|
|
4905
|
+
36,
|
|
4906
|
+
"String!"
|
|
4907
|
+
]
|
|
4908
|
+
}
|
|
4909
|
+
],
|
|
4910
|
+
"createPartnerWalletPaymentRequest": [
|
|
4911
|
+
306,
|
|
4912
|
+
{
|
|
4913
|
+
"brandUid": [
|
|
4914
|
+
36,
|
|
4915
|
+
"String!"
|
|
4916
|
+
],
|
|
4917
|
+
"input": [
|
|
4918
|
+
311,
|
|
4919
|
+
"CreateBrandWalletPaymentRequestInput!"
|
|
4920
|
+
],
|
|
4921
|
+
"walletUid": [
|
|
4922
|
+
36,
|
|
4923
|
+
"String!"
|
|
4924
|
+
]
|
|
4925
|
+
}
|
|
4926
|
+
],
|
|
4927
|
+
"preparePartnerWalletPayment": [
|
|
4928
|
+
306,
|
|
4929
|
+
{
|
|
4930
|
+
"brandUid": [
|
|
4931
|
+
36,
|
|
4932
|
+
"String!"
|
|
4933
|
+
],
|
|
4934
|
+
"input": [
|
|
4935
|
+
312,
|
|
4936
|
+
"PrepareBrandWalletPaymentInput!"
|
|
4937
|
+
],
|
|
4938
|
+
"walletUid": [
|
|
4939
|
+
36,
|
|
4940
|
+
"String!"
|
|
4941
|
+
]
|
|
4942
|
+
}
|
|
4943
|
+
],
|
|
4810
4944
|
"createPartnerBrandApp": [
|
|
4811
4945
|
154,
|
|
4812
4946
|
{
|
|
@@ -7151,7 +7285,325 @@ var types_default = {
|
|
|
7151
7285
|
"__typename": [
|
|
7152
7286
|
36
|
|
7153
7287
|
]
|
|
7154
|
-
}
|
|
7288
|
+
},
|
|
7289
|
+
"BrandWallet": {
|
|
7290
|
+
"accessReady": [
|
|
7291
|
+
39
|
|
7292
|
+
],
|
|
7293
|
+
"balance": [
|
|
7294
|
+
301
|
|
7295
|
+
],
|
|
7296
|
+
"balanceStale": [
|
|
7297
|
+
39
|
|
7298
|
+
],
|
|
7299
|
+
"capabilities": [
|
|
7300
|
+
302
|
|
7301
|
+
],
|
|
7302
|
+
"displayName": [
|
|
7303
|
+
36
|
|
7304
|
+
],
|
|
7305
|
+
"status": [
|
|
7306
|
+
36
|
|
7307
|
+
],
|
|
7308
|
+
"uid": [
|
|
7309
|
+
36
|
|
7310
|
+
],
|
|
7311
|
+
"__typename": [
|
|
7312
|
+
36
|
|
7313
|
+
]
|
|
7314
|
+
},
|
|
7315
|
+
"BrandWalletActivity": {
|
|
7316
|
+
"amountMinor": [
|
|
7317
|
+
36
|
|
7318
|
+
],
|
|
7319
|
+
"counterparty": [
|
|
7320
|
+
303
|
|
7321
|
+
],
|
|
7322
|
+
"currency": [
|
|
7323
|
+
36
|
|
7324
|
+
],
|
|
7325
|
+
"description": [
|
|
7326
|
+
36
|
|
7327
|
+
],
|
|
7328
|
+
"direction": [
|
|
7329
|
+
36
|
|
7330
|
+
],
|
|
7331
|
+
"feeMinor": [
|
|
7332
|
+
36
|
|
7333
|
+
],
|
|
7334
|
+
"occurredAt": [
|
|
7335
|
+
0
|
|
7336
|
+
],
|
|
7337
|
+
"operationKind": [
|
|
7338
|
+
313
|
|
7339
|
+
],
|
|
7340
|
+
"operationUid": [
|
|
7341
|
+
36
|
|
7342
|
+
],
|
|
7343
|
+
"status": [
|
|
7344
|
+
36
|
|
7345
|
+
],
|
|
7346
|
+
"uid": [
|
|
7347
|
+
36
|
|
7348
|
+
],
|
|
7349
|
+
"__typename": [
|
|
7350
|
+
36
|
|
7351
|
+
]
|
|
7352
|
+
},
|
|
7353
|
+
"BrandWalletActivityResponse": {
|
|
7354
|
+
"activity": [
|
|
7355
|
+
299
|
|
7356
|
+
],
|
|
7357
|
+
"activityStale": [
|
|
7358
|
+
39
|
|
7359
|
+
],
|
|
7360
|
+
"hasNextPage": [
|
|
7361
|
+
39
|
|
7362
|
+
],
|
|
7363
|
+
"ledgerCheckedAt": [
|
|
7364
|
+
0
|
|
7365
|
+
],
|
|
7366
|
+
"nextCursor": [
|
|
7367
|
+
36
|
|
7368
|
+
],
|
|
7369
|
+
"totalCount": [
|
|
7370
|
+
38
|
|
7371
|
+
],
|
|
7372
|
+
"__typename": [
|
|
7373
|
+
36
|
|
7374
|
+
]
|
|
7375
|
+
},
|
|
7376
|
+
"BrandWalletBalance": {
|
|
7377
|
+
"availableMinor": [
|
|
7378
|
+
36
|
|
7379
|
+
],
|
|
7380
|
+
"currency": [
|
|
7381
|
+
36
|
|
7382
|
+
],
|
|
7383
|
+
"refreshedAt": [
|
|
7384
|
+
0
|
|
7385
|
+
],
|
|
7386
|
+
"totalMinor": [
|
|
7387
|
+
36
|
|
7388
|
+
],
|
|
7389
|
+
"__typename": [
|
|
7390
|
+
36
|
|
7391
|
+
]
|
|
7392
|
+
},
|
|
7393
|
+
"BrandWalletCapabilities": {
|
|
7394
|
+
"canRequest": [
|
|
7395
|
+
39
|
|
7396
|
+
],
|
|
7397
|
+
"canSend": [
|
|
7398
|
+
39
|
|
7399
|
+
],
|
|
7400
|
+
"canTransfer": [
|
|
7401
|
+
39
|
|
7402
|
+
],
|
|
7403
|
+
"missingPermissions": [
|
|
7404
|
+
36
|
|
7405
|
+
],
|
|
7406
|
+
"__typename": [
|
|
7407
|
+
36
|
|
7408
|
+
]
|
|
7409
|
+
},
|
|
7410
|
+
"BrandWalletCounterparty": {
|
|
7411
|
+
"type": [
|
|
7412
|
+
305
|
|
7413
|
+
],
|
|
7414
|
+
"value": [
|
|
7415
|
+
36
|
|
7416
|
+
],
|
|
7417
|
+
"__typename": [
|
|
7418
|
+
36
|
|
7419
|
+
]
|
|
7420
|
+
},
|
|
7421
|
+
"BrandWalletCounterpartyInput": {
|
|
7422
|
+
"type": [
|
|
7423
|
+
305
|
|
7424
|
+
],
|
|
7425
|
+
"value": [
|
|
7426
|
+
36
|
|
7427
|
+
],
|
|
7428
|
+
"__typename": [
|
|
7429
|
+
36
|
|
7430
|
+
]
|
|
7431
|
+
},
|
|
7432
|
+
"BrandWalletCounterpartyType": {},
|
|
7433
|
+
"BrandWalletOperation": {
|
|
7434
|
+
"amountMinor": [
|
|
7435
|
+
36
|
|
7436
|
+
],
|
|
7437
|
+
"clientRequestKey": [
|
|
7438
|
+
36
|
|
7439
|
+
],
|
|
7440
|
+
"confirmedAt": [
|
|
7441
|
+
0
|
|
7442
|
+
],
|
|
7443
|
+
"counterparty": [
|
|
7444
|
+
303
|
|
7445
|
+
],
|
|
7446
|
+
"createdAt": [
|
|
7447
|
+
0
|
|
7448
|
+
],
|
|
7449
|
+
"createdBy": [
|
|
7450
|
+
307
|
|
7451
|
+
],
|
|
7452
|
+
"currency": [
|
|
7453
|
+
36
|
|
7454
|
+
],
|
|
7455
|
+
"description": [
|
|
7456
|
+
36
|
|
7457
|
+
],
|
|
7458
|
+
"destinationWalletUid": [
|
|
7459
|
+
36
|
|
7460
|
+
],
|
|
7461
|
+
"feeMinor": [
|
|
7462
|
+
36
|
|
7463
|
+
],
|
|
7464
|
+
"hasLink": [
|
|
7465
|
+
39
|
|
7466
|
+
],
|
|
7467
|
+
"kind": [
|
|
7468
|
+
313
|
|
7469
|
+
],
|
|
7470
|
+
"lastErrorCode": [
|
|
7471
|
+
36
|
|
7472
|
+
],
|
|
7473
|
+
"link": [
|
|
7474
|
+
36
|
|
7475
|
+
],
|
|
7476
|
+
"linkExpiresAt": [
|
|
7477
|
+
0
|
|
7478
|
+
],
|
|
7479
|
+
"netMinor": [
|
|
7480
|
+
36
|
|
7481
|
+
],
|
|
7482
|
+
"pendingCancelOperationUid": [
|
|
7483
|
+
36
|
|
7484
|
+
],
|
|
7485
|
+
"preparedExpiresAt": [
|
|
7486
|
+
0
|
|
7487
|
+
],
|
|
7488
|
+
"provider": [
|
|
7489
|
+
309
|
|
7490
|
+
],
|
|
7491
|
+
"providerResourceId": [
|
|
7492
|
+
36
|
|
7493
|
+
],
|
|
7494
|
+
"providerStatus": [
|
|
7495
|
+
36
|
|
7496
|
+
],
|
|
7497
|
+
"settledAt": [
|
|
7498
|
+
0
|
|
7499
|
+
],
|
|
7500
|
+
"status": [
|
|
7501
|
+
314
|
|
7502
|
+
],
|
|
7503
|
+
"submittedAt": [
|
|
7504
|
+
0
|
|
7505
|
+
],
|
|
7506
|
+
"uid": [
|
|
7507
|
+
36
|
|
7508
|
+
],
|
|
7509
|
+
"updatedAt": [
|
|
7510
|
+
0
|
|
7511
|
+
],
|
|
7512
|
+
"walletUid": [
|
|
7513
|
+
36
|
|
7514
|
+
],
|
|
7515
|
+
"__typename": [
|
|
7516
|
+
36
|
|
7517
|
+
]
|
|
7518
|
+
},
|
|
7519
|
+
"BrandWalletOperationCreator": {
|
|
7520
|
+
"email": [
|
|
7521
|
+
36
|
|
7522
|
+
],
|
|
7523
|
+
"uid": [
|
|
7524
|
+
36
|
|
7525
|
+
],
|
|
7526
|
+
"__typename": [
|
|
7527
|
+
36
|
|
7528
|
+
]
|
|
7529
|
+
},
|
|
7530
|
+
"BrandWalletOperationsResponse": {
|
|
7531
|
+
"hasNextPage": [
|
|
7532
|
+
39
|
|
7533
|
+
],
|
|
7534
|
+
"nextCursor": [
|
|
7535
|
+
36
|
|
7536
|
+
],
|
|
7537
|
+
"operations": [
|
|
7538
|
+
306
|
|
7539
|
+
],
|
|
7540
|
+
"totalCount": [
|
|
7541
|
+
38
|
|
7542
|
+
],
|
|
7543
|
+
"__typename": [
|
|
7544
|
+
36
|
|
7545
|
+
]
|
|
7546
|
+
},
|
|
7547
|
+
"BrandWalletProvider": {},
|
|
7548
|
+
"BrandWalletsResponse": {
|
|
7549
|
+
"hasNextPage": [
|
|
7550
|
+
39
|
|
7551
|
+
],
|
|
7552
|
+
"nextCursor": [
|
|
7553
|
+
36
|
|
7554
|
+
],
|
|
7555
|
+
"totalCount": [
|
|
7556
|
+
38
|
|
7557
|
+
],
|
|
7558
|
+
"wallets": [
|
|
7559
|
+
298
|
|
7560
|
+
],
|
|
7561
|
+
"__typename": [
|
|
7562
|
+
36
|
|
7563
|
+
]
|
|
7564
|
+
},
|
|
7565
|
+
"CreateBrandWalletPaymentRequestInput": {
|
|
7566
|
+
"amountMinor": [
|
|
7567
|
+
36
|
|
7568
|
+
],
|
|
7569
|
+
"clientRequestKey": [
|
|
7570
|
+
36
|
|
7571
|
+
],
|
|
7572
|
+
"currency": [
|
|
7573
|
+
36
|
|
7574
|
+
],
|
|
7575
|
+
"description": [
|
|
7576
|
+
36
|
|
7577
|
+
],
|
|
7578
|
+
"payer": [
|
|
7579
|
+
304
|
|
7580
|
+
],
|
|
7581
|
+
"__typename": [
|
|
7582
|
+
36
|
|
7583
|
+
]
|
|
7584
|
+
},
|
|
7585
|
+
"PrepareBrandWalletPaymentInput": {
|
|
7586
|
+
"amountMinor": [
|
|
7587
|
+
36
|
|
7588
|
+
],
|
|
7589
|
+
"clientRequestKey": [
|
|
7590
|
+
36
|
|
7591
|
+
],
|
|
7592
|
+
"counterparty": [
|
|
7593
|
+
304
|
|
7594
|
+
],
|
|
7595
|
+
"currency": [
|
|
7596
|
+
36
|
|
7597
|
+
],
|
|
7598
|
+
"description": [
|
|
7599
|
+
36
|
|
7600
|
+
],
|
|
7601
|
+
"__typename": [
|
|
7602
|
+
36
|
|
7603
|
+
]
|
|
7604
|
+
},
|
|
7605
|
+
"WalletOperationKind": {},
|
|
7606
|
+
"WalletOperationStatus": {}
|
|
7155
7607
|
}
|
|
7156
7608
|
};
|
|
7157
7609
|
|
|
@@ -7308,18 +7760,40 @@ function createITMPartnerClient(config) {
|
|
|
7308
7760
|
"ITM Partner SDK: token is required. Get one from backstage: Settings > Partner API."
|
|
7309
7761
|
);
|
|
7310
7762
|
}
|
|
7311
|
-
|
|
7763
|
+
const adminSession = "adminSession" in config ? config.adminSession : void 0;
|
|
7764
|
+
if (adminSession !== void 0 && typeof adminSession !== "function" && (typeof adminSession !== "string" || !adminSession.trim())) {
|
|
7765
|
+
throw new Error("ITM Partner SDK: adminSession must be a non-empty string or a function.");
|
|
7766
|
+
}
|
|
7767
|
+
const tokenClient = (withSession) => createSafeClient({
|
|
7312
7768
|
url: baseUrl ?? DEFAULT_API_URL,
|
|
7313
7769
|
signal,
|
|
7314
7770
|
headers: async () => {
|
|
7315
7771
|
const resolvedExtraHeaders = typeof extraHeaders === "function" ? await extraHeaders() : extraHeaders;
|
|
7772
|
+
let session;
|
|
7773
|
+
if (withSession && adminSession !== void 0) {
|
|
7774
|
+
try {
|
|
7775
|
+
session = typeof adminSession === "function" ? await adminSession() : adminSession;
|
|
7776
|
+
} catch {
|
|
7777
|
+
throw new Error("ITM Partner SDK: admin session is unavailable.");
|
|
7778
|
+
}
|
|
7779
|
+
if (typeof session !== "string" || !session.trim()) throw new Error("ITM Partner SDK: admin session is unavailable.");
|
|
7780
|
+
if (session.trim() === token.trim()) throw new Error("ITM Partner SDK: adminSession must be an admin session, not the partner key.");
|
|
7781
|
+
}
|
|
7316
7782
|
return {
|
|
7317
7783
|
...sanitizeHeaders(resolvedExtraHeaders),
|
|
7784
|
+
...session ? { authorization: `Bearer ${session.trim()}` } : {},
|
|
7318
7785
|
"x-partner-api-key": token,
|
|
7319
7786
|
"Content-Type": "application/json"
|
|
7320
7787
|
};
|
|
7321
7788
|
}
|
|
7322
7789
|
});
|
|
7790
|
+
const ordinary = tokenClient(false);
|
|
7791
|
+
if (adminSession === void 0) return ordinary;
|
|
7792
|
+
const wallet = tokenClient(true);
|
|
7793
|
+
return {
|
|
7794
|
+
query: (request) => (request.listPartnerWallets || request.getPartnerWalletOperation || request.listPartnerWalletOperations || request.listPartnerWalletActivity ? wallet : ordinary).query(request),
|
|
7795
|
+
mutation: (request) => (request.preparePartnerWalletPayment || request.confirmPartnerWalletOperation || request.createPartnerWalletPaymentRequest ? wallet : ordinary).mutation(request)
|
|
7796
|
+
};
|
|
7323
7797
|
}
|
|
7324
7798
|
function sanitizeHeaders(headers) {
|
|
7325
7799
|
return Object.fromEntries(Object.entries(headers ?? {}).filter(([name]) => !RESERVED_AGENT_HEADERS.has(name.toLowerCase())));
|