@andco/protocol 0.0.6 → 0.0.8

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 (63) hide show
  1. package/README.md +22 -71
  2. package/dist/api-errors.d.ts +5 -5
  3. package/dist/api-errors.d.ts.map +1 -1
  4. package/dist/api-errors.js +5 -5
  5. package/dist/consent.d.ts +2 -2
  6. package/dist/consent.d.ts.map +1 -1
  7. package/dist/consent.js +10 -19
  8. package/dist/errors.d.ts +46 -7
  9. package/dist/errors.d.ts.map +1 -1
  10. package/dist/errors.js +51 -8
  11. package/dist/format-money.d.ts +3 -0
  12. package/dist/format-money.d.ts.map +1 -0
  13. package/dist/format-money.js +7 -0
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/intent-input.d.ts +124 -124
  18. package/dist/intent-input.d.ts.map +1 -1
  19. package/dist/intent-input.js +14 -14
  20. package/dist/miniapp-icon.d.ts +2 -2
  21. package/dist/miniapp-icon.d.ts.map +1 -1
  22. package/dist/miniapp-icon.js +6 -58
  23. package/dist/native-intent.d.ts +20 -29
  24. package/dist/native-intent.d.ts.map +1 -1
  25. package/dist/native-intent.js +13 -56
  26. package/dist/pagination.d.ts +71 -0
  27. package/dist/pagination.d.ts.map +1 -0
  28. package/dist/pagination.js +63 -0
  29. package/dist/rar/account-matchers.d.ts +52 -52
  30. package/dist/rar/account-matchers.d.ts.map +1 -1
  31. package/dist/rar/account-matchers.js +81 -72
  32. package/dist/rar/bank.d.ts +86 -84
  33. package/dist/rar/bank.d.ts.map +1 -1
  34. package/dist/rar/bank.js +26 -24
  35. package/dist/rar/catalog.d.ts +57 -56
  36. package/dist/rar/catalog.d.ts.map +1 -1
  37. package/dist/rar/catalog.js +1 -0
  38. package/dist/rar/detail.d.ts +1 -1
  39. package/dist/rar/detail.d.ts.map +1 -1
  40. package/dist/rar/detail.js +1 -1
  41. package/dist/service-grants.d.ts +6 -3
  42. package/dist/service-grants.d.ts.map +1 -1
  43. package/dist/service-grants.js +17 -3
  44. package/dist/transport/financial-events.d.ts +10 -22
  45. package/dist/transport/financial-events.d.ts.map +1 -1
  46. package/dist/transport/financial-events.js +36 -62
  47. package/dist/transport/generated/oauth-api.d.ts +269 -96
  48. package/dist/transport/generated/oauth-api.d.ts.map +1 -1
  49. package/dist/transport/intents.d.ts +11 -10
  50. package/dist/transport/intents.d.ts.map +1 -1
  51. package/dist/transport/intents.js +20 -19
  52. package/dist/transport/rest.d.ts +3 -3
  53. package/dist/transport/rest.d.ts.map +1 -1
  54. package/dist/transport/rest.js +1 -1
  55. package/dist/transport/runtime.js +3 -3
  56. package/dist/utils.js +3 -3
  57. package/dist/webhooks.d.ts +92 -12
  58. package/dist/webhooks.d.ts.map +1 -1
  59. package/dist/webhooks.js +95 -20
  60. package/package.json +1 -1
  61. package/dist/native-copy.d.ts +0 -28
  62. package/dist/native-copy.d.ts.map +0 -1
  63. package/dist/native-copy.js +0 -400
@@ -1 +1 @@
1
- {"version":3,"file":"intent-input.d.ts","sourceRoot":"","sources":["../src/intent-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAmF7B;;;;;;GAMG;AACH,QAAA,MAAM,YAAY;;;;;;0BAGhB,CAAC;AAEH,kGAAkG;AAClG,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,YAAY,CAAC,CAAC;AAK/D,oGAAoG;AACpG,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;0BAI7B,CAAC;AAcH,gFAAgF;AAChF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAK9E,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOvD;AAED,6GAA6G;AAC7G,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,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A6D,CAAC;AAEnG,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,qGAAqG;AACrG,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO;;eAEzD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB;;aAA6D,CAAC;AAEhG,sFAAsF;AACtF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,kGAAkG;AAClG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO;;eAEtD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;IACnC,4EAA4E;;CAEpE,CAAC;AAEX,mGAAmG;AACnG,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAEnD;AAED,2GAA2G;AAC3G,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAShF;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;aAOrC,CAAC;AAEH,gGAAgG;AAChG,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,OAAO;;;;;;;;;;;;;eAE3D"}
@@ -1,6 +1,6 @@
1
1
  import * as v from "valibot";
2
2
  import { ANDCO_API_ORIGIN } from "./constants.js";
3
- import { AccountAliasSchema } from "./rar/account-matchers.js";
3
+ import { AccountKeySchema } from "./rar/account-matchers.js";
4
4
  import { MoneySchema } from "./rar/money.js";
5
5
  const text = (max) => v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(max));
6
6
  const accountId = /* @__PURE__ */ v.pipe(v.string(), v.uuid());
@@ -45,18 +45,18 @@ const signedAmount = { currency: v.literal("CLP"), value: amountValue };
45
45
  const noteText = /* @__PURE__ */ v.pipe(v.string(), v.trim(), v.check((value) => [...value].length <= 140, "note_too_long"));
46
46
  /**
47
47
  * The account a transfer names, in the vocabulary of the `bank_transfer` matchers it has to fit:
48
- * `{ type: "alias", alias }` and `{ type: "account", id }` name one Andco account, and
48
+ * `{ type: "account_key", accountKey }` and `{ type: "account", id }` name one Andco account, and
49
49
  * `{ type: "external", ... }` names one account at another Chilean bank with every field the
50
50
  * `external` matcher can fix. A transfer names exactly one account, so nothing here is a pattern.
51
51
  *
52
52
  * @example
53
- * const source: TransferAccount = { type: "alias", alias: "caja-santiago" };
53
+ * const source: TransferAccount = { type: "account_key", accountKey: "caja-santiago" };
54
54
  * const payroll: TransferAccount = {
55
55
  * type: "external", bank_id: "banco_de_chile", account_type: "checking", account_id: "1234567890",
56
56
  * holder_id: "12345678-5", holder_name: "Ada Lovelace",
57
57
  * };
58
58
  */
59
- const transferAlias = { type: /* @__PURE__ */ v.literal("alias"), alias: AccountAliasSchema };
59
+ const transferAccountKey = { type: /* @__PURE__ */ v.literal("account_key"), accountKey: AccountKeySchema };
60
60
  const transferAccount = { type: /* @__PURE__ */ v.literal("account"), id: accountId };
61
61
  const transferExternal = {
62
62
  type: /* @__PURE__ */ v.literal("external"),
@@ -67,21 +67,21 @@ const transferExternal = {
67
67
  holder_name: text(256),
68
68
  };
69
69
  /**
70
- * One Andco account of the Grant's subject, named by Account Alias or by identifier: where a
70
+ * One Andco account of the Grant's subject, named by Account Key or by identifier: where a
71
71
  * transfer's money leaves from, where a deposit lands, and the account a closure closes.
72
72
  *
73
73
  * @example
74
- * const account: IntentAccount = { type: "alias", alias: "ventas" };
74
+ * const account: IntentAccount = { type: "account_key", accountKey: "ventas" };
75
75
  */
76
76
  const andcoAccount = /* @__PURE__ */ v.variant("type", [
77
- v.strictObject(transferAlias),
77
+ v.strictObject(transferAccountKey),
78
78
  v.strictObject(transferAccount),
79
79
  ]);
80
80
  /** Where a transfer's money leaves from: always an Andco account of the Grant's subject. */
81
81
  const transferSource = andcoAccount;
82
82
  /** Where a signed transfer's money lands: nothing on this path is left for a person to complete. */
83
83
  const signedTransferDestination = /* @__PURE__ */ v.variant("type", [
84
- v.strictObject(transferAlias),
84
+ v.strictObject(transferAccountKey),
85
85
  v.strictObject(transferAccount),
86
86
  v.strictObject(transferExternal),
87
87
  ]);
@@ -92,7 +92,7 @@ const signedTransferDestination = /* @__PURE__ */ v.variant("type", [
92
92
  */
93
93
  const lockedDestination = { editable: /* @__PURE__ */ v.optional(v.literal(false), false) };
94
94
  const proposedTransferDestination = /* @__PURE__ */ v.variant("type", [
95
- v.strictObject({ ...transferAlias, ...lockedDestination }),
95
+ v.strictObject({ ...transferAccountKey, ...lockedDestination }),
96
96
  v.strictObject({ ...transferAccount, ...lockedDestination }),
97
97
  v.strictObject({ ...transferExternal, ...lockedDestination }),
98
98
  ]);
@@ -136,7 +136,7 @@ const common = {
136
136
  * wrong ones.
137
137
  *
138
138
  * `transfer` is the only way money movement is expressed: money leaving an account towards a
139
- * `destination`, both named in the `bank_transfer` matcher vocabulary (`alias`, `account`,
139
+ * `destination`, both named in the `bank_transfer` matcher vocabulary (`account_key`, `account`,
140
140
  * `external`). A null `source` is the confirmation screen's source picker; the amount and the
141
141
  * destination are always locked there (`editable: true` is refused). Who may approve the Intent without a person belongs to the Grant, never to
142
142
  * the operation itself.
@@ -144,7 +144,7 @@ const common = {
144
144
  * @example
145
145
  * safeParseIntentCreate({
146
146
  * type: "transfer", expires_in: "30 minutes", source: null,
147
- * destination: { type: "alias", alias: "proveedores" },
147
+ * destination: { type: "account_key", accountKey: "proveedores" },
148
148
  * amount: { currency: "CLP", value: "40000" },
149
149
  * note: { value: "Factura 42", editable: true },
150
150
  * });
@@ -175,7 +175,7 @@ export const IntentCreateSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
175
175
  type: v.literal("account_opening"),
176
176
  // The holder's own name for the account, unique per subject (ADR 0028) and never reused once
177
177
  // the account closes.
178
- alias: AccountAliasSchema,
178
+ accountKey: AccountKeySchema,
179
179
  name: v.optional(accountName),
180
180
  upsert: v.optional(v.boolean(), false),
181
181
  }),
@@ -206,7 +206,7 @@ export function safeParseIntentCreate(input) {
206
206
  * come from inside the signature, the second one cannot arrive in a header or a query string.
207
207
  *
208
208
  * `account_opening` is signed on the same terms, and `upsert` is the reason it matters here. The
209
- * flag decides whether naming an Account Alias that already exists is a refusal or a request for the
209
+ * flag decides whether naming an Account Key that already exists is a refusal or a request for the
210
210
  * account already carrying it, which is a difference in what the instruction *orders*. Carried as a
211
211
  * transport option — a header, a query parameter, a field beside the assertion — anybody holding the
212
212
  * signed instruction could flip it, and the order executed would not be the order signed.
@@ -240,7 +240,7 @@ export const SignedIntentSchema = /* @__PURE__ */ v.pipe(v.variant("type", [
240
240
  iat: v.optional(v.pipe(v.number(), v.integer())),
241
241
  nbf: v.optional(v.pipe(v.number(), v.integer())),
242
242
  type: v.literal("account_opening"),
243
- alias: AccountAliasSchema,
243
+ accountKey: AccountKeySchema,
244
244
  name: v.optional(accountName),
245
245
  // Inside the signature, never beside it: outside the claims anyone holding the assertion could
246
246
  // turn "create this account" into "create it or hand me the one that is already there".
@@ -1,4 +1,4 @@
1
1
  import type { AndCoMiniappManifest } from "./miniapp-manifest.js";
2
- /** Selects a same-origin manifest icon suited to compact native Host chrome. */
3
- export declare function resolveAndCoMiniappIconUrl(manifest: AndCoMiniappManifest, manifestUrl: string | URL): string;
2
+ /** Selects the first valid same-origin icon in manifest order. */
3
+ export declare function resolveAndCoMiniappIconUrl(manifest: AndCoMiniappManifest, manifestUrl: string | URL): string | undefined;
4
4
  //# sourceMappingURL=miniapp-icon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"miniapp-icon.d.ts","sourceRoot":"","sources":["../src/miniapp-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAwDlE,gFAAgF;AAChF,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG,UAsBnG"}
1
+ {"version":3,"file":"miniapp-icon.d.ts","sourceRoot":"","sources":["../src/miniapp-icon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,kEAAkE;AAClE,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,GAAG,GAAG,sBAWnG"}
@@ -1,68 +1,16 @@
1
1
  import { SafeURL } from "./urls.js";
2
- function iconPurposeRank(purpose) {
3
- const purposes = purpose?.toLowerCase().split(/\s+/).filter(Boolean) ?? [];
4
- if (purposes.includes("any"))
5
- return 0;
6
- if (purposes.includes("maskable"))
7
- return 1;
8
- return 2;
9
- }
10
- function iconSizeScore(sizes) {
11
- const sizeTokens = sizes?.toLowerCase().split(/\s+/) ?? [];
12
- if (sizeTokens.includes("any"))
13
- return { shapeRank: 0, sizeDistance: 0 };
14
- const dimensions = sizeTokens.flatMap((size) => {
15
- const match = /^(\d+)x(\d+)$/.exec(size);
16
- if (!match)
17
- return [];
18
- const width = Number(match[1]);
19
- const height = Number(match[2]);
20
- if (!Number.isSafeInteger(width) || !Number.isSafeInteger(height) || width < 1 || height < 1)
21
- return [];
22
- return [{ width, height }];
23
- });
24
- if (dimensions.some(({ width, height }) => width === height && width >= 40)) {
25
- return {
26
- shapeRank: 0,
27
- sizeDistance: Math.min(...dimensions
28
- .filter(({ width, height }) => width === height && width >= 40)
29
- .map(({ width }) => Math.abs(width - 64))),
30
- };
31
- }
32
- if (dimensions.some(({ width, height }) => width === height)) {
33
- return {
34
- shapeRank: 1,
35
- sizeDistance: Math.min(...dimensions.filter(({ width, height }) => width === height).map(({ width }) => Math.abs(width - 64))),
36
- };
37
- }
38
- if (dimensions.length) {
39
- return {
40
- shapeRank: 2,
41
- sizeDistance: Math.min(...dimensions.map(({ width, height }) => Math.abs(Math.max(width, height) - 64))),
42
- };
43
- }
44
- return { shapeRank: 3, sizeDistance: Number.MAX_SAFE_INTEGER };
45
- }
46
- /** Selects a same-origin manifest icon suited to compact native Host chrome. */
2
+ /** Selects the first valid same-origin icon in manifest order. */
47
3
  export function resolveAndCoMiniappIconUrl(manifest, manifestUrl) {
48
4
  const base = new SafeURL(manifestUrl);
49
- const candidates = [];
50
- for (const [index, icon] of manifest.icons.entries()) {
5
+ for (const icon of manifest.icons) {
51
6
  try {
52
7
  const url = new SafeURL(new URL(icon.src, base));
53
- if (url.origin !== base.origin)
54
- continue;
55
- const { shapeRank, sizeDistance } = iconSizeScore(icon.sizes);
56
- candidates.push({ url: url.href, purposeRank: iconPurposeRank(icon.purpose), shapeRank, sizeDistance, index });
8
+ if (url.origin === base.origin)
9
+ return url.href;
57
10
  }
58
11
  catch {
59
- // Icons are presentational only: an invalid URL must not invalidate the Miniapp.
12
+ // An invalid icon must not invalidate the Miniapp.
60
13
  }
61
14
  }
62
- candidates.sort((left, right) => left.shapeRank - right.shapeRank ||
63
- left.sizeDistance - right.sizeDistance ||
64
- left.purposeRank - right.purposeRank ||
65
- left.url.localeCompare(right.url) ||
66
- left.index - right.index);
67
- return candidates[0]?.url;
15
+ return undefined;
68
16
  }
@@ -1,9 +1,8 @@
1
1
  import * as v from "valibot";
2
- import { ANDCO_NATIVE_TEXT as t } from "./native-copy.js";
3
2
  /**
4
3
  * An account at another bank, the only destination a person may still correct on a screen.
5
4
  *
6
- * An Andco account named by Alias or identifier already denotes exactly one account, so there is
5
+ * An Andco account named by AccountKey or identifier already denotes exactly one account, so there is
7
6
  * nothing on the screen to correct: it is never editable.
8
7
  */
9
8
  declare const editableDestination: v.ObjectSchema<{
@@ -52,9 +51,11 @@ export declare const AndCoNativeIntentPreparationSchema: v.ObjectSchema<{
52
51
  readonly note: v.NullableSchema<v.StringSchema<undefined>, undefined>;
53
52
  readonly outcome: v.PicklistSchema<["credited", "reversed"], undefined>;
54
53
  readonly receipt_time_source: v.PicklistSchema<["bank_timestamp", "unknown"], undefined>;
55
- readonly account_holder_name_masked: v.StringSchema<undefined>;
56
- readonly account_number_masked: v.StringSchema<undefined>;
57
- readonly bank_id: v.StringSchema<undefined>;
54
+ readonly sender_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
55
+ readonly sender_national_id: v.NullableSchema<v.StringSchema<undefined>, undefined>;
56
+ readonly sender_bank_name: v.NullableSchema<v.StringSchema<undefined>, undefined>;
57
+ readonly sender_account_type: v.NullableSchema<v.PicklistSchema<["checking", "debit", "savings"], undefined>, undefined>;
58
+ readonly sender_account_number: v.NullableSchema<v.StringSchema<undefined>, undefined>;
58
59
  readonly amount: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
59
60
  readonly currency: v.LiteralSchema<"CLP", undefined>;
60
61
  }, undefined>, undefined>;
@@ -85,8 +86,8 @@ export declare const AndCoNativeIntentPreparationSchema: v.ObjectSchema<{
85
86
  readonly signed: v.BooleanSchema<undefined>;
86
87
  readonly destination: v.VariantSchema<"type", [v.ObjectSchema<{
87
88
  readonly editable: v.LiteralSchema<false, undefined>;
88
- readonly type: v.LiteralSchema<"alias", undefined>;
89
- readonly alias: v.StringSchema<undefined>;
89
+ readonly type: v.LiteralSchema<"account_key", undefined>;
90
+ readonly accountKey: v.StringSchema<undefined>;
90
91
  }, undefined>, v.ObjectSchema<{
91
92
  readonly editable: v.LiteralSchema<false, undefined>;
92
93
  readonly type: v.LiteralSchema<"account", undefined>;
@@ -101,8 +102,8 @@ export declare const AndCoNativeIntentPreparationSchema: v.ObjectSchema<{
101
102
  readonly editable: v.BooleanSchema<undefined>;
102
103
  }, undefined>], undefined>;
103
104
  readonly source: v.NullableSchema<v.VariantSchema<"type", [v.ObjectSchema<{
104
- readonly type: v.LiteralSchema<"alias", undefined>;
105
- readonly alias: v.StringSchema<undefined>;
105
+ readonly type: v.LiteralSchema<"account_key", undefined>;
106
+ readonly accountKey: v.StringSchema<undefined>;
106
107
  }, undefined>, v.ObjectSchema<{
107
108
  readonly type: v.LiteralSchema<"account", undefined>;
108
109
  readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>]>;
@@ -261,9 +262,11 @@ export declare function requestAndCoNativeIntent(options: {
261
262
  note: string | null;
262
263
  outcome: "credited" | "reversed";
263
264
  receipt_time_source: "unknown" | "bank_timestamp";
264
- account_holder_name_masked: string;
265
- account_number_masked: string;
266
- bank_id: string;
265
+ sender_name: string | null;
266
+ sender_national_id: string | null;
267
+ sender_bank_name: string | null;
268
+ sender_account_type: "checking" | "debit" | "savings" | null;
269
+ sender_account_number: string | null;
267
270
  amount: string;
268
271
  currency: "CLP";
269
272
  }[];
@@ -294,8 +297,8 @@ export declare function requestAndCoNativeIntent(options: {
294
297
  signed: boolean;
295
298
  destination: {
296
299
  editable: false;
297
- type: "alias";
298
- alias: string;
300
+ type: "account_key";
301
+ accountKey: string;
299
302
  } | {
300
303
  editable: false;
301
304
  type: "account";
@@ -310,8 +313,8 @@ export declare function requestAndCoNativeIntent(options: {
310
313
  editable: boolean;
311
314
  };
312
315
  source: {
313
- type: "alias";
314
- alias: string;
316
+ type: "account_key";
317
+ accountKey: string;
315
318
  } | {
316
319
  type: "account";
317
320
  id: string;
@@ -403,7 +406,7 @@ export declare class AndCoNativeIntentSession {
403
406
  /** Stops polling and notifications without cancelling the financial operation. */
404
407
  dispose(): void;
405
408
  }
406
- /** Server-authoritative lifecycle and display values used by both native renderers. */
409
+ /** Server-authoritative lifecycle state used by native renderers. */
407
410
  export declare function ANDCO_NATIVE_INTENT_VIEW(data: AndCoNativeIntentPreparation, now?: number, observedAt?: number): {
408
411
  terminal: boolean;
409
412
  expired: boolean;
@@ -411,21 +414,9 @@ export declare function ANDCO_NATIVE_INTENT_VIEW(data: AndCoNativeIntentPreparat
411
414
  frozen: boolean;
412
415
  remaining: number | null;
413
416
  canSubmit: boolean;
414
- title: string;
415
- status: string;
416
417
  };
417
418
  /** The destination a person may still correct, which is the only one a screen may send back. */
418
419
  export type AndCoNativeIntentDestination = v.InferOutput<typeof editableDestination>;
419
- /**
420
- * The lines a native sheet shows for where the money lands, so both renderers read one answer: a
421
- * deposit's account as a payer at another bank types it, a transfer's Andco account by Alias or by
422
- * identifier, or another bank's account as the form holds it (a person's corrections included).
423
- * `null` when the Intent names no destination.
424
- *
425
- * @example
426
- * const lines = ANDCO_NATIVE_INTENT_DESTINATION_LINES(data, form); // ["Cuenta proveedores"]
427
- */
428
- export declare function ANDCO_NATIVE_INTENT_DESTINATION_LINES(data: AndCoNativeIntentPreparation, form: Pick<AndCoNativeIntentForm, "destination"> | null, locale?: Parameters<typeof t>[2]): string[] | null;
429
420
  /** User-edited values, separate from the durable financial state. */
430
421
  export type AndCoNativeIntentForm = {
431
422
  source: string;
@@ -1 +1 @@
1
- {"version":3,"file":"native-intent.d.ts","sourceRoot":"","sources":["../src/native-intent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAiC,iBAAiB,IAAI,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAoBzF;;;;;GAKG;AACH,QAAA,MAAM,mBAAmB;;;;;;;;aAQvB,CAAC;AA2BH,+FAA+F;AAC/F,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAmF7C,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kCAAkC,CAAC,CAA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KAAK,EAAE,gCAAgC,GAAG,IAAI;;;;EAc/C"}
@@ -1,6 +1,5 @@
1
1
  import * as v from "valibot";
2
2
  import { TransferConfirmationSchema } from "./intent-input.js";
3
- import { ANDCO_NATIVE_INTENT_TYPE_COPY, ANDCO_NATIVE_TEXT as t } from "./native-copy.js";
4
3
  import { MONEY_PATTERN, MoneyOrZeroSchema } from "./rar/money.js";
5
4
  import { SafeURL } from "./urls.js";
6
5
  const text = /* @__PURE__ */ v.string();
@@ -16,13 +15,13 @@ const money = MoneyOrZeroSchema;
16
15
  const transmittedAmount = /* @__PURE__ */ v.pipe(text, v.regex(new RegExp(MONEY_PATTERN)));
17
16
  const uuid = /* @__PURE__ */ v.pipe(text, v.uuid());
18
17
  const accountType = /* @__PURE__ */ v.picklist(["checking", "debit", "savings"]);
19
- /** One Andco account, by Account Alias or by identifier, in the matcher vocabulary of a request. */
20
- const aliasAccount = /* @__PURE__ */ v.object({ type: v.literal("alias"), alias: text });
18
+ /** One Andco account, by Account Key or by identifier, in the matcher vocabulary of a request. */
19
+ const accountKeyAccount = /* @__PURE__ */ v.object({ type: v.literal("account_key"), accountKey: text });
21
20
  const idAccount = /* @__PURE__ */ v.object({ type: v.literal("account"), id: uuid });
22
21
  /**
23
22
  * An account at another bank, the only destination a person may still correct on a screen.
24
23
  *
25
- * An Andco account named by Alias or identifier already denotes exactly one account, so there is
24
+ * An Andco account named by AccountKey or identifier already denotes exactly one account, so there is
26
25
  * nothing on the screen to correct: it is never editable.
27
26
  */
28
27
  const editableDestination = /* @__PURE__ */ v.object({
@@ -83,9 +82,11 @@ export const AndCoNativeIntentPreparationSchema = /* @__PURE__ */ v.object({
83
82
  note: v.nullable(text),
84
83
  outcome: v.picklist(["credited", "reversed"]),
85
84
  receipt_time_source: v.picklist(["bank_timestamp", "unknown"]),
86
- account_holder_name_masked: text,
87
- account_number_masked: text,
88
- bank_id: text,
85
+ sender_name: v.nullable(text),
86
+ sender_national_id: v.nullable(text),
87
+ sender_bank_name: v.nullable(text),
88
+ sender_account_type: v.nullable(accountType),
89
+ sender_account_number: v.nullable(text),
89
90
  amount: money,
90
91
  currency: v.literal("CLP"),
91
92
  })),
@@ -98,11 +99,11 @@ export const AndCoNativeIntentPreparationSchema = /* @__PURE__ */ v.object({
98
99
  settled: v.nullable(v.object({ currency: v.literal("CLP"), value: money, at: text })),
99
100
  signed: v.boolean(),
100
101
  destination: v.variant("type", [
101
- v.object({ ...aliasAccount.entries, editable: v.literal(false) }),
102
+ v.object({ ...accountKeyAccount.entries, editable: v.literal(false) }),
102
103
  v.object({ ...idAccount.entries, editable: v.literal(false) }),
103
104
  editableDestination,
104
105
  ]),
105
- source: v.nullable(v.variant("type", [aliasAccount, idAccount])),
106
+ source: v.nullable(v.variant("type", [accountKeyAccount, idAccount])),
106
107
  }),
107
108
  ]),
108
109
  sources: v.array(v.object({ id: uuid, number: text, name: v.nullable(text) })),
@@ -307,7 +308,7 @@ export class AndCoNativeIntentSession {
307
308
  if (this.disposed || this.snapshot.pending)
308
309
  return;
309
310
  if (this.snapshot.retryCommand && this.snapshot.retryCommand.action !== command.action) {
310
- this.publish({ ...this.snapshot, error: t("Revisa la operación pendiente antes de iniciar otra acción.") });
311
+ this.publish({ ...this.snapshot, error: "native_intent_pending_operation" });
311
312
  return;
312
313
  }
313
314
  clearTimeout(this.timer);
@@ -342,7 +343,7 @@ export class AndCoNativeIntentSession {
342
343
  this.listeners.clear();
343
344
  }
344
345
  }
345
- /** Server-authoritative lifecycle and display values used by both native renderers. */
346
+ /** Server-authoritative lifecycle state used by native renderers. */
346
347
  export function ANDCO_NATIVE_INTENT_VIEW(data, now = Date.now(), observedAt = now) {
347
348
  const intent = data.intent;
348
349
  const remaining = intent.expires_at === null
@@ -365,61 +366,17 @@ export function ANDCO_NATIVE_INTENT_VIEW(data, now = Date.now(), observedAt = no
365
366
  (intent.type === "deposit" ||
366
367
  (!processing && intent.can_confirm) ||
367
368
  (intent.status === "processing.confirmed" && data.retryable)),
368
- title: t(ANDCO_NATIVE_INTENT_TYPE_COPY[intent.type].title),
369
- status: ["succeeded", "completed"].includes(intent.status)
370
- ? t("Operación completada")
371
- : expired
372
- ? t("La solicitud venció")
373
- : processing
374
- ? t("Procesando la operación")
375
- : terminal
376
- ? t("La operación finalizó")
377
- : t("Revisa los datos antes de continuar"),
378
369
  };
379
370
  }
380
371
  /**
381
372
  * Where the money lands when it is another bank's account, or `null` when a screen cannot correct
382
- * it: an Andco account named by Alias or identifier already denotes exactly one account.
373
+ * it: an Andco account named by AccountKey or identifier already denotes exactly one account.
383
374
  */
384
375
  function proposedDestination(intent) {
385
376
  if (intent.type === "transfer" && intent.destination.type === "external")
386
377
  return intent.destination;
387
378
  return null;
388
379
  }
389
- /**
390
- * The lines a native sheet shows for where the money lands, so both renderers read one answer: a
391
- * deposit's account as a payer at another bank types it, a transfer's Andco account by Alias or by
392
- * identifier, or another bank's account as the form holds it (a person's corrections included).
393
- * `null` when the Intent names no destination.
394
- *
395
- * @example
396
- * const lines = ANDCO_NATIVE_INTENT_DESTINATION_LINES(data, form); // ["Cuenta proveedores"]
397
- */
398
- export function ANDCO_NATIVE_INTENT_DESTINATION_LINES(data, form, locale) {
399
- const intent = data.intent;
400
- const kind = (type) => t({ checking: "Corriente", debit: "Vista", savings: "Ahorro" }[type], {}, locale);
401
- if (intent.type === "deposit") {
402
- const account = intent.destination;
403
- return [
404
- account.holder_name,
405
- ...(account.holder_id ? [account.holder_id] : []),
406
- "Andco",
407
- `${kind(account.account_type)} · ${account.number}`,
408
- ];
409
- }
410
- const destination = intent.destination;
411
- if (destination.type === "alias")
412
- return [t("Cuenta {{alias}}", { alias: destination.alias }, locale)];
413
- if (destination.type === "account")
414
- return [t("Cuenta Andco {{id}}", { id: destination.id.slice(-8) }, locale)];
415
- const external = form?.destination ?? destination;
416
- return [
417
- external.holder_name,
418
- external.holder_id,
419
- external.bank_id,
420
- `${kind(external.account_type)} · ${external.account_id}`,
421
- ];
422
- }
423
380
  /** Restores accepted command values; otherwise defaults only an unambiguous source. */
424
381
  export function ANDCO_NATIVE_INTENT_FORM(data, retry) {
425
382
  const intent = data.intent;
@@ -0,0 +1,71 @@
1
+ import * as v from "valibot";
2
+ /** Position and size of a cursor page; forward and backward arguments are exclusive. */
3
+ export type PaginationCursor = Pick<v.InferInput<ReturnType<typeof paginationSchema>>, "after" | "first" | "before" | "last">;
4
+ /** Position and size of an offset page. */
5
+ export type PaginationOffset = Pick<v.InferInput<ReturnType<typeof paginationSchema>>, "offset" | "limit">;
6
+ export type Pagination = PaginationCursor | PaginationOffset;
7
+ export type Edge<T> = {
8
+ cursor: string;
9
+ node: T;
10
+ };
11
+ export type PageInfo = {
12
+ startCursor: string | null;
13
+ endCursor: string | null;
14
+ hasPreviousPage: boolean;
15
+ hasNextPage: boolean;
16
+ };
17
+ export type Connection<T> = {
18
+ edges: Edge<T>[];
19
+ pageInfo: PageInfo;
20
+ };
21
+ /** Validated pagination suitable for SQL, GraphQL, and transport adapters. */
22
+ export type NormalizedPagination = v.InferOutput<ReturnType<typeof paginationSchema>>;
23
+ /**
24
+ * Validates one pagination family and supplies its default position and size.
25
+ * TODO: simplify into a constant, not a function.
26
+ */
27
+ export declare function paginationSchema(maximum?: number): v.SchemaWithPipe<readonly [v.ObjectSchema<{
28
+ readonly after: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
29
+ readonly first: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, number, undefined>]>, undefined>;
30
+ readonly before: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>, v.MaxLengthAction<string, 2048, undefined>]>, undefined>;
31
+ readonly last: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, number, undefined>]>, undefined>;
32
+ readonly offset: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 2147483647, undefined>]>, undefined>;
33
+ readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, number, undefined>]>, undefined>;
34
+ }, undefined>, v.CheckAction<{
35
+ after?: string | undefined;
36
+ first?: number | undefined;
37
+ before?: string | undefined;
38
+ last?: number | undefined;
39
+ offset?: number | undefined;
40
+ limit?: number | undefined;
41
+ }, "Pagination argument families cannot be mixed">, v.TransformAction<{
42
+ after?: string | undefined;
43
+ first?: number | undefined;
44
+ before?: string | undefined;
45
+ last?: number | undefined;
46
+ offset?: number | undefined;
47
+ limit?: number | undefined;
48
+ }, {
49
+ size: number;
50
+ after: string | undefined;
51
+ first: number | undefined;
52
+ before: string | undefined;
53
+ last: number | undefined;
54
+ offset: number | undefined;
55
+ limit: number | undefined;
56
+ }>, v.CheckAction<{
57
+ size: number;
58
+ after: string | undefined;
59
+ first: number | undefined;
60
+ before: string | undefined;
61
+ last: number | undefined;
62
+ offset: number | undefined;
63
+ limit: number | undefined;
64
+ }, "Invalid default page size">]>;
65
+ /** Validates the argument family and sizes before a request is made. */
66
+ export declare function normalizePagination(input?: Pagination, maximum?: number): NormalizedPagination;
67
+ /** Returns only the public arguments; internal normalization fields never cross the wire. */
68
+ export declare function paginationParameters(input?: Pagination, maximum?: number): PaginationCursor & PaginationOffset;
69
+ /** Constructs metadata from actual edge positions, retaining terminal-page cursors. */
70
+ export declare function connection<T>(edges: Edge<T>[], hasPreviousPage?: boolean, hasNextPage?: boolean): Connection<T>;
71
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"p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,OAAO,SAAM,GAAG,oBAAoB,CAE/F;AAED,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,KAAK,GAAE,UAAe,EAAE,OAAO,SAAM,GAAG,gBAAgB,GAAG,gBAAgB,CAU/G;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,eAAe,UAAQ,EAAE,WAAW,UAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,CAU3G"}
@@ -0,0 +1,63 @@
1
+ import * as v from "valibot";
2
+ /**
3
+ * Validates one pagination family and supplies its default position and size.
4
+ * TODO: simplify into a constant, not a function.
5
+ */
6
+ export function paginationSchema(maximum = 100) {
7
+ const pageSize = v.pipe(v.number(), v.safeInteger(), v.minValue(1), v.maxValue(maximum));
8
+ const cursor = v.pipe(v.string(), v.nonEmpty(), v.maxLength(2048));
9
+ return v.pipe(v.object({
10
+ after: v.optional(cursor),
11
+ first: v.optional(pageSize),
12
+ before: v.optional(cursor),
13
+ last: v.optional(pageSize),
14
+ offset: v.optional(v.pipe(v.number(), v.safeInteger(), v.minValue(0), v.maxValue(2147483647))),
15
+ limit: v.optional(pageSize),
16
+ }), v.check((fields) => {
17
+ const forward = fields.after !== undefined || fields.first !== undefined;
18
+ const backward = fields.before !== undefined || fields.last !== undefined;
19
+ const offset = fields.offset !== undefined || fields.limit !== undefined;
20
+ return Number(forward) + Number(backward) + Number(offset) <= 1;
21
+ }, "Pagination argument families cannot be mixed"), v.transform((fields) => {
22
+ const backward = fields.before !== undefined || fields.last !== undefined;
23
+ const offset = fields.offset !== undefined || fields.limit !== undefined;
24
+ const size = fields.first ?? fields.last ?? fields.limit ?? Math.min(100, maximum);
25
+ return {
26
+ size,
27
+ after: fields.after,
28
+ first: !backward ? size : undefined,
29
+ before: fields.before,
30
+ last: backward ? size : undefined,
31
+ offset: offset ? (fields.offset ?? 0) : undefined,
32
+ limit: offset ? size : undefined,
33
+ };
34
+ }), v.check((page) => v.is(pageSize, page.size), "Invalid default page size"));
35
+ }
36
+ /** Validates the argument family and sizes before a request is made. */
37
+ export function normalizePagination(input = {}, maximum = 100) {
38
+ return v.parse(paginationSchema(maximum), input);
39
+ }
40
+ /** Returns only the public arguments; internal normalization fields never cross the wire. */
41
+ export function paginationParameters(input = {}, maximum = 100) {
42
+ const page = normalizePagination(input, maximum);
43
+ return {
44
+ after: page.after,
45
+ first: page.offset === undefined ? page.first : undefined,
46
+ before: page.before,
47
+ last: page.last,
48
+ offset: page.offset,
49
+ limit: page.limit,
50
+ };
51
+ }
52
+ /** Constructs metadata from actual edge positions, retaining terminal-page cursors. */
53
+ export function connection(edges, hasPreviousPage = false, hasNextPage = false) {
54
+ return {
55
+ edges,
56
+ pageInfo: {
57
+ startCursor: edges[0]?.cursor ?? null,
58
+ endCursor: edges.at(-1)?.cursor ?? null,
59
+ hasPreviousPage,
60
+ hasNextPage,
61
+ },
62
+ };
63
+ }