@andco/protocol 0.0.11 → 0.0.13

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 (120) hide show
  1. package/dist/api-errors.d.ts +5 -128
  2. package/dist/api-errors.d.ts.map +1 -1
  3. package/dist/api-errors.js +5 -131
  4. package/dist/authorization-preparation.d.ts +3 -3
  5. package/dist/authorization-preparation.d.ts.map +1 -1
  6. package/dist/authorization-preparation.js +4 -0
  7. package/dist/authorization.js +2 -2
  8. package/dist/errors.d.ts +111 -16
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +124 -12
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1 -0
  14. package/dist/intent-input.d.ts +1791 -725
  15. package/dist/intent-input.d.ts.map +1 -1
  16. package/dist/intent-input.js +325 -157
  17. package/dist/issues.d.ts +62 -0
  18. package/dist/issues.d.ts.map +1 -0
  19. package/dist/issues.js +61 -0
  20. package/dist/messages/index.d.ts +2 -2
  21. package/dist/messages/index.d.ts.map +1 -1
  22. package/dist/messages/index.js +10 -3
  23. package/dist/messages/set-preferences.d.ts +13 -1
  24. package/dist/messages/set-preferences.d.ts.map +1 -1
  25. package/dist/messages/set-preferences.js +31 -9
  26. package/dist/miniapp-manifest.d.ts +2 -2
  27. package/dist/miniapp-manifest.d.ts.map +1 -1
  28. package/dist/miniapp-manifest.js +1 -1
  29. package/dist/native-intent.d.ts +48 -28
  30. package/dist/native-intent.d.ts.map +1 -1
  31. package/dist/native-intent.js +76 -24
  32. package/dist/pagination.d.ts +37 -31
  33. package/dist/pagination.d.ts.map +1 -1
  34. package/dist/pagination.js +72 -24
  35. package/dist/rar/account-matchers.d.ts +47 -240
  36. package/dist/rar/account-matchers.d.ts.map +1 -1
  37. package/dist/rar/account-matchers.js +52 -131
  38. package/dist/rar/bank.d.ts +280 -392
  39. package/dist/rar/bank.d.ts.map +1 -1
  40. package/dist/rar/bank.js +68 -137
  41. package/dist/rar/catalog.d.ts +305 -288
  42. package/dist/rar/catalog.d.ts.map +1 -1
  43. package/dist/rar/catalog.js +69 -29
  44. package/dist/rar/detail.d.ts +15 -32
  45. package/dist/rar/detail.d.ts.map +1 -1
  46. package/dist/rar/detail.js +14 -34
  47. package/dist/rar/index.d.ts +2 -1
  48. package/dist/rar/index.d.ts.map +1 -1
  49. package/dist/rar/index.js +2 -1
  50. package/dist/rar/json-schemas.generated.d.ts +4 -0
  51. package/dist/rar/json-schemas.generated.d.ts.map +1 -0
  52. package/dist/rar/json-schemas.generated.js +3570 -0
  53. package/dist/rar/money.d.ts +5 -5
  54. package/dist/rar/money.d.ts.map +1 -1
  55. package/dist/rar/money.js +5 -5
  56. package/dist/rar/project-users.d.ts +40 -14
  57. package/dist/rar/project-users.d.ts.map +1 -1
  58. package/dist/rar/project-users.js +20 -23
  59. package/dist/rar/subject-data.d.ts +96 -48
  60. package/dist/rar/subject-data.d.ts.map +1 -1
  61. package/dist/rar/subject-data.js +61 -34
  62. package/dist/rar/subject.d.ts +18 -85
  63. package/dist/rar/subject.d.ts.map +1 -1
  64. package/dist/rar/subject.js +23 -51
  65. package/dist/rest/accounts.d.ts +347 -0
  66. package/dist/rest/accounts.d.ts.map +1 -0
  67. package/dist/rest/accounts.js +108 -0
  68. package/dist/rest/addresses.d.ts +581 -0
  69. package/dist/rest/addresses.d.ts.map +1 -0
  70. package/dist/rest/addresses.js +190 -0
  71. package/dist/rest/api-error.d.ts +104 -0
  72. package/dist/rest/api-error.d.ts.map +1 -0
  73. package/dist/rest/api-error.js +103 -0
  74. package/dist/rest/authorization.d.ts +123 -0
  75. package/dist/rest/authorization.d.ts.map +1 -0
  76. package/dist/rest/authorization.js +62 -0
  77. package/dist/rest/catalog.d.ts +199 -0
  78. package/dist/rest/catalog.d.ts.map +1 -0
  79. package/dist/rest/catalog.js +63 -0
  80. package/dist/rest/common.d.ts +637 -0
  81. package/dist/rest/common.d.ts.map +1 -0
  82. package/dist/rest/common.js +172 -0
  83. package/dist/rest/contract.d.ts +3480 -0
  84. package/dist/rest/contract.d.ts.map +1 -0
  85. package/dist/rest/contract.js +120 -0
  86. package/dist/rest/events.d.ts +145 -0
  87. package/dist/rest/events.d.ts.map +1 -0
  88. package/dist/rest/events.js +42 -0
  89. package/dist/rest/http.d.ts +49 -0
  90. package/dist/rest/http.d.ts.map +1 -0
  91. package/dist/rest/http.js +25 -0
  92. package/dist/rest/identity.d.ts +627 -0
  93. package/dist/rest/identity.d.ts.map +1 -0
  94. package/dist/rest/identity.js +128 -0
  95. package/dist/rest/index.d.ts +14 -0
  96. package/dist/rest/index.d.ts.map +1 -0
  97. package/dist/rest/index.js +13 -0
  98. package/dist/rest/intents.d.ts +4556 -0
  99. package/dist/rest/intents.d.ts.map +1 -0
  100. package/dist/rest/intents.js +551 -0
  101. package/dist/rest/signatures.d.ts +110 -0
  102. package/dist/rest/signatures.d.ts.map +1 -0
  103. package/dist/rest/signatures.js +113 -0
  104. package/dist/rest/subjects.d.ts +14 -0
  105. package/dist/rest/subjects.d.ts.map +1 -0
  106. package/dist/rest/subjects.js +22 -0
  107. package/dist/service-grants.d.ts +2 -2
  108. package/dist/service-grants.d.ts.map +1 -1
  109. package/dist/service-grants.js +1 -1
  110. package/dist/transport/generated/oauth-api.d.ts +5547 -1448
  111. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  112. package/dist/transport/intents.d.ts +9 -134
  113. package/dist/transport/intents.d.ts.map +1 -1
  114. package/dist/transport/intents.js +21 -405
  115. package/dist/transport/rest.d.ts +15 -5
  116. package/dist/transport/rest.d.ts.map +1 -1
  117. package/dist/userinfo.d.ts +22 -9
  118. package/dist/userinfo.d.ts.map +1 -1
  119. package/dist/userinfo.js +17 -12
  120. package/package.json +13 -2
@@ -0,0 +1,108 @@
1
+ import { oc } from "@orpc/contract";
2
+ import * as v from "valibot";
3
+ import { AccountKeySchema } from "../rar/account-matchers.js";
4
+ import { AndcoAPIError, errors } from "./api-error.js";
5
+ import { connection, cursorlessConnection, ForwardPageQuery, InsufficientAuthorization, InvalidIdentifier, InvalidOrigin, InvalidRequest, InvalidToken, NotFound, PageQuery, ServerError, TemporarilyUnavailable, UnsupportedVersion, } from "./common.js";
6
+ import { http } from "./http.js";
7
+ /**
8
+ * A decimal figure issued by the external bank, as the bank sent it: a string, never a number, with
9
+ * no bound on its digits. Andco republishes it untouched so a reconciliation can compare it byte for
10
+ * byte with the bank's own record; tightening it would turn a quirk of the bank into the refusal of a
11
+ * legitimate bank fact.
12
+ */
13
+ export const BankDecimal = /* @__PURE__ */ v.pipe(v.string(), v.regex(/^-?[0-9]+(?:\.[0-9]+)?$/));
14
+ /**
15
+ * The subject's connection with the bank needs the person back before the bank can answer for them.
16
+ * `code` says what the person has to do, and `interaction_url` is where they do it in Platform.
17
+ * Nothing is wrong with the Grant: the same request succeeds afterwards, and retrying before then
18
+ * answers the same.
19
+ */
20
+ export class BankConnectionInteractionRequired extends /* @__PURE__ */ AndcoAPIError.define("interaction_required", 409, v.pipe(v.object({
21
+ code: v.pipe(v.picklist([
22
+ "bank_connection_pin_required",
23
+ "bank_connection_reconnect_required",
24
+ "bank_representative_replacement_required",
25
+ ]), v.description("What the person has to do: type the web PIN (`bank_connection_pin_required`), connect the account again (`bank_connection_reconnect_required`) or, for an Organization, connect another bank representative (`bank_representative_replacement_required`).")),
26
+ interaction_url: v.pipe(v.optional(v.pipe(v.string(), v.url())), v.description("Where in Platform the person does what `code` names.")),
27
+ }), v.description("The subject's bank connection needs the person back before the bank can answer for them."))) {
28
+ constructor(data, message) {
29
+ super(data, message);
30
+ }
31
+ }
32
+ /** The `after` of the accounts walk is not a cursor this collection returned. Start again without it. */
33
+ export class InvalidAccountsCursor extends /* @__PURE__ */ AndcoAPIError.define("invalid_accounts_cursor", 400, v.pipe(v.object({}), v.description("`after` or `before` is not a cursor the accounts collection returned."))) {
34
+ constructor(message) {
35
+ super({}, message);
36
+ }
37
+ }
38
+ /**
39
+ * The `after` of the transactions walk is not the cursor the bank issued for the next page. The
40
+ * bank's cursor travels untouched: take it from `pageInfo.endCursor` and nothing else.
41
+ */
42
+ export class InvalidCursor extends /* @__PURE__ */ AndcoAPIError.define("invalid_cursor", 400, v.pipe(v.object({}), v.description("`after` is not a cursor the bank issued."))) {
43
+ constructor(message) {
44
+ super({}, message);
45
+ }
46
+ }
47
+ /** One of the subject's personal bank accounts. */
48
+ export const BankAccount = /* @__PURE__ */ v.strictObject({
49
+ id: v.pipe(v.string(), v.uuid()),
50
+ accountKey: v.pipe(v.nullable(AccountKeySchema), v.description("The Account Key its holder chose, or null for an account opened before account keys existed. Exact-match input for `GET /accounts?accountKey=`.")),
51
+ name: v.pipe(v.nullable(v.string()), v.description("The account's own name, the one `account_opening.succeeded` announces; the product name for an account nobody named; null for an account nobody named that the balance projection does not know yet. Show the Account Key or a placeholder of your own for null, never made-up text.")),
52
+ number: v.string(),
53
+ type: v.pipe(v.nullable(v.string()), v.description("Null while the balance projection does not know the account yet.")),
54
+ currency: v.pipe(v.nullable(v.pipe(v.string(), v.regex(/^[A-Z]{3}$/))), v.description("Null while the balance projection does not know the account yet.")),
55
+ balance: v.pipe(v.nullable(BankDecimal), v.description("The ledger balance the bank maintains for the account, as a decimal string, never a number. It is what the account holds after its last movement; funds the bank has on hold are not subtracted from it. Null while the balance projection does not know the account yet, for example right after it is opened, and null when the Grant lacks `read_balance`; a listing never fails for it and never makes up a zero.")),
56
+ });
57
+ /** A page of the subject's accounts. */
58
+ export const AccountPage = /* @__PURE__ */ connection(BankAccount, "A standard connection. Edge cursors remain present on nonempty terminal pages. Reads are live; offset positions can shift under concurrent changes.");
59
+ /**
60
+ * One account transaction, as the bank reports it. Keys are camelCase because this schema describes
61
+ * the wire shape the server sends here, which differs from the snake_case of the rest of the
62
+ * contract; `movement_type` keeps the bank's own field name.
63
+ */
64
+ export const BankTransaction = /* @__PURE__ */ v.strictObject({
65
+ id: v.pipe(v.string(), v.uuid()),
66
+ transactionId: v.nullable(v.string()),
67
+ description: v.string(),
68
+ amount: v.pipe(BankDecimal, v.description("Issued by the external bank and republished exactly as the bank sent it, with none of the digit-count bound of an Andco-defined amount. What tells an inflow from an outflow is `movement_type`, not a sign: the bank sends the amount as a positive figure.")),
69
+ movement_type: v.pipe(v.picklist(["deposit", "interest", "withdrawal"]), v.description("The kind of movement, under the bank's own field name and in its own words. `deposit` and `interest` bring money into this account and raise its balance; `withdrawal` takes money out and lowers it. `amount` is always positive, so `movement_type` is what tells an inflow from an outflow.")),
70
+ origin: v.nullable(v.string()),
71
+ date: v.pipe(v.string(), v.isoTimestamp()),
72
+ runningBalance: v.pipe(v.nullable(BankDecimal), v.description("Same provenance as `amount`: issued by the external bank and republished exactly, never normalized. Real balances do go negative, so the sign is not narrowed away.")),
73
+ paymentType: v.nullable(v.string()),
74
+ reversed: v.boolean(),
75
+ note: v.nullable(v.string()),
76
+ });
77
+ /** A page of one account's transactions, read live from the bank. */
78
+ export const BankTransactionPage = /* @__PURE__ */ cursorlessConnection(BankTransaction, "A connection read live from the bank, which issues one cursor per page and walks forward only. `pageInfo.endCursor` is that cursor and is null on the last page; `pageInfo.startCursor` is always null and `pageInfo.hasPreviousPage` always false. An edge's `cursor` is null: the bank names no position inside a page, so a walk resumes from the end of a page, never from one transaction.");
79
+ /** Lists the personal bank accounts the Grant reaches, with their balances. */
80
+ export const listAccounts = /* @__PURE__ */ oc
81
+ .meta(http({
82
+ method: "GET",
83
+ path: "/accounts",
84
+ summary: "List personal bank accounts and balances",
85
+ description: "Paginated by cursor, in publication order. `?accountKey=` switches from walking the collection to addressing one account by the identifier its holder chose: an exact match, not a search, and `after`/`first` are ignored alongside it. Returns edges and camelCase pageInfo. Cursor and offset argument families cannot be mixed.",
86
+ successDescription: "Active bank accounts granted by bank_accounts:read",
87
+ }))
88
+ .errors(errors(InvalidRequest, InvalidAccountsCursor, InvalidToken, InvalidOrigin, InsufficientAuthorization, UnsupportedVersion, ServerError, BankConnectionInteractionRequired, TemporarilyUnavailable))
89
+ .input(v.object({
90
+ accountKey: v.pipe(v.optional(AccountKeySchema), v.description("Exact-match lookup by Account Key. Not compatible with `after`/`limit` paging.")),
91
+ ...PageQuery,
92
+ }))
93
+ .output(AccountPage);
94
+ /** Lists one account's transactions, newest first, read from the bank. */
95
+ export const listAccountTransactions = /* @__PURE__ */ oc
96
+ .meta(http({
97
+ method: "GET",
98
+ path: "/accounts/{bank_account_id}/transactions",
99
+ summary: "List one account's transactions",
100
+ description: "Answers the transactions the account's statement presentation reads, so an integrator sees exactly what a person would see, newest first, one page at a time: feed `pageInfo.endCursor` back as `?after=` while `pageInfo.hasNextPage`. Granted by a `bank_transaction` authorization detail with `read` whose `accounts` reach this account. The account is named by its identifier or by its Account Key, whichever the integrator knows: a segment shaped like a UUID is an identifier, any other is an Account Key of the Grant's subject. The permission is the same for both and the key is resolved on this request: an account the Grant does not reach, by identifier or by key, and a key that names no account of the subject answer `404`, as if it did not exist, whether or not the account exists. The page is read from the bank on behalf of the subject, and the bank's read model walks forward only: `pageInfo.endCursor` is the bank's own cursor for the next page, handed over untouched, and `after` accepts nothing else (`invalid_cursor` otherwise). There is no cursor per transaction, no backward walk and no offset: `before`, `last`, `offset` and `limit` answer `invalid_request`. Returns edges and camelCase pageInfo.",
101
+ successDescription: "Authorized cursor page of account transactions, newest first",
102
+ }))
103
+ .errors(errors(InvalidRequest, InvalidIdentifier, InvalidCursor, InvalidToken, InvalidOrigin, InsufficientAuthorization, NotFound, UnsupportedVersion, ServerError, BankConnectionInteractionRequired, TemporarilyUnavailable))
104
+ .input(v.object({
105
+ bank_account_id: v.pipe(v.string(), v.maxLength(64), v.description("The account's identifier (a UUID) or its Account Key.")),
106
+ ...ForwardPageQuery,
107
+ }))
108
+ .output(BankTransactionPage);