@andco/protocol 0.1.0-ti.0 → 0.1.0-ti.2

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.
@@ -154,7 +154,7 @@ export interface paths {
154
154
  put?: never;
155
155
  /**
156
156
  * Close this application's no-target deposit collection with an explicit close Grant action
157
- * @description Idempotent. Preserves existing terminal outcomes. Does not move funds, cancel commands AndCo already accepted, or grant account transaction access.
157
+ * @description Idempotent. Preserves existing terminal outcomes. Does not move funds, cancel commands AndCo already accepted, or grant account movement access.
158
158
  */
159
159
  post: operations["closeDeposit"];
160
160
  delete?: never;
@@ -174,7 +174,9 @@ export interface paths {
174
174
  put?: never;
175
175
  /**
176
176
  * Create an intent under the exact OAuth Grant
177
- * @description The same creation has three representations, and the content type picks between them. An `application/json` body is an Intent born waiting for an Approval. An `application/jwt` body is one Signed Instruction, sent as a compact JWS whose verified payload is `SignedAccountOpeningIntentClaims` or `SignedAccountClosureIntentClaims`, and every value the operation uses comes from those claims and none from the envelope carrying them. An `application/jose+json` body is a signed transfer with `approved: false`: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization, whose payload is `SignedTransferClaims`. It creates a transfer Intent that waits for a decision and answers a TransferIntent with `transfer_id` null. It is verified as `POST /transfers` verifies a signed transfer, with the same rules for the `jti` (a UUID in lowercase, and the only idempotency-key), `exp`, the keys, the `sender` and the `receiver`; the `unusable_key` reason means that the key is registered, but AndCo could not load it to check this signature, so its person registers a new key and revokes this one, then you sign again. A repeat of the same envelope answers the same Intent, and another body under the same `jti` answers `409 idempotency_conflict`. A signed transfer with `approved: true` answers `400 approved_use_transfers` and nothing is recorded: its signature is the approval, so send it to `POST /transfers`. A signed account opening or closure with `approved: true` stays accepted here and is born approved. A string body sent as anything but `application/jwt` answers `415 unsupported_media_type`. A Signed Instruction that does not verify answers `400 invalid_signed_instruction` with its `reason`, and one whose `exp` passed `401 expired_signed_instruction`. A signed account Intent is born approved when the signing client's Grant holds the family's `approve` action (`bank_account`); otherwise it waits, like a proposal, for the person on the hosted screen or for `POST /intents/{intent_id}/approve` by a Grant that holds it. Opening and closing an account fail synchronously with `403 account_key_out_of_grant` when the account_key is outside the Grant's `accounts` patterns and with `409 account_key_taken` when the account_key names an account of the subject (always for a closed one; otherwise unless `upsert`). The new account's number arrives in the `account_opening.succeeded` event as `account: { id, accountKey, number, name }`. Once the request is valid and authorized (a malformed body is still `400 invalid_request` and a Grant without the permission still `403 insufficient_authorization`), an opening and a transfer between two accounts of the same holder work where the bank serves them: the answer is `201` with the Intent `requires_action` and its `authorization_url`, or, for a signed account Intent whose signer also holds the family's `approve`, the Intent born `approved`. Where the deployment's bank does not serve one, the same request answers `501 not_implemented` with `code: account_opening_not_implemented` or `code: own_account_transfer_not_implemented`; a closure always answers `501 not_implemented` with `code: account_closure_not_implemented`. Nothing is created in those cases. A subject without a bank connection to a company cannot open an account: `422 bank_connection_unavailable` with the `intent_id`. A signed account Intent born approved answers the refusals of `POST /intents/{intent_id}/approve`.
177
+ * @description The same creation has three representations, and the content type picks between them. An `application/json` body is an Intent born waiting for an Approval. An `application/jwt` body is one Signed Instruction, sent as a compact JWS whose verified payload is `SignedAccountOpeningIntentClaims` or `SignedAccountClosureIntentClaims`, and every value the operation uses comes from those claims and none from the envelope carrying them. An `application/jose+json` body is a signed transfer with `approved: false`: a `SignedTransferEnvelope`, a JWS in the General JSON Serialization, whose payload is `SignedTransferClaims`. It creates a transfer Intent that waits for a decision and answers a TransferIntent with `transfer_id` null. It is verified as `POST /transfers` verifies a signed transfer, with the same rules for the `jti` (a UUID in lowercase, and the only idempotency-key), `exp`, the keys, the `sender` and the `receiver`; the `unusable_key` reason means that the key is registered, but AndCo could not load it to check this signature, so its person registers a new key and revokes this one, then you sign again. A repeat of the same envelope answers the same Intent, and another body under the same `jti` answers `409 idempotency_conflict`. A signed transfer with `approved: true` answers `400 approved_use_transfers` and nothing is recorded: its signature is the approval, so send it to `POST /transfers`. A signed account opening or closure with `approved: true` stays accepted here and is born approved. A string body sent as anything but `application/jwt` answers `415 unsupported_media_type`. A Signed Instruction that does not verify answers `400 invalid_signed_instruction` with its `reason`, and one whose `exp` passed `401 expired_signed_instruction`. A signed account Intent is born approved when the signing client's Grant holds the family's `approve` action (`bank_account`); otherwise it waits, like a proposal, for the person on the hosted screen or for `POST /intents/{intent_id}/approve` by a Grant that holds it. Opening and closing an account fail synchronously with `403 account_key_out_of_grant` when the account_key is outside the Grant's `accounts` patterns and with `409 account_key_taken` when the account_key names an account of the subject (always for a closed one; otherwise unless `upsert`). The new account's number arrives in the `account_opening.succeeded` event as `account: { id, accountKey, number, name }`. Once the request is valid and authorized (a malformed body is still `400 invalid_request` and a Grant without the permission still `403 insufficient_authorization`), an opening and a `bank_transfer` proposal between two accounts of the same holder work where the bank serves them: the answer is `201` with the Intent `requires_action` and its `authorization_url`, or, for a signed account Intent whose signer also holds the family's `approve`, the Intent born `approved`. A transfer that `bank_own_account_transfer` covers is released at once instead (below). Where the deployment's bank does not serve one, the same request answers `501 not_implemented` with `code: account_opening_not_implemented` or `code: own_account_transfer_not_implemented`; a closure always answers `501 not_implemented` with `code: account_closure_not_implemented`. Nothing is created in those cases. A subject without a bank connection to a company cannot open an account: `422 bank_connection_unavailable` with the `intent_id`. A signed account Intent born approved answers the refusals of `POST /intents/{intent_id}/approve`.
178
+ *
179
+ * A `transfer` proposal needs `bank_transfer` `create` or `bank_own_account_transfer` `create`. When the Grant holds `bank_own_account_transfer` `create` whose `accounts` cover the named `sender` and `receiver` (two different active accounts of the Grant's subject) and the amount is not `editable`, the answer is a TransferIntent born `approved` with `transfer_id` set: nobody decides it, and it is released at once with nobody present. Its outcome lives on the Transfer, which reads `processing` and then `succeeded` or `failed`, never on the Intent. The same `Idempotency-Key` never names both kinds of transfer (`409 idempotency_conflict`). Any other transfer is a `bank_transfer` proposal, bounded by that detail alone. A Grant that holds no `bank_transfer` `create` refuses what `bank_own_account_transfer` does not cover with nothing created: `422 destination_not_own_account` when the `receiver` is missing or is not an account of the subject, `422 invalid_source` when the `sender` is missing, unusable or outside `accounts`, `422 invalid_destination` when the `receiver` cannot receive (closed, another currency, the `sender` itself) or is outside `accounts`, and `400 invalid_request` with the detail `transfer_amount_not_editable` for an editable amount. Where the deployment's bank does not serve transfers between own accounts, `501 not_implemented` with `code: own_account_transfer_not_implemented`. If the release cannot go on because only a person can, the answer is `409 interaction_required` before anything is stored. If it fails after the Transfer was stored, the same request sent again releases that Transfer again and answers the same Intent. An approved Intent has no client cancel.
178
180
  */
179
181
  post: operations["createIntent"];
180
182
  delete?: never;
@@ -351,7 +353,7 @@ export interface paths {
351
353
  patch?: never;
352
354
  trace?: never;
353
355
  };
354
- "/accounts/{bank_account_id}/transactions": {
356
+ "/accounts/{bank_account_id}/movements": {
355
357
  parameters: {
356
358
  query?: never;
357
359
  header?: never;
@@ -359,10 +361,10 @@ export interface paths {
359
361
  cookie?: never;
360
362
  };
361
363
  /**
362
- * List one account's transactions
363
- * @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 AndCo on behalf of the subject, and its read model walks forward only: `pageInfo.endCursor` is AndCo'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.
364
+ * List one account's Movements
365
+ * @description Answers the Movements 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_movement` 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 AndCo on behalf of the subject, and its read model walks forward only: `pageInfo.endCursor` is AndCo's own cursor for the next page, handed over untouched, and `after` accepts nothing else (`invalid_cursor` otherwise). There is no cursor per Movement, no backward walk and no offset: `before`, `last`, `offset` and `limit` answer `invalid_request`. Returns edges and camelCase pageInfo.
364
366
  */
365
- get: operations["listAccountTransactions"];
367
+ get: operations["listAccountMovements"];
366
368
  put?: never;
367
369
  post?: never;
368
370
  delete?: never;
@@ -479,7 +481,7 @@ export interface paths {
479
481
  cookie?: never;
480
482
  };
481
483
  /**
482
- * Replay account facts with account transaction read permission
484
+ * Replay account facts with account movement read permission
483
485
  * @description Returns edges and camelCase pageInfo. Cursor and offset argument families cannot be mixed.
484
486
  */
485
487
  get: operations["readAccountEvents"];
@@ -797,32 +799,42 @@ export interface components {
797
799
  }[];
798
800
  pageInfo: components["schemas"]["PageInfo"];
799
801
  };
800
- BankTransaction: {
802
+ Movement: {
803
+ /** @constant */
804
+ object: "movement";
801
805
  /** Format: uuid */
802
806
  id: string;
803
- transactionId: string | null;
807
+ /** @description The ledger id of the transaction that posted this Movement, or null when AndCo has none. A Transfer that succeeded carries the same id of its debit. */
808
+ transaction_id: string | null;
804
809
  description: string;
805
- /** @description Issued by AndCo and republished exactly as AndCo 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: AndCo sends the amount as a positive figure. */
806
- amount: string;
810
+ /** @description A positive integer in whole pesos (CLP). What tells an inflow from an outflow is `movement_type`, not a sign. */
811
+ amount: number;
807
812
  /**
808
- * @description The kind of movement, under AndCo'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.
813
+ * @description The currency of the account: a permission never assumes it, so the node names it.
814
+ * @constant
815
+ */
816
+ currency: "CLP";
817
+ /**
818
+ * @description The kind of Movement, in AndCo's 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.
809
819
  * @enum {string}
810
820
  */
811
821
  movement_type: "deposit" | "interest" | "withdrawal";
812
- origin: string | null;
822
+ movement_origin: string | null;
813
823
  /** Format: date-time */
814
- date: string;
815
- /** @description Same provenance as `amount`: issued by AndCo and republished exactly, never normalized. Real balances do go negative, so the sign is not narrowed away. */
816
- runningBalance: string | null;
817
- paymentType: string | null;
824
+ movement_date: string;
825
+ /** @description The balance after this Movement, an integer in whole pesos, or null when AndCo did not send one: it is never made up. Real balances do go negative, so the sign is not narrowed away. */
826
+ running_balance: number | null;
827
+ payment_type: string | null;
818
828
  reversed: boolean;
819
829
  note: string | null;
830
+ /** @description The id of the Transfer that this debit belongs to, only when the Grant may read that Transfer: one this client created for the same subject, or any Transfer of an account that a `bank_transfer` `read` detail covers. Always present. A null never means that no Transfer exists: it means no Transfer that this Grant may read, and it is also null for a Movement without a `transaction_id` and for one that AndCo has posted before AndCo recorded the Transfer, which fills on a later read. It is null for a credit too, except the credit leg of an own-account Transfer, which links by the same read rule as the debit. */
831
+ transfer_id: string | null;
820
832
  };
821
- /** @description A connection read live from AndCo, 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: AndCo names no position inside a page, so a walk resumes from the end of a page, never from one transaction. */
822
- BankTransactionPage: {
833
+ /** @description A connection read live from AndCo, 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: AndCo names no position inside a page, so a walk resumes from the end of a page, never from one Movement. */
834
+ MovementPage: {
823
835
  edges: {
824
836
  cursor: string | null;
825
- node: components["schemas"]["BankTransaction"];
837
+ node: components["schemas"]["Movement"];
826
838
  }[];
827
839
  pageInfo: components["schemas"]["PageInfo"];
828
840
  };
@@ -4234,7 +4246,7 @@ export interface operations {
4234
4246
  };
4235
4247
  };
4236
4248
  };
4237
- /** @description `deposit_amount_out_of_bounds`, `deposit_destination_ambiguous`, `amount_out_of_grant`, `invalid_source`, `invalid_destination`, `transfer_sender_identity_unavailable`, `unsupported_bank`, `bank_connection_unavailable`, `bank_account_number_missing`, `bank_authorization_denied`, `bank_holder_without_account`, `bank_account_limit_reached`, `bank_refused`, `insufficient_funds`, `bank_rejected`, `bank_review_required` */
4249
+ /** @description `deposit_amount_out_of_bounds`, `deposit_destination_ambiguous`, `destination_not_own_account`, `amount_out_of_grant`, `invalid_source`, `invalid_destination`, `transfer_sender_identity_unavailable`, `unsupported_bank`, `bank_connection_unavailable`, `bank_account_number_missing`, `bank_authorization_denied`, `bank_holder_without_account`, `bank_account_limit_reached`, `bank_refused`, `insufficient_funds`, `bank_rejected`, `bank_review_required` */
4238
4250
  422: {
4239
4251
  headers: {
4240
4252
  [name: string]: unknown;
@@ -4264,6 +4276,18 @@ export interface operations {
4264
4276
  message?: string;
4265
4277
  /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4266
4278
  hint?: string;
4279
+ } | {
4280
+ /** @constant */
4281
+ error: "destination_not_own_account";
4282
+ /**
4283
+ * Format: uuid
4284
+ * @description The Intent the refusal is about, when it was refused at its release rather than at its creation.
4285
+ */
4286
+ intent_id?: string;
4287
+ /** @description An English sentence for the developer reading a log. Never branch on it and never show it to a person. */
4288
+ message?: string;
4289
+ /** @description When present, an English sentence suggesting to the developer what to do about the error. Never branch on it and never show it to a person. */
4290
+ hint?: string;
4267
4291
  } | {
4268
4292
  /** @constant */
4269
4293
  error: "amount_out_of_grant";
@@ -5902,7 +5926,7 @@ export interface operations {
5902
5926
  };
5903
5927
  };
5904
5928
  };
5905
- listAccountTransactions: {
5929
+ listAccountMovements: {
5906
5930
  parameters: {
5907
5931
  query?: {
5908
5932
  after?: components["parameters"]["After"];
@@ -5916,13 +5940,13 @@ export interface operations {
5916
5940
  };
5917
5941
  requestBody?: never;
5918
5942
  responses: {
5919
- /** @description Authorized cursor page of account transactions, newest first */
5943
+ /** @description Authorized cursor page of account Movements, newest first */
5920
5944
  200: {
5921
5945
  headers: {
5922
5946
  [name: string]: unknown;
5923
5947
  };
5924
5948
  content: {
5925
- "application/json": components["schemas"]["BankTransactionPage"];
5949
+ "application/json": components["schemas"]["MovementPage"];
5926
5950
  };
5927
5951
  };
5928
5952
  /** @description `invalid_request`, `invalid_identifier`, `invalid_cursor` */