@tandem-language-exchange/content-store 1.1.0 → 1.1.1

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.
@@ -0,0 +1,92 @@
1
+ type CMSProvider = 'contentful' | 'sanity';
2
+ interface S3Config {
3
+ bucket: string;
4
+ region: string;
5
+ accessKeyId: string;
6
+ secretAccessKey: string;
7
+ }
8
+
9
+ declare class ContentStore {
10
+ private client;
11
+ private bucket;
12
+ constructor(cfg: S3Config);
13
+ /** {cms}-{contentType}-{timestamp}.json */
14
+ buildVersionedKey(cms: string, contentType: string, timestamp: number): string;
15
+ /** {cms}-{contentType}.json (always points at the latest version) */
16
+ buildLatestKey(cms: string, contentType: string): string;
17
+ upload(key: string, data: unknown): Promise<string>;
18
+ download(key: string): Promise<unknown>;
19
+ /**
20
+ * Copies a versioned object to the "latest" key so that it always reflects
21
+ * the most recent sync while older timestamped versions are retained.
22
+ */
23
+ copyToLatest(sourceKey: string, cms: string, contentType: string): Promise<string>;
24
+ }
25
+
26
+ interface BundleInfo {
27
+ [key: string]: string;
28
+ }
29
+ interface BundleItem {
30
+ [key: string]: any;
31
+ }
32
+ interface FetchBundlesOptions {
33
+ cms: CMSProvider;
34
+ contentTypes: string[];
35
+ }
36
+ interface QueryOptions {
37
+ /**
38
+ * Filter items by matching property values (exact equality, or array for IN).
39
+ * Keys may use dot notation for nested paths, e.g. `{ 'meta._id': 'abc' }` matches
40
+ * `item.meta._id`.
41
+ *
42
+ * Contentful-style operators on the path (before `[`):
43
+ * - `{ 'field[exists]': true }` — field is present and non-empty (not null, undefined,
44
+ * `''`, `[]`, or `{}`).
45
+ * - `{ 'field[exists]': false }` — field is missing or empty (same emptiness rules).
46
+ * Nested paths work, e.g. `{ 'blocks.hero[exists]': false }`.
47
+ */
48
+ fields?: Record<string, unknown>;
49
+ /**
50
+ * Properties to include in each result object. Omit to return all properties.
51
+ * Keys may use dot notation; nested segments become nested objects in the result,
52
+ * e.g. `['slug', 'meta._updatedAt']` → `{ slug, meta: { _updatedAt } }`.
53
+ */
54
+ select?: string[];
55
+ /** Maximum number of items to return. */
56
+ limit?: number;
57
+ /**
58
+ * How many levels deep to return.
59
+ * - 1 = the item's own scalar properties only; nested objects/refs are nulled.
60
+ * - 2 = the item including its direct references; refs inside those are nulled.
61
+ * - 3 = three levels deep, and so on.
62
+ * - Omit to return the full depth.
63
+ */
64
+ include?: number;
65
+ }
66
+ /**
67
+ * Trims nested object depth.
68
+ *
69
+ * `remaining` represents how many levels the current object is allowed.
70
+ * - Scalar properties are always kept.
71
+ * - Nested objects / arrays-of-objects consume one level. When `remaining`
72
+ * drops to 1 they are replaced with `null` (no budget left for refs).
73
+ */
74
+ declare function trimDepth(value: unknown, remaining: number): unknown;
75
+ /**
76
+ * Downloads the latest bundles from S3 and writes them as JSON files to `outputDir`.
77
+ *
78
+ * @returns A map of contentType to absolute file path.
79
+ */
80
+ declare function fetchBundles(store: ContentStore, outputDir: string, options: FetchBundlesOptions): Promise<Record<string, string>>;
81
+ /**
82
+ * Queries a previously fetched bundle from the local filesystem.
83
+ */
84
+ declare function queryBundle(outputDir: string, cms: CMSProvider, contentType: string, options?: QueryOptions): Promise<unknown[]>;
85
+
86
+ interface SDKConfig {
87
+ s3: S3Config;
88
+ /** Directory where bundle JSON files are saved on the local filesystem. */
89
+ outputDir: string;
90
+ }
91
+
92
+ export { type BundleInfo as B, type CMSProvider as C, type FetchBundlesOptions as F, type QueryOptions as Q, type SDKConfig as S, type BundleItem as a, ContentStore as b, type S3Config as c, fetchBundles as f, queryBundle as q, trimDepth as t };
package/node.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/node.js';
package/node.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Re-export for `@tandem-language-exchange/content-store/node`.
3
+ * Root file so resolvers that ignore package "exports" still resolve.
4
+ */
5
+ export * from './dist/node.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tandem-language-exchange/content-store",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,13 +11,16 @@
11
11
  "default": "./dist/index.js"
12
12
  },
13
13
  "./node": {
14
- "types": "./dist/node.d.ts",
15
- "import": "./dist/node.js",
16
- "default": "./dist/node.js"
14
+ "types": "./node.d.ts",
15
+ "import": "./node.js",
16
+ "default": "./node.js"
17
17
  }
18
18
  },
19
19
  "files": [
20
+ "node.js",
21
+ "node.d.ts",
20
22
  "dist/index.*",
23
+ "dist/index-*.d.ts",
21
24
  "dist/node.*",
22
25
  "dist/sdk/",
23
26
  "dist/client/",