@owneraio/finp2p-sdk-js 0.28.41 → 0.29.0
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 +22 -1
- package/lib/OwneraAPI/__tests__/utils.test.d.ts +1 -0
- package/lib/OwneraAPI/__tests__/utils.test.js +82 -0
- package/lib/OwneraAPI/__tests__/utils.test.js.map +1 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.d.ts +1 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.js +149 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/agreements.test.js.map +1 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.d.ts +1 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.js +502 -0
- package/lib/OwneraAPI/finp2p-node-api/__tests__/collateral.test.js.map +1 -0
- package/lib/OwneraAPI/finp2p-node-api/agreements.d.ts +8 -0
- package/lib/OwneraAPI/finp2p-node-api/agreements.js +31 -0
- package/lib/OwneraAPI/finp2p-node-api/agreements.js.map +1 -0
- package/lib/OwneraAPI/finp2p-node-api/collateral.d.ts +16 -0
- package/lib/OwneraAPI/finp2p-node-api/collateral.js +131 -0
- package/lib/OwneraAPI/finp2p-node-api/collateral.js.map +1 -0
- package/lib/OwneraAPI/index.js +4 -0
- package/lib/OwneraAPI/index.js.map +1 -1
- package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.d.ts +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.js +15 -0
- package/lib/OwneraAPI/oss-api/__tests__/filterUtils.test.js.map +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.d.ts +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.js +175 -0
- package/lib/OwneraAPI/oss-api/__tests__/getAgreements.test.js.map +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.d.ts +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.js +321 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralAgreements.test.js.map +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.d.ts +1 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.js +152 -0
- package/lib/OwneraAPI/oss-api/__tests__/getCollateralReports.test.js.map +1 -0
- package/lib/OwneraAPI/oss-api/oss.js +576 -0
- package/lib/OwneraAPI/oss-api/oss.js.map +1 -1
- package/lib/OwneraAPI/utils.js +51 -9
- package/lib/OwneraAPI/utils.js.map +1 -1
- package/lib/types/Agreements/Agreements.d.ts +355 -0
- package/lib/types/Agreements/Agreements.js +3 -0
- package/lib/types/Agreements/Agreements.js.map +1 -0
- package/lib/types/Agreements/index.d.ts +1 -0
- package/lib/types/Agreements/index.js +18 -0
- package/lib/types/Agreements/index.js.map +1 -0
- package/lib/types/Collateral/Collateral.d.ts +564 -0
- package/lib/types/Collateral/Collateral.js +3 -0
- package/lib/types/Collateral/Collateral.js.map +1 -0
- package/lib/types/Collateral/index.d.ts +1 -0
- package/lib/types/Collateral/index.js +18 -0
- package/lib/types/Collateral/index.js.map +1 -0
- package/lib/types/Core/OwneraAPI.d.ts +4 -0
- package/lib/types/Oss/Agreements.d.ts +671 -0
- package/lib/types/Oss/Agreements.js +3 -0
- package/lib/types/Oss/Agreements.js.map +1 -0
- package/lib/types/Oss/Oss.d.ts +63 -0
- package/lib/types/Oss/index.d.ts +1 -0
- package/lib/types/Oss/index.js +1 -0
- package/lib/types/Oss/index.js.map +1 -1
- package/lib/types/Oss/utils.d.ts +7 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/utils.d.ts +5 -0
- package/lib/types/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -527,6 +527,251 @@ pageInfo {
|
|
|
527
527
|
totalCount
|
|
528
528
|
totalLeft
|
|
529
529
|
}`;
|
|
530
|
+
const emptyPageInfo = { hasNextPage: false, totalCount: 0, totalLeft: 0 };
|
|
531
|
+
// agreement (resource type 107) fragments — selections validated against the
|
|
532
|
+
// oss feature/collateral-mobility schema on local6 (ownership.graphql).
|
|
533
|
+
const accountPolicyFragment = `
|
|
534
|
+
policyId
|
|
535
|
+
version
|
|
536
|
+
direction
|
|
537
|
+
eligibility { assetTypes assetNameRegexp assetCodes ledgerNames }
|
|
538
|
+
constraints { allowedCounterOrganizations allowedCounterAssetTypes allowedCounterFinIds allowedCounterRoles }
|
|
539
|
+
authorization { requiredRoles requiredSigners threshold }
|
|
540
|
+
conditions {
|
|
541
|
+
name
|
|
542
|
+
trigger { type asserterRole }
|
|
543
|
+
authorization { requiredRoles requiredSigners threshold }
|
|
544
|
+
constraints { allowedCounterOrganizations allowedCounterAssetTypes allowedCounterFinIds allowedCounterRoles }
|
|
545
|
+
}
|
|
546
|
+
allowedInitiatorRoles
|
|
547
|
+
agreementRef
|
|
548
|
+
beneficialOwnerRole
|
|
549
|
+
boundParty
|
|
550
|
+
signers { signerParty }
|
|
551
|
+
`;
|
|
552
|
+
const containerSpecFragment = `
|
|
553
|
+
key
|
|
554
|
+
servesRoles
|
|
555
|
+
boundParty
|
|
556
|
+
provisionerRole
|
|
557
|
+
provisionerParty
|
|
558
|
+
eligibleAssets { network standard tokenId }
|
|
559
|
+
policyTemplate { ${accountPolicyFragment} }
|
|
560
|
+
`;
|
|
561
|
+
// AgreementSchemaReference is a union: the url arm carries `url`, the document arm `key`.
|
|
562
|
+
const agreementSchemaFragment = `
|
|
563
|
+
name
|
|
564
|
+
version
|
|
565
|
+
reference {
|
|
566
|
+
... on AgreementSchemaUrlReference { url format hash { hash hashAlgorithm } }
|
|
567
|
+
... on AgreementSchemaDocumentReference { key path format hash { hash hashAlgorithm } }
|
|
568
|
+
}
|
|
569
|
+
`;
|
|
570
|
+
const agreementAccountFragment = `
|
|
571
|
+
agreementId
|
|
572
|
+
finId
|
|
573
|
+
orgId
|
|
574
|
+
custodianOrgId
|
|
575
|
+
policyId
|
|
576
|
+
policyVersion
|
|
577
|
+
servesRoles
|
|
578
|
+
provisionerRole
|
|
579
|
+
status
|
|
580
|
+
footprints { network standard tokenId networkAccount }
|
|
581
|
+
spec { ${containerSpecFragment} }
|
|
582
|
+
`;
|
|
583
|
+
const agreementFragment = `
|
|
584
|
+
id
|
|
585
|
+
organizationId
|
|
586
|
+
status
|
|
587
|
+
version
|
|
588
|
+
consentRoles
|
|
589
|
+
participants { organizationId roles }
|
|
590
|
+
roles { role parties }
|
|
591
|
+
eligibleAssets { network standard tokenId }
|
|
592
|
+
termsType
|
|
593
|
+
terms
|
|
594
|
+
validFrom
|
|
595
|
+
validUntil
|
|
596
|
+
signatures { role signerParty }
|
|
597
|
+
events {
|
|
598
|
+
id
|
|
599
|
+
eventType
|
|
600
|
+
emitterRole
|
|
601
|
+
sequence
|
|
602
|
+
occurredAt
|
|
603
|
+
payloadType
|
|
604
|
+
payload
|
|
605
|
+
referencedEventIds
|
|
606
|
+
after { changeStateTo }
|
|
607
|
+
}
|
|
608
|
+
accounts { ${agreementAccountFragment} }
|
|
609
|
+
setup {
|
|
610
|
+
... on AgreementProvisioningSpec {
|
|
611
|
+
provisionerRole
|
|
612
|
+
policyTemplate { ${accountPolicyFragment} }
|
|
613
|
+
containers { ${containerSpecFragment} }
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
definition {
|
|
617
|
+
name
|
|
618
|
+
version
|
|
619
|
+
emitterRoles
|
|
620
|
+
guard
|
|
621
|
+
states { onCreation onApproval allowedStates finalStates }
|
|
622
|
+
schema { ${agreementSchemaFragment} }
|
|
623
|
+
allowedEvents { type guard schema { ${agreementSchemaFragment} } }
|
|
624
|
+
transitions { event toState fromStates guard targetSelectableByEvent selectableStates }
|
|
625
|
+
}
|
|
626
|
+
`;
|
|
627
|
+
// collateral facade module fragments (collateral.graphql) — folded entities,
|
|
628
|
+
// decoded terms, no base64, no raw events.
|
|
629
|
+
const collateralAgreementFragment = `
|
|
630
|
+
agreementId
|
|
631
|
+
orgId
|
|
632
|
+
status
|
|
633
|
+
version
|
|
634
|
+
termsType
|
|
635
|
+
consentRoles
|
|
636
|
+
eligibleAssets { network standard tokenId }
|
|
637
|
+
definitionSchemaKey
|
|
638
|
+
terms {
|
|
639
|
+
baseCurrency
|
|
640
|
+
haircutApplyMethod
|
|
641
|
+
eligibleAssets { assetId haircut caip19 }
|
|
642
|
+
}
|
|
643
|
+
roles { role parties }
|
|
644
|
+
participants { orgId role }
|
|
645
|
+
containers { key finId orgId status boundParty }
|
|
646
|
+
validFrom
|
|
647
|
+
validUntil
|
|
648
|
+
createdAt
|
|
649
|
+
`;
|
|
650
|
+
// The asset an execution plan moved, with the attribution line's valuation overlaid.
|
|
651
|
+
const collateralReportActionAssetFragment = `
|
|
652
|
+
assetIdType
|
|
653
|
+
assetId
|
|
654
|
+
name
|
|
655
|
+
ticker
|
|
656
|
+
assetIdentifierType
|
|
657
|
+
assetIdentifierValue
|
|
658
|
+
metadata { appliedHaircut baseUnitPrice baseValue baseUnits finalUnitPrice finalValue finalUnits }
|
|
659
|
+
`;
|
|
660
|
+
const collateralReportFragment = `
|
|
661
|
+
reportId
|
|
662
|
+
agreementId
|
|
663
|
+
type
|
|
664
|
+
currency
|
|
665
|
+
senderOrgId
|
|
666
|
+
senderProfileId
|
|
667
|
+
receiverOrgId
|
|
668
|
+
receiverProfileId
|
|
669
|
+
reportCreatorId
|
|
670
|
+
nominalMarginAmount
|
|
671
|
+
deadline
|
|
672
|
+
eventId
|
|
673
|
+
containerKey
|
|
674
|
+
calledParty
|
|
675
|
+
overlayStatus
|
|
676
|
+
sequence
|
|
677
|
+
fulfillmentMode
|
|
678
|
+
createdAt
|
|
679
|
+
statusHistory { status sequence emitterRole emitterOrgId note timestamp }
|
|
680
|
+
resolutions { resolvedBy sequence timestamp note }
|
|
681
|
+
rejections { rejectedBy sequence timestamp note }
|
|
682
|
+
actions {
|
|
683
|
+
action
|
|
684
|
+
nominalAmount
|
|
685
|
+
recoveredAsset { assetId quantity }
|
|
686
|
+
}
|
|
687
|
+
settlement { assetId }
|
|
688
|
+
negotiations {
|
|
689
|
+
negotiationId
|
|
690
|
+
kind
|
|
691
|
+
status
|
|
692
|
+
openedBy
|
|
693
|
+
standingRound
|
|
694
|
+
standingBy
|
|
695
|
+
agreedLines { assetId quantity }
|
|
696
|
+
intentId
|
|
697
|
+
rounds { round action by lines { assetId quantity } intentId reason sequence timestamp }
|
|
698
|
+
}
|
|
699
|
+
exceptions {
|
|
700
|
+
exceptionId
|
|
701
|
+
status
|
|
702
|
+
blame
|
|
703
|
+
reason
|
|
704
|
+
raisedBy
|
|
705
|
+
details { executionPlanId assetId quantity }
|
|
706
|
+
eventId
|
|
707
|
+
sequence
|
|
708
|
+
timestamp
|
|
709
|
+
}
|
|
710
|
+
manualResolves {
|
|
711
|
+
manualResolveId
|
|
712
|
+
exceptionIds
|
|
713
|
+
requestedBy
|
|
714
|
+
reason
|
|
715
|
+
eventId
|
|
716
|
+
sequence
|
|
717
|
+
timestamp
|
|
718
|
+
decisions { status decidedBy reason sequence timestamp }
|
|
719
|
+
}
|
|
720
|
+
coverageRechecks { requestedBy reason eventId sequence timestamp }
|
|
721
|
+
executionPlans {
|
|
722
|
+
planId
|
|
723
|
+
status
|
|
724
|
+
asset { ${collateralReportActionAssetFragment} }
|
|
725
|
+
quantity
|
|
726
|
+
failureReason
|
|
727
|
+
instructions { sequence status errorCode errorMessage }
|
|
728
|
+
createdAt
|
|
729
|
+
lastModified
|
|
730
|
+
}
|
|
731
|
+
attributionProposals {
|
|
732
|
+
proposalId
|
|
733
|
+
round
|
|
734
|
+
status
|
|
735
|
+
lines {
|
|
736
|
+
assetId
|
|
737
|
+
quantity
|
|
738
|
+
metadata { appliedHaircut baseUnitPrice baseValue baseUnits finalUnitPrice finalValue finalUnits }
|
|
739
|
+
}
|
|
740
|
+
proposedBy
|
|
741
|
+
decidedBy
|
|
742
|
+
completed
|
|
743
|
+
eventId
|
|
744
|
+
decisionEventId
|
|
745
|
+
sequence
|
|
746
|
+
timestamp
|
|
747
|
+
}
|
|
748
|
+
`;
|
|
749
|
+
const collateralContainerBookFragment = `
|
|
750
|
+
agreementId
|
|
751
|
+
containerKey
|
|
752
|
+
finId
|
|
753
|
+
boundParty
|
|
754
|
+
booksAvailable
|
|
755
|
+
holdings { assetId quantity }
|
|
756
|
+
activity { assetId quantity direction reportId timestampMs transactionId operationType }
|
|
757
|
+
earmarks { reportId holdings { assetId quantity } }
|
|
758
|
+
unattributed { assetId quantity }
|
|
759
|
+
`;
|
|
760
|
+
// A connection page is complete when its root resolved and no node is null. `nodes: null` is a valid
|
|
761
|
+
// empty page; a field error that nulls anything is caught earlier, because these reads are `strict`.
|
|
762
|
+
const isCompletePage = (page) => { var _a; return !!page && ((_a = page.nodes) !== null && _a !== void 0 ? _a : []).every((node) => node !== null && node !== undefined); };
|
|
763
|
+
// OSS `CollateralAgreementOrderField` values: the only order literals `getCollateralAgreements` sends.
|
|
764
|
+
const COLLATERAL_AGREEMENT_ORDER_FIELDS = ['CREATED_AT', 'AGREEMENT_ID'];
|
|
765
|
+
// OSS `CollateralReportOrderField` values: the only order literals `getCollateralReports` sends.
|
|
766
|
+
const COLLATERAL_REPORT_ORDER_FIELDS = ['CREATED_AT'];
|
|
767
|
+
const COLLATERAL_REPORT_CHANGE_KINDS = [
|
|
768
|
+
'CREATED',
|
|
769
|
+
'STATUS_CHANGED',
|
|
770
|
+
'RESOLVED',
|
|
771
|
+
'NEGOTIATION',
|
|
772
|
+
'REJECTED',
|
|
773
|
+
'EXCEPTION',
|
|
774
|
+
];
|
|
530
775
|
// execution plan fragments
|
|
531
776
|
const termFragment = `
|
|
532
777
|
term {
|
|
@@ -2474,6 +2719,112 @@ subscription getReceipts {
|
|
|
2474
2719
|
r.onNext(data);
|
|
2475
2720
|
} }));
|
|
2476
2721
|
},
|
|
2722
|
+
// -- agreements (resource type 107): raw read-model pushes (ownership.graphql)
|
|
2723
|
+
getAgreementAddedSubscription: (r) => {
|
|
2724
|
+
var _a;
|
|
2725
|
+
const args = ((_a = r.orgIds) === null || _a === void 0 ? void 0 : _a.length) ? `(orgIds: ${JSON.stringify(r.orgIds)})` : '';
|
|
2726
|
+
const query = `
|
|
2727
|
+
subscription agreementAddedSubscription {
|
|
2728
|
+
agreementAdded${args} {
|
|
2729
|
+
${agreementFragment}
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
`;
|
|
2733
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2734
|
+
},
|
|
2735
|
+
getAgreementChangedSubscription: (r) => {
|
|
2736
|
+
var _a, _b;
|
|
2737
|
+
const filters = [];
|
|
2738
|
+
if ((_a = r.agreementIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
2739
|
+
filters.push(`agreementIds: ${JSON.stringify(r.agreementIds)}`);
|
|
2740
|
+
if ((_b = r.orgIds) === null || _b === void 0 ? void 0 : _b.length)
|
|
2741
|
+
filters.push(`orgIds: ${JSON.stringify(r.orgIds)}`);
|
|
2742
|
+
const args = filters.length ? `(${filters.join(', ')})` : '';
|
|
2743
|
+
const query = `
|
|
2744
|
+
subscription agreementChangedSubscription {
|
|
2745
|
+
agreementChanged${args} {
|
|
2746
|
+
${agreementFragment}
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
`;
|
|
2750
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2751
|
+
},
|
|
2752
|
+
// -- collateral facade subscriptions (collateral.graphql): the fully folded
|
|
2753
|
+
// entities; gated per org by the OSS `enabled_features` config (`collateral`).
|
|
2754
|
+
getCollateralAgreementAddedSubscription: (r) => {
|
|
2755
|
+
var _a;
|
|
2756
|
+
const args = ((_a = r.orgIds) === null || _a === void 0 ? void 0 : _a.length) ? `(orgIds: ${JSON.stringify(r.orgIds)})` : '';
|
|
2757
|
+
const query = `
|
|
2758
|
+
subscription collateralAgreementAddedSubscription {
|
|
2759
|
+
collateralAgreementAdded${args} {
|
|
2760
|
+
${collateralAgreementFragment}
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
`;
|
|
2764
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2765
|
+
},
|
|
2766
|
+
getCollateralAgreementChangedSubscription: (r) => {
|
|
2767
|
+
var _a, _b;
|
|
2768
|
+
const filters = [];
|
|
2769
|
+
if ((_a = r.agreementIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
2770
|
+
filters.push(`agreementIds: ${JSON.stringify(r.agreementIds)}`);
|
|
2771
|
+
if ((_b = r.orgIds) === null || _b === void 0 ? void 0 : _b.length)
|
|
2772
|
+
filters.push(`orgIds: ${JSON.stringify(r.orgIds)}`);
|
|
2773
|
+
const args = filters.length ? `(${filters.join(', ')})` : '';
|
|
2774
|
+
const query = `
|
|
2775
|
+
subscription collateralAgreementChangedSubscription {
|
|
2776
|
+
collateralAgreementChanged${args} {
|
|
2777
|
+
${collateralAgreementFragment}
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
`;
|
|
2781
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2782
|
+
},
|
|
2783
|
+
getCollateralReportChangedSubscription: (r) => {
|
|
2784
|
+
var _a, _b, _c;
|
|
2785
|
+
const filters = [];
|
|
2786
|
+
if ((_a = r.agreementIds) === null || _a === void 0 ? void 0 : _a.length)
|
|
2787
|
+
filters.push(`agreementIds: ${JSON.stringify(r.agreementIds)}`);
|
|
2788
|
+
if ((_b = r.reportIds) === null || _b === void 0 ? void 0 : _b.length)
|
|
2789
|
+
filters.push(`reportIds: ${JSON.stringify(r.reportIds)}`);
|
|
2790
|
+
// Kinds are interpolated as raw enum literals, so only known ones may pass. An unknown kind is
|
|
2791
|
+
// refused rather than dropped: dropping the last one would silently widen the stream to every change.
|
|
2792
|
+
const changeKinds = (_c = r.changeKinds) !== null && _c !== void 0 ? _c : [];
|
|
2793
|
+
const unknownKinds = changeKinds.filter((kind) => !COLLATERAL_REPORT_CHANGE_KINDS.includes(kind));
|
|
2794
|
+
if (unknownKinds.length) {
|
|
2795
|
+
throw {
|
|
2796
|
+
code: 400,
|
|
2797
|
+
name: 'UnknownChangeKind',
|
|
2798
|
+
message: `Unknown collateral report change kind(s): ${unknownKinds.join(', ')}`,
|
|
2799
|
+
};
|
|
2800
|
+
}
|
|
2801
|
+
if (changeKinds.length)
|
|
2802
|
+
filters.push(`changeKinds: [${changeKinds.join(', ')}]`);
|
|
2803
|
+
const args = filters.length ? `(${filters.join(', ')})` : '';
|
|
2804
|
+
const query = `
|
|
2805
|
+
subscription collateralReportChangedSubscription {
|
|
2806
|
+
collateralReportChanged${args} {
|
|
2807
|
+
kind
|
|
2808
|
+
report {
|
|
2809
|
+
${collateralReportFragment}
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
`;
|
|
2814
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2815
|
+
},
|
|
2816
|
+
getCollateralContainerBookChangedSubscription: (r) => {
|
|
2817
|
+
var _a;
|
|
2818
|
+
const args = ((_a = r.agreementIds) === null || _a === void 0 ? void 0 : _a.length) ? `(agreementIds: ${JSON.stringify(r.agreementIds)})` : '';
|
|
2819
|
+
const query = `
|
|
2820
|
+
subscription collateralContainerBookChangedSubscription {
|
|
2821
|
+
collateralContainerBookChanged${args} {
|
|
2822
|
+
${collateralContainerBookFragment}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
`;
|
|
2826
|
+
return client.subscribe(Object.assign(Object.assign({}, r), { query }));
|
|
2827
|
+
},
|
|
2477
2828
|
getUserHoldingChangedSubscription: (r) => {
|
|
2478
2829
|
const query = `
|
|
2479
2830
|
subscription userHoldingChangedSubscription {
|
|
@@ -2921,6 +3272,231 @@ query getWorkflowById {
|
|
|
2921
3272
|
}
|
|
2922
3273
|
return node;
|
|
2923
3274
|
}),
|
|
3275
|
+
// models - agreements (resource type 107)
|
|
3276
|
+
getAgreements: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (request = {}) {
|
|
3277
|
+
var _a;
|
|
3278
|
+
const { filter } = request;
|
|
3279
|
+
const { id, idContains, organizationId, status } = filter || {};
|
|
3280
|
+
const filters = `
|
|
3281
|
+
filter: [
|
|
3282
|
+
${id ? `{key:"id",operator:EQ,value:${gqlString(id)}},` : ''}
|
|
3283
|
+
${idContains ? `{key:"id",operator:CONTAINS,value:${gqlString(idContains)}},` : ''}
|
|
3284
|
+
${organizationId ? `{key:"organizationId",operator:EQ,value:${gqlString(organizationId)}},` : ''}
|
|
3285
|
+
${(status === null || status === void 0 ? void 0 : status.length) ? `{key:"status",operator:IN,value:${gqlStringList(status)}},` : ''}
|
|
3286
|
+
]
|
|
3287
|
+
`;
|
|
3288
|
+
const query = `
|
|
3289
|
+
query getAgreements {
|
|
3290
|
+
agreements
|
|
3291
|
+
(${filters},
|
|
3292
|
+
${(0, queryUtils_1.paginateFragment)({ after: filter === null || filter === void 0 ? void 0 : filter.after, limit: filter === null || filter === void 0 ? void 0 : filter.limit, skip: filter === null || filter === void 0 ? void 0 : filter.skip })})
|
|
3293
|
+
{
|
|
3294
|
+
nodes {
|
|
3295
|
+
${agreementFragment}
|
|
3296
|
+
}
|
|
3297
|
+
${pageInfoFragment}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
`;
|
|
3301
|
+
const readyCondition = {
|
|
3302
|
+
match: (response) => isCompletePage(response === null || response === void 0 ? void 0 : response.agreements),
|
|
3303
|
+
name: 'getAgreements',
|
|
3304
|
+
strict: true,
|
|
3305
|
+
data: request,
|
|
3306
|
+
};
|
|
3307
|
+
const response = yield (0, utils_2.ossQuery)(client, logger, query, readyCondition);
|
|
3308
|
+
return { data: (_a = response.agreements.nodes) !== null && _a !== void 0 ? _a : [], pageInfo: response.agreements.pageInfo };
|
|
3309
|
+
}),
|
|
3310
|
+
getAgreementAccounts: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (request = {}) {
|
|
3311
|
+
var _a;
|
|
3312
|
+
const { filter } = request;
|
|
3313
|
+
const { agreementId, finId, orgId, status } = filter || {};
|
|
3314
|
+
const filters = `
|
|
3315
|
+
filter: [
|
|
3316
|
+
${agreementId ? `{key:"agreementId",operator:EQ,value:${gqlString(agreementId)}},` : ''}
|
|
3317
|
+
${finId ? `{key:"finId",operator:EQ,value:${gqlString(finId)}},` : ''}
|
|
3318
|
+
${orgId ? `{key:"orgId",operator:EQ,value:${gqlString(orgId)}},` : ''}
|
|
3319
|
+
${(status === null || status === void 0 ? void 0 : status.length) ? `{key:"status",operator:IN,value:${gqlStringList(status)}},` : ''}
|
|
3320
|
+
]
|
|
3321
|
+
`;
|
|
3322
|
+
const query = `
|
|
3323
|
+
query getAgreementAccounts {
|
|
3324
|
+
agreementAccounts
|
|
3325
|
+
(${filters},
|
|
3326
|
+
${(0, queryUtils_1.paginateFragment)({ after: filter === null || filter === void 0 ? void 0 : filter.after, limit: filter === null || filter === void 0 ? void 0 : filter.limit, skip: filter === null || filter === void 0 ? void 0 : filter.skip })})
|
|
3327
|
+
{
|
|
3328
|
+
nodes {
|
|
3329
|
+
${agreementAccountFragment}
|
|
3330
|
+
}
|
|
3331
|
+
${pageInfoFragment}
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
`;
|
|
3335
|
+
const readyCondition = {
|
|
3336
|
+
match: (response) => isCompletePage(response === null || response === void 0 ? void 0 : response.agreementAccounts),
|
|
3337
|
+
name: 'getAgreementAccounts',
|
|
3338
|
+
strict: true,
|
|
3339
|
+
data: request,
|
|
3340
|
+
};
|
|
3341
|
+
const response = yield (0, utils_2.ossQuery)(client, logger, query, readyCondition);
|
|
3342
|
+
return { data: (_a = response.agreementAccounts.nodes) !== null && _a !== void 0 ? _a : [], pageInfo: response.agreementAccounts.pageInfo };
|
|
3343
|
+
}),
|
|
3344
|
+
// models - collateral facade (collateral.graphql, `collateral` namespace root;
|
|
3345
|
+
// gated by the OSS `enabled_features` config — unlicensed orgs get a GraphQL error)
|
|
3346
|
+
getCollateralAgreements: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (request = {}) {
|
|
3347
|
+
var _a, _b;
|
|
3348
|
+
const { filter } = request;
|
|
3349
|
+
const { agreementId, agreementIdContains, orgId, status, createdAtFrom, createdAtTo, sortField, sortOrder } = filter || {};
|
|
3350
|
+
// 0 is a valid bound, so presence is checked rather than truthiness (as for reports).
|
|
3351
|
+
const hasFrom = createdAtFrom !== undefined && createdAtFrom !== null;
|
|
3352
|
+
const hasTo = createdAtTo !== undefined && createdAtTo !== null;
|
|
3353
|
+
// Interpolated raw into the document as enum literals, so only the schema's values get through.
|
|
3354
|
+
// A given but unknown value is refused, not replaced: a silent default would page in the wrong order.
|
|
3355
|
+
if (sortField !== undefined && !COLLATERAL_AGREEMENT_ORDER_FIELDS.includes(sortField)) {
|
|
3356
|
+
throw {
|
|
3357
|
+
code: 400,
|
|
3358
|
+
name: 'InvalidSortField',
|
|
3359
|
+
message: `Unknown collateral agreement sort field: ${sortField}`,
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
if (sortOrder !== undefined && sortOrder !== 'ASC' && sortOrder !== 'DESC') {
|
|
3363
|
+
throw { code: 400, name: 'InvalidSortOrder', message: `Unknown sort order: ${sortOrder}` };
|
|
3364
|
+
}
|
|
3365
|
+
const orderField = sortField !== null && sortField !== void 0 ? sortField : 'CREATED_AT';
|
|
3366
|
+
const orderDirection = sortOrder !== null && sortOrder !== void 0 ? sortOrder : 'DESC';
|
|
3367
|
+
const filters = `
|
|
3368
|
+
filter: [
|
|
3369
|
+
${agreementId ? `{key:"agreementId",operator:EQ,value:${gqlString(agreementId)}},` : ''}
|
|
3370
|
+
${agreementIdContains ? `{key:"agreementId",operator:CONTAINS,value:${gqlString(agreementIdContains)}},` : ''}
|
|
3371
|
+
${orgId ? `{key:"orgId",operator:EQ,value:${gqlString(orgId)}},` : ''}
|
|
3372
|
+
${(status === null || status === void 0 ? void 0 : status.length) ? `{key:"status",operator:IN,value:${gqlStringList(status)}},` : ''}
|
|
3373
|
+
${hasFrom ? `{key:"createdAt",operator:GTE,value:${gqlString(createdAtFrom)}},` : ''}
|
|
3374
|
+
${hasTo ? `{key:"createdAt",operator:LTE,value:${gqlString(createdAtTo)}},` : ''}
|
|
3375
|
+
]
|
|
3376
|
+
`;
|
|
3377
|
+
const query = `
|
|
3378
|
+
query getCollateralAgreements {
|
|
3379
|
+
collateral {
|
|
3380
|
+
agreements
|
|
3381
|
+
(${filters},
|
|
3382
|
+
${(0, queryUtils_1.paginateFragment)({ after: filter === null || filter === void 0 ? void 0 : filter.after, limit: filter === null || filter === void 0 ? void 0 : filter.limit, skip: filter === null || filter === void 0 ? void 0 : filter.skip })}
|
|
3383
|
+
orderBy: {field: ${orderField}, direction: ${orderDirection}})
|
|
3384
|
+
{
|
|
3385
|
+
nodes {
|
|
3386
|
+
${collateralAgreementFragment}
|
|
3387
|
+
}
|
|
3388
|
+
${pageInfoFragment}
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
`;
|
|
3393
|
+
const readyCondition = {
|
|
3394
|
+
match: (response) => {
|
|
3395
|
+
var _a;
|
|
3396
|
+
return isCompletePage((_a = response === null || response === void 0 ? void 0 : response.collateral) === null || _a === void 0 ? void 0 : _a.agreements);
|
|
3397
|
+
},
|
|
3398
|
+
name: 'getCollateralAgreements',
|
|
3399
|
+
strict: true,
|
|
3400
|
+
data: request,
|
|
3401
|
+
};
|
|
3402
|
+
const response = yield (0, utils_2.ossQuery)(client, logger, query, readyCondition);
|
|
3403
|
+
const page = response.collateral.agreements;
|
|
3404
|
+
return { data: (_a = page.nodes) !== null && _a !== void 0 ? _a : [], pageInfo: (_b = page.pageInfo) !== null && _b !== void 0 ? _b : emptyPageInfo };
|
|
3405
|
+
}),
|
|
3406
|
+
getCollateralReports: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (request = {}) {
|
|
3407
|
+
var _a, _b;
|
|
3408
|
+
const { filter } = request;
|
|
3409
|
+
const { agreementId, reportId, reportIdContains, overlayStatus, type, createdAtFrom, createdAtTo, sortField, sortOrder, } = filter || {};
|
|
3410
|
+
// createdAt is epoch SECONDS on a report, and the bounds are inclusive: GTE/LTE, not GT/LT.
|
|
3411
|
+
// A bound of 0 is a real instant, so these test for undefined rather than truthiness.
|
|
3412
|
+
const hasFrom = createdAtFrom !== undefined && createdAtFrom !== null;
|
|
3413
|
+
const hasTo = createdAtTo !== undefined && createdAtTo !== null;
|
|
3414
|
+
// Interpolated raw into the document as enum literals, so only the schema's values get through.
|
|
3415
|
+
// A given but unknown value is refused, not replaced: a silent default would page in the wrong order.
|
|
3416
|
+
if (sortField !== undefined && !COLLATERAL_REPORT_ORDER_FIELDS.includes(sortField)) {
|
|
3417
|
+
throw {
|
|
3418
|
+
code: 400,
|
|
3419
|
+
name: 'InvalidSortField',
|
|
3420
|
+
message: `Unknown collateral report sort field: ${sortField}`,
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
if (sortOrder !== undefined && sortOrder !== 'ASC' && sortOrder !== 'DESC') {
|
|
3424
|
+
throw { code: 400, name: 'InvalidSortOrder', message: `Unknown sort order: ${sortOrder}` };
|
|
3425
|
+
}
|
|
3426
|
+
const orderField = sortField !== null && sortField !== void 0 ? sortField : 'CREATED_AT';
|
|
3427
|
+
const orderDirection = sortOrder !== null && sortOrder !== void 0 ? sortOrder : 'DESC';
|
|
3428
|
+
const filters = `
|
|
3429
|
+
filter: [
|
|
3430
|
+
${agreementId ? `{key:"agreementId",operator:EQ,value:${gqlString(agreementId)}},` : ''}
|
|
3431
|
+
${reportId ? `{key:"reportId",operator:EQ,value:${gqlString(reportId)}},` : ''}
|
|
3432
|
+
${reportIdContains ? `{key:"reportId",operator:CONTAINS,value:${gqlString(reportIdContains)}},` : ''}
|
|
3433
|
+
${(overlayStatus === null || overlayStatus === void 0 ? void 0 : overlayStatus.length) ? `{key:"overlayStatus",operator:IN,value:${gqlStringList(overlayStatus)}},` : ''}
|
|
3434
|
+
${(type === null || type === void 0 ? void 0 : type.length) ? `{key:"type",operator:IN,value:${gqlStringList(type)}},` : ''}
|
|
3435
|
+
${hasFrom ? `{key:"createdAt",operator:GTE,value:${gqlString(createdAtFrom)}},` : ''}
|
|
3436
|
+
${hasTo ? `{key:"createdAt",operator:LTE,value:${gqlString(createdAtTo)}},` : ''}
|
|
3437
|
+
]
|
|
3438
|
+
`;
|
|
3439
|
+
const query = `
|
|
3440
|
+
query getCollateralReports {
|
|
3441
|
+
collateral {
|
|
3442
|
+
reports
|
|
3443
|
+
(${filters},
|
|
3444
|
+
${(0, queryUtils_1.paginateFragment)({ after: filter === null || filter === void 0 ? void 0 : filter.after, limit: filter === null || filter === void 0 ? void 0 : filter.limit, skip: filter === null || filter === void 0 ? void 0 : filter.skip })}
|
|
3445
|
+
orderBy: {field: ${orderField}, direction: ${orderDirection}})
|
|
3446
|
+
{
|
|
3447
|
+
nodes {
|
|
3448
|
+
${collateralReportFragment}
|
|
3449
|
+
}
|
|
3450
|
+
${pageInfoFragment}
|
|
3451
|
+
}
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
`;
|
|
3455
|
+
const readyCondition = {
|
|
3456
|
+
match: (response) => { var _a; return isCompletePage((_a = response === null || response === void 0 ? void 0 : response.collateral) === null || _a === void 0 ? void 0 : _a.reports); },
|
|
3457
|
+
name: 'getCollateralReports',
|
|
3458
|
+
strict: true,
|
|
3459
|
+
data: request,
|
|
3460
|
+
};
|
|
3461
|
+
const response = yield (0, utils_2.ossQuery)(client, logger, query, readyCondition);
|
|
3462
|
+
const page = response.collateral.reports;
|
|
3463
|
+
return { data: (_a = page.nodes) !== null && _a !== void 0 ? _a : [], pageInfo: (_b = page.pageInfo) !== null && _b !== void 0 ? _b : emptyPageInfo };
|
|
3464
|
+
}),
|
|
3465
|
+
getCollateralContainerBooks: (request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3466
|
+
var _a;
|
|
3467
|
+
const { agreementId } = request;
|
|
3468
|
+
if (!agreementId) {
|
|
3469
|
+
throw {
|
|
3470
|
+
code: 400,
|
|
3471
|
+
name: 'AgreementIdIsRequired',
|
|
3472
|
+
message: 'agreementId is required to get the container books!',
|
|
3473
|
+
};
|
|
3474
|
+
}
|
|
3475
|
+
const query = `
|
|
3476
|
+
query getCollateralContainerBooks {
|
|
3477
|
+
collateral {
|
|
3478
|
+
containerBooks(agreementId: ${gqlString(agreementId)}) {
|
|
3479
|
+
agreementId
|
|
3480
|
+
containers {
|
|
3481
|
+
${collateralContainerBookFragment}
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
`;
|
|
3487
|
+
const readyCondition = {
|
|
3488
|
+
match: (response) => {
|
|
3489
|
+
var _a;
|
|
3490
|
+
const books = (_a = response === null || response === void 0 ? void 0 : response.collateral) === null || _a === void 0 ? void 0 : _a.containerBooks;
|
|
3491
|
+
return isCompletePage(books && { nodes: books.containers });
|
|
3492
|
+
},
|
|
3493
|
+
name: 'getCollateralContainerBooks',
|
|
3494
|
+
strict: true,
|
|
3495
|
+
data: request,
|
|
3496
|
+
};
|
|
3497
|
+
const response = yield (0, utils_2.ossQuery)(client, logger, query, readyCondition);
|
|
3498
|
+
return (_a = response.collateral.containerBooks.containers) !== null && _a !== void 0 ? _a : [];
|
|
3499
|
+
}),
|
|
2924
3500
|
};
|
|
2925
3501
|
return ossInterface;
|
|
2926
3502
|
};
|