@focusbc/bbs-lib 0.0.11 → 0.0.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +0 -211
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@focusbc/bbs-lib",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "BBS map rendering library (deck.gl + @focusbc/map-rendering)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/readme.md CHANGED
@@ -49,214 +49,3 @@ overlay.rightClick().subscribe(({ shape, lat, lng }) => {
49
49
 
50
50
  overlay.setContext(newContext)
51
51
  ```
52
-
53
- ---
54
-
55
- ## Development
56
-
57
- Install dependencies and build from the `bbs-lib/` directory:
58
-
59
- ```bash
60
- yarn install
61
- yarn build
62
- ```
63
-
64
- From the repository root:
65
-
66
- ```bash
67
- yarn bbs-lib build
68
- ```
69
-
70
- `yarn build` produces two outputs under `dist/`:
71
-
72
- | Output | Used by |
73
- |--------|---------|
74
- | `dist/index.js` (+ types) | npm consumers (`import '@focusbc/bbs-lib'`) |
75
- | `dist/browser/bbs-lib.js` | Browser `import()` — uploaded to Cloud Storage and served by the Integration API |
76
-
77
- Only `dist/**/*` and this README are published to npm. The `demo/` and `sandbox/` folders are not included in the npm package.
78
-
79
- ---
80
-
81
- ## Local testing
82
-
83
- ### Sandbox (library development)
84
-
85
- The `sandbox/` folder bundles the **local library source** and is meant for day-to-day development.
86
-
87
- 1. Copy `sandbox/config.example.ts` to `sandbox/config.ts` and set `INTEGRATION_API_BASE` and `BBS_API_KEY`.
88
- 2. Start the Integration API locally.
89
- 3. Build and serve:
90
-
91
- ```bash
92
- yarn sandbox:build
93
- npx --yes serve sandbox -p 5173
94
- # or: yarn sandbox:watch (rebuild on save)
95
- ```
96
-
97
- ### Client demo
98
-
99
- The client-facing reference lives in [`demo/`](demo/). It loads the pre-built browser bundle from the deployed Integration API — no local library build. See [`demo/README.md`](demo/README.md).
100
-
101
- ```bash
102
- yarn demo:serve # http://localhost:5174
103
- ```
104
-
105
- ---
106
-
107
- ## How the library is delivered
108
-
109
- There are **two separate publish paths**. They share the same source but target different consumers:
110
-
111
- ```txt
112
- yarn build
113
- ├── dist/index.js → npm publish → apps using a bundler
114
- └── dist/browser/bbs-lib.js → gcloud upload → GCS bucket → Integration API /bbs-lib/*
115
- ↑
116
- config/environments.sh
117
- ```
118
-
119
- | Path | Command | Destination | Who uses it |
120
- |------|---------|-------------|-------------|
121
- | **npm package** | `yarn release:lib` (includes `npm publish`) | [npm registry](https://www.npmjs.com/package/@focusbc/bbs-lib) | Teams importing the library in their own build |
122
- | **Browser bundle** | `yarn upload:browser` (or part of `release:lib`) | Cloud Storage bucket for staging or production | The [`demo/`](demo/) and any client doing `import(url)` without a bundler |
123
-
124
- The browser bundle is **not** loaded from Cloud Storage directly. The Integration API exposes it anonymously at `/bbs-lib/latest/bbs-lib.js` and reads from the bucket configured in its own deployment (`integration-api/appsettings.*.json`).
125
-
126
- ---
127
-
128
- ## Upload environments — `config/environments.sh`
129
-
130
- This file is the **single place to define where the browser bundle is uploaded**. It is used by:
131
-
132
- - `scripts/upload-browser-bundle.sh` (`yarn upload:browser`)
133
- - `scripts/release-lib.sh` (`yarn release:lib`)
134
-
135
- It does **not** affect:
136
-
137
- - The npm registry
138
- - The client [`demo/`](demo/) configuration (that lives in `demo/index.html`)
139
- - Which bucket the Integration API reads from at runtime (that is `Storage.BucketName` in `integration-api/appsettings.<Environment>.json`)
140
-
141
- ### What it contains
142
-
143
- ```bash
144
- BBS_LIB_DEFAULT_ENVIRONMENT=staging # used when BBS_LIB_ENVIRONMENT is not set
145
-
146
- BBS_LIB_STAGING_BUCKET=vv-tenant-uefa-transition-stg
147
- BBS_LIB_PRODUCTION_BUCKET=vv-tenant-uefa-prd
148
- ```
149
-
150
- The bucket names **must match** `Storage.BucketName` in the corresponding Integration API appsettings file. If they diverge, uploads will succeed but the API will serve stale or missing files.
151
-
152
- ### Choosing staging vs production
153
-
154
- By default, all uploads go to **staging**:
155
-
156
- ```bash
157
- yarn upload:browser # → gs://vv-tenant-uefa-transition-stg/bbs-lib/...
158
- yarn release:lib # → npm + staging bucket
159
- ```
160
-
161
- To target **production**:
162
-
163
- ```bash
164
- BBS_LIB_ENVIRONMENT=production yarn upload:browser
165
- BBS_LIB_ENVIRONMENT=production yarn release:lib
166
- ```
167
-
168
- Each command uploads to **one** environment only. There is no automatic dual upload.
169
-
170
- ### Where files land in the bucket
171
-
172
- After upload, objects are written to:
173
-
174
- ```txt
175
- gs://<bucket>/bbs-lib/latest/bbs-lib.js ← demo loads this via the API
176
- gs://<bucket>/bbs-lib/latest/bbs-lib.js.map
177
- gs://<bucket>/bbs-lib/versions/<package-version>/bbs-lib.js
178
- gs://<bucket>/bbs-lib/versions/<package-version>/bbs-lib.js.map
179
- ```
180
-
181
- ### Advanced overrides
182
-
183
- These take precedence over `BBS_LIB_ENVIRONMENT` (rarely needed):
184
-
185
- ```bash
186
- BBS_LIB_BUCKET=vv-tenant-uefa-prd yarn upload:browser
187
- BBS_LIB_BUCKET_URI=gs://vv-tenant-uefa-prd/bbs-lib yarn upload:browser
188
- ```
189
-
190
- If a previous release exported `BBS_LIB_BUCKET_URI` in your shell, run `unset BBS_LIB_BUCKET_URI` before uploading, or pass the target explicitly.
191
-
192
- ---
193
-
194
- ## Releasing
195
-
196
- ### Prerequisites
197
-
198
- 1. Access to publish `@focusbc/bbs-lib` under the `@focusbc` npm scope.
199
- 2. [Google Cloud CLI](https://cloud.google.com/sdk) installed and authenticated (`gcloud auth login`).
200
- 3. Permission to decrypt/encrypt with the KMS key used by `auxiliary/scripts/decrypt_file.sh`.
201
- 4. `bbs-lib/.npmrc.enc` present (encrypted npm token — the only credential file committed to the repo).
202
-
203
- ### Full release — `yarn release:lib`
204
-
205
- Runs `scripts/release-lib.sh`. From `bbs-lib/`:
206
-
207
- ```bash
208
- yarn release:lib # patch bump (default): 0.0.5 → 0.0.6
209
- yarn release:lib minor # minor bump
210
- yarn release:lib major # major bump
211
- ```
212
-
213
- From the repository root: `yarn release:bbs-lib`
214
-
215
- **What the script does, in order:**
216
-
217
- 1. Decrypts `bbs-lib/.npmrc.enc` into a temporary `.npmrc`.
218
- 2. Bumps the version in `package.json` (`--no-git-tag-version`).
219
- 3. Runs `yarn build` (TypeScript + browser bundle).
220
- 4. Publishes to npm (`npm publish --access public`).
221
- 5. Uploads `dist/browser/bbs-lib.js` to the bucket defined in [`config/environments.sh`](config/environments.sh) (staging by default).
222
- 6. Re-encrypts and removes the temporary `.npmrc`.
223
-
224
- If the script fails **after** the version bump, check `package.json` before retrying — the version may already have been incremented locally.
225
-
226
- ### Upload browser bundle only — `yarn upload:browser`
227
-
228
- Use this when you need to refresh the hosted JS **without** publishing a new npm version:
229
-
230
- ```bash
231
- yarn build
232
- yarn upload:browser
233
- ```
234
-
235
- Same environment selection as above (`BBS_LIB_ENVIRONMENT=production` for production).
236
-
237
- ### Recommended workflow
238
-
239
- ```txt
240
- 1. Develop and test locally → sandbox/
241
- 2. Full release to staging → yarn release:lib
242
- 3. Verify the client demo → yarn demo:serve (demo points at staging API)
243
- 4. Promote bundle to production → BBS_LIB_ENVIRONMENT=production yarn upload:browser
244
- (or yarn release:lib if you also need a new npm version)
245
- 5. Deploy Integration API → only if API code changed (e.g. /bbs-lib endpoint)
246
- ```
247
-
248
- Steps 2 and 4 upload to Cloud Storage. Step 5 is only needed when the Integration API itself changed — the demo loads the bundle through the already-deployed API.
249
-
250
- ---
251
-
252
- ## Folder reference
253
-
254
- | Path | Purpose |
255
- |------|---------|
256
- | `src/` | Library source |
257
- | `dist/` | Build output (npm + browser bundle) |
258
- | `demo/` | Client-facing static demo — see [`demo/README.md`](demo/README.md) |
259
- | `sandbox/` | Internal dev page bundling local source |
260
- | [`config/environments.sh`](config/environments.sh) | Browser bundle upload targets (staging / production buckets) |
261
- | `scripts/release-lib.sh` | Full release pipeline |
262
- | `scripts/upload-browser-bundle.sh` | Browser bundle upload only |