sinfactura-types 1.10.286 → 1.10.288

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.
@@ -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 value names no adapter we have. A
446
- * data defect on the SUBSCRIPTION row, not an outage.
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. `string` rather than a union because it is
505
- * the SUBSCRIPTION row's own raw value and nothing validates it on write — a
506
- * union here would assert a guarantee the data does not carry, and the value
507
- * matching no adapter is exactly the one `historyError` reports as
508
- * `INVALID_PROVIDER`.
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
  /**
@@ -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: Pick<Subscription, 'planTier' | 'status' | 'billingCycle' | 'freeUntil' | 'trialEndsAt'>;
431
- after: Pick<Subscription, 'planTier' | 'status' | 'billingCycle' | 'freeUntil' | 'trialEndsAt'>;
497
+ before: SubscriptionAuditFields;
498
+ after: SubscriptionAuditFields;
432
499
  reason: string;
433
500
  }
434
501
  /**
@@ -458,5 +525,30 @@ declare global {
458
525
  */
459
526
  pdfUrl?: string;
460
527
  }
528
+ /**
529
+ * One tier's `SK: PLAN` template row, as assessed by
530
+ * `report-plan-catalog-drift` (`POST /platform/operations`). Plan features
531
+ * are code (`planFeatureMatrix.ts`) and cannot drift; the template row is
532
+ * the only catalogue state a seeder/admin write can still leave stale.
533
+ */
534
+ interface TierCatalogDrift {
535
+ tier: PlanTier;
536
+ /** A tier with no `SK: PLAN` row is unpurchasable, whatever its features are. */
537
+ hasTemplate: boolean;
538
+ /** `priceMonthlyCents === 0` on the template — exempt from the provider-identifier check. */
539
+ free: boolean;
540
+ /**
541
+ * Provider-identifier KEY NAMES the template is missing (e.g.
542
+ * `mpPreApprovalPlanIdAnnual`), never their values — a report is not the
543
+ * place to echo a catalogue's payment-provider IDs.
544
+ */
545
+ missingProviderIds: string[];
546
+ }
547
+ /** `data` shape of `report-plan-catalog-drift` — 200 when clean, 409 (`PLAN_CATALOG_DRIFT`) when `drift` is `true`. */
548
+ interface PlanCatalogDriftReport {
549
+ /** True when ANY tier lacks a template row, or a paid one is missing a provider identifier. */
550
+ drift: boolean;
551
+ tiers: TierCatalogDrift[];
552
+ }
461
553
  }
462
554
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.286",
3
+ "version": "1.10.288",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",