@lessly/sdk-app 0.3.0 → 0.4.0

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 CHANGED
@@ -4,6 +4,8 @@ The Lessly SDK for App is a TypeScript SDK that provides runtime bindings and ty
4
4
 
5
5
  **Note:** The `src/gen` directory contains generated SDK code and should not be edited by hand. Generated files are produced by running `npm run generate` with an API catalog.
6
6
 
7
+ The committed `src/gen` is a **convenience snapshot** — it lets the repo type-check, test, and build offline. It is **not** the source of truth: canonical generation happens **at publish time**, when Cloud Build regenerates `src/gen` from the live catalog before publishing. The catalog is **mid-migration**, so the committed snapshot's namespaces (currently `organization` and `playground`) will **grow as platform extensions migrate to `@lessly/tools`** — a namespace only appears once its tools carry a REST binding (tools without one are excluded until migrated). Regenerate the snapshot with `npx tsx scripts/generate.ts <catalog.json> src/gen && npm run sync-exports` against the live catalog (`https://api.lessly.dev/catalog/tools`).
8
+
7
9
  ## Usage
8
10
 
9
11
  Create a client with `createLesslyApp`, then call operations through the Proxy namespace tree:
@@ -17,10 +19,13 @@ const sdk = createLesslyApp({
17
19
  // getCsrfToken defaults to reading the `lessly_csrf` cookie; override for SSR/tests.
18
20
  });
19
21
 
20
- const { domains } = await sdk.tracking.domains.list({ page: 1 });
21
- await sdk.tracking.domains.create({ host: 'links.example.com' });
22
+ const connectors = await sdk.organization.connectors.list({ productId: 'prod_123' });
23
+ await sdk.organization.product.create({ name: 'Acme' });
22
24
  ```
23
25
 
26
+ The available namespaces track the live catalog and grow as platform extensions migrate; check
27
+ `package.json` `exports` (or `src/gen/manifest.gen.ts`) for what a given version exposes.
28
+
24
29
  Errors are surfaced as a typed `LesslyApiError` (`status`, `code`, `body`).
25
30
 
26
31
  ### TanStack Query
@@ -34,14 +39,14 @@ explicitly:
34
39
  // React example — works the same with any @tanstack/*-query adapter.
35
40
  import { useQuery, useMutation } from '@tanstack/react-query';
36
41
  import {
37
- trackingDomainsListQueryOptions,
38
- trackingDomainsCreateMutationOptions,
39
- } from '@lessly/sdk-app/tracking';
40
-
41
- function Domains() {
42
- const { data } = useQuery(trackingDomainsListQueryOptions(sdk, { page: 1 }));
43
- const create = useMutation(trackingDomainsCreateMutationOptions(sdk));
44
- // create.mutate({ host: 'links.example.com' })
42
+ organizationConnectorsListQueryOptions,
43
+ organizationProductCreateMutationOptions,
44
+ } from '@lessly/sdk-app/organization';
45
+
46
+ function Connectors() {
47
+ const { data } = useQuery(organizationConnectorsListQueryOptions(sdk, { productId: 'prod_123' }));
48
+ const create = useMutation(organizationProductCreateMutationOptions(sdk));
49
+ // create.mutate({ name: 'Acme' })
45
50
  }
46
51
  ```
47
52
 
@@ -116,10 +121,15 @@ MUST publish with an explicit override:
116
121
  npm publish --registry https://registry.npmjs.org/
117
122
  ```
118
123
 
119
- Base-version resolution (the `npm view <pkg>@<channel> dist-tags` lookup inside the pipeline
120
- CLI) follows the same rule: it reads the registry from `package.json`'s `publishConfig.registry`
121
- first, falling back to the `.npmrc` `@lessly:registry` value if `publishConfig.registry` is
122
- absent. This requires no change to the CLI's `--channel`/`--catalog-url`/`--baseline` contract.
124
+ Base-version resolution (the `npm view` lookups inside the pipeline CLI — both the per-channel
125
+ version and the package-wide max-version probe) follows the same rule, and in **two** steps:
126
+ it reads the registry from `package.json`'s `publishConfig.registry` first (falling back to the
127
+ `.npmrc` `@lessly:registry` value if absent), **and** passes that registry as an explicit CLI
128
+ scope override (`--@lessly:registry=<registry>`) on every `npm view`. The `--registry` flag alone
129
+ is not enough: because the package is scoped `@lessly`, the `.npmrc` `@lessly:registry=<GAR>` entry
130
+ would otherwise outrank it and silently resolve the lookup against GAR — which is exactly how an
131
+ early run read GAR's `0.1.x` line instead of the empty npmjs registry and skipped the `0.2.0`
132
+ floor. This requires no change to the CLI's `--channel`/`--catalog-url`/`--baseline` contract.
123
133
 
124
134
  ### Snapshot shape
125
135