@tandem-language-exchange/content-store 1.0.12 → 1.0.13

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/README.md +81 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -34,6 +34,33 @@ const sdk = new ContentStoreSDK({
34
34
  | `s3.secretAccessKey` | AWS IAM secret key |
35
35
  | `outputDir` | Local directory where bundle JSON files are written |
36
36
 
37
+ ### S3 config via environment variables
38
+
39
+ The CLI commands (`fetch-content-bundles`, `query`) read S3 credentials automatically from the following environment variables — no code needed:
40
+
41
+ | Variable | Description |
42
+ | --- | --- |
43
+ | `CONTENT_STORE_S3_BUCKET` | S3 bucket name |
44
+ | `CONTENT_STORE_S3_REGION` | AWS region (default: `eu-central-1`) |
45
+ | `AWS_ACCESS_KEY` | AWS IAM access key |
46
+ | `AWS_SECRET_ACCESS_KEY` | AWS IAM secret key |
47
+
48
+ When using the SDK class directly, pass the values explicitly as shown above. You can load them from env vars yourself:
49
+
50
+ ```typescript
51
+ const sdk = new ContentStoreSDK({
52
+ s3: {
53
+ bucket: process.env.CONTENT_STORE_S3_BUCKET!,
54
+ region: process.env.CONTENT_STORE_S3_REGION!,
55
+ accessKeyId: process.env.AWS_ACCESS_KEY!,
56
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
57
+ },
58
+ outputDir: './content-cache',
59
+ });
60
+ ```
61
+
62
+ ---
63
+
37
64
  ## `fetchBundles(options)`
38
65
 
39
66
  Downloads the latest content bundles from S3 and saves them as JSON files to `outputDir`.
@@ -62,7 +89,7 @@ const files = await sdk.fetchBundles({
62
89
  }
63
90
  ```
64
91
 
65
- Files are written to `outputDir` with the naming pattern `content-{cms}-{contentType}.json`.
92
+ Files are written to `outputDir` with the naming pattern `{cms}-{contentType}.json`.
66
93
 
67
94
  ## `queryBundle(cms, contentType, options?)`
68
95
 
@@ -192,6 +219,59 @@ Query options are applied in this order:
192
219
  3. **`include`** — trim nested depth
193
220
  4. **`select`** — pick output properties
194
221
 
222
+ ## CLI
223
+
224
+ The package ships two CLI entry points that can be called from npm scripts in a consuming application.
225
+
226
+ ### `fetch-content-bundles` — download bundles from S3
227
+
228
+ Downloads the latest version of each requested content type bundle from S3 and writes them as JSON files to a local directory. Reads S3 credentials from environment variables (see [S3 config via environment variables](#s3-config-via-environment-variables)).
229
+
230
+ ```bash
231
+ npx fetch-content-bundles --cms contentful --types gridLayout,page
232
+ ```
233
+
234
+ | Flag | Required | Default | Description |
235
+ | --- | --- | --- | --- |
236
+ | `--cms <provider>` | Yes | | `contentful` or `sanity` |
237
+ | `--types <types>` | Yes | | Comma-separated content types |
238
+ | `--output <dir>` | No | `./content-cache` | Local directory to write bundle files to |
239
+
240
+ Files are written as `{cms}-{contentType}.json` inside the output directory.
241
+
242
+ **Typical use in a host app's `package.json`:**
243
+
244
+ ```json
245
+ "scripts": {
246
+ "fetch-content": "fetch-content-bundles --cms contentful --types gridLayout,iconWithText,page --output ./content-cache"
247
+ }
248
+ ```
249
+
250
+ ### `content-store query` — query a local bundle
251
+
252
+ Reads a previously fetched bundle from disk and prints filtered results as JSON. Invoke via `npx` or as a local script using `node`:
253
+
254
+ ```bash
255
+ npx @tandem-language-exchange/content-store query \
256
+ --cms contentful --type gridLayout \
257
+ --fields '{"columns":"2"}' \
258
+ --select title,bodyBefore \
259
+ --limit 5 \
260
+ --include 2
261
+ ```
262
+
263
+ | Flag | Required | Default | Description |
264
+ | --- | --- | --- | --- |
265
+ | `--cms <provider>` | Yes | | `contentful` or `sanity` |
266
+ | `--type <type>` | Yes | | Content type to query |
267
+ | `--output <dir>` | No | `./content-cache` | Directory where bundles are stored |
268
+ | `--fields <json>` | No | | JSON filter object (e.g. `'{"columns":"2"}'`) |
269
+ | `--select <props>` | No | | Comma-separated properties to include in results |
270
+ | `--limit <n>` | No | | Maximum number of results |
271
+ | `--include <n>` | No | | Depth of nested references to include |
272
+
273
+ ---
274
+
195
275
  ## Standalone functions
196
276
 
197
277
  The core `fetchBundles` and `queryBundle` functions are also available as standalone imports for use outside the SDK class:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tandem-language-exchange/content-store",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",