@degenerate/generic 0.2.7 → 0.4.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.
Files changed (165) hide show
  1. package/dist/_settings/database-settings.d.ts +3 -0
  2. package/dist/_settings/database-settings.d.ts.map +1 -1
  3. package/dist/_settings/database-settings.js +3 -0
  4. package/dist/application/audit-log/additional-ids/create-audit-log-additional-ids-with-query.d.ts.map +1 -1
  5. package/dist/application/audit-log/additional-ids/create-multiple-path-alai.d.ts.map +1 -1
  6. package/dist/application/audit-log/additional-ids/create-query-audit-log-for-alai.d.ts.map +1 -1
  7. package/dist/application/audit-log/create-application-audit-log.d.ts.map +1 -1
  8. package/dist/application/audit-log/create-application-audit-log.js +1 -1
  9. package/dist/application/database/firestore/generics/add-items-to-database.d.ts.map +1 -1
  10. package/dist/application/database/firestore/generics/add-items-to-database.js +2 -2
  11. package/dist/application/database/firestore/generics/add-or-update-items-to-database.d.ts.map +1 -1
  12. package/dist/application/database/firestore/generics/add-or-update-items-to-database.js +3 -3
  13. package/dist/application/database/firestore/generics/create-database-change-information.d.ts.map +1 -1
  14. package/dist/application/database/firestore/generics/delete-items-on-database.d.ts.map +1 -1
  15. package/dist/application/database/firestore/generics/delete-items-on-database.js +2 -2
  16. package/dist/application/database/firestore/generics/get-item-from-database.d.ts.map +1 -1
  17. package/dist/application/database/firestore/generics/get-item-from-database.js +2 -2
  18. package/dist/application/database/firestore/generics/get-items-different-path-on-database.d.ts.map +1 -1
  19. package/dist/application/database/firestore/generics/get-items-different-path-on-database.js +2 -2
  20. package/dist/application/database/firestore/generics/get-items-from-database.d.ts.map +1 -1
  21. package/dist/application/database/firestore/generics/get-items-from-database.js +1 -1
  22. package/dist/application/database/firestore/generics/update-items-on-database.d.ts.map +1 -1
  23. package/dist/application/database/firestore/generics/update-items-on-database.js +2 -2
  24. package/dist/application/database/firestore/generics/update-items-properties-on-database.d.ts.map +1 -1
  25. package/dist/application/database/firestore/generics/update-items-properties-on-database.js +2 -2
  26. package/dist/authorization/index.d.ts +1 -0
  27. package/dist/authorization/index.d.ts.map +1 -1
  28. package/dist/authorization/index.js +1 -0
  29. package/dist/authorization/jwt/keys/create-public-key-pem.d.ts.map +1 -1
  30. package/dist/authorization/jwt/keys/create-secret-key-pem.d.ts.map +1 -1
  31. package/dist/authorization/jwt/sign/create-authorization-issuer.d.ts.map +1 -1
  32. package/dist/authorization/jwt/sign/create-authorization-subject.d.ts.map +1 -1
  33. package/dist/authorization/jwt/sign/create-jwt-options.d.ts +7 -1
  34. package/dist/authorization/jwt/sign/create-jwt-options.d.ts.map +1 -1
  35. package/dist/authorization/jwt/sign/create-jwt-signed-token.d.ts.map +1 -1
  36. package/dist/authorization/jwt/transform/transform-token-payload-to-safe-payload.d.ts.map +1 -1
  37. package/dist/authorization/jwt/verify/get-decoded-jwt-header.d.ts.map +1 -1
  38. package/dist/authorization/jwt/verify/get-decoded-jwt-signed-token-payload.d.ts.map +1 -1
  39. package/dist/authorization/jwt/verify/verify-jwt-signed-token.d.ts.map +1 -1
  40. package/dist/authorization/safe/request/decode-bearer-token.d.ts.map +1 -1
  41. package/dist/authorization/safe/request/decode-safe-request.d.ts.map +1 -1
  42. package/dist/authorization/safe/request/determine-issuer-from-request.d.ts.map +1 -1
  43. package/dist/authorization/safe/request/issuer/determine-issuer-from-bearer-token.d.ts.map +1 -1
  44. package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.d.ts +31 -0
  45. package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.d.ts.map +1 -0
  46. package/dist/authorization/safe/request/verify-jwt-bearer-token-for-audience.js +50 -0
  47. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-audience.d.ts.map +1 -1
  48. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-expiration-time.d.ts.map +1 -1
  49. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issued-at-time.d.ts.map +1 -1
  50. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-issuer.d.ts.map +1 -1
  51. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-not-before-time.d.ts.map +1 -1
  52. package/dist/authorization/safe/validation/jwt/payload/verify-authorization-subject.d.ts.map +1 -1
  53. package/dist/authorization/safe/validation/jwt/verify-token-header.d.ts.map +1 -1
  54. package/dist/authorization/safe/validation/jwt/verify-token-payload.d.ts.map +1 -1
  55. package/dist/crypto/calculate-combined-hash.d.ts.map +1 -1
  56. package/dist/crypto/calculate-hash.d.ts +1 -1
  57. package/dist/crypto/calculate-hash.d.ts.map +1 -1
  58. package/dist/crypto/calculate-hash.js +1 -1
  59. package/dist/crypto/index.d.ts +1 -0
  60. package/dist/crypto/index.d.ts.map +1 -1
  61. package/dist/crypto/index.js +1 -0
  62. package/dist/crypto/private-public-keys/create-key-pair-from-mnemonic.d.ts.map +1 -1
  63. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.d.ts.map +1 -1
  64. package/dist/crypto/private-public-keys/create-key-pair-from-private-key.js +1 -1
  65. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts +11 -0
  66. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.d.ts.map +1 -0
  67. package/dist/crypto/private-public-keys/create-key-pair-from-public-key.js +51 -0
  68. package/dist/crypto/private-public-keys/generation/create-entropy-for-elliptical-curve.d.ts.map +1 -1
  69. package/dist/crypto/private-public-keys/generation/generate-key-pair.d.ts.map +1 -1
  70. package/dist/crypto/private-public-keys/generation/get-private-public-key-from-keypair.d.ts.map +1 -1
  71. package/dist/crypto/signature/create-crypto-signature.d.ts +11 -0
  72. package/dist/crypto/signature/create-crypto-signature.d.ts.map +1 -1
  73. package/dist/crypto/signature/create-crypto-signature.js +14 -1
  74. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts +4 -0
  75. package/dist/crypto/signature/verify-crypto-signature-by-data.d.ts.map +1 -1
  76. package/dist/crypto/signature/verify-crypto-signature-by-data.js +8 -2
  77. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts +4 -0
  78. package/dist/crypto/signature/verify-crypto-signature-by-hash.d.ts.map +1 -1
  79. package/dist/crypto/signature/verify-crypto-signature-by-hash.js +7 -1
  80. package/dist/errors/index.d.ts +2 -0
  81. package/dist/errors/index.d.ts.map +1 -1
  82. package/dist/errors/index.js +2 -0
  83. package/dist/errors/share-data/share-data-errors.d.ts +105 -1
  84. package/dist/errors/share-data/share-data-errors.d.ts.map +1 -1
  85. package/dist/errors/share-data/share-data-errors.js +148 -1
  86. package/dist/errors/shareblock/shareblock-errors.d.ts +40 -0
  87. package/dist/errors/shareblock/shareblock-errors.d.ts.map +1 -0
  88. package/dist/errors/shareblock/shareblock-errors.js +50 -0
  89. package/dist/errors/validation/crypto-validation-errors.d.ts +8 -0
  90. package/dist/errors/validation/crypto-validation-errors.d.ts.map +1 -0
  91. package/dist/errors/validation/crypto-validation-errors.js +15 -0
  92. package/dist/helpers/array/array-helpers.d.ts.map +1 -1
  93. package/dist/helpers/crypto/cryptography-helpers.d.ts.map +1 -1
  94. package/dist/helpers/data/data-helpers.d.ts.map +1 -1
  95. package/dist/helpers/file/file-helpers.d.ts.map +1 -1
  96. package/dist/helpers/id-helpers.d.ts.map +1 -1
  97. package/dist/helpers/lodash/lodash-helpers.d.ts.map +1 -1
  98. package/dist/helpers/object-helpers.d.ts.map +1 -1
  99. package/dist/helpers/object-validation-helpers.d.ts.map +1 -1
  100. package/dist/helpers/request/params-object-helpers.d.ts +6 -13
  101. package/dist/helpers/request/params-object-helpers.d.ts.map +1 -1
  102. package/dist/helpers/request/params-object-helpers.js +11 -21
  103. package/dist/helpers/request/query-object-helpers.d.ts.map +1 -1
  104. package/dist/helpers/request/request-object-helpers.d.ts.map +1 -1
  105. package/dist/models/application/audit-log/application-audit-log-models.d.ts +82 -92
  106. package/dist/models/application/audit-log/application-audit-log-models.d.ts.map +1 -1
  107. package/dist/models/application/database/firestore-models.d.ts +158 -307
  108. package/dist/models/application/database/firestore-models.d.ts.map +1 -1
  109. package/dist/models/authorization/authorization-models.d.ts +34 -44
  110. package/dist/models/authorization/authorization-models.d.ts.map +1 -1
  111. package/dist/models/authorization/authorization-models.js +2 -2
  112. package/dist/models/crypto/crypto-models.d.ts +1 -7
  113. package/dist/models/crypto/crypto-models.d.ts.map +1 -1
  114. package/dist/models/data/data-models.d.ts +27 -13
  115. package/dist/models/data/data-models.d.ts.map +1 -1
  116. package/dist/models/data/data-models.js +23 -2
  117. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts +1 -9
  118. package/dist/models/dynamic-execution/dynamic-execution-models.d.ts.map +1 -1
  119. package/dist/models/events/share-event-models.d.ts +91 -120
  120. package/dist/models/events/share-event-models.d.ts.map +1 -1
  121. package/dist/models/events/share-event-models.js +35 -4
  122. package/dist/models/functions/share-data-function-models.d.ts +23 -193
  123. package/dist/models/functions/share-data-function-models.d.ts.map +1 -1
  124. package/dist/models/functions/share-data-function-models.js +1 -1
  125. package/dist/models/generic/request-response-models.d.ts +1 -7
  126. package/dist/models/generic/request-response-models.d.ts.map +1 -1
  127. package/dist/models/index.d.ts +4 -1
  128. package/dist/models/index.d.ts.map +1 -1
  129. package/dist/models/index.js +4 -1
  130. package/dist/models/rules/share-rule-models.d.ts +759 -1116
  131. package/dist/models/rules/share-rule-models.d.ts.map +1 -1
  132. package/dist/models/rules/share-rule-models.js +6 -6
  133. package/dist/models/safe/safe-transaction-models.d.ts +28 -30
  134. package/dist/models/safe/safe-transaction-models.d.ts.map +1 -1
  135. package/dist/models/safe/transactions/authorities-transactions-models.d.ts +77 -419
  136. package/dist/models/safe/transactions/authorities-transactions-models.d.ts.map +1 -1
  137. package/dist/models/safe/transactions/authorities-transactions-models.js +3 -3
  138. package/dist/models/safe/transactions/events-transactions-models.d.ts +22 -372
  139. package/dist/models/safe/transactions/events-transactions-models.d.ts.map +1 -1
  140. package/dist/models/safe/transactions/events-transactions-models.js +1 -1
  141. package/dist/models/safe/transactions/functions-transactions-models.d.ts +22 -372
  142. package/dist/models/safe/transactions/functions-transactions-models.d.ts.map +1 -1
  143. package/dist/models/safe/transactions/functions-transactions-models.js +1 -1
  144. package/dist/models/safe/transactions/rules-transactions-models.d.ts +59 -603
  145. package/dist/models/safe/transactions/rules-transactions-models.d.ts.map +1 -1
  146. package/dist/models/safe/transactions/sharedata-transactions-models.d.ts +256 -388
  147. package/dist/models/safe/transactions/sharedata-transactions-models.d.ts.map +1 -1
  148. package/dist/models/safe/transactions/sharedata-transactions-models.js +30 -4
  149. package/dist/models/share-data/share-data-crypto-models.d.ts +344 -0
  150. package/dist/models/share-data/share-data-crypto-models.d.ts.map +1 -0
  151. package/dist/models/share-data/share-data-crypto-models.js +131 -0
  152. package/dist/models/share-data/share-data-models.d.ts +114 -0
  153. package/dist/models/share-data/share-data-models.d.ts.map +1 -0
  154. package/dist/models/share-data/{share-data.js → share-data-models.js} +1 -1
  155. package/dist/models/share-data/share-data-persistence-models.d.ts +165 -0
  156. package/dist/models/share-data/share-data-persistence-models.d.ts.map +1 -0
  157. package/dist/models/share-data/share-data-persistence-models.js +101 -0
  158. package/dist/models/shareblock/shareblock-models.d.ts +489 -0
  159. package/dist/models/shareblock/shareblock-models.d.ts.map +1 -0
  160. package/dist/models/shareblock/shareblock-models.js +395 -0
  161. package/dist/transactions/authority/create-safe-transaction-authority-data.d.ts.map +1 -1
  162. package/dist/transactions/authority/create-safe-transaction-authority.d.ts.map +1 -1
  163. package/package.json +30 -22
  164. package/dist/models/share-data/share-data.d.ts +0 -181
  165. package/dist/models/share-data/share-data.d.ts.map +0 -1
@@ -0,0 +1,489 @@
1
+ import z from 'zod';
2
+ /**
3
+ * The four ShareBlock specializations the platform uses to move money
4
+ * through a loan's lifecycle.
5
+ *
6
+ * - `Clearing` — neutral holding spot funds pass through before they're
7
+ * committed to either side of a deal. Used to net
8
+ * borrower and lender flows before settling.
9
+ * - `Funding` — the lender-funded pool that backs a specific loan.
10
+ * Holds principal between funding and disbursement.
11
+ * - `Distribution` — the destination ShareBlock that pays principal to a
12
+ * borrower or returns/interest to a lender.
13
+ * - `GraceRepayment` — the borrower-repayment block for Rapture's Grace
14
+ * product. Per-lender Grace-or-yield decisions are
15
+ * toggled while the loan is in flight, snapshotted at
16
+ * repayment-initiate, and drive the blended-rate
17
+ * allocation when the borrower pays. Terminal state is
18
+ * either `fullyRepaid: true` OR `defaulted: true`,
19
+ * mutually exclusive.
20
+ *
21
+ * New ShareBlock variants should be additive — never re-use a value with new
22
+ * semantics, since downstream rule libraries pattern-match on the literal.
23
+ */
24
+ export declare enum ShareBlockType {
25
+ Clearing = "Clearing",
26
+ Funding = "Funding",
27
+ Distribution = "Distribution",
28
+ GraceRepayment = "GraceRepayment"
29
+ }
30
+ export declare const ShareBlockTypeSchema: z.ZodEnum<{
31
+ Clearing: "Clearing";
32
+ Funding: "Funding";
33
+ Distribution: "Distribution";
34
+ GraceRepayment: "GraceRepayment";
35
+ }>;
36
+ /**
37
+ * Roles a participant plays inside a ShareBlock. A single party may hold
38
+ * multiple roles across different ShareBlocks (e.g. the same uid is `Lender`
39
+ * on a Funding block and `Recipient` on a Distribution block).
40
+ */
41
+ export declare enum ShareBlockParticipantRole {
42
+ Borrower = "Borrower",
43
+ Lender = "Lender",
44
+ Platform = "Platform",
45
+ Recipient = "Recipient"
46
+ }
47
+ export declare const ShareBlockParticipantRoleSchema: z.ZodEnum<{
48
+ Borrower: "Borrower";
49
+ Lender: "Lender";
50
+ Platform: "Platform";
51
+ Recipient: "Recipient";
52
+ }>;
53
+ /**
54
+ * A party in a ShareBlock with their associated role and committed amount.
55
+ * `committedAmount` is the headline contribution promised by the participant;
56
+ * `settledAmount` tracks how much has actually moved (so partial fills are
57
+ * representable). Both are in the ShareBlock's `currency`.
58
+ */
59
+ export declare const IShareBlockParticipantSchema: z.ZodObject<{
60
+ userId: z.ZodString;
61
+ role: z.ZodEnum<{
62
+ Borrower: "Borrower";
63
+ Lender: "Lender";
64
+ Platform: "Platform";
65
+ Recipient: "Recipient";
66
+ }>;
67
+ committedAmount: z.ZodNumber;
68
+ settledAmount: z.ZodNumber;
69
+ }, z.core.$strip>;
70
+ export type IShareBlockParticipant = z.infer<typeof IShareBlockParticipantSchema>;
71
+ /**
72
+ * The mutable state carried inside a ShareBlock's `_currentState`. This is
73
+ * the canonical shape rules and functions inspect when proposing changes.
74
+ *
75
+ * - `balance` — funds currently held in the ShareBlock. Never negative.
76
+ * - `currency` — ISO-4217 code (e.g. `'USD'`, `'CAD'`). Pinned at creation.
77
+ * - `isOpen` — whether the ShareBlock will accept further transactions.
78
+ * Closing is irreversible; once `false`, all standard rules
79
+ * reject mutating proposals.
80
+ * - `participants` — committed parties keyed by `userId`. Adding a
81
+ * participant goes through a rule-gated function so the
82
+ * participant list itself is auditable.
83
+ */
84
+ export declare const IShareBlockStateSchema: z.ZodObject<{
85
+ blockType: z.ZodEnum<{
86
+ Clearing: "Clearing";
87
+ Funding: "Funding";
88
+ Distribution: "Distribution";
89
+ GraceRepayment: "GraceRepayment";
90
+ }>;
91
+ balance: z.ZodNumber;
92
+ currency: z.ZodString;
93
+ isOpen: z.ZodBoolean;
94
+ participants: z.ZodRecord<z.ZodString, z.ZodObject<{
95
+ userId: z.ZodString;
96
+ role: z.ZodEnum<{
97
+ Borrower: "Borrower";
98
+ Lender: "Lender";
99
+ Platform: "Platform";
100
+ Recipient: "Recipient";
101
+ }>;
102
+ committedAmount: z.ZodNumber;
103
+ settledAmount: z.ZodNumber;
104
+ }, z.core.$strip>>;
105
+ }, z.core.$strip>;
106
+ export type IShareBlockState = z.infer<typeof IShareBlockStateSchema>;
107
+ /**
108
+ * Funding-specific extension of `IShareBlockState`. Adds:
109
+ *
110
+ * - `committed` — once `true`, the block's funds are locked: deposits and
111
+ * withdrawals become no-ops, and a "committed-is-monotonic"
112
+ * rule blocks any proposal that flips it back to `false`.
113
+ * - `committedBy` / `committedAt` — audit attribution for the commit moment.
114
+ *
115
+ * Clearing ShareBlocks don't carry these fields; the discriminator is the
116
+ * `blockType` on the base state.
117
+ */
118
+ export declare const IFundingShareBlockStateSchema: z.ZodObject<{
119
+ balance: z.ZodNumber;
120
+ currency: z.ZodString;
121
+ isOpen: z.ZodBoolean;
122
+ participants: z.ZodRecord<z.ZodString, z.ZodObject<{
123
+ userId: z.ZodString;
124
+ role: z.ZodEnum<{
125
+ Borrower: "Borrower";
126
+ Lender: "Lender";
127
+ Platform: "Platform";
128
+ Recipient: "Recipient";
129
+ }>;
130
+ committedAmount: z.ZodNumber;
131
+ settledAmount: z.ZodNumber;
132
+ }, z.core.$strip>>;
133
+ blockType: z.ZodLiteral<"Funding">;
134
+ committed: z.ZodBoolean;
135
+ committedBy: z.ZodOptional<z.ZodString>;
136
+ committedAt: z.ZodOptional<z.ZodNumber>;
137
+ }, z.core.$strip>;
138
+ export type IFundingShareBlockState = z.infer<typeof IFundingShareBlockStateSchema>;
139
+ /**
140
+ * Distribution-specific extension of `IShareBlockState`. Adds:
141
+ *
142
+ * - `distributed` — once `true`, the block is fully paid out and further
143
+ * disbursements become no-ops. Enforced as monotonic by
144
+ * a dedicated rule (mirrors Funding's `committed`).
145
+ * - `distributedAt` — audit attribution for the moment the block was
146
+ * marked fully distributed.
147
+ *
148
+ * Clearing ShareBlocks don't carry these fields; the discriminator is the
149
+ * `blockType` on the base state.
150
+ */
151
+ export declare const IDistributionShareBlockStateSchema: z.ZodObject<{
152
+ balance: z.ZodNumber;
153
+ currency: z.ZodString;
154
+ isOpen: z.ZodBoolean;
155
+ participants: z.ZodRecord<z.ZodString, z.ZodObject<{
156
+ userId: z.ZodString;
157
+ role: z.ZodEnum<{
158
+ Borrower: "Borrower";
159
+ Lender: "Lender";
160
+ Platform: "Platform";
161
+ Recipient: "Recipient";
162
+ }>;
163
+ committedAmount: z.ZodNumber;
164
+ settledAmount: z.ZodNumber;
165
+ }, z.core.$strip>>;
166
+ blockType: z.ZodLiteral<"Distribution">;
167
+ distributed: z.ZodBoolean;
168
+ distributedBy: z.ZodOptional<z.ZodString>;
169
+ distributedAt: z.ZodOptional<z.ZodNumber>;
170
+ }, z.core.$strip>;
171
+ export type IDistributionShareBlockState = z.infer<typeof IDistributionShareBlockStateSchema>;
172
+ /**
173
+ * GraceRepayment-specific participant. Extends the base participant with
174
+ * three Grace-specific fields plus a denormalized ShareBlock count:
175
+ *
176
+ * - `graceDecision` — Lender-only field. The lender's current
177
+ * choice: take their yield, grant Grace, or
178
+ * undecided (the initial state when the
179
+ * GraceRepayment block is constructed).
180
+ * Borrower and Platform participants always
181
+ * carry `'undecided'` and never mutate it.
182
+ * - `decidedAtMs` — Unix-ms timestamp the lender last set their
183
+ * decision. `null` while undecided.
184
+ * - `snapshotDecision` — The locked-in decision at the moment the
185
+ * borrower initiated repayment. `null` until
186
+ * snapshot. After snapshot it's the
187
+ * authoritative value the per-lender
188
+ * settlement uses.
189
+ * - `shareBlockCount` — Derived count of $10 ShareBlocks held by
190
+ * this lender on this loan
191
+ * (`committedAmount / 1000` for cents-based
192
+ * committed amounts). Cached for fast UI
193
+ * queries; the canonical source is still
194
+ * `committedAmount`.
195
+ */
196
+ export declare const IGraceRepaymentParticipantSchema: z.ZodObject<{
197
+ userId: z.ZodString;
198
+ role: z.ZodEnum<{
199
+ Borrower: "Borrower";
200
+ Lender: "Lender";
201
+ Platform: "Platform";
202
+ Recipient: "Recipient";
203
+ }>;
204
+ committedAmount: z.ZodNumber;
205
+ settledAmount: z.ZodNumber;
206
+ graceDecision: z.ZodEnum<{
207
+ yield: "yield";
208
+ grace: "grace";
209
+ undecided: "undecided";
210
+ }>;
211
+ decidedAtMs: z.ZodOptional<z.ZodNumber>;
212
+ snapshotDecision: z.ZodOptional<z.ZodEnum<{
213
+ yield: "yield";
214
+ grace: "grace";
215
+ }>>;
216
+ shareBlockCount: z.ZodNumber;
217
+ }, z.core.$strip>;
218
+ export type IGraceRepaymentParticipant = z.infer<typeof IGraceRepaymentParticipantSchema>;
219
+ /**
220
+ * GraceRepayment-specific extension of `IShareBlockState`. Adds:
221
+ *
222
+ * - `outstandingPrincipalCents` — running principal balance the
223
+ * borrower owes. Decrements as
224
+ * repayments land.
225
+ * - `outstandingInterestCents` — interest owed at the time of
226
+ * repayment snapshot. Computed
227
+ * atomically at snapshot from the
228
+ * blended rate; decrements as
229
+ * repayments land.
230
+ * - `repaymentSnapshotAtMs` — unix-ms timestamp the per-lender
231
+ * Grace decisions were locked in.
232
+ * `null` until the borrower
233
+ * initiates repayment.
234
+ * - `blendedRatePercent` — weighted-average effective rate
235
+ * computed at snapshot. `null` pre-
236
+ * snapshot.
237
+ * - `finalEffectiveRatePercent` — what the borrower actually pays;
238
+ * equal to `blendedRatePercent`
239
+ * under the standard formula. `null`
240
+ * pre-snapshot.
241
+ * - `fullyRepaid` / `defaulted` — mutually exclusive terminal flags.
242
+ * Both monotonic (once true, never
243
+ * back to false).
244
+ * - `defaultReason` / `defaultedAtMs` — audit attribution for the
245
+ * default moment.
246
+ *
247
+ * Participants are typed as `IGraceRepaymentParticipant` (extended
248
+ * with per-lender Grace decision fields).
249
+ */
250
+ export declare const IGraceRepaymentShareBlockStateSchema: z.ZodObject<{
251
+ balance: z.ZodNumber;
252
+ currency: z.ZodString;
253
+ isOpen: z.ZodBoolean;
254
+ blockType: z.ZodLiteral<"GraceRepayment">;
255
+ participants: z.ZodRecord<z.ZodString, z.ZodObject<{
256
+ userId: z.ZodString;
257
+ role: z.ZodEnum<{
258
+ Borrower: "Borrower";
259
+ Lender: "Lender";
260
+ Platform: "Platform";
261
+ Recipient: "Recipient";
262
+ }>;
263
+ committedAmount: z.ZodNumber;
264
+ settledAmount: z.ZodNumber;
265
+ graceDecision: z.ZodEnum<{
266
+ yield: "yield";
267
+ grace: "grace";
268
+ undecided: "undecided";
269
+ }>;
270
+ decidedAtMs: z.ZodOptional<z.ZodNumber>;
271
+ snapshotDecision: z.ZodOptional<z.ZodEnum<{
272
+ yield: "yield";
273
+ grace: "grace";
274
+ }>>;
275
+ shareBlockCount: z.ZodNumber;
276
+ }, z.core.$strip>>;
277
+ outstandingPrincipalCents: z.ZodNumber;
278
+ outstandingInterestCents: z.ZodNumber;
279
+ repaymentSnapshotAtMs: z.ZodOptional<z.ZodNumber>;
280
+ blendedRatePercent: z.ZodOptional<z.ZodNumber>;
281
+ finalEffectiveRatePercent: z.ZodOptional<z.ZodNumber>;
282
+ snapshotBaselineRatePercent: z.ZodOptional<z.ZodNumber>;
283
+ snapshotGraceMicroInterestPercent: z.ZodOptional<z.ZodNumber>;
284
+ snapshotGracePerShareBlockFeeCents: z.ZodOptional<z.ZodNumber>;
285
+ fullyRepaid: z.ZodBoolean;
286
+ defaulted: z.ZodBoolean;
287
+ defaultReason: z.ZodOptional<z.ZodString>;
288
+ defaultedAtMs: z.ZodOptional<z.ZodNumber>;
289
+ }, z.core.$strip>;
290
+ export type IGraceRepaymentShareBlockState = z.infer<typeof IGraceRepaymentShareBlockStateSchema>;
291
+ /**
292
+ * Static information about a ShareBlock — set at construction and never
293
+ * mutated through transactions. Lives outside `IShareBlockState` because
294
+ * the rule-evaluation engine compares state shapes, and including identity
295
+ * metadata in that comparison would treat any new ShareBlock as a "change."
296
+ */
297
+ export declare const IShareBlockMetadataSchema: z.ZodObject<{
298
+ shareBlockId: z.ZodString;
299
+ blockType: z.ZodEnum<{
300
+ Clearing: "Clearing";
301
+ Funding: "Funding";
302
+ Distribution: "Distribution";
303
+ GraceRepayment: "GraceRepayment";
304
+ }>;
305
+ relatedLoanApplicationId: z.ZodOptional<z.ZodString>;
306
+ description: z.ZodOptional<z.ZodString>;
307
+ createdAt: z.ZodNumber;
308
+ createdBy: z.ZodString;
309
+ }, z.core.$strip>;
310
+ export type IShareBlockMetadata = z.infer<typeof IShareBlockMetadataSchema>;
311
+ /**
312
+ * Input shape every ShareBlock factory's `initialState` argument accepts.
313
+ * The factory layers the variant-specific defaults on top (`blockType`,
314
+ * `committed: false`, `distributed: false`, `isOpen: true`) — callers only
315
+ * supply the genuinely variant-agnostic fields.
316
+ *
317
+ * Used by the HTTP create route to validate the wire payload before
318
+ * dispatching to the matching factory.
319
+ */
320
+ export declare const IShareBlockInitialStateInputSchema: z.ZodObject<{
321
+ currency: z.ZodString;
322
+ participants: z.ZodRecord<z.ZodString, z.ZodObject<{
323
+ userId: z.ZodString;
324
+ role: z.ZodEnum<{
325
+ Borrower: "Borrower";
326
+ Lender: "Lender";
327
+ Platform: "Platform";
328
+ Recipient: "Recipient";
329
+ }>;
330
+ committedAmount: z.ZodNumber;
331
+ settledAmount: z.ZodNumber;
332
+ }, z.core.$strip>>;
333
+ balance: z.ZodOptional<z.ZodNumber>;
334
+ }, z.core.$strip>;
335
+ export type IShareBlockInitialStateInput = z.infer<typeof IShareBlockInitialStateInputSchema>;
336
+ /**
337
+ * Input shapes for the standard ShareBlock mutating functions. Each function
338
+ * the factory wires up takes one of these and proposes a new
339
+ * `IShareBlockState`. Rules judge the transition; the ShareData container
340
+ * applies it iff every rule passes.
341
+ */
342
+ export declare const IShareBlockDepositInputSchema: z.ZodObject<{
343
+ userId: z.ZodString;
344
+ amount: z.ZodNumber;
345
+ }, z.core.$strip>;
346
+ export type IShareBlockDepositInput = z.infer<typeof IShareBlockDepositInputSchema>;
347
+ export declare const IShareBlockWithdrawInputSchema: z.ZodObject<{
348
+ userId: z.ZodString;
349
+ amount: z.ZodNumber;
350
+ }, z.core.$strip>;
351
+ export type IShareBlockWithdrawInput = z.infer<typeof IShareBlockWithdrawInputSchema>;
352
+ export declare const IShareBlockCloseInputSchema: z.ZodObject<{
353
+ userId: z.ZodString;
354
+ }, z.core.$strip>;
355
+ export type IShareBlockCloseInput = z.infer<typeof IShareBlockCloseInputSchema>;
356
+ /**
357
+ * Input for the Funding-specific `commit` function. Records who pulled the
358
+ * trigger on locking the funded amount; the function itself stamps
359
+ * `committedAt` from the system clock.
360
+ */
361
+ export declare const IShareBlockCommitInputSchema: z.ZodObject<{
362
+ userId: z.ZodString;
363
+ }, z.core.$strip>;
364
+ export type IShareBlockCommitInput = z.infer<typeof IShareBlockCommitInputSchema>;
365
+ /**
366
+ * Input for the Funding-specific `registerLender` function. Adds a new
367
+ * `Lender`-role participant to the block so they can subsequently
368
+ * `deposit` (deposit gates on participant.role === Lender).
369
+ *
370
+ * The caller (Rapture's authenticated endpoint) is responsible for
371
+ * authorizing the registration — i.e. for confirming that `userId` is the
372
+ * authenticated user pledging on this loan. The shareblock layer just
373
+ * enforces structural invariants (no duplicate userId, positive
374
+ * committedAmount, block must be open and not committed).
375
+ */
376
+ export declare const IShareBlockRegisterLenderInputSchema: z.ZodObject<{
377
+ userId: z.ZodString;
378
+ committedAmount: z.ZodNumber;
379
+ }, z.core.$strip>;
380
+ export type IShareBlockRegisterLenderInput = z.infer<typeof IShareBlockRegisterLenderInputSchema>;
381
+ /**
382
+ * Input for the Distribution-specific `fund` function. Distinct from
383
+ * `IShareBlockDepositInput` only at the type level: keeps the wire shape
384
+ * narrow to "money coming in from another block" semantics rather than the
385
+ * general-purpose deposit on Clearing.
386
+ */
387
+ export declare const IShareBlockFundInputSchema: z.ZodObject<{
388
+ fromBlockId: z.ZodOptional<z.ZodString>;
389
+ amount: z.ZodNumber;
390
+ }, z.core.$strip>;
391
+ export type IShareBlockFundInput = z.infer<typeof IShareBlockFundInputSchema>;
392
+ /**
393
+ * Input for the Distribution-specific `disburse` function. `userId` must
394
+ * resolve to a participant with role `Recipient`, or the function no-ops.
395
+ */
396
+ export declare const IShareBlockDisburseInputSchema: z.ZodObject<{
397
+ userId: z.ZodString;
398
+ amount: z.ZodNumber;
399
+ }, z.core.$strip>;
400
+ export type IShareBlockDisburseInput = z.infer<typeof IShareBlockDisburseInputSchema>;
401
+ /**
402
+ * Input for the Distribution-specific `markFullyDistributed` function.
403
+ * Records who declared the block fully paid out; the function stamps
404
+ * `distributedAt`.
405
+ */
406
+ export declare const IShareBlockMarkFullyDistributedInputSchema: z.ZodObject<{
407
+ userId: z.ZodString;
408
+ }, z.core.$strip>;
409
+ export type IShareBlockMarkFullyDistributedInput = z.infer<typeof IShareBlockMarkFullyDistributedInputSchema>;
410
+ /**
411
+ * Input for the GraceRepayment `setLenderGraceDecision` function.
412
+ * Lender-callable while the block is open and pre-snapshot. The block's
413
+ * rules also enforce that the calling userId matches the participant
414
+ * being mutated (lenders can only set their own decisions, not others').
415
+ */
416
+ export declare const IShareBlockSetLenderGraceDecisionInputSchema: z.ZodObject<{
417
+ userId: z.ZodString;
418
+ decision: z.ZodEnum<{
419
+ yield: "yield";
420
+ grace: "grace";
421
+ }>;
422
+ decidedAtMs: z.ZodNumber;
423
+ }, z.core.$strip>;
424
+ export type IShareBlockSetLenderGraceDecisionInput = z.infer<typeof IShareBlockSetLenderGraceDecisionInputSchema>;
425
+ /**
426
+ * Input for the GraceRepayment `snapshotForRepayment` function.
427
+ * Platform-only. Atomic: freezes every Lender participant's
428
+ * `snapshotDecision` from their current `graceDecision`, computes
429
+ * `blendedRatePercent` and `finalEffectiveRatePercent` from the
430
+ * weighted decisions, sets `outstandingInterestCents` to the final
431
+ * computed amount, and stamps `repaymentSnapshotAtMs`.
432
+ *
433
+ * `graceMicroInterestPercent` and `gracePerShareBlockFeeCents` are the
434
+ * platform-fee configuration values used in the math; passing them via
435
+ * the input keeps the variant function pure (no implicit config
436
+ * lookup).
437
+ */
438
+ export declare const IShareBlockSnapshotForRepaymentInputSchema: z.ZodObject<{
439
+ userId: z.ZodString;
440
+ baselineRatePercent: z.ZodNumber;
441
+ termDays: z.ZodNumber;
442
+ graceMicroInterestPercent: z.ZodNumber;
443
+ gracePerShareBlockFeeCents: z.ZodNumber;
444
+ snapshotAtMs: z.ZodNumber;
445
+ }, z.core.$strip>;
446
+ export type IShareBlockSnapshotForRepaymentInput = z.infer<typeof IShareBlockSnapshotForRepaymentInputSchema>;
447
+ /**
448
+ * Input for the GraceRepayment `recordRepayment` function. Platform-only.
449
+ * Applies an inbound borrower payment per the snapshot decisions:
450
+ * yield-ShareBlock lenders receive their share of `borrowerInterest`;
451
+ * grace-ShareBlock lenders receive only the micro-interest minus the
452
+ * per-ShareBlock fee. Decrements `outstandingInterestCents` first,
453
+ * then `outstandingPrincipalCents`. Auto-marks `fullyRepaid` when
454
+ * both reach zero.
455
+ *
456
+ * `paymentAttemptId` is the idempotency key — a second call with the
457
+ * same id is a no-op.
458
+ */
459
+ export declare const IShareBlockRecordRepaymentInputSchema: z.ZodObject<{
460
+ userId: z.ZodString;
461
+ paymentAttemptId: z.ZodString;
462
+ amountCents: z.ZodNumber;
463
+ paidAtMs: z.ZodNumber;
464
+ }, z.core.$strip>;
465
+ export type IShareBlockRecordRepaymentInput = z.infer<typeof IShareBlockRecordRepaymentInputSchema>;
466
+ /**
467
+ * Input for the GraceRepayment `markFullyRepaid` function. Platform-only.
468
+ * Asserts `outstandingPrincipalCents === 0 && outstandingInterestCents
469
+ * === 0` before flipping. Mutually exclusive with `markDefaulted`.
470
+ */
471
+ export declare const IShareBlockMarkFullyRepaidInputSchema: z.ZodObject<{
472
+ userId: z.ZodString;
473
+ asOf: z.ZodNumber;
474
+ }, z.core.$strip>;
475
+ export type IShareBlockMarkFullyRepaidInput = z.infer<typeof IShareBlockMarkFullyRepaidInputSchema>;
476
+ /**
477
+ * Input for the GraceRepayment `markDefaulted` function. Platform-only.
478
+ * Mutually exclusive with `markFullyRepaid`. Sets the terminal default
479
+ * flag + audit metadata; the post-default flow (lender write-off,
480
+ * borrower loyalty reset, identity-reveal opt-ins) happens in Rapture's
481
+ * trigger layer, not here.
482
+ */
483
+ export declare const IShareBlockMarkDefaultedInputSchema: z.ZodObject<{
484
+ userId: z.ZodString;
485
+ reason: z.ZodString;
486
+ asOf: z.ZodNumber;
487
+ }, z.core.$strip>;
488
+ export type IShareBlockMarkDefaultedInput = z.infer<typeof IShareBlockMarkDefaultedInputSchema>;
489
+ //# sourceMappingURL=shareblock-models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shareblock-models.d.ts","sourceRoot":"","sources":["../../../src/models/shareblock/shareblock-models.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB;;;;;;;;;;;;;;;;;;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