sinfactura-types 1.10.270 → 1.10.271

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.
@@ -97,10 +97,42 @@ declare global {
97
97
  startTimestamp: number;
98
98
  /** Unix ms, UTC. Derived from `date` + `endTime` — see {@link Appointment.startTimestamp}. */
99
99
  endTimestamp: number;
100
- /** RRULE string for a repeating booking. Absent means a one-off. */
100
+ /**
101
+ * RRULE string for a repeating booking. Absent means a one-off.
102
+ *
103
+ * ⚠️ **Accepted and stored VERBATIM. Nothing expands it yet** — no RRULE
104
+ * parser and no occurrence generator exists, so a client that sends one
105
+ * receives a `200` and a SINGLE appointment, with nothing anywhere saying
106
+ * the rule was ignored. Only the server-side expander can ever populate
107
+ * {@link Appointment.recurrenceId} on a child row; until it lands, reading
108
+ * this field as "a series exists" is wrong.
109
+ */
101
110
  recurrenceRule?: string;
102
111
  /** The parent row a generated occurrence was expanded from. */
103
112
  recurrenceId?: string;
113
+ /**
114
+ * Dates excluded from the series this row's {@link Appointment.recurrenceRule}
115
+ * describes — RFC 5545's `EXDATE`, as `YYYY-MM-DD` strings matching
116
+ * {@link Appointment.date}'s own format rather than as timestamps.
117
+ *
118
+ * ⚠️ **Declared, NOT yet honoured.** The expander does not read it, so a
119
+ * date listed here is still generated today. It is published ahead of that
120
+ * deliberately and narrowly: the field costs nothing now, and having it
121
+ * means the «omitir fechas» work is a behaviour change rather than a
122
+ * contract change plus a bump plus a wait. ⚠️ Do not read its presence as
123
+ * a promise that an occurrence was skipped.
124
+ *
125
+ * ⚠️ **It lives on the series parent, never on an occurrence**, and that is
126
+ * what makes it different from simply cancelling a generated row. A
127
+ * client-side exclusion list the server does not know about diverges the
128
+ * moment anything else writes to the series — a later re-expansion would
129
+ * mint the very dates the operator excluded, and nothing would look wrong.
130
+ *
131
+ * ⚠️ Dates only, no times: the rule already fixes the time of day, so a
132
+ * per-occurrence time override is a different feature and must not be
133
+ * smuggled in here.
134
+ */
135
+ recurrenceExceptions?: string[];
104
136
  /**
105
137
  * On a `RESCHEDULED` row: the appointment that replaced it.
106
138
  * On the replacement: {@link Appointment.rescheduledFrom}.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AUTOMATION_RULE_STATUSES = exports.AUTOMATION_TRIGGERS = void 0;
3
+ exports.AUTOMATION_RULE_STATUSES = exports.AUTOMATION_SEND_STATUSES = exports.ATTRIBUTION_WINDOW_HOURS = exports.AUTOMATION_TRIGGERS = void 0;
4
4
  /**
5
5
  * The {@link AutomationTrigger} vocabulary as a RUNTIME value, so the api's Zod
6
6
  * enum, the configuration screen's picker and the published union all derive
@@ -12,6 +12,28 @@ exports.AUTOMATION_RULE_STATUSES = exports.AUTOMATION_TRIGGERS = void 0;
12
12
  * member added HERE and not to the union does not.
13
13
  */
14
14
  exports.AUTOMATION_TRIGGERS = ['ABANDONED_CART'];
15
+ /**
16
+ * How long after a send an order may still be attributed to it, in HOURS.
17
+ *
18
+ * ⚠️ **Fixed in ONE place on purpose.** An hour and a fortnight give very
19
+ * different conversion numbers, so a window each surface picks for itself
20
+ * guarantees two surfaces that disagree and no way to say which is right. Every
21
+ * reader — the evaluator, the analytics tab, any later report — derives from
22
+ * this constant rather than choosing.
23
+ *
24
+ * 72 hours is a PRODUCT number, not a technical one: the shortest window that
25
+ * survives a customer reading a mail on a phone, thinking about it, and buying at
26
+ * the weekend, and short enough that an order two weeks later is not credited to
27
+ * a mail nobody remembers. It moves here if the operator wants it different.
28
+ */
29
+ exports.ATTRIBUTION_WINDOW_HOURS = 72;
30
+ /** {@link AutomationSendStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
31
+ exports.AUTOMATION_SEND_STATUSES = [
32
+ 'queued',
33
+ 'sent',
34
+ 'failed',
35
+ 'skipped',
36
+ ];
15
37
  /** {@link AutomationRuleStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
16
38
  exports.AUTOMATION_RULE_STATUSES = [
17
39
  'paused',
@@ -336,6 +336,98 @@ declare global {
336
336
  createdAt: number;
337
337
  updatedAt?: number;
338
338
  }
339
+ /**
340
+ * `'queued'` — accepted, not yet handed to a transport. `'sent'` — handed
341
+ * over. `'failed'` — the transport refused or errored. `'skipped'` — the rule
342
+ * matched but the send was withheld, by the frequency cap or by a live
343
+ * consent re-check.
344
+ *
345
+ * Deliberately the same four values as {@link CampaignRecipientStatus}, and
346
+ * deliberately a SEPARATE type rather than an alias: the two vocabularies
347
+ * agree today by coincidence of design, and aliasing would make a future
348
+ * automation-only state (a rule paused mid-flight, say) a breaking change to
349
+ * every campaign consumer.
350
+ */
351
+ type AutomationSendStatus = 'queued' | 'sent' | 'failed' | 'skipped';
352
+ /**
353
+ * One row per automated send: what a rule decided to do about one customer,
354
+ * once.
355
+ *
356
+ * This is BOTH halves of the job — the frequency cap
357
+ * ({@link AutomationRule.maxSendsPerCustomer}) is counted against these rows,
358
+ * and the analytics tab pages them. Modelled on {@link CampaignRecipient},
359
+ * which is the nearest precedent for a per-send record.
360
+ *
361
+ * ⚠️ **Nothing writes these yet.** Like {@link AutomationRule} itself, the
362
+ * shape is published ahead of its consumer so the app can build attribution
363
+ * against a type it can compile with. A row does not exist until the
364
+ * evaluator slice ships.
365
+ *
366
+ * ⚠️ **Consent is re-checked LIVE at send time and never inherited.** A send
367
+ * the rule matched but consent refused is recorded `'skipped'` with a reason
368
+ * rather than dropped, so the refusal is auditable — and an ABSENT marketing
369
+ * channel is NOT consent.
370
+ */
371
+ interface AutomationSend {
372
+ storeId: string;
373
+ automationRuleId: string;
374
+ automationSendId: string;
375
+ customerId: string;
376
+ status: AutomationSendStatus;
377
+ /**
378
+ * The trigger occurrence this send answers, so a rule that fires twice for
379
+ * one customer produces two distinguishable rows.
380
+ */
381
+ trigger: AutomationTrigger;
382
+ /** Unix MILLISECONDS. Present on `'sent'` rows only. */
383
+ sentAt?: number;
384
+ /** Unix MILLISECONDS. Present on `'failed'` rows only. */
385
+ failedAt?: number;
386
+ /**
387
+ * Machine-readable cause for the `'failed'` and `'skipped'` cases — a bare
388
+ * SCREAMING_SNAKE code, never a human sentence, so a report can group on it.
389
+ */
390
+ reason?: string;
391
+ /**
392
+ * The products this send actually offered, in the order it offered them.
393
+ *
394
+ * ⚠️ **On the SEND, not on {@link AutomationRule}**, and that placement is
395
+ * the design rather than an accident of where it fit. A cross-sell rule does
396
+ * not name products — the association model picks them per send, from what
397
+ * the triggering invoice contained — so a `productIds` on the rule would be
398
+ * a field the evaluator never reads, which is exactly the "shipped ahead of
399
+ * its emitter" shape this domain has already decided against. What a rule
400
+ * offered on a given day is also the only thing attribution can honestly be
401
+ * computed against, since the catalogue moves underneath it.
402
+ */
403
+ productIds?: string[];
404
+ /**
405
+ * The order attributed to this send, if one was.
406
+ *
407
+ * ⚠️ **LAST TOUCH inside {@link ATTRIBUTION_WINDOW_HOURS}.** One order
408
+ * attributes to at most ONE send, so per-rule conversions can never sum to
409
+ * more than total orders — which is the property that keeps an analytics
410
+ * panel trustworthy. Numbers that do not add up destroy confidence in a
411
+ * whole panel faster than a missing feature does.
412
+ *
413
+ * ⚠️ A consequence a surface MUST render for: a rule can legitimately show
414
+ * ZERO conversions while its sends are delivered and opened, because another
415
+ * rule keeps winning the last touch. That is correct behaviour, and a bare
416
+ * `0` beside it will be read as a broken rule and switched off.
417
+ *
418
+ * ⚠️ **There is deliberately NO money on this row.** A snapshotted order
419
+ * total keeps counting after the order is credited or cancelled, and nothing
420
+ * would update it — recovered revenue silently including a refunded sale is
421
+ * a number an operator acts on. Revenue, if it is ever wanted, is a live
422
+ * aggregate over the orders, never a figure stamped here.
423
+ */
424
+ orderId?: string;
425
+ /** Unix MILLISECONDS the attribution was made. Present only with {@link AutomationSend.orderId}. */
426
+ attributedAt?: number;
427
+ /** Unix MILLISECONDS. */
428
+ createdAt: number;
429
+ updatedAt?: number;
430
+ }
339
431
  /** One datapoint of the campaign-engagement time series. `t` is epoch MILLISECONDS. */
340
432
  interface CampaignEmailMetricPoint {
341
433
  t: number;
@@ -413,6 +505,23 @@ declare global {
413
505
  * member added HERE and not to the union does not.
414
506
  */
415
507
  export declare const AUTOMATION_TRIGGERS: readonly ["ABANDONED_CART"];
508
+ /**
509
+ * How long after a send an order may still be attributed to it, in HOURS.
510
+ *
511
+ * ⚠️ **Fixed in ONE place on purpose.** An hour and a fortnight give very
512
+ * different conversion numbers, so a window each surface picks for itself
513
+ * guarantees two surfaces that disagree and no way to say which is right. Every
514
+ * reader — the evaluator, the analytics tab, any later report — derives from
515
+ * this constant rather than choosing.
516
+ *
517
+ * 72 hours is a PRODUCT number, not a technical one: the shortest window that
518
+ * survives a customer reading a mail on a phone, thinking about it, and buying at
519
+ * the weekend, and short enough that an order two weeks later is not credited to
520
+ * a mail nobody remembers. It moves here if the operator wants it different.
521
+ */
522
+ export declare const ATTRIBUTION_WINDOW_HOURS = 72;
523
+ /** {@link AutomationSendStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
524
+ export declare const AUTOMATION_SEND_STATUSES: readonly ["queued", "sent", "failed", "skipped"];
416
525
  /** {@link AutomationRuleStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
417
526
  export declare const AUTOMATION_RULE_STATUSES: readonly ["paused", "active", "archived"];
418
527
  export {};
package/dist/marketing.js CHANGED
@@ -9,6 +9,28 @@
9
9
  * member added HERE and not to the union does not.
10
10
  */
11
11
  export const AUTOMATION_TRIGGERS = ['ABANDONED_CART'];
12
+ /**
13
+ * How long after a send an order may still be attributed to it, in HOURS.
14
+ *
15
+ * ⚠️ **Fixed in ONE place on purpose.** An hour and a fortnight give very
16
+ * different conversion numbers, so a window each surface picks for itself
17
+ * guarantees two surfaces that disagree and no way to say which is right. Every
18
+ * reader — the evaluator, the analytics tab, any later report — derives from
19
+ * this constant rather than choosing.
20
+ *
21
+ * 72 hours is a PRODUCT number, not a technical one: the shortest window that
22
+ * survives a customer reading a mail on a phone, thinking about it, and buying at
23
+ * the weekend, and short enough that an order two weeks later is not credited to
24
+ * a mail nobody remembers. It moves here if the operator wants it different.
25
+ */
26
+ export const ATTRIBUTION_WINDOW_HOURS = 72;
27
+ /** {@link AutomationSendStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
28
+ export const AUTOMATION_SEND_STATUSES = [
29
+ 'queued',
30
+ 'sent',
31
+ 'failed',
32
+ 'skipped',
33
+ ];
12
34
  /** {@link AutomationRuleStatus} as a runtime value — see {@link AUTOMATION_TRIGGERS}. */
13
35
  export const AUTOMATION_RULE_STATUSES = [
14
36
  'paused',
package/dist/product.d.ts CHANGED
@@ -547,5 +547,79 @@ declare global {
547
547
  pricePaused?: boolean;
548
548
  priceListId?: number;
549
549
  }
550
+ /**
551
+ * One product that co-occurs with another, with the three figures that say
552
+ * whether the co-occurrence means anything.
553
+ *
554
+ * ⚠️ **`lift` is not optional and must not be dropped as "the advanced one".**
555
+ * Support and confidence alone recommend the carrier bag beside every invoice:
556
+ * a universally-attached product co-occurs with everything at high confidence
557
+ * precisely BECAUSE it is attached to everything, and confidence has no term
558
+ * that notices. Lift divides by how often the suggestion sells on its own, so
559
+ * it is the only one of the three that can say "these two go together" rather
560
+ * than "this one sells a lot". A ranking without it is not a weaker
561
+ * recommendation, it is a popularity list wearing a recommendation's name.
562
+ */
563
+ interface ProductAssociationEntry {
564
+ productId: string;
565
+ /** Fraction of all baskets containing BOTH products. 0–1. */
566
+ support: number;
567
+ /** Fraction of baskets containing the ANCHOR that also contain this one. 0–1. */
568
+ confidence: number;
569
+ /**
570
+ * `confidence` divided by this product's own standalone frequency.
571
+ *
572
+ * `1` means independent — the pairing tells you nothing. Below `1` means the
573
+ * two sell together LESS than chance, which is a real signal and must not be
574
+ * clamped away. Above `1` is the only range worth suggesting from.
575
+ */
576
+ lift: number;
577
+ }
578
+ /**
579
+ * The co-occurrence model for ONE anchor product in one store: what else to
580
+ * suggest when this product is sold.
581
+ *
582
+ * ⚠️ **RANKED AND TRUNCATED SERVER-SIDE, so every consumer sees one answer.**
583
+ * The ordering is part of the artifact, not a client concern — two surfaces
584
+ * ranking the same figures differently is how the same store gets two
585
+ * different "top suggestion" answers with nothing wrong anywhere.
586
+ *
587
+ * ⚠️ **JOB-WRITTEN and offline**, on the same footing as {@link Product.abcClass}
588
+ * — an operator edit is overwritten on the next run without warning.
589
+ *
590
+ * ⚠️ **Absence means NOT COMPUTED, never "nothing goes with this."** A store
591
+ * where the job has never run and a product with genuinely no partners are
592
+ * indistinguishable here, so a surface must not render absence as a finding.
593
+ *
594
+ * ⚠️ **Suggestions ride the MAIL, never the comprobante.** Once ARCA returns a
595
+ * CAE the voucher is authorised and its content is what was filed; appending a
596
+ * recommendation to it afterwards is a fiscal defect, not a layout choice. This
597
+ * is a constraint on every consumer of this shape, which is why it is stated
598
+ * here rather than in whichever surface happens to read it first.
599
+ */
600
+ interface ProductAssociations {
601
+ storeId: string;
602
+ /** The product these suggestions are FOR. */
603
+ productId: string;
604
+ /** Ranked best-first and already truncated. May be empty. */
605
+ suggestions: ProductAssociationEntry[];
606
+ /**
607
+ * How many baskets the model was computed over.
608
+ *
609
+ * ⚠️ Published because the figures above are meaningless without it: a
610
+ * `confidence` of 1.0 drawn from three baskets is noise, and nothing else on
611
+ * this row would say so. A consumer should refuse to suggest below whatever
612
+ * floor it decides rather than rendering a confident number from nothing.
613
+ */
614
+ basketCount: number;
615
+ /**
616
+ * Unix ms the model was last computed.
617
+ *
618
+ * Same reasoning as {@link Product.abcClassifiedAt}: co-occurrence is a
619
+ * statement about a trailing window and it decays, so a set of figures with
620
+ * no stamp cannot be told from one that was right a year ago.
621
+ */
622
+ computedAt: number;
623
+ }
550
624
  }
551
625
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sinfactura-types",
3
- "version": "1.10.270",
3
+ "version": "1.10.271",
4
4
  "description": "Shared wire and entity contracts for the SINFACTURA platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",