@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.
@@ -18,10 +18,14 @@ const sdk = createLesslyApp({
18
18
  // getCsrfToken defaults to reading the `lessly_csrf` cookie; override for SSR/tests.
19
19
  });
20
20
 
21
- const { domains } = await sdk.tracking.domains.list({ page: 1 });
22
- await sdk.tracking.domains.create({ host: 'links.example.com' });
21
+ const connectors = await sdk.organization.connectors.list({ productId: 'prod_123' });
22
+ await sdk.organization.product.create({ name: 'Acme' });
23
23
  ```
24
24
 
25
+ > The exact namespaces you see depend on the live catalog — see
26
+ > [Namespaces and subpath imports](#namespaces-and-subpath-imports). The calls
27
+ > above use `organization`; substitute the namespace/resource you need.
28
+
25
29
  `productId` is the active product — read it from your `./App` props or the
26
30
  `X-Product-Id` header (see APP-005), never decoded from a token.
27
31
 
@@ -35,7 +39,7 @@ distinguish platform-defined failure reasons:
35
39
  import { LesslyApiError } from '@lessly/sdk-app';
36
40
 
37
41
  try {
38
- await sdk.tracking.domains.create({ host: 'links.example.com' });
42
+ await sdk.organization.product.create({ name: 'Acme' });
39
43
  } catch (err) {
40
44
  if (err instanceof LesslyApiError) {
41
45
  if (err.status === 409) {
@@ -57,14 +61,14 @@ instance explicitly:
57
61
  // React example — works the same with any @tanstack/*-query adapter.
58
62
  import { useQuery, useMutation } from '@tanstack/react-query';
59
63
  import {
60
- trackingDomainsListQueryOptions,
61
- trackingDomainsCreateMutationOptions,
62
- } from '@lessly/sdk-app/tracking';
63
-
64
- function Domains() {
65
- const { data } = useQuery(trackingDomainsListQueryOptions(sdk, { page: 1 }));
66
- const create = useMutation(trackingDomainsCreateMutationOptions(sdk));
67
- // create.mutate({ host: 'links.example.com' })
64
+ organizationConnectorsListQueryOptions,
65
+ organizationProductCreateMutationOptions,
66
+ } from '@lessly/sdk-app/organization';
67
+
68
+ function Connectors() {
69
+ const { data } = useQuery(organizationConnectorsListQueryOptions(sdk, { productId: 'prod_123' }));
70
+ const create = useMutation(organizationProductCreateMutationOptions(sdk));
71
+ // create.mutate({ name: 'Acme' })
68
72
  }
69
73
  ```
70
74
 
@@ -73,7 +77,7 @@ so they also work directly with `queryClient.ensureQueryData(...)` and friends
73
77
  — useful for prefetching outside a component, e.g. in a route loader:
74
78
 
75
79
  ```ts
76
- await queryClient.ensureQueryData(trackingDomainsListQueryOptions(sdk, { page: 1 }));
80
+ await queryClient.ensureQueryData(organizationConnectorsListQueryOptions(sdk, { productId: 'prod_123' }));
77
81
  ```
78
82
 
79
83
  Prefer these factories over hand-rolling calls against `sdk.<namespace>...`
@@ -83,12 +87,18 @@ it automatically when you run `npm i @lessly/sdk-app@latest`.
83
87
 
84
88
  ## Namespaces and subpath imports
85
89
 
86
- The SDK is organized by namespace (`tracking`, `mail`, `playground`, ...). Call
87
- operations off `sdk.<namespace>.<resource>.<action>(...)`, and import that
90
+ The SDK is organized by namespace (currently `organization` and `playground`).
91
+ Call operations off `sdk.<namespace>.<resource>.<action>(...)`, and import that
88
92
  namespace's option factories from the matching subpath,
89
93
  `@lessly/sdk-app/<namespace>` — not the package root. This keeps each App's
90
94
  bundle limited to the namespaces it actually uses.
91
95
 
96
+ The available namespaces track the live catalog and **grow as platform
97
+ extensions migrate to `@lessly/tools`** — a namespace appears here only once its
98
+ tools carry a REST binding. Run `npm i @lessly/sdk-app@latest` to pick up newly
99
+ migrated namespaces. To see exactly what a given version exposes, check its
100
+ subpaths in `package.json` `exports`, or the `manifest.gen.ts` namespace list.
101
+
92
102
  ## What not to do
93
103
 
94
104
  - Don't `fetch` a platform host directly, and don't use any other HTTP client
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lessly/sdk-app",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "engines": {
@@ -39,6 +39,11 @@
39
39
  "import": "./dist/index.js",
40
40
  "require": "./dist/index.cjs"
41
41
  },
42
+ "./deployment": {
43
+ "types": "./dist/deployment/index.d.ts",
44
+ "import": "./dist/deployment/index.js",
45
+ "require": "./dist/deployment/index.cjs"
46
+ },
42
47
  "./organization": {
43
48
  "types": "./dist/organization/index.d.ts",
44
49
  "import": "./dist/organization/index.js",
@@ -49,5 +54,6 @@
49
54
  "import": "./dist/playground/index.js",
50
55
  "require": "./dist/playground/index.cjs"
51
56
  }
52
- }
57
+ },
58
+ "sdkContentHash": "sha256:11f8d92935d26f553961ebfbafc4c032fbab2060ab5ad9c22b353899cff359a5"
53
59
  }