sinfactura-types 1.10.410 → 1.10.412

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/account.d.ts CHANGED
@@ -34,6 +34,12 @@ declare global {
34
34
  details?: string;
35
35
  debit?: number;
36
36
  credit?: number;
37
+ /**
38
+ * The movement's amount in this row's `currency` — equal to whichever of
39
+ * `credit`/`debit` is set. ⚠️ LEGACY: a manual `POST /account` row written
40
+ * before `source*` existed carries the amount the operator TYPED here, in
41
+ * the typed currency, while `credit`/`debit` beside it are converted.
42
+ */
37
43
  amount?: number;
38
44
  /**
39
45
  * Absent = an ordinary movement, which is every row written to date.
@@ -66,7 +72,29 @@ declare global {
66
72
  * being normalized to catalogId.
67
73
  */
68
74
  currency?: string;
75
+ /**
76
+ * Pesos per unit of this row's `currency` at write time (ADR-0013), so
77
+ * `credit * currencyValue` is the movement in pesos.
78
+ *
79
+ * ⚠️ LEGACY, forward-only: rows written before `source*` existed can carry
80
+ * the TYPED or PAID currency's rate instead — a non-peso row with `1` here
81
+ * is the tell. Treat `1` on a non-peso row as absent; no row is backfilled.
82
+ */
69
83
  currencyValue?: number;
84
+ /**
85
+ * PROVENANCE — the currency the money arrived in, when it differs from
86
+ * `currency` (or an operator override changed the amount). Audit only: the
87
+ * row's money is `credit`/`debit`/`amount`, in `currency`. Set together with
88
+ * `sourceCurrencyValue`; `sourceAmount` rides with them on the manual and
89
+ * payment-link writers, while the order-derived receivable and return
90
+ * credit carry the pair alone. Published to the operator, withheld from the
91
+ * customer wire.
92
+ */
93
+ sourceCurrency?: string;
94
+ /** Pesos per unit of `sourceCurrency` as applied — the operator's override when one was typed. */
95
+ sourceCurrencyValue?: number;
96
+ /** The amount as typed or paid, in `sourceCurrency`. */
97
+ sourceAmount?: number;
70
98
  /**
71
99
  * @deprecated Unix ms at which `currencyValue` was effective (ADR-0013) —
72
100
  * but NO writer stamps it on ACCOUNT rows: only the parallel Cash mirror
package/dist/ai.d.ts CHANGED
@@ -575,5 +575,31 @@ declare global {
575
575
  * Check `GatingErrorCode` IN ADDITION to this union, never instead of it.
576
576
  */
577
577
  type QuoteDraftErrorCode = 'VALIDATION_FAILED' | 'QUOTE_DRAFT_NO_MATCH' | 'QUOTE_DRAFT_AMBIGUOUS' | 'COST_CEILING_EXCEEDED' | 'AI_OPT_OUT' | 'QUOTE_DRAFT_BLOCKED' | 'QUOTE_DRAFT_GENERATION_FAILED' | 'QUOTE_DRAFT_UNGROUNDED' | 'QUOTE_DRAFT_INVALID_QUANTITY' | 'QUOTE_DRAFT_DUPLICATE_LINE' | 'QUOTE_DRAFT_TOO_MANY_LINES';
578
+ /**
579
+ * The ONE spent-budget refusal every AI spend route answers —
580
+ * `POST /products/enrich`, `/reports/narrative`, `/marketing/copy`,
581
+ * `/reminders/draft`, `/suppliers/doc-extract`,
582
+ * `/suppliers/price-list-extract` and `/presupuestos/draft`, and any AI
583
+ * route added later. There is no second spelling and no 429 for it.
584
+ *
585
+ * - 403 — the TENANT's own ceiling. Carries `feature`, `upsell` and `period`.
586
+ * `upsell` is true only for `monthly`: a daily tenant ceiling is one
587
+ * app-wide value no upgrade lifts, and it resets on its own.
588
+ * - 503 — the PLATFORM-wide ceiling, an operator hard stop no tenant action
589
+ * clears. Carries `period` only.
590
+ *
591
+ * `message` repeats the code rather than prose; switch on `error` and the status.
592
+ */
593
+ type AiCostCeilingRefusal = {
594
+ error: 'COST_CEILING_EXCEEDED';
595
+ message: 'COST_CEILING_EXCEEDED';
596
+ feature: 'aiFeatures';
597
+ upsell: boolean;
598
+ period: 'daily' | 'monthly';
599
+ } | {
600
+ error: 'COST_CEILING_EXCEEDED';
601
+ message: 'COST_CEILING_EXCEEDED';
602
+ period: 'daily' | 'monthly';
603
+ };
578
604
  }
579
605
  export {};
@@ -43,7 +43,7 @@
43
43
  // BREAKING change to every subscriber that exhaustively switches on it, even
44
44
  // though it adds rather than removes.
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.ORDER_CREATED_SOURCES = exports.PRINT_JOB_SETTLED_OUTCOMES = exports.WEBHOOK_EVENT_TYPES = void 0;
46
+ exports.CUSTOMER_CREATED_SOURCES = exports.ORDER_CREATED_SOURCES = exports.PRINT_JOB_SETTLED_OUTCOMES = exports.WEBHOOK_EVENT_TYPES = void 0;
47
47
  /**
48
48
  * Every event an integrator can subscribe to — print-state transitions and
49
49
  * business events alike.
@@ -72,6 +72,8 @@ exports.WEBHOOK_EVENT_TYPES = [
72
72
  'order.created',
73
73
  'order.status_changed',
74
74
  'invoice.generated',
75
+ 'customer.created',
76
+ 'customer.imported',
75
77
  ];
76
78
  /** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
77
79
  exports.PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
@@ -99,3 +101,18 @@ exports.PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
99
101
  * learn about.
100
102
  */
101
103
  exports.ORDER_CREATED_SOURCES = ['pos', 'storefront', 'service_delivery', 'mercadolibre'];
104
+ /**
105
+ * Where a `customer.created` event was minted — the three paths that create
106
+ * ONE human customer per request.
107
+ *
108
+ * ⚠️ A CLOSED union: rule 1 applies, so a fourth member mints
109
+ * `customer.created.v2` rather than widening this.
110
+ *
111
+ * ⚠️ The bulk CSV import is deliberately NOT a member. It creates up to 10,000
112
+ * rows in one call, and one event per row would fan 10,000 × subscribers
113
+ * deliveries out of a single request already near its time ceiling. It emits
114
+ * one {@link CustomerImportedPayload} instead.
115
+ *
116
+ * The store's synthetic walk-in customer is never announced: it is not a person.
117
+ */
118
+ exports.CUSTOMER_CREATED_SOURCES = ['pos', 'storefront', 'mercadolibre'];
package/dist/order.d.ts CHANGED
@@ -622,6 +622,17 @@ declare global {
622
622
  * disagree and a create agrees with what an edit recomputes. The `SALE#`
623
623
  * rows omit their own `cost` in the same case rather than booking a `0`.
624
624
  *
625
+ * ⚠️ **Denominated in this order's `currency`**, like `total`, and so is
626
+ * each `items[].cost`. `Product.cost` is stated in the PRODUCT's currency;
627
+ * every writer (the four create legs and `mode: 'edit'`) converts it at
628
+ * write time at the rate this row freezes as `currencyValue`, so
629
+ * `total - cost` is one denomination. A product whose currency has no
630
+ * usable rate is never converted 1:1: the create legs omit `cost` and log
631
+ * `ORDER_COST_CURRENCY_UNRATED`, and an edit refuses with that code.
632
+ * ⚠️ Forward-only: rows written before the conversion carry the PRODUCT's
633
+ * figure, which on a foreign-currency order is usually pesos. Nothing
634
+ * backfills them, and an edit keeps an untouched line's stored cost.
635
+ *
625
636
  * ⚠️ Optional for TWO reasons now, and only one of them is the audience. The
626
637
  * customer boundary removes it — `stripBasketCost` deletes it from the
627
638
  * customer `GET /orders` legs and from every customer-reaching socket frame.
package/dist/webhook.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * immediately subscribable — and a store that subscribes to an event with no
11
11
  * emit site gets silence it cannot distinguish from "nothing happened".
12
12
  */
13
- export declare const WEBHOOK_EVENT_TYPES: readonly ["print.queued", "print.received", "print.printed", "print.failed", "print.agent.connected", "print.agent.disconnected", "print.printer.online", "print.printer.offline", "print.job.settled", "payment.received", "product.stock_low", "product.stock_out", "order.created", "order.status_changed", "invoice.generated"];
13
+ export declare const WEBHOOK_EVENT_TYPES: readonly ["print.queued", "print.received", "print.printed", "print.failed", "print.agent.connected", "print.agent.disconnected", "print.printer.online", "print.printer.offline", "print.job.settled", "payment.received", "product.stock_low", "product.stock_out", "order.created", "order.status_changed", "invoice.generated", "customer.created", "customer.imported"];
14
14
  export type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
15
15
  /** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
16
16
  export declare const PRINT_JOB_SETTLED_OUTCOMES: readonly ["printed", "failed"];
@@ -484,3 +484,73 @@ export interface InvoiceGeneratedPayload {
484
484
  */
485
485
  occurredAt: number;
486
486
  }
487
+ /**
488
+ * Where a `customer.created` event was minted — the three paths that create
489
+ * ONE human customer per request.
490
+ *
491
+ * ⚠️ A CLOSED union: rule 1 applies, so a fourth member mints
492
+ * `customer.created.v2` rather than widening this.
493
+ *
494
+ * ⚠️ The bulk CSV import is deliberately NOT a member. It creates up to 10,000
495
+ * rows in one call, and one event per row would fan 10,000 × subscribers
496
+ * deliveries out of a single request already near its time ceiling. It emits
497
+ * one {@link CustomerImportedPayload} instead.
498
+ *
499
+ * The store's synthetic walk-in customer is never announced: it is not a person.
500
+ */
501
+ export declare const CUSTOMER_CREATED_SOURCES: readonly ["pos", "storefront", "mercadolibre"];
502
+ export type CustomerCreatedSource = (typeof CUSTOMER_CREATED_SOURCES)[number];
503
+ /**
504
+ * Payload for `customer.created` — a new human customer row is durable.
505
+ *
506
+ * ⚠️ **Ids only, never identity.** Name, email, phone, CUIT, the `afip[]`
507
+ * fiscal block and `marketing.consent[].ip` are all personal data under Ley
508
+ * 25.326 leaving our network to a tenant-registered URL. An integrator that
509
+ * needs the row reads `GET /customers` under its own token. Enumerated, never
510
+ * spread from the row.
511
+ *
512
+ * ⚠️ **Upserts do not emit.** An operator edit, a storefront profile change or
513
+ * a repeat MercadoLibre buyer resolving to an existing row is silence.
514
+ *
515
+ * ⚠️ **The MercadoLibre leg is AT-MOST-ONCE**, for the same reason as the
516
+ * `order.created` MercadoLibre leg: it rides an SQS consumer, and a record that
517
+ * commits the customer then dies before the emit is redelivered to a resolver
518
+ * that now MATCHES the row and so creates nothing.
519
+ */
520
+ export interface CustomerCreatedPayload {
521
+ customerId: string;
522
+ source: CustomerCreatedSource;
523
+ /**
524
+ * Server-stamped Unix milliseconds, taken at the post-commit emit — same
525
+ * convention and reason as {@link OrderCreatedPayload.occurredAt}. NOT
526
+ * `Customer.createdAt`.
527
+ */
528
+ occurredAt: number;
529
+ }
530
+ /**
531
+ * Payload for `customer.imported` — ONE event per bulk CSV import that wrote
532
+ * at least one row.
533
+ *
534
+ * The import reserves a CONTIGUOUS block of customer ids for the whole file
535
+ * before the first row lands; `firstCustomerId`..`lastCustomerId` is that
536
+ * block. A reader lists the new rows with `GET /customers` over that range.
537
+ *
538
+ * ⚠️ **The range is the RESERVATION, not the set that landed.** A row the
539
+ * store refused mid-import leaves a gap, so `createdCount` can be smaller than
540
+ * the range width; never derive the count from the ids.
541
+ *
542
+ * ⚠️ **A partly failed import still emits** when any row landed: those rows
543
+ * are durable whatever happened to the rest, and silence would be
544
+ * indistinguishable from "nothing was imported".
545
+ *
546
+ * Ids and a count only — never a row, for the reasons on
547
+ * {@link CustomerCreatedPayload}.
548
+ */
549
+ export interface CustomerImportedPayload {
550
+ firstCustomerId: string;
551
+ lastCustomerId: string;
552
+ /** Rows that actually landed. Always at least 1: a zero-row import emits nothing. */
553
+ createdCount: number;
554
+ /** Server-stamped Unix milliseconds at the emit. */
555
+ occurredAt: number;
556
+ }
package/dist/webhook.js CHANGED
@@ -69,6 +69,8 @@ export const WEBHOOK_EVENT_TYPES = [
69
69
  'order.created',
70
70
  'order.status_changed',
71
71
  'invoice.generated',
72
+ 'customer.created',
73
+ 'customer.imported',
72
74
  ];
73
75
  /** Terminal outcomes for a print job. Closed union — a job printed, or it failed. */
74
76
  export const PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
@@ -96,3 +98,18 @@ export const PRINT_JOB_SETTLED_OUTCOMES = ['printed', 'failed'];
96
98
  * learn about.
97
99
  */
98
100
  export const ORDER_CREATED_SOURCES = ['pos', 'storefront', 'service_delivery', 'mercadolibre'];
101
+ /**
102
+ * Where a `customer.created` event was minted — the three paths that create
103
+ * ONE human customer per request.
104
+ *
105
+ * ⚠️ A CLOSED union: rule 1 applies, so a fourth member mints
106
+ * `customer.created.v2` rather than widening this.
107
+ *
108
+ * ⚠️ The bulk CSV import is deliberately NOT a member. It creates up to 10,000
109
+ * rows in one call, and one event per row would fan 10,000 × subscribers
110
+ * deliveries out of a single request already near its time ceiling. It emits
111
+ * one {@link CustomerImportedPayload} instead.
112
+ *
113
+ * The store's synthetic walk-in customer is never announced: it is not a person.
114
+ */
115
+ export const CUSTOMER_CREATED_SOURCES = ['pos', 'storefront', 'mercadolibre'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.410",
3
+ "version": "1.10.412",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",