sinfactura-types 1.10.285 → 1.10.287
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.
- package/dist/cjs/socket.js +22 -0
- package/dist/platform.d.ts +12 -7
- package/dist/socket.d.ts +37 -0
- package/dist/socket.js +22 -0
- package/dist/subscription.d.ts +70 -3
- package/package.json +1 -1
package/dist/cjs/socket.js
CHANGED
|
@@ -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/platform.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface PlatformConfigEntry {
|
|
|
13
13
|
min?: number;
|
|
14
14
|
max?: number;
|
|
15
15
|
maxLength?: number;
|
|
16
|
+
allowedValues?: string[];
|
|
16
17
|
updatedBy?: string;
|
|
17
18
|
updatedAt?: number;
|
|
18
19
|
previousValue?: string | number | boolean;
|
|
@@ -442,8 +443,10 @@ export interface PlatformOverridesRosterResponse {
|
|
|
442
443
|
* - `EXTERNAL_RESOURCE_NOT_FOUND` — we hold a provider-side id the provider no
|
|
443
444
|
* longer recognizes, typically because the tenant cancelled or deleted it in
|
|
444
445
|
* the provider's own dashboard. Permanent until the linkage is re-made.
|
|
445
|
-
* - `INVALID_PROVIDER` — the stored provider
|
|
446
|
-
* data defect on the
|
|
446
|
+
* - `INVALID_PROVIDER` — the SUBSCRIPTION row's stored `provider` is present
|
|
447
|
+
* but names no adapter we have. A data defect on the row, not an outage. The
|
|
448
|
+
* row still shows the resolved `provider`, with no history: no provider is
|
|
449
|
+
* asked while the stored value is in doubt.
|
|
447
450
|
* - `PROVIDER_UNAVAILABLE` — everything else: an outage, a rate limit, an
|
|
448
451
|
* expired token. The only one of the four worth retrying, and the only one
|
|
449
452
|
* expected to clear on its own.
|
|
@@ -501,11 +504,13 @@ export interface TenantBillingRollupRow {
|
|
|
501
504
|
/** Unix ms. */
|
|
502
505
|
canceledAt: number | null;
|
|
503
506
|
/**
|
|
504
|
-
* The resolved billing provider
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* `
|
|
507
|
+
* The resolved billing provider: the SUBSCRIPTION row's stored `provider`
|
|
508
|
+
* when it is a recognised one, else the provider its linked ids belong to,
|
|
509
|
+
* else the platform default. `null` only when the tenant has no
|
|
510
|
+
* SUBSCRIPTION row. A stored value that names no adapter is NOT echoed here
|
|
511
|
+
* — the row shows the resolved provider and `historyError` reports the
|
|
512
|
+
* defect as `INVALID_PROVIDER`. Typed `string` rather than a union so a
|
|
513
|
+
* provider added later does not break an older consumer.
|
|
509
514
|
*/
|
|
510
515
|
provider: string | null;
|
|
511
516
|
/**
|
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/dist/subscription.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ declare global {
|
|
|
39
39
|
*/
|
|
40
40
|
type SubscriptionStatus = 'trialing' | 'active' | 'past_due' | 'readonly' | 'canceled';
|
|
41
41
|
type BillingCycle = 'monthly' | 'annual';
|
|
42
|
+
/** Billing provider that holds a tenant's subscription money. */
|
|
43
|
+
type SubscriptionProvider = 'stripe' | 'mercadopago';
|
|
42
44
|
/**
|
|
43
45
|
* Shape of a single entitlement on a (tier, feature) cell.
|
|
44
46
|
*
|
|
@@ -341,6 +343,15 @@ declare global {
|
|
|
341
343
|
status: SubscriptionStatus;
|
|
342
344
|
/** Billing currency snapshotted from the plan template; `null` on free/unbilled tiers (basico). */
|
|
343
345
|
currency: 'ARS' | 'USD' | null;
|
|
346
|
+
/**
|
|
347
|
+
* Resolved billing provider: the store's saved provider when it is a
|
|
348
|
+
* recognised one, else the provider its linked ids belong to (`sub_`/`cus_`
|
|
349
|
+
* → stripe, any other subscription id → mercadopago), else the platform
|
|
350
|
+
* default. Optional because the `GET /store` subscription embed does not
|
|
351
|
+
* carry it; `GET /subscription` always does. Provider ids
|
|
352
|
+
* (`externalCustomerId`/`externalSubscriptionId`) are never exposed.
|
|
353
|
+
*/
|
|
354
|
+
provider?: SubscriptionProvider;
|
|
344
355
|
billingCycle: BillingCycle | null;
|
|
345
356
|
currentPeriodStart: number | null;
|
|
346
357
|
currentPeriodEnd: number | null;
|
|
@@ -401,7 +412,14 @@ declare global {
|
|
|
401
412
|
* DynamoDB write + audit row. `trialEndsAt` is required (non-null) when
|
|
402
413
|
* `status === 'trialing'`; `reason` is the audit message (min 10 chars).
|
|
403
414
|
* `freeUntil`/`trialEndsAt` are three-state: omit to leave untouched,
|
|
404
|
-
* `null` to clear, or a value to set.
|
|
415
|
+
* `null` to clear, or a value to set. Nothing else is ever removed: provider
|
|
416
|
+
* ids and the collection mode survive every override, including a provider
|
|
417
|
+
* change.
|
|
418
|
+
*
|
|
419
|
+
* When the request carries `provider` or `externalSubscriptionId`, the write
|
|
420
|
+
* only lands if the row's `status` and `externalSubscriptionId` are still what
|
|
421
|
+
* the server read; otherwise 409 `SUBSCRIPTION_CHANGED` (nothing written, no
|
|
422
|
+
* audit row) — reload and retry.
|
|
405
423
|
*/
|
|
406
424
|
interface SubscriptionAdminOverrideInput {
|
|
407
425
|
planTier: PlanTier;
|
|
@@ -411,14 +429,63 @@ declare global {
|
|
|
411
429
|
freeUntil?: string | null;
|
|
412
430
|
/** Trial end (Unix ms). Required (non-null) when `status === 'trialing'`; `null` clears it otherwise. */
|
|
413
431
|
trialEndsAt?: number | null;
|
|
432
|
+
/**
|
|
433
|
+
* Provider subscription id. Omit to leave untouched; there is no clear.
|
|
434
|
+
* The RESULTING row — this id, else the stored one, paired with the
|
|
435
|
+
* resulting provider — must match: Stripe ids start `sub_`, MercadoPago
|
|
436
|
+
* ids never do. A mismatch is 400 `EXTERNAL_SUBSCRIPTION_ID_PROVIDER_MISMATCH`
|
|
437
|
+
* (nothing written) unless `status` is `canceled`. The check runs on every
|
|
438
|
+
* PUT, including one that omits both this and `provider`.
|
|
439
|
+
*/
|
|
440
|
+
externalSubscriptionId?: string;
|
|
441
|
+
/**
|
|
442
|
+
* Billing provider. SET-only. Refused with 409 `EXISTING_PROVIDER_SUBSCRIPTION`
|
|
443
|
+
* (nothing written) when the store has a subscription id on another rail
|
|
444
|
+
* and is not `canceled`. An accepted change writes the provider only — the
|
|
445
|
+
* old rail's ids and mode are kept, so a late payment on the old rail still
|
|
446
|
+
* finds the store; the resulting-row id check above still applies. When
|
|
447
|
+
* the store has no recognised saved provider, supplying this or
|
|
448
|
+
* `externalSubscriptionId` also saves the resolved provider.
|
|
449
|
+
*/
|
|
450
|
+
provider?: SubscriptionProvider;
|
|
414
451
|
reason: string;
|
|
415
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* The subscription fields an override audit row's `before`/`after` slice
|
|
455
|
+
* records. A field the write cleared is recorded as `null` in `after` (the
|
|
456
|
+
* gift writer omits it instead). Provider customer ids are never recorded
|
|
457
|
+
* (an MP payer id can be an email).
|
|
458
|
+
*/
|
|
459
|
+
type SubscriptionAuditFields = {
|
|
460
|
+
planTier: PlanTier;
|
|
461
|
+
status: SubscriptionStatus;
|
|
462
|
+
billingCycle?: BillingCycle;
|
|
463
|
+
freeUntil?: string | null;
|
|
464
|
+
trialEndsAt?: number | null;
|
|
465
|
+
externalSubscriptionId?: string;
|
|
466
|
+
/**
|
|
467
|
+
* The stored `provider` as written, not validated — a corrupt stored value
|
|
468
|
+
* (the one `GET /tenants/billing` flags `INVALID_PROVIDER`) is recorded
|
|
469
|
+
* as-is, so this is `string` rather than `SubscriptionProvider`.
|
|
470
|
+
*/
|
|
471
|
+
provider?: string;
|
|
472
|
+
/**
|
|
473
|
+
* MercadoPago collection model. Present on rows that have carried a
|
|
474
|
+
* MercadoPago mode — a Stripe row may still hold a stale value, so read
|
|
475
|
+
* it together with `provider`.
|
|
476
|
+
*/
|
|
477
|
+
mode?: 'preapproval' | 'manual';
|
|
478
|
+
};
|
|
416
479
|
/**
|
|
417
480
|
* One audit row for a MANAGER out-of-band subscription change, as returned by
|
|
418
481
|
* `GET /platform/stores/{storeId}/subscription/audit`. Written by
|
|
419
482
|
* the override endpoint and the gift endpoint to the
|
|
420
483
|
* `AUDIT#SUBSCRIPTION#{storeId}` partition. `before`/`after` carry the
|
|
421
484
|
* subscription fields an operator can change.
|
|
485
|
+
*
|
|
486
|
+
* ⚠️ The same partition also carries entitlement-override and advancedPricing
|
|
487
|
+
* rows whose `before`/`after` hold different keys, so consumers must read
|
|
488
|
+
* each side structurally rather than trusting every field to be present.
|
|
422
489
|
*/
|
|
423
490
|
interface SubscriptionAuditEntry {
|
|
424
491
|
storeId: string;
|
|
@@ -427,8 +494,8 @@ declare global {
|
|
|
427
494
|
userId: string;
|
|
428
495
|
fullName: string;
|
|
429
496
|
};
|
|
430
|
-
before:
|
|
431
|
-
after:
|
|
497
|
+
before: SubscriptionAuditFields;
|
|
498
|
+
after: SubscriptionAuditFields;
|
|
432
499
|
reason: string;
|
|
433
500
|
}
|
|
434
501
|
/**
|