@lemonadecms/client 0.2.1 → 0.2.2

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/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.2
6
+
7
+ - Correct the npm-specific README with global/collection defaults, direct
8
+ reference-ID filtering, authorization limits and accurate 0.2.1 feature
9
+ availability. No SDK runtime, CLI or dependency changes from 0.2.1.
10
+
5
11
  ## 0.2.1
6
12
 
7
13
  - Filter top-level Reference fields by linked entry UUID with eq/ne/in/not_in,
package/README.md CHANGED
@@ -30,7 +30,7 @@ runtime library or framework dependency is required.
30
30
 
31
31
  ## Configure and read content
32
32
 
33
- Version 0.2.0 connects to `https://api.lemonadecms.com` automatically. Strict hostname routing returns 404 for API URLs on `https://lemonadecms.com`. Upgrade earlier clients to 0.2.0 and change explicit CLI/configured-target URLs to `https://api.lemonadecms.com`. Explicit CLI settings still take precedence; no redirect or fallback is attempted. Configure your
33
+ Version 0.2.0 connects to `https://api.lemonadecms.com` automatically. Strict hostname routing returns 404 for API URLs on `https://lemonadecms.com`. Upgrade earlier clients to 0.2.2 and change explicit CLI/configured-target URLs to `https://api.lemonadecms.com`. Explicit CLI settings still take precedence; no redirect or fallback is attempted. Configure your
34
34
  workspace and delivery key; there is no URL or local CMS option. Your website
35
35
  can run locally while reading content from Lemonade production. Installing the
36
36
  package does not create an account, workspace or delivery key.
@@ -85,6 +85,64 @@ environment override. Ask your Owner for a credential belonging to the intended
85
85
  environment. The server rechecks current access, expiry and revocation on every
86
86
  request.
87
87
 
88
+ ## Global and collection defaults (0.2.1+)
89
+
90
+ Use `defaults` for shared locale, limit, filters, sort, includeRemote and maxPages.
91
+ Use `collections` for typed per-model settings. Request values override collection
92
+ values, then global values. Global, collection and request filters combine with
93
+ AND; `filters: []` does not remove configured predicates. Configuration is copied
94
+ at client construction. No schema fetch, retry or runtime dependency is added.
95
+
96
+ The example assumes generated `article` and `product` models, each with a top-level
97
+ Reference field named `tenant`. Filter directly by the linked entry UUID; a
98
+ separate `tenant_id` text field is unnecessary. Regenerate your model types after
99
+ adding the relation. Relation predicates require the matching CMS backend.
100
+
101
+ ```ts
102
+ import { createCMSClient } from '@lemonadecms/client';
103
+ import type { Models } from './cms-models';
104
+
105
+ type TenantContent = Pick<Models, 'article' | 'product'>;
106
+ const tenantId = 'YOUR_TENANT_ENTRY_UUID';
107
+ const cms = createCMSClient<TenantContent>({
108
+ projectId: 'YOUR_WORKSPACE_UUID',
109
+ publicKey: 'YOUR_PUBLIC_DELIVERY_KEY',
110
+ defaults: {
111
+ locale: 'en',
112
+ limit: 25,
113
+ filters: [{ field: 'tenant', op: 'eq', value: tenantId }],
114
+ },
115
+ });
116
+ const articles = await cms.content('article').list({ limit: 10 });
117
+ ```
118
+
119
+ `tenantId` must come from your application's intended tenant entry UUID. Global
120
+ fields must exist on every queried model; use collection defaults when only some
121
+ models have the relation. Use another client for the tenant directory itself.
122
+
123
+ | Field | Operators | Values |
124
+ | --- | --- | --- |
125
+ | Reference | `eq`, `ne` | Linked entry UUID or `null` |
126
+ | Reference | `in`, `not_in` | 1–100 UUIDs |
127
+ | References | `contains_any`, `contains_all` | 1–100 unique UUIDs |
128
+
129
+ IDs are compared case-insensitively in the requested published or saved-draft
130
+ snapshot. These filters do not fetch or traverse target fields. Both source and
131
+ target models must be accessible in the requested language. Dotted `tenant.id`,
132
+ nested relations, reverse-list predicates and relation sorting are unsupported.
133
+ Existing ten-leaf, depth-four, 31-node and 4 KiB filter limits still apply.
134
+
135
+ Defaults are query conveniences, **not tenant authorization**. `get()`/`getMany()`
136
+ inherit locale/includeRemote only and do not inherit filters. Reference expansion
137
+ is not constrained by defaults. A shared public key can read every record it
138
+ permits. Use separate workspace credentials for hard isolation, or trusted server
139
+ authorization for every entry and referenced resource. Never rely on a caller's
140
+ unverified tenant ID as authorization.
141
+
142
+ Statistics inherit locale/filters; `findOne()` keeps limit 1. Related reads inherit
143
+ global defaults only, never the parent collection's settings. Traversal snapshots
144
+ its effective query and honors maxPages (default 1,000; maximum 10,000).
145
+
88
146
  ## Find one entry
89
147
 
90
148
  In the updated source build, `findOne()` returns the first matching complete
@@ -202,14 +260,14 @@ resources. Unavailable embeds are omitted; entry routes are never invented.
202
260
  Plain text retains authored text with block/list/hard-break newlines. Plain text
203
261
  is not escaped HTML: use text interpolation.
204
262
 
205
- The source SDK also supports opt-in v2 quotations, escaped code blocks, accessible
263
+ SDK 0.2.1 and later support opt-in v2 quotations, escaped code blocks, accessible
206
264
  rectangular tables and external-media cards. Configure the field's
207
265
  `document_version: 2` and enabled features, then set `richTextVersion: 2` on the
208
266
  published or server preview client. This explicitly sends
209
267
  `Lemonade-Accept-Content: rich-text.v2`; default reads remain v1. The updated type
210
268
  generator requests `relationships.v1,rich-text.v2,unique-identifiers.v1` schema extensions.
211
- These additions require the updated backend, SDK and website renderer; published
212
- 0.2.0 does not contain them.
269
+ These additions require the updated backend and website renderer, together with
270
+ SDK 0.2.1 or later. Earlier packages do not contain these advanced formats.
213
271
 
214
272
  External-media HTML stays static: no iframe, autoplay or provider request is
215
273
  created by these helpers. `externalMediaDescriptor(node)` returns validated,
@@ -335,16 +393,16 @@ saved-draft previews remain supported. The browser helper is the dependency-free
335
393
  See [setup, editor workflow, Astro reference and protocol](https://github.com/ilara-booqself/lemonadecms/blob/main/docs/visual-composer.md).
336
394
 
337
395
 
338
- ## Source additions awaiting a release
396
+ ## Reverse relationships (0.2.1+)
339
397
 
340
- The source checkout adds opt-in rich-text v2 (described above) and on-demand
398
+ SDK 0.2.1 adds opt-in rich-text v2 (described above) and on-demand
341
399
  reverse collections through
342
400
  `cms.content('author').related(authorId, 'articles', {limit: 10})`. Updated
343
401
  `lemonade types generate` negotiates the relationship extension and generates a
344
402
  separate `Relationships` map for `createCMSClient<Models, Relationships>`.
345
403
  Ordinary entries and `fields` retain their shape. This requires the updated
346
- backend and a separately published package beyond 0.2.0; deployment and npm
347
- publication are separate gates. The source SDK retains zero runtime dependencies.
404
+ backend and SDK 0.2.1 or later. Installing npm does not deploy the backend.
405
+ The SDK retains zero runtime dependencies.
348
406
 
349
407
  Management migrations configuring a reverse list need both source and target
350
408
  model keys and actions in the management credential, independently of the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemonadecms/client",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Framework-independent content delivery and developer tooling for Lemonade CMS",
5
5
  "license": "MIT",
6
6
  "homepage": "https://lemonadecms.com/guides/sdk",