sinfactura-types 1.10.364 → 1.10.366
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/customerAddress.js +21 -0
- package/dist/cjs/customerContact.js +16 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/socket.js +19 -0
- package/dist/customer.d.ts +65 -0
- package/dist/customerAddress.d.ts +128 -0
- package/dist/customerAddress.js +20 -0
- package/dist/customerContact.d.ts +96 -0
- package/dist/customerContact.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/socket.d.ts +1 -1
- package/dist/socket.js +19 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A customer's address book: several addresses per customer, each of one
|
|
3
|
+
// KIND, at most one DEFAULT per kind.
|
|
4
|
+
//
|
|
5
|
+
// The default is NOT a flag on the address row — two rows can each be written
|
|
6
|
+
// "default" at once, and nothing can make two row flags exclusive. It is ONE
|
|
7
|
+
// pointer per kind on the CUSTOMER row (`CustomerRow.defaultBillingAddressId` /
|
|
8
|
+
// `defaultDeliveryAddressId` — STORAGE-ONLY, never on the wire; `isDefault` and
|
|
9
|
+
// the frame's `defaultAddressId` publish it), written in the SAME transaction as the
|
|
10
|
+
// customer's denormalised copy of that address, so the pointer and the copy can
|
|
11
|
+
// never disagree:
|
|
12
|
+
//
|
|
13
|
+
// - `billing` → `Customer.address` / `city` / `province` / `postalCode`
|
|
14
|
+
// - `delivery` → `Customer.deliveryAddress`
|
|
15
|
+
//
|
|
16
|
+
// Every existing reader of those fields keeps working unchanged. Forward-only:
|
|
17
|
+
// a customer written before the address book has no address rows; the first
|
|
18
|
+
// edit of their address (through `/customers/addresses`, `POST /customers`, the
|
|
19
|
+
// storefront profile, or an order's `saveAsDefault`) creates the row and points
|
|
20
|
+
// the default at it. Nothing sweeps.
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// A customer's CONTACTS: the people who act for one customer — the person who
|
|
3
|
+
// orders is not always the person who pays, and both belong to that customer.
|
|
4
|
+
//
|
|
5
|
+
// Purely ADDITIVE. Nothing on the CUSTOMER row mirrors a contact: `Customer.phone`
|
|
6
|
+
// and `Customer.email` stay the customer's OWN details (`email` is a login
|
|
7
|
+
// identity with a uniqueness claim, and SMS / marketing read `phone` / `email`
|
|
8
|
+
// directly), so there is no default contact, no pointer and no legacy writer to
|
|
9
|
+
// keep in step. A contact is never a notification target and never feeds the
|
|
10
|
+
// customer's `search` index.
|
|
11
|
+
//
|
|
12
|
+
// ⚠️ A contact is ANOTHER person's personal data (Ley 25.326), held by the store
|
|
13
|
+
// about the customer's staff. Never log a contact's name, phone or email, and
|
|
14
|
+
// never hand one to the customer unreviewed: the art. 14 export carries contacts
|
|
15
|
+
// on the STAFF surface only, never on the storefront self-service export.
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/cjs/index.js
CHANGED
|
@@ -39,6 +39,8 @@ __exportStar(require("./cash.js"), exports);
|
|
|
39
39
|
__exportStar(require("./categories.js"), exports);
|
|
40
40
|
__exportStar(require("./currency.js"), exports);
|
|
41
41
|
__exportStar(require("./customer.js"), exports);
|
|
42
|
+
__exportStar(require("./customerAddress.js"), exports);
|
|
43
|
+
__exportStar(require("./customerContact.js"), exports);
|
|
42
44
|
__exportStar(require("./customerNote.js"), exports);
|
|
43
45
|
__exportStar(require("./cycleCount.js"), exports);
|
|
44
46
|
__exportStar(require("./delivery.js"), exports);
|
package/dist/cjs/socket.js
CHANGED
|
@@ -159,6 +159,25 @@ exports.SOCKET_ACTIONS = [
|
|
|
159
159
|
* `dynamoUpdate`'s own `'operator-and-customer'` fan-out never runs.
|
|
160
160
|
*/
|
|
161
161
|
'customerNote',
|
|
162
|
+
/**
|
|
163
|
+
* A customer's address-book row was created, edited or deleted, or its
|
|
164
|
+
* kind's default moved — or every address of one customer was erased or
|
|
165
|
+
* moved by a merge (`change: 'purged'`). `data` is `CustomerAddressChange`.
|
|
166
|
+
* OPERATOR audience only, with an ids-only `lowTierData`; the rows are
|
|
167
|
+
* written by raw transactions, or as extra `transactions` items on a
|
|
168
|
+
* `dynamoUpdate` whose echo carries only the CUSTOMER row, so no automatic
|
|
169
|
+
* `'operator-and-customer'` fan-out carries them.
|
|
170
|
+
*/
|
|
171
|
+
'customerAddress',
|
|
172
|
+
/**
|
|
173
|
+
* A customer's contact (a person acting for the customer) was created,
|
|
174
|
+
* edited or deleted — or every contact of one customer was erased or moved
|
|
175
|
+
* by a merge (`change: 'purged'`). `data` is `CustomerContactChange`.
|
|
176
|
+
* OPERATOR audience only, with an ids-only `lowTierData`; the rows are
|
|
177
|
+
* written by raw transactions, so no automatic `'operator-and-customer'`
|
|
178
|
+
* fan-out carries them.
|
|
179
|
+
*/
|
|
180
|
+
'customerContact',
|
|
162
181
|
/**
|
|
163
182
|
* A delivery created, or an event appended to its timeline. Operator-only —
|
|
164
183
|
* `wsPostStore(..., { audience: 'operator' })`, NEVER
|
package/dist/customer.d.ts
CHANGED
|
@@ -259,6 +259,11 @@ declare global {
|
|
|
259
259
|
* ⚠️ The stamp is written ONCE, under
|
|
260
260
|
* `attribute_not_exists(anonymizedAt)`. A retry reads the ORIGINAL
|
|
261
261
|
* timestamp back; it is never refreshed.
|
|
262
|
+
*
|
|
263
|
+
* The row is TERMINAL for edits: `POST /customers` (an update) and the
|
|
264
|
+
* storefront `POST /user` refuse it with `409 CUSTOMER_ANONYMIZED` and
|
|
265
|
+
* write nothing — on their pre-read, and again through their own write
|
|
266
|
+
* condition when the erasure commits after that read.
|
|
262
267
|
*/
|
|
263
268
|
anonymizedAt?: number;
|
|
264
269
|
/**
|
|
@@ -573,6 +578,24 @@ declare global {
|
|
|
573
578
|
* the survivor's (one transaction each — never lost, never duplicated).
|
|
574
579
|
*/
|
|
575
580
|
notesMoved: number;
|
|
581
|
+
/**
|
|
582
|
+
* Address-book rows THIS run moved from the merged customer into the
|
|
583
|
+
* survivor's partition. They arrive NON-default: the survivor keeps its
|
|
584
|
+
* own default pointers (`CustomerRow.defaultBillingAddressId` /
|
|
585
|
+
* `defaultDeliveryAddressId`) and its own
|
|
586
|
+
* denormalised address. A moved row that was the MERGED customer's default
|
|
587
|
+
* has that pointer REMOVEd from the merged row in the same transaction, so
|
|
588
|
+
* no pointer is left naming a row outside its customer's partition; the
|
|
589
|
+
* merged row's denormalised address copy stays as it was.
|
|
590
|
+
*/
|
|
591
|
+
addressesMoved: number;
|
|
592
|
+
/**
|
|
593
|
+
* Contact rows (`CUSTOMER_CONTACT#{storeId}#{customerId}`) THIS run moved
|
|
594
|
+
* from the merged customer into the survivor's partition, one transaction
|
|
595
|
+
* each. A contact whose id is taken on the survivor is re-keyed to a fresh
|
|
596
|
+
* id. Contacts carry no pointer on the CUSTOMER row, so nothing else moves.
|
|
597
|
+
*/
|
|
598
|
+
contactsMoved: number;
|
|
576
599
|
/**
|
|
577
600
|
* Both sides' `BALANCE-{customerId}-{date}` checkpoints were invalidated —
|
|
578
601
|
* a checkpoint bakes a running balance for a ledger that just changed
|
|
@@ -642,6 +665,20 @@ declare global {
|
|
|
642
665
|
* Each entry is text and dates only — never the author or last editor.
|
|
643
666
|
*/
|
|
644
667
|
notes?: CustomerNoteExportEntry[];
|
|
668
|
+
/**
|
|
669
|
+
* The subject's address book, oldest first. On BOTH surfaces — it is the
|
|
670
|
+
* subject's own data. Each entry is the address and its dates only.
|
|
671
|
+
*/
|
|
672
|
+
addresses: CustomerAddressExportEntry[];
|
|
673
|
+
/**
|
|
674
|
+
* The customer's contacts (the people who act for it), oldest first.
|
|
675
|
+
* PRESENT ONLY on the STAFF-initiated export, exactly like `notes`: each
|
|
676
|
+
* entry is a THIRD party's personal data (name, role, phone, email) held
|
|
677
|
+
* about the subject, so staff review it before handing the file over.
|
|
678
|
+
* ABSENT — never read — on the storefront self-service export. Each entry
|
|
679
|
+
* carries the contact and its dates only.
|
|
680
|
+
*/
|
|
681
|
+
contacts?: CustomerContactExportEntry[];
|
|
645
682
|
/**
|
|
646
683
|
* Per COLLECTION, and honest: `true` means the read stopped before the
|
|
647
684
|
* end of that partition and rows are MISSING from this export.
|
|
@@ -655,6 +692,9 @@ declare global {
|
|
|
655
692
|
accountLedger: boolean;
|
|
656
693
|
/** Present exactly when `notes` is. */
|
|
657
694
|
notes?: boolean;
|
|
695
|
+
addresses: boolean;
|
|
696
|
+
/** Present exactly when `contacts` is. */
|
|
697
|
+
contacts?: boolean;
|
|
658
698
|
};
|
|
659
699
|
}
|
|
660
700
|
/**
|
|
@@ -714,6 +754,31 @@ declare global {
|
|
|
714
754
|
* storefront response omits both counts (`WebAnonymizeCustomerResult`).
|
|
715
755
|
*/
|
|
716
756
|
notesEraseComplete: boolean;
|
|
757
|
+
/**
|
|
758
|
+
* Address-book rows (`CUSTOMER_ADDRESS#{storeId}#{customerId}`) DELETED by
|
|
759
|
+
* this erasure — the whole row goes, like a note. The default pointers on
|
|
760
|
+
* the CUSTOMER row go with the rest of its personal attributes.
|
|
761
|
+
*/
|
|
762
|
+
addressesErased: number;
|
|
763
|
+
/**
|
|
764
|
+
* `false` when the address partition could not be read or deleted to the
|
|
765
|
+
* end. Re-issuing the erasure re-runs the deletion; BOTH erasure handlers
|
|
766
|
+
* write a deduped `ERROR` row (`CUSTOMER_ANONYMIZE_ADDRESSES_INCOMPLETE`).
|
|
767
|
+
* On BOTH wires — the subject's own addresses.
|
|
768
|
+
*/
|
|
769
|
+
addressesEraseComplete: boolean;
|
|
770
|
+
/**
|
|
771
|
+
* Contact rows (`CUSTOMER_CONTACT#{storeId}#{customerId}`) DELETED by this
|
|
772
|
+
* erasure — the whole row goes. Nothing on the CUSTOMER row mirrors one.
|
|
773
|
+
*/
|
|
774
|
+
contactsErased: number;
|
|
775
|
+
/**
|
|
776
|
+
* `false` when the contact partition could not be read or deleted to the
|
|
777
|
+
* end. Re-issuing the erasure re-runs the deletion; BOTH erasure handlers
|
|
778
|
+
* write a deduped `ERROR` row (`CUSTOMER_ANONYMIZE_CONTACTS_INCOMPLETE`).
|
|
779
|
+
* On BOTH wires — counts only.
|
|
780
|
+
*/
|
|
781
|
+
contactsEraseComplete: boolean;
|
|
717
782
|
}
|
|
718
783
|
/**
|
|
719
784
|
* A stored `Customer` plus the session tokens. Same caveat as `AuthUser`:
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/** What an address is FOR. Each kind has its own default. */
|
|
3
|
+
type CustomerAddressKind = 'billing' | 'delivery';
|
|
4
|
+
/**
|
|
5
|
+
* One address as it crosses the wire — an explicit allow-list of the stored
|
|
6
|
+
* row (no `PK`/`SK`, no `storeId`).
|
|
7
|
+
*
|
|
8
|
+
* `addressId` is the row's sort key — `{13-digit creation ms}-{8 hex}` —
|
|
9
|
+
* opaque to a client: address a row by `{ customerId, addressId }`, never
|
|
10
|
+
* parse it. `isDefault` is DERIVED on read from the customer's pointer for
|
|
11
|
+
* this `kind`; it is not stored on the row.
|
|
12
|
+
*/
|
|
13
|
+
interface CustomerAddress {
|
|
14
|
+
addressId: string;
|
|
15
|
+
customerId: string;
|
|
16
|
+
kind: CustomerAddressKind;
|
|
17
|
+
/** Free operator label ("Depósito", "Casa"). Empty string when unset. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Recipient. Mirrors `deliveryAddress.fullName` when this is the delivery default. */
|
|
20
|
+
fullName: string;
|
|
21
|
+
/** Recipient phone. Mirrors `deliveryAddress.phone` when this is the delivery default. */
|
|
22
|
+
phone: string;
|
|
23
|
+
address: string;
|
|
24
|
+
city: string;
|
|
25
|
+
province: string;
|
|
26
|
+
postalCode: string;
|
|
27
|
+
isDefault: boolean;
|
|
28
|
+
createdAt: number;
|
|
29
|
+
updatedAt: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `GET /customers/addresses?customerId=` — one page, ascending by
|
|
33
|
+
* `addressId` (oldest first).
|
|
34
|
+
*/
|
|
35
|
+
interface CustomerAddressPage {
|
|
36
|
+
items: CustomerAddress[];
|
|
37
|
+
/** Opaque; pass back as `?startKey=`. Absent once the walk is drained. */
|
|
38
|
+
nextCursor?: string;
|
|
39
|
+
/** `true` whenever more addresses exist past this page — never a silent prefix. */
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `data` of the `customerAddress` socket frame. OPERATOR audience only — the
|
|
44
|
+
* customer's own socket is NOT addressed (staff only, for now: no storefront
|
|
45
|
+
* address-book surface consumes it).
|
|
46
|
+
*
|
|
47
|
+
* `address` is the whole row on the admin tier for `created` / `updated`.
|
|
48
|
+
* It is absent on a `deleted` change, and on the rare `updated` frame of a
|
|
49
|
+
* legacy writer (`POST /customers`, the storefront profile, `saveAsDefault`)
|
|
50
|
+
* whose post-commit read of the row failed — refetch then. It is ALWAYS
|
|
51
|
+
* absent on the copy an operator socket that cannot prove admin tier
|
|
52
|
+
* receives (`lowTierData` — the ids only, `{ change, customerId, addressId,
|
|
53
|
+
* kind, defaultAddressId? }`, or `{ change, customerId, movedTo? }` for
|
|
54
|
+
* `purged`). The low tier is every socket that is not ADMIN, SUPERVISOR or
|
|
55
|
+
* MANAGER — a USER WITH the `customers` flag included — so the frame never
|
|
56
|
+
* carries an address there; a capable USER refetches through the gated GET.
|
|
57
|
+
*
|
|
58
|
+
* `defaultAddressId` is the kind's default AFTER the change, so a client
|
|
59
|
+
* re-marks its cached list without a refetch; ABSENT means the kind has no
|
|
60
|
+
* default now (a legacy writer that cleared the address unmarked it — the
|
|
61
|
+
* row itself was kept, unchanged).
|
|
62
|
+
*
|
|
63
|
+
* `purged` is ONE frame for the whole customer: drop every cached address
|
|
64
|
+
* for `customerId`. Sent when the Ley 25.326 art. 16 erasure deleted them (no
|
|
65
|
+
* `movedTo`), and when a customer merge moved them to the survivor
|
|
66
|
+
* (`movedTo` = survivor's id — refetch its list).
|
|
67
|
+
*/
|
|
68
|
+
type CustomerAddressChange = {
|
|
69
|
+
change: 'created' | 'updated' | 'deleted';
|
|
70
|
+
customerId: string;
|
|
71
|
+
addressId: string;
|
|
72
|
+
kind: CustomerAddressKind;
|
|
73
|
+
defaultAddressId?: string;
|
|
74
|
+
address?: CustomerAddress;
|
|
75
|
+
} | {
|
|
76
|
+
change: 'purged';
|
|
77
|
+
customerId: string;
|
|
78
|
+
movedTo?: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* One address as BOTH art. 14 exports carry it (staff and self-service) —
|
|
82
|
+
* the subject's own data, so it is included on both, projected to the
|
|
83
|
+
* address itself and its dates.
|
|
84
|
+
*/
|
|
85
|
+
interface CustomerAddressExportEntry {
|
|
86
|
+
addressId: string;
|
|
87
|
+
kind: CustomerAddressKind;
|
|
88
|
+
label: string;
|
|
89
|
+
fullName: string;
|
|
90
|
+
phone: string;
|
|
91
|
+
address: string;
|
|
92
|
+
city: string;
|
|
93
|
+
province: string;
|
|
94
|
+
postalCode: string;
|
|
95
|
+
isDefault: boolean;
|
|
96
|
+
createdAt: number;
|
|
97
|
+
updatedAt: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Every DOMAIN refusal on `/customers/addresses`, one bare code each (the
|
|
101
|
+
* generic `VALIDATION_FAILED`, `CAPABILITY_REQUIRED` and `INVALID_CURSOR`
|
|
102
|
+
* are not listed). None of them writes.
|
|
103
|
+
*
|
|
104
|
+
* - `CUSTOMER_ADDRESS_CUSTOMER_NOT_FOUND` (404) — not a customer of the
|
|
105
|
+
* caller's store; covers «no such id», so the route is no cross-tenant
|
|
106
|
+
* existence oracle.
|
|
107
|
+
* - `CUSTOMER_ADDRESS_CUSTOMER_ANONYMIZED` (409) — erased under Ley 25.326
|
|
108
|
+
* art. 16; enforced atomically with the write.
|
|
109
|
+
* - `CUSTOMER_ADDRESS_CUSTOMER_MERGED` (409) — folded into another customer
|
|
110
|
+
* (`mergedInto`); write on the survivor.
|
|
111
|
+
* - `CUSTOMER_ADDRESS_NOT_FOUND` (404) — no such address for that customer.
|
|
112
|
+
* - `CUSTOMER_ADDRESS_IS_DEFAULT` (409) — the address is its kind's default;
|
|
113
|
+
* make another address the default first. The default is what
|
|
114
|
+
* `Customer.address` / `deliveryAddress` mirror, so it is never deleted
|
|
115
|
+
* out from under them.
|
|
116
|
+
* - `CUSTOMER_ADDRESS_WRITE_CONTENDED` (503) — the customer's default or the
|
|
117
|
+
* address changed under every bounded retry; retry is safe. ALSO answered
|
|
118
|
+
* by `POST /customers` and the storefront `POST /user` when an edit of
|
|
119
|
+
* the address loses to a rival that moved the default or its copy — those
|
|
120
|
+
* refuse on the FIRST failure, with no retry of their own.
|
|
121
|
+
*
|
|
122
|
+
* Those two legacy writers' other row-state refusals are not in this union:
|
|
123
|
+
* `409 CUSTOMER_ANONYMIZED` (see `Customer.anonymizedAt`) and `409
|
|
124
|
+
* CUSTOMER_MERGE_IN_PROGRESS` (merged or mid-merge after their read).
|
|
125
|
+
*/
|
|
126
|
+
type CustomerAddressErrorCode = 'CUSTOMER_ADDRESS_CUSTOMER_NOT_FOUND' | 'CUSTOMER_ADDRESS_CUSTOMER_ANONYMIZED' | 'CUSTOMER_ADDRESS_CUSTOMER_MERGED' | 'CUSTOMER_ADDRESS_NOT_FOUND' | 'CUSTOMER_ADDRESS_IS_DEFAULT' | 'CUSTOMER_ADDRESS_WRITE_CONTENDED';
|
|
127
|
+
}
|
|
128
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// A customer's address book: several addresses per customer, each of one
|
|
2
|
+
// KIND, at most one DEFAULT per kind.
|
|
3
|
+
//
|
|
4
|
+
// The default is NOT a flag on the address row — two rows can each be written
|
|
5
|
+
// "default" at once, and nothing can make two row flags exclusive. It is ONE
|
|
6
|
+
// pointer per kind on the CUSTOMER row (`CustomerRow.defaultBillingAddressId` /
|
|
7
|
+
// `defaultDeliveryAddressId` — STORAGE-ONLY, never on the wire; `isDefault` and
|
|
8
|
+
// the frame's `defaultAddressId` publish it), written in the SAME transaction as the
|
|
9
|
+
// customer's denormalised copy of that address, so the pointer and the copy can
|
|
10
|
+
// never disagree:
|
|
11
|
+
//
|
|
12
|
+
// - `billing` → `Customer.address` / `city` / `province` / `postalCode`
|
|
13
|
+
// - `delivery` → `Customer.deliveryAddress`
|
|
14
|
+
//
|
|
15
|
+
// Every existing reader of those fields keeps working unchanged. Forward-only:
|
|
16
|
+
// a customer written before the address book has no address rows; the first
|
|
17
|
+
// edit of their address (through `/customers/addresses`, `POST /customers`, the
|
|
18
|
+
// storefront profile, or an order's `saveAsDefault`) creates the row and points
|
|
19
|
+
// the default at it. Nothing sweeps.
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/**
|
|
3
|
+
* One contact as it crosses the wire — an explicit allow-list of the stored
|
|
4
|
+
* row (no `PK`/`SK`, no `storeId`).
|
|
5
|
+
*
|
|
6
|
+
* `contactId` is the row's sort key — `{13-digit creation ms}-{8 hex}` —
|
|
7
|
+
* opaque to a client: address a row by `{ customerId, contactId }`, never
|
|
8
|
+
* parse it. Every text field is an empty string when unset.
|
|
9
|
+
*/
|
|
10
|
+
interface CustomerContact {
|
|
11
|
+
contactId: string;
|
|
12
|
+
customerId: string;
|
|
13
|
+
/** The person's name. */
|
|
14
|
+
fullName: string;
|
|
15
|
+
/** What they do for the customer ("Compras", "Pagos", "Encargado"). Free text. */
|
|
16
|
+
role: string;
|
|
17
|
+
phone: string;
|
|
18
|
+
email: string;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
updatedAt: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `GET /customers/contacts?customerId=` — one page, ascending by `contactId`
|
|
24
|
+
* (oldest first).
|
|
25
|
+
*/
|
|
26
|
+
interface CustomerContactPage {
|
|
27
|
+
items: CustomerContact[];
|
|
28
|
+
/** Opaque; pass back as `?startKey=`. Absent once the walk is drained. */
|
|
29
|
+
nextCursor?: string;
|
|
30
|
+
/** `true` whenever more contacts exist past this page — never a silent prefix. */
|
|
31
|
+
truncated: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `data` of the `customerContact` socket frame. OPERATOR audience only — the
|
|
35
|
+
* customer's own socket is NOT addressed.
|
|
36
|
+
*
|
|
37
|
+
* `contact` is the whole row on the admin tier for `created` / `updated`,
|
|
38
|
+
* and absent on `deleted`. It is ALWAYS absent on the copy an operator socket
|
|
39
|
+
* that cannot prove admin tier receives (`lowTierData` — the ids only,
|
|
40
|
+
* `{ change, customerId, contactId }`, or `{ change, customerId, movedTo? }`
|
|
41
|
+
* for `purged`). The low tier is every socket that is not ADMIN, SUPERVISOR
|
|
42
|
+
* or MANAGER — a USER WITH the `customers` flag included — so the frame never
|
|
43
|
+
* carries a contact there; a capable USER refetches through the gated GET.
|
|
44
|
+
*
|
|
45
|
+
* `purged` is ONE frame for the whole customer: drop every cached contact for
|
|
46
|
+
* `customerId`. Sent when the Ley 25.326 art. 16 erasure deleted them (no
|
|
47
|
+
* `movedTo`), and when a customer merge moved them to the survivor
|
|
48
|
+
* (`movedTo` = survivor's id — refetch its list).
|
|
49
|
+
*/
|
|
50
|
+
type CustomerContactChange = {
|
|
51
|
+
change: 'created' | 'updated' | 'deleted';
|
|
52
|
+
customerId: string;
|
|
53
|
+
contactId: string;
|
|
54
|
+
contact?: CustomerContact;
|
|
55
|
+
} | {
|
|
56
|
+
change: 'purged';
|
|
57
|
+
customerId: string;
|
|
58
|
+
movedTo?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* One contact as the STAFF art. 14 export carries it: the contact and its
|
|
62
|
+
* dates. The self-service export never reads the contacts partition.
|
|
63
|
+
*/
|
|
64
|
+
interface CustomerContactExportEntry {
|
|
65
|
+
contactId: string;
|
|
66
|
+
fullName: string;
|
|
67
|
+
role: string;
|
|
68
|
+
phone: string;
|
|
69
|
+
email: string;
|
|
70
|
+
createdAt: number;
|
|
71
|
+
updatedAt: number;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Every DOMAIN refusal on `/customers/contacts`, one bare code each (the
|
|
75
|
+
* generic `VALIDATION_FAILED`, `CAPABILITY_REQUIRED` and `INVALID_CURSOR`
|
|
76
|
+
* are not listed). None of them writes.
|
|
77
|
+
*
|
|
78
|
+
* - `CUSTOMER_CONTACT_CUSTOMER_NOT_FOUND` (404) — not a customer of the
|
|
79
|
+
* caller's store; covers «no such id», so the route is no cross-tenant
|
|
80
|
+
* existence oracle. DELETE is the exception: it reads the contact
|
|
81
|
+
* first, so an unknown or foreign customer answers
|
|
82
|
+
* `CUSTOMER_CONTACT_NOT_FOUND` there (same 404).
|
|
83
|
+
* - `CUSTOMER_CONTACT_CUSTOMER_ANONYMIZED` (409) — erased under Ley 25.326
|
|
84
|
+
* art. 16; enforced atomically with the write.
|
|
85
|
+
* - `CUSTOMER_CONTACT_CUSTOMER_MERGED` (409) — folded into another customer
|
|
86
|
+
* (`mergedInto`); write on the survivor.
|
|
87
|
+
* - `CUSTOMER_CONTACT_CUSTOMER_MERGE_IN_PROGRESS` (409) — a merge INTO this
|
|
88
|
+
* customer is unfinished; its contacts are still arriving. Retry once the
|
|
89
|
+
* merge completes.
|
|
90
|
+
* - `CUSTOMER_CONTACT_NOT_FOUND` (404) — no such contact for that customer.
|
|
91
|
+
* - `CUSTOMER_CONTACT_WRITE_CONTENDED` (503) — the contact was edited under
|
|
92
|
+
* every bounded retry; retry is safe.
|
|
93
|
+
*/
|
|
94
|
+
type CustomerContactErrorCode = 'CUSTOMER_CONTACT_CUSTOMER_NOT_FOUND' | 'CUSTOMER_CONTACT_CUSTOMER_ANONYMIZED' | 'CUSTOMER_CONTACT_CUSTOMER_MERGED' | 'CUSTOMER_CONTACT_CUSTOMER_MERGE_IN_PROGRESS' | 'CUSTOMER_CONTACT_NOT_FOUND' | 'CUSTOMER_CONTACT_WRITE_CONTENDED';
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// A customer's CONTACTS: the people who act for one customer — the person who
|
|
2
|
+
// orders is not always the person who pays, and both belong to that customer.
|
|
3
|
+
//
|
|
4
|
+
// Purely ADDITIVE. Nothing on the CUSTOMER row mirrors a contact: `Customer.phone`
|
|
5
|
+
// and `Customer.email` stay the customer's OWN details (`email` is a login
|
|
6
|
+
// identity with a uniqueness claim, and SMS / marketing read `phone` / `email`
|
|
7
|
+
// directly), so there is no default contact, no pointer and no legacy writer to
|
|
8
|
+
// keep in step. A contact is never a notification target and never feeds the
|
|
9
|
+
// customer's `search` index.
|
|
10
|
+
//
|
|
11
|
+
// ⚠️ A contact is ANOTHER person's personal data (Ley 25.326), held by the store
|
|
12
|
+
// about the customer's staff. Never log a contact's name, phone or email, and
|
|
13
|
+
// never hand one to the customer unreviewed: the art. 14 export carries contacts
|
|
14
|
+
// on the STAFF surface only, never on the storefront self-service export.
|
|
15
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export * from './cash.ts';
|
|
|
15
15
|
export * from './categories.ts';
|
|
16
16
|
export * from './currency.ts';
|
|
17
17
|
export * from './customer.ts';
|
|
18
|
+
export * from './customerAddress.ts';
|
|
19
|
+
export * from './customerContact.ts';
|
|
18
20
|
export * from './customerNote.ts';
|
|
19
21
|
export * from './cycleCount.ts';
|
|
20
22
|
export * from './delivery.ts';
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ export * from "./cash.js";
|
|
|
23
23
|
export * from "./categories.js";
|
|
24
24
|
export * from "./currency.js";
|
|
25
25
|
export * from "./customer.js";
|
|
26
|
+
export * from "./customerAddress.js";
|
|
27
|
+
export * from "./customerContact.js";
|
|
26
28
|
export * from "./customerNote.js";
|
|
27
29
|
export * from "./cycleCount.js";
|
|
28
30
|
export * from "./delivery.js";
|
package/dist/socket.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* A client must ignore actions it does not own rather than assume it
|
|
27
27
|
* receives all of them.
|
|
28
28
|
*/
|
|
29
|
-
export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "automation-rules", "baskets", "cart", "brands", "cash", "categories", "campaigns", "customers", "customerNote", "deliveries", "globals", "inventory", "invoices", "literals", "loyalty", "orders", "presupuestos", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "whatsapp-message", "payment_received", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts", "stockTransfers"];
|
|
29
|
+
export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "automation-rules", "baskets", "cart", "brands", "cash", "categories", "campaigns", "customers", "customerNote", "customerAddress", "customerContact", "deliveries", "globals", "inventory", "invoices", "literals", "loyalty", "orders", "presupuestos", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "whatsapp-message", "payment_received", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts", "stockTransfers"];
|
|
30
30
|
/** Union of every server→client data-frame action. */
|
|
31
31
|
export type SocketAction = (typeof SOCKET_ACTIONS)[number];
|
|
32
32
|
/**
|
package/dist/socket.js
CHANGED
|
@@ -156,6 +156,25 @@ export const SOCKET_ACTIONS = [
|
|
|
156
156
|
* `dynamoUpdate`'s own `'operator-and-customer'` fan-out never runs.
|
|
157
157
|
*/
|
|
158
158
|
'customerNote',
|
|
159
|
+
/**
|
|
160
|
+
* A customer's address-book row was created, edited or deleted, or its
|
|
161
|
+
* kind's default moved — or every address of one customer was erased or
|
|
162
|
+
* moved by a merge (`change: 'purged'`). `data` is `CustomerAddressChange`.
|
|
163
|
+
* OPERATOR audience only, with an ids-only `lowTierData`; the rows are
|
|
164
|
+
* written by raw transactions, or as extra `transactions` items on a
|
|
165
|
+
* `dynamoUpdate` whose echo carries only the CUSTOMER row, so no automatic
|
|
166
|
+
* `'operator-and-customer'` fan-out carries them.
|
|
167
|
+
*/
|
|
168
|
+
'customerAddress',
|
|
169
|
+
/**
|
|
170
|
+
* A customer's contact (a person acting for the customer) was created,
|
|
171
|
+
* edited or deleted — or every contact of one customer was erased or moved
|
|
172
|
+
* by a merge (`change: 'purged'`). `data` is `CustomerContactChange`.
|
|
173
|
+
* OPERATOR audience only, with an ids-only `lowTierData`; the rows are
|
|
174
|
+
* written by raw transactions, so no automatic `'operator-and-customer'`
|
|
175
|
+
* fan-out carries them.
|
|
176
|
+
*/
|
|
177
|
+
'customerContact',
|
|
159
178
|
/**
|
|
160
179
|
* A delivery created, or an event appended to its timeline. Operator-only —
|
|
161
180
|
* `wsPostStore(..., { audience: 'operator' })`, NEVER
|