buzzcasting-storage 3.21.4 → 3.21.8
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/README.md +38 -41
- package/dist/buzzcasting-storage.d.ts +10 -0
- package/dist/buzzcasting-storage.esm.js +325 -328
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -6,6 +6,15 @@ BuzzCasting Social Media Wall & Dataviz [More info](https://www.touchflows.com/s
|
|
|
6
6
|
|
|
7
7
|
Currently supported are: Local Storage, Session Storage, IDB Keyval, Dexie, Window object
|
|
8
8
|
|
|
9
|
+
## Documentation
|
|
10
|
+
|
|
11
|
+
`docs/` is typedoc-generated API reference (regenerated by `npm run docs`, overwritten every time — don't hand-edit it). Hand-written architecture guides live in [`documentation/`](documentation/) instead:
|
|
12
|
+
|
|
13
|
+
- [documentation/architecture.md](documentation/architecture.md) — the `BuzzcastingStorageManager`/`Widget`/`BuzzcastingStorageReader` pipeline, the subscribe → fetch → hash-diff → broadcast → re-read data flow, and why a `Widget` can only ever render `cloud`/`series`/`messages` data.
|
|
14
|
+
- [documentation/storage-backends.md](documentation/storage-backends.md) — the five interchangeable storage backends, the Dexie schema, and the staleness/expiry model (there isn't much of one).
|
|
15
|
+
- [documentation/known-issues.md](documentation/known-issues.md) — confirmed bugs and inconsistencies in the current codebase (e.g. `ApiClient.loadDashboards` actually fetching the widgets endpoint, not a dashboards one) worth knowing about before you hit them yourself.
|
|
16
|
+
- [documentation/moderation.md](documentation/moderation.md) — `hideMessage`/`hideLabels`: a soft `visible` flag in Dexie plus a remote call for messages, a remote-only call with no local implementation at all for cloud labels, and the separate, deployment-time `MODERATION` enum that gates which messages are ever fetched in the first place.
|
|
17
|
+
|
|
9
18
|
## Features
|
|
10
19
|
|
|
11
20
|
- ✨ Fully customized [eslint](https://eslint.org/) configuration based on the config by [Antfu](https://github.com/antfu/eslint-config)
|
|
@@ -18,59 +27,47 @@ Currently supported are: Local Storage, Session Storage, IDB Keyval, Dexie, Wind
|
|
|
18
27
|
|
|
19
28
|
## Get started
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
```ts
|
|
24
|
-
import BuzzcastingStorageManager, {
|
|
25
|
-
IMessages,
|
|
26
|
-
IQuery,
|
|
27
|
-
IStorageManager,
|
|
28
|
-
} from 'buzzcasting-storage'
|
|
29
|
-
|
|
30
|
-
const options: IStorageManager = {
|
|
31
|
-
app: 'my-subdomain',
|
|
32
|
-
version: 'v4',
|
|
33
|
-
token: 'meta',
|
|
34
|
-
bearer: 'bearer_token',
|
|
35
|
-
storage: 'dexie',
|
|
36
|
-
moderation: 'none',
|
|
37
|
-
beforeTime: null,
|
|
38
|
-
delay: 0,
|
|
39
|
-
period: 0,
|
|
40
|
-
}
|
|
30
|
+
This package has two entry points, used by two different kinds of consumer — see [documentation/architecture.md](documentation/architecture.md) for the full picture.
|
|
41
31
|
|
|
42
|
-
|
|
32
|
+
**A rendered widget component** (e.g. a `cards-widget`/`series-widget`/`cloud-widget` in `buzzcasting-app`) uses `Widget`, keyed off its own `data-*` attributes:
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
```ts
|
|
35
|
+
import { Widget } from 'buzzcasting-storage'
|
|
36
|
+
import type { IResponse } from 'buzzcasting-utils'
|
|
37
|
+
|
|
38
|
+
// element.dataset.{widget,dashboard,type} become the query; window.__bc.opts
|
|
39
|
+
// must already be set up by the host app (it supplies `presentation`).
|
|
40
|
+
const setData = (response: IResponse) => {
|
|
41
|
+
if (!response.success) return
|
|
42
|
+
// ...update component state from response.data
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
const
|
|
45
|
+
const widget = new Widget(element, [setData])
|
|
46
|
+
widget.subscribe() // registers with the app-level BuzzcastingStorageManager
|
|
51
47
|
```
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
`Widget` only supports `series`, `cloud`, and `messages` query types — nothing else (this is a hard architectural constraint, see [documentation/architecture.md](documentation/architecture.md)).
|
|
54
50
|
|
|
55
|
-
The
|
|
51
|
+
**The host app itself** (once, at startup) constructs the orchestrator every `Widget` rendezvouses with over a shared `BroadcastChannel`:
|
|
56
52
|
|
|
57
53
|
```ts
|
|
58
|
-
|
|
54
|
+
import { BuzzcastingStorageManager } from 'buzzcasting-storage'
|
|
55
|
+
import type { IStorageOptions } from 'buzzcasting-utils'
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
const options: IStorageOptions = {
|
|
58
|
+
app: 'my-subdomain',
|
|
59
|
+
version: 'v4',
|
|
60
|
+
presentation: 'presentation_id',
|
|
61
|
+
locale: 'en-US',
|
|
62
|
+
bearer: 'bearer_token',
|
|
63
|
+
storage: 'dexie', // the only backend actually exercised in production - see documentation/storage-backends.md
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
break
|
|
70
|
-
default:
|
|
71
|
-
// console.log('[storage]', messageEvent.data)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
66
|
+
const storageManager = new BuzzcastingStorageManager(options)
|
|
67
|
+
storageManager.startBroadcastListener() // begins listening for widget SUBSCRIBE/UPDATE events
|
|
68
|
+
|
|
69
|
+
// on whatever interval/event the host app decides:
|
|
70
|
+
await storageManager.update()
|
|
74
71
|
```
|
|
75
72
|
|
|
76
73
|
### Git Clone
|
|
@@ -25,6 +25,7 @@ export declare class BuzzcastingStorageManager {
|
|
|
25
25
|
cleanMessages: () => Promise<void>;
|
|
26
26
|
hideMessage: (query: IQuery) => Promise<IResponse>;
|
|
27
27
|
hideLabels: (query: IQuery) => Promise<IResponse>;
|
|
28
|
+
approveMessage: (query: IQuery) => Promise<void>;
|
|
28
29
|
getSubscribers: () => Promise<any[]>;
|
|
29
30
|
deleteSubscribers: () => Promise<any[]>;
|
|
30
31
|
bulk: (table: string, queries: IQuery[]) => Promise<IResponse | number | undefined>;
|
|
@@ -128,6 +129,15 @@ export declare class Widget {
|
|
|
128
129
|
* This takes place when the container indicates it has finished loading (ready)
|
|
129
130
|
*/
|
|
130
131
|
subscribe(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Tell the container to drop this widget from its subscriber list - the
|
|
134
|
+
* counterpart to subscribe(), called from destroy() when the widget's own
|
|
135
|
+
* component unmounts (e.g. the builder switches to a different slide).
|
|
136
|
+
* Without this, the container's subscriber list only ever grows: every
|
|
137
|
+
* widget ever mounted in the session stays in it, and every periodic
|
|
138
|
+
* refresh re-fetches all of them, not just the ones actually on screen.
|
|
139
|
+
*/
|
|
140
|
+
unsubscribe(): void;
|
|
131
141
|
/**
|
|
132
142
|
* Generic call to any query type
|
|
133
143
|
*
|