wontopos 2.2.28 → 2.2.29
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/wontopos.js +20 -8
- package/package.json +1 -1
package/dist/wontopos.js
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* runtime's (never disabled by this SDK; Node 18+ floors TLS at 1.2). Prefer
|
|
38
38
|
* `Client.fromEnv()` over keys in source code.
|
|
39
39
|
*/
|
|
40
|
-
const VERSION = "2.2.
|
|
40
|
+
const VERSION = "2.2.29";
|
|
41
41
|
/** Runtime info helps support debug a report ("node 18 on Windows...") —
|
|
42
42
|
* platform only, never anything identifying. Browsers have no `process` (and
|
|
43
43
|
* silently drop the UA header anyway). */
|
|
@@ -448,9 +448,18 @@ export class Client {
|
|
|
448
448
|
// tenant id and got nothing. Falling back there writes one customer's memories into
|
|
449
449
|
// whatever store this client defaults to, silently. Omission is a choice; a blank
|
|
450
450
|
// string is a bug, and it should say so where it happened.
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
//
|
|
452
|
+
// The check is `typeof !== "string"`, not `!String(userId).trim()`. The old form
|
|
453
|
+
// only caught a blank STRING, and the value a failed lookup actually produces in
|
|
454
|
+
// JavaScript is `null` — `String(null)` is the truthy "null", so it sailed through
|
|
455
|
+
// the guard and then `null || default` sent the write to the client's default
|
|
456
|
+
// store. `0` (an integer primary key) did the same. Both are the exact outcome the
|
|
457
|
+
// guard was written to stop, and both were still silent.
|
|
458
|
+
//
|
|
459
|
+
// `undefined` alone means "omitted", because that is what an absent argument is.
|
|
460
|
+
if (userId !== undefined && (typeof userId !== "string" || !userId.trim())) {
|
|
461
|
+
throw new Error(`userId must be a non-blank string; got ${JSON.stringify(userId)}. Omit it to use the client's ` +
|
|
462
|
+
"default store, or pass a real store id — anything else would silently write into the default store.");
|
|
454
463
|
}
|
|
455
464
|
const id = userId || this.defaultUser;
|
|
456
465
|
warnIfStoreIdCollapses(id);
|
|
@@ -682,9 +691,12 @@ export class Client {
|
|
|
682
691
|
}
|
|
683
692
|
/** Delete a store and ALL its memories. Returns `{ user_id, status }`. */
|
|
684
693
|
deleteStore(userId) {
|
|
694
|
+
// Validate BEFORE warning. The warning helper lowercases the id, so a non-string
|
|
695
|
+
// used to die there as "id.toLowerCase is not a function" — the caller got a
|
|
696
|
+
// TypeError from our internals instead of being told what was wrong with the id.
|
|
697
|
+
if (typeof userId !== "string" || !userId.trim())
|
|
698
|
+
throw new Error("userId is required (a non-blank string) — deleteStore never falls back to the default store.");
|
|
685
699
|
warnIfStoreIdCollapses(userId); // destructive: the collision warning belongs here too
|
|
686
|
-
if (!userId || !userId.trim())
|
|
687
|
-
throw new Error("userId is required (non-blank) — deleteStore never falls back to the default store.");
|
|
688
700
|
return this.request("DELETE", "/api/v1/memory/collection", { user_id: userId });
|
|
689
701
|
}
|
|
690
702
|
// ----- speakers (who said it) -----
|
|
@@ -722,8 +734,8 @@ export class Client {
|
|
|
722
734
|
/** Delete ALL memories for a store (GDPR erase). `userId` is required on purpose -
|
|
723
735
|
* this is destructive, so it never falls back to the default store. */
|
|
724
736
|
deleteAll(userId) {
|
|
725
|
-
if (
|
|
726
|
-
throw new Error("userId is required (non-blank) for deleteAll —
|
|
737
|
+
if (typeof userId !== "string" || !userId.trim())
|
|
738
|
+
throw new Error("userId is required (a non-blank string) for deleteAll — anything else would wipe the default store.");
|
|
727
739
|
// These two take the store id directly instead of going through uid(), so the
|
|
728
740
|
// collision warning — the one that says `Alice.Smith` and `alice_smith` are ONE
|
|
729
741
|
// store — never fired on the two calls that DESTROY data. Erasing the wrong
|
package/package.json
CHANGED