sinfactura-types 1.10.285 → 1.10.286

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.
@@ -111,6 +111,28 @@ exports.SOCKET_ACTIONS = [
111
111
  * silently turn a no-op into a fan-out.
112
112
  */
113
113
  'campaigns',
114
+ /**
115
+ * A customer row created or updated. `data` is the LIST-VISIBLE projection
116
+ * of the row (`projectCustomerOperatorBroadcast`), never the raw CUSTOMER
117
+ * row — `scrubForCustomer` knows nothing about this entity, so that
118
+ * allow-list IS the scrub. ⚠️ **MOST paths send to the shopper's socket too.** Every
119
+ * `dynamoUpdate`-driven write echoes with `'operator-and-customer'`
120
+ * (hardcoded), and so do the money paths where a shopper watches their own
121
+ * balance move; `'operator'` alone is the newer minority — the `lastBuy`
122
+ * stamp, the CSV import, the MercadoLibre buyer, the avatar write. Do not
123
+ * read this frame as operator-only: the projection is the same either way,
124
+ * and a client that receives one it cannot place is expected to DROP it
125
+ * rather than treat arrival as membership.
126
+ *
127
+ * ⚠️ **TWO shapes, discriminated by the PRESENCE of `customerId`.** The
128
+ * per-row frame carries it. The bulk-import frame is `CustomersRefetchData`
129
+ * — `{ refetch: true }`, no id and no customer data at all, meaning "drop
130
+ * the cached customer list and refetch it". The CSV import sends per-row
131
+ * frames up to a small created-row cap and exactly ONE refetch frame above
132
+ * it, because one SQS send per created row is unaffordable at import scale.
133
+ * See `CustomersRefetchData` for why a consumer that does not know the
134
+ * second shape degrades quietly rather than wrongly.
135
+ */
114
136
  'customers',
115
137
  /**
116
138
  * A delivery created, or an event appended to its timeline. Operator-only —
package/dist/socket.d.ts CHANGED
@@ -49,6 +49,43 @@ export interface CustomDomainSocketPayload {
49
49
  error?: string;
50
50
  };
51
51
  }
52
+ /**
53
+ * `data` of the BULK-IMPORT `customers` frame: "drop your cached customer list
54
+ * and refetch it". Audience `'operator'` — a customer holds no operator
55
+ * customer list, and the frame names no customer to address.
56
+ *
57
+ * The CSV import can create ~10,000 customers in one request, and a projected
58
+ * frame per created row is an SQS send per created row on a handler already
59
+ * near the 29s Lambda ceiling. So the import sends per-row frames only up to a
60
+ * small created-row cap and exactly one of these above it. ⚠️ The cap lives
61
+ * with the producer and is deliberately NOT restated here: it is a cost
62
+ * threshold that will be tuned, and a number on the wire contract would be
63
+ * read as one a consumer may rely on.
64
+ *
65
+ * ⚠️ **Carries no `customerId` and no customer fields whatsoever**, and that
66
+ * emptiness is what makes it safe to fan out to every operator socket on the
67
+ * store no matter what the import contained — there is nothing on it to scope,
68
+ * scrub or disclose. Keep it that way: adding even a list of created ids turns
69
+ * a refetch signal back into a payload with an audience decision behind it.
70
+ *
71
+ * ⚠️ **Discriminate on the ABSENCE of `customerId`**, the same split
72
+ * `LogDeleteAllData` makes against `LogDeleteOneData`. `refetch` is the
73
+ * positive spelling of that one discriminator, never a second axis.
74
+ *
75
+ * ⚠️ **A consumer that does not yet know this shape degrades to the old
76
+ * behaviour SILENTLY.** `app` drops a `customers` frame carrying no
77
+ * `customerId` — it has no row to place — so until it handles this one, an
78
+ * over-cap import leaves the cached list stale exactly as it was before this
79
+ * frame existed. That fallback is intended: stale, never wrong. It is also the
80
+ * first thing to check when an over-cap import "sends nothing".
81
+ */
82
+ export interface CustomersRefetchData {
83
+ /**
84
+ * Literal `true`, so the shape cannot be spelled `{ refetch: false }` —
85
+ * "no refetch needed" is a frame that was never sent, not a field value.
86
+ */
87
+ refetch: true;
88
+ }
52
89
  /** Runtime guard — narrows an untrusted string to a known action. */
53
90
  export declare const isSocketAction: (value: unknown) => value is SocketAction;
54
91
  /**
package/dist/socket.js CHANGED
@@ -108,6 +108,28 @@ export const SOCKET_ACTIONS = [
108
108
  * silently turn a no-op into a fan-out.
109
109
  */
110
110
  'campaigns',
111
+ /**
112
+ * A customer row created or updated. `data` is the LIST-VISIBLE projection
113
+ * of the row (`projectCustomerOperatorBroadcast`), never the raw CUSTOMER
114
+ * row — `scrubForCustomer` knows nothing about this entity, so that
115
+ * allow-list IS the scrub. ⚠️ **MOST paths send to the shopper's socket too.** Every
116
+ * `dynamoUpdate`-driven write echoes with `'operator-and-customer'`
117
+ * (hardcoded), and so do the money paths where a shopper watches their own
118
+ * balance move; `'operator'` alone is the newer minority — the `lastBuy`
119
+ * stamp, the CSV import, the MercadoLibre buyer, the avatar write. Do not
120
+ * read this frame as operator-only: the projection is the same either way,
121
+ * and a client that receives one it cannot place is expected to DROP it
122
+ * rather than treat arrival as membership.
123
+ *
124
+ * ⚠️ **TWO shapes, discriminated by the PRESENCE of `customerId`.** The
125
+ * per-row frame carries it. The bulk-import frame is `CustomersRefetchData`
126
+ * — `{ refetch: true }`, no id and no customer data at all, meaning "drop
127
+ * the cached customer list and refetch it". The CSV import sends per-row
128
+ * frames up to a small created-row cap and exactly ONE refetch frame above
129
+ * it, because one SQS send per created row is unaffordable at import scale.
130
+ * See `CustomersRefetchData` for why a consumer that does not know the
131
+ * second shape degrades quietly rather than wrongly.
132
+ */
111
133
  'customers',
112
134
  /**
113
135
  * A delivery created, or an event appended to its timeline. Operator-only —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.285",
3
+ "version": "1.10.286",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",