buzzcasting-storage 3.21.2 → 3.21.4

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.
@@ -1,5 +1,5 @@
1
1
  //#region \0rolldown/runtime.js
2
- var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, i, o, s) => {
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
3
  if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
4
  get: ((e) => i[e]).bind(null, d),
5
5
  enumerable: !(s = n(i, d)) || s.enumerable
@@ -118,7 +118,42 @@ var ee = (e) => {
118
118
  level: e,
119
119
  message: t
120
120
  });
121
- }, E = (e) => {
121
+ };
122
+ (class e {
123
+ static EPOCH = Date.UTC(1970, 0, 1).valueOf();
124
+ static SHARD_ID = 1;
125
+ static SEQUENCE = 1;
126
+ static generate({ timestamp: t = Date.now(), shard_id: n = e.SHARD_ID } = {}) {
127
+ t = t instanceof Date ? t.valueOf() : new Date(t).valueOf();
128
+ let r = BigInt(t) - BigInt(e.EPOCH) << BigInt(22);
129
+ return r |= BigInt(n % 1024) << BigInt(12), r |= BigInt(e.SEQUENCE++ % 4096), r.toString();
130
+ }
131
+ static parse(t) {
132
+ let n = e.binary(t);
133
+ return {
134
+ timestamp: e.extractBits(t, 1, 41),
135
+ shard_id: e.extractBits(t, 42, 10),
136
+ sequence: e.extractBits(t, 52),
137
+ binary: n
138
+ };
139
+ }
140
+ static isValid(t) {
141
+ if (!/^[\d]{19}$/.test(t)) return !1;
142
+ try {
143
+ return e.parse(t), !0;
144
+ } catch {
145
+ return !1;
146
+ }
147
+ }
148
+ static extractBits(t, n, r) {
149
+ return parseInt(r ? e.binary(t).substring(n, n + r) : e.binary(t).substring(n), 2);
150
+ }
151
+ static binary(e) {
152
+ let t = BigInt(e).toString(2);
153
+ return t.length < 64 ? "0000000000000000000000000000000000000000000000000000000000000000".substring(0, 64 - t.length) + t : t;
154
+ }
155
+ });
156
+ var E = (e) => {
122
157
  switch (e?.type) {
123
158
  case l.MESSAGES: return u.MESSAGES;
124
159
  case l.SERIES: return u.SERIES;
@@ -160,7 +195,7 @@ function ne(e, t) {
160
195
  }({});
161
196
  //#endregion
162
197
  //#region package.json
163
- var re = "3.21.1", ie = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
198
+ var re = "3.21.3", ie = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
164
199
  (function(n, r) {
165
200
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self, n.readNDJSONStream = r());
166
201
  })(e, (function() {
@@ -478,7 +513,7 @@ var re = "3.21.1", ie = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
478
513
  ].join("/"), {
479
514
  ...n,
480
515
  body: r,
481
- method: "put"
516
+ method: "post"
482
517
  }).then((e) => {
483
518
  if (!e.ok) throw Error(e.statusText);
484
519
  return e;
@@ -4651,7 +4686,7 @@ var { liveQuery: j, mergeRanges: oe, rangesOverlap: se, RangeSet: ce, cmp: le, E
4651
4686
  }
4652
4687
  };
4653
4688
  hideMessage = async (e, t) => {
4654
- await this.db.table(l.TOPICS).where("message_id").equals(e).modify({ visible: t ? 1 : 0 }).catch((e) => (console.error("%chide%c %cstorage%c %cmessage", u.KO, u.NONE, u.STORAGE, u.NONE, u.HIDE, e.message), 0));
4689
+ await this.db.table(l.TOPICS).where("message_id").equals(e).modify({ visible: +!!t }).catch((e) => (console.error("%chide%c %cstorage%c %cmessage", u.KO, u.NONE, u.STORAGE, u.NONE, u.HIDE, e.message), 0));
4655
4690
  };
4656
4691
  setMessages = async (e, t) => {
4657
4692
  if (e.type !== l.MESSAGES) return 400;
@@ -4672,7 +4707,7 @@ var { liveQuery: j, mergeRanges: oe, rangesOverlap: se, RangeSet: ce, cmp: le, E
4672
4707
  impressions: i.topics[0]?.impressions || i.dynamics?.semrush_visits || 0,
4673
4708
  reach: i.topics[0]?.reach || i.dynamics?.potential_reach || 0,
4674
4709
  sentiment: i.topics[0]?.sentiment || 0,
4675
- approved: i.topics[0]?.approved ? 1 : 0
4710
+ approved: +!!i.topics[0]?.approved
4676
4711
  }, await this.db.table(l.MESSAGES).put({
4677
4712
  id: i.id,
4678
4713
  utc: i.utc,
@@ -4716,7 +4751,7 @@ var { liveQuery: j, mergeRanges: oe, rangesOverlap: se, RangeSet: ce, cmp: le, E
4716
4751
  e.message
4717
4752
  ]);
4718
4753
  }), await t.data.topics.forEach(async (e) => {
4719
- let t = e.message_id, n = e.visible ? 1 : 0, i = e.approve ? 1 : 0, a = e.title;
4754
+ let t = e.message_id, n = +!!e.visible, i = +!!e.approve, a = e.title;
4720
4755
  await this.db.table(l.TOPICS).where("message_id").equals(t).modify({
4721
4756
  visible: n,
4722
4757
  approve: i
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "buzzcasting-storage",
3
3
  "type": "module",
4
- "version": "3.21.2",
4
+ "version": "3.21.4",
5
5
  "private": false,
6
6
  "author": {
7
7
  "name": "Mark Tamis, TouchFlows SAS",
@@ -44,7 +44,7 @@
44
44
  "@typescript-eslint/eslint-plugin": "^8.57.1",
45
45
  "@typescript-eslint/parser": "^8.57.1",
46
46
  "@vitest/coverage-v8": "^4.1.0",
47
- "buzzcasting-utils": "^1.13.0",
47
+ "buzzcasting-utils": "^1.13.5",
48
48
  "camelcase": "^9.0.0",
49
49
  "changelogen": "^0.6.2",
50
50
  "eslint": "^9.39.4",
@@ -52,11 +52,11 @@
52
52
  "typedoc": "^0.28.17",
53
53
  "typedoc-plugin-markdown": "^4.11.0",
54
54
  "typescript": "^5.9.3",
55
- "vite": "^8.0.1",
55
+ "vite": "^8.1.2",
56
56
  "vite-plugin-dts": "^4.5.4",
57
57
  "vitest": "^4.1.0"
58
58
  },
59
59
  "lint-staged": {
60
60
  "*.ts": "npm run lint"
61
61
  }
62
- }
62
+ }