@loxtep/sdk 0.7.14 → 0.7.17

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 (107) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +27 -13
  3. package/dist/cli/cli-list-output.d.ts +27 -0
  4. package/dist/cli/cli-list-output.d.ts.map +1 -0
  5. package/dist/cli/cli-list-output.js +30 -0
  6. package/dist/cli/cli-list-output.js.map +1 -0
  7. package/dist/cli/commands/activity-cmd.d.ts.map +1 -1
  8. package/dist/cli/commands/activity-cmd.js +7 -28
  9. package/dist/cli/commands/activity-cmd.js.map +1 -1
  10. package/dist/cli/commands/bundle-cmd.d.ts +15 -0
  11. package/dist/cli/commands/bundle-cmd.d.ts.map +1 -0
  12. package/dist/cli/commands/bundle-cmd.js +44 -0
  13. package/dist/cli/commands/bundle-cmd.js.map +1 -0
  14. package/dist/cli/commands/config-cmd.d.ts.map +1 -1
  15. package/dist/cli/commands/config-cmd.js +18 -2
  16. package/dist/cli/commands/config-cmd.js.map +1 -1
  17. package/dist/cli/commands/data-contracts-cmd.d.ts +1 -0
  18. package/dist/cli/commands/data-contracts-cmd.d.ts.map +1 -1
  19. package/dist/cli/commands/data-contracts-cmd.js +4 -1
  20. package/dist/cli/commands/data-contracts-cmd.js.map +1 -1
  21. package/dist/cli/commands/data-products-cmd.d.ts +1 -0
  22. package/dist/cli/commands/data-products-cmd.d.ts.map +1 -1
  23. package/dist/cli/commands/data-products-cmd.js +4 -1
  24. package/dist/cli/commands/data-products-cmd.js.map +1 -1
  25. package/dist/cli/commands/domains-cmd.d.ts +1 -0
  26. package/dist/cli/commands/domains-cmd.d.ts.map +1 -1
  27. package/dist/cli/commands/domains-cmd.js +4 -1
  28. package/dist/cli/commands/domains-cmd.js.map +1 -1
  29. package/dist/cli/commands/improvements-cmd.d.ts.map +1 -1
  30. package/dist/cli/commands/improvements-cmd.js +7 -14
  31. package/dist/cli/commands/improvements-cmd.js.map +1 -1
  32. package/dist/cli/commands/ingest-cmd.d.ts +20 -0
  33. package/dist/cli/commands/ingest-cmd.d.ts.map +1 -0
  34. package/dist/cli/commands/ingest-cmd.js +95 -0
  35. package/dist/cli/commands/ingest-cmd.js.map +1 -0
  36. package/dist/cli/commands/init-cmd.d.ts +14 -1
  37. package/dist/cli/commands/init-cmd.d.ts.map +1 -1
  38. package/dist/cli/commands/init-cmd.js +152 -41
  39. package/dist/cli/commands/init-cmd.js.map +1 -1
  40. package/dist/cli/commands/instances-cmd.d.ts.map +1 -1
  41. package/dist/cli/commands/instances-cmd.js +5 -8
  42. package/dist/cli/commands/instances-cmd.js.map +1 -1
  43. package/dist/cli/commands/projects-cmd.d.ts +13 -0
  44. package/dist/cli/commands/projects-cmd.d.ts.map +1 -0
  45. package/dist/cli/commands/projects-cmd.js +31 -0
  46. package/dist/cli/commands/projects-cmd.js.map +1 -0
  47. package/dist/cli/commands/standards-cmd.d.ts +1 -0
  48. package/dist/cli/commands/standards-cmd.d.ts.map +1 -1
  49. package/dist/cli/commands/standards-cmd.js +4 -1
  50. package/dist/cli/commands/standards-cmd.js.map +1 -1
  51. package/dist/cli/commands/triggers-cmd.d.ts +1 -0
  52. package/dist/cli/commands/triggers-cmd.d.ts.map +1 -1
  53. package/dist/cli/commands/triggers-cmd.js +4 -1
  54. package/dist/cli/commands/triggers-cmd.js.map +1 -1
  55. package/dist/cli/commands/workflows-cmd.d.ts +1 -0
  56. package/dist/cli/commands/workflows-cmd.d.ts.map +1 -1
  57. package/dist/cli/commands/workflows-cmd.js +8 -2
  58. package/dist/cli/commands/workflows-cmd.js.map +1 -1
  59. package/dist/cli/create-cli-client.d.ts +3 -3
  60. package/dist/cli/create-cli-client.d.ts.map +1 -1
  61. package/dist/cli/create-cli-client.js +5 -1
  62. package/dist/cli/create-cli-client.js.map +1 -1
  63. package/dist/cli/help.d.ts.map +1 -1
  64. package/dist/cli/help.js +15 -4
  65. package/dist/cli/help.js.map +1 -1
  66. package/dist/cli/index.js +58 -7
  67. package/dist/cli/index.js.map +1 -1
  68. package/dist/cli/load-cli-config.d.ts +23 -0
  69. package/dist/cli/load-cli-config.d.ts.map +1 -0
  70. package/dist/cli/load-cli-config.js +29 -0
  71. package/dist/cli/load-cli-config.js.map +1 -0
  72. package/dist/cli/project-context.d.ts +4 -0
  73. package/dist/cli/project-context.d.ts.map +1 -1
  74. package/dist/cli/project-context.js +13 -0
  75. package/dist/cli/project-context.js.map +1 -1
  76. package/dist/client/index.d.ts +1 -1
  77. package/dist/client/index.d.ts.map +1 -1
  78. package/dist/client/index.js.map +1 -1
  79. package/dist/client/list-summaries.d.ts +106 -0
  80. package/dist/client/list-summaries.d.ts.map +1 -0
  81. package/dist/client/list-summaries.js +107 -0
  82. package/dist/client/list-summaries.js.map +1 -0
  83. package/dist/client/workflows-types.d.ts +28 -0
  84. package/dist/client/workflows-types.d.ts.map +1 -1
  85. package/dist/client/workflows.d.ts +2 -1
  86. package/dist/client/workflows.d.ts.map +1 -1
  87. package/dist/client/workflows.js +7 -0
  88. package/dist/client/workflows.js.map +1 -1
  89. package/dist/config/workspace-config.d.ts +4 -0
  90. package/dist/config/workspace-config.d.ts.map +1 -1
  91. package/dist/config/workspace-config.js +7 -0
  92. package/dist/config/workspace-config.js.map +1 -1
  93. package/dist/index.d.ts +2 -0
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +1 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/lib/sdk-ingest-bundle.d.ts +24 -0
  98. package/dist/lib/sdk-ingest-bundle.d.ts.map +1 -0
  99. package/dist/lib/sdk-ingest-bundle.js +73 -0
  100. package/dist/lib/sdk-ingest-bundle.js.map +1 -0
  101. package/docs/code-first-cli.md +3 -3
  102. package/docs/examples/generate-ingest-bundle.mjs +133 -0
  103. package/docs/examples/write-events.mjs +54 -0
  104. package/docs/getting-started.md +95 -29
  105. package/docs/quick-reference.md +18 -4
  106. package/docs/sdk-first-ingest.md +304 -0
  107. package/package.json +1 -1
@@ -0,0 +1,304 @@
1
+ # SDK-first ingest — your first data product and `get_writer`
2
+
3
+ You logged in, ran `init`, and `attach`. This guide takes you from there to
4
+ **writing events from application code** with `client.get_writer(name)`.
5
+
6
+ That is the primary greenfield path when you are **not** wiring a SaaS connector
7
+ first — you want your app (or ETL job) to push events into a **source** data
8
+ product on your attached instance.
9
+
10
+ > **Full CLI workspace setup:** [Getting Started](./getting-started.md) steps 1–4.
11
+ > **Code-first workflow modules:** [Code-first CLI](./code-first-cli.md).
12
+
13
+ ---
14
+
15
+ ## What you are building
16
+
17
+ ```text
18
+ Your app ──get_writer──▶ rstreams queue ──▶ source data product (catalog)
19
+ ▲ ▲
20
+ │ │
21
+ @loxtep/sdk provisioned at deploy time
22
+ fromWorkspace()
23
+ ```
24
+
25
+ `get_writer` resolves **queue**, **bot**, and **stream bus** config from
26
+ **deployment metadata** (`deployment_bindings` on the data product). A catalog
27
+ row alone is not enough — the ingestion workflow must be **saved and deployed**
28
+ on your attached instance first.
29
+
30
+ ---
31
+
32
+ ## Prerequisites
33
+
34
+ Run from your scaffolded workspace (directory with `.loxtep/project.json`):
35
+
36
+ ```bash
37
+ pnpm exec loxtep config list # project_id + instance_id should be set
38
+ pnpm exec loxtep domains list # you need a domain_id for the data product
39
+ ```
40
+
41
+ Every org has at least one domain. Copy a `domain_id` from the list.
42
+
43
+ ---
44
+
45
+ ## Overview (four phases)
46
+
47
+ | Phase | What | How |
48
+ | ----- | ---- | --- |
49
+ | 1 | Workspace ready | `login` → `init` → `attach` (done) |
50
+ | 2 | Provision runtime | SDK connector + workflow bundle + deploy |
51
+ | 3 | Verify | `data-products list` / `data-products get` |
52
+ | 4 | Write events | `LoxtepClient.fromWorkspace()` + `get_writer` |
53
+
54
+ Phases 2–4 below.
55
+
56
+ ---
57
+
58
+ ## Phase 2 — Provision runtime (required before `get_writer`)
59
+
60
+ Runtime provisioning creates the workflow graph (SDK connection node → source
61
+ data product node), saves it to your project workspace, and **deploys** it to your
62
+ instance so queues and bots exist.
63
+
64
+ ### Option A — CLI one-shot (recommended, no MCP)
65
+
66
+ From your workspace root (after `login`, `init`, `attach`):
67
+
68
+ ```bash
69
+ pnpm exec loxtep ingest provision --name app-events
70
+ ```
71
+
72
+ This command:
73
+
74
+ 1. Creates an org-level **SDK connector** (`connector_type: "sdk"`).
75
+ 2. Builds and saves the workflow bundle (`workflow.json` + connection + source data product).
76
+ 3. **Deploys** to your attached instance (unless you pass `--no-deploy` or `--dry-run`).
77
+
78
+ Validate first without writing:
79
+
80
+ ```bash
81
+ pnpm exec loxtep ingest provision --name app-events --dry-run
82
+ ```
83
+
84
+ ### Option B — Helper script + bundle save
85
+
86
+ Generate bundle JSON only:
87
+
88
+ ```bash
89
+ node node_modules/@loxtep/sdk/docs/examples/generate-ingest-bundle.mjs
90
+ ```
91
+
92
+ Then persist and deploy via CLI:
93
+
94
+ ```bash
95
+ pnpm exec loxtep bundle save --dry-run --file .loxtep/sdk-ingest-bundle.json
96
+ pnpm exec loxtep bundle save --file .loxtep/sdk-ingest-bundle.json
97
+ pnpm exec loxtep workflows deploy \
98
+ --project-id <project-id-from-config-list> \
99
+ --instance-id <instance-id-from-config-list>
100
+ ```
101
+
102
+ Or set `LOXTEP_AUTO_SAVE=1` on the helper script to save + deploy in one step.
103
+
104
+ Poll until deployment completes (Web UI **Observe**, or `loxtep observe status`).
105
+
106
+ ### Option C — Loxtep MCP (Cursor / agent)
107
+
108
+ Use **`loxtep_build`** → `save_workflow_bundle` if you prefer MCP authoring.
109
+ Same bundle shape as below; deploy with `loxtep workflows deploy` or MCP
110
+ `deploy_project`.
111
+
112
+ ### Option D — Web UI (Studio)
113
+
114
+ Create an **ingestion** workflow with an **SDK** connection node and a **source**
115
+ data product node, then deploy to your attached instance from the Studio deploy
116
+ flow.
117
+
118
+ ---
119
+
120
+ ### Workflow bundle shape
121
+
122
+ Minimal ingestion bundle (SDK connection → source data product). Replace UUIDs
123
+ and names; `connector_id` must be the SDK connector from step 2A or 2B.
124
+
125
+ ```json
126
+ {
127
+ "workflow.json": {
128
+ "workflow_id": "<workflow-uuid>",
129
+ "organization_id": "<org-uuid>",
130
+ "project_id": "<project-uuid>",
131
+ "name": "SDK App Events Ingest",
132
+ "workflow_type": "ingestion",
133
+ "domain_id": "<domain-uuid>",
134
+ "status": "active",
135
+ "configuration": {},
136
+ "metadata": {},
137
+ "created_at": "2026-07-23T00:00:00.000Z",
138
+ "updated_at": "2026-07-23T00:00:00.000Z"
139
+ },
140
+ "connections/<connection-uuid>.json": {
141
+ "connection_id": "<connection-uuid>",
142
+ "organization_id": "<org-uuid>",
143
+ "project_id": "<project-uuid>",
144
+ "workflow_id": "<workflow-uuid>",
145
+ "connector_id": "<sdk-connector-uuid>",
146
+ "key": "sdk-input",
147
+ "name": "SDK Input",
148
+ "type": "sdk",
149
+ "status": "active",
150
+ "configuration": {
151
+ "sdk_type": "nodejs",
152
+ "event_type": "app-events"
153
+ },
154
+ "created_at": "2026-07-23T00:00:00.000Z",
155
+ "updated_at": "2026-07-23T00:00:00.000Z"
156
+ },
157
+ "data-products/<data-product-uuid>.json": {
158
+ "data_product_id": "<data-product-uuid>",
159
+ "organization_id": "<org-uuid>",
160
+ "project_id": "<project-uuid>",
161
+ "workflow_id": "<workflow-uuid>",
162
+ "upstream_entity_id": "<connection-uuid>",
163
+ "upstream_entity_type": "connections",
164
+ "domain_id": "<domain-uuid>",
165
+ "name": "app-events",
166
+ "kind": "source",
167
+ "status": "draft",
168
+ "owner": {},
169
+ "governance": {
170
+ "classification": "internal",
171
+ "pii_fields": [],
172
+ "compliance_requirements": [],
173
+ "tags": []
174
+ },
175
+ "metadata": {},
176
+ "created_at": "2026-07-23T00:00:00.000Z",
177
+ "updated_at": "2026-07-23T00:00:00.000Z"
178
+ }
179
+ }
180
+ ```
181
+
182
+ The **`name`** on the data product node (`app-events` above) is what you pass
183
+ to `get_writer('app-events')`.
184
+
185
+ ---
186
+
187
+ ### Do not stop at `data-products create`
188
+
189
+ ```bash
190
+ # Creates a catalog row only — get_writer will fail with "not deployed"
191
+ pnpm exec loxtep data-products create --name app-events --domain-id <uuid> --kind source
192
+ ```
193
+
194
+ Use **`data-products create`** only when you already have (or will immediately
195
+ add) a deployed workflow that sets `deployment_bindings`. For greenfield SDK
196
+ ingest, prefer the bundle + deploy path above.
197
+
198
+ ---
199
+
200
+ ## Phase 3 — Verify deployment
201
+
202
+ ```bash
203
+ pnpm exec loxtep data-products list
204
+ pnpm exec loxtep data-products get <data-product-id>
205
+ ```
206
+
207
+ A deployable source data product includes **`deployment_bindings`** with
208
+ `queue_name`, `bot_id`, and `instance_id`. If those are missing, finish Phase 2
209
+ before writing.
210
+
211
+ Re-run code generation after platform changes:
212
+
213
+ ```bash
214
+ pnpm exec loxtep generate
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Phase 4 — Write events from your app
220
+
221
+ Copy or run the example:
222
+
223
+ ```bash
224
+ node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
225
+ ```
226
+
227
+ Or embed in your service:
228
+
229
+ ```typescript
230
+ import { LoxtepClient } from '@loxtep/sdk';
231
+
232
+ const client = await LoxtepClient.fromWorkspace();
233
+
234
+ // Name from Phase 2 bundle / data-products list (case-sensitive)
235
+ const writer = await client.get_writer('app-events');
236
+
237
+ writer.write({
238
+ event_id: 'evt_001',
239
+ occurred_at: new Date().toISOString(),
240
+ payload: { user_id: 'u_1', action: 'signup' },
241
+ });
242
+
243
+ await writer.close(); // flush buffered events
244
+ ```
245
+
246
+ Optional writer tuning:
247
+
248
+ ```typescript
249
+ await client.get_writer('app-events', {
250
+ batch_size: 500,
251
+ max_retries: 5,
252
+ });
253
+ ```
254
+
255
+ Read back (after data has landed):
256
+
257
+ ```typescript
258
+ const reader = await client.get_reader('app-events', {
259
+ bot_id: 'my-app-reader',
260
+ });
261
+ for await (const event of reader) {
262
+ console.log(event);
263
+ break;
264
+ }
265
+ ```
266
+
267
+ ---
268
+
269
+ ## End-to-end checklist
270
+
271
+ ```bash
272
+ pnpm exec loxtep login
273
+ pnpm exec loxtep init
274
+ pnpm exec loxtep attach --instance <instance-id>
275
+ pnpm exec loxtep domains list
276
+
277
+ pnpm exec loxtep ingest provision --name app-events
278
+ # or: generate-ingest-bundle.mjs + loxtep bundle save
279
+
280
+ pnpm exec loxtep data-products list
281
+ node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Troubleshooting
287
+
288
+ | Symptom | Cause | Fix |
289
+ | ------- | ----- | --- |
290
+ | `StreamingError: … is not deployed` | No `deployment_bindings` | Complete Phase 2 (bundle + deploy) |
291
+ | `NotFoundError: Data product '…' not found` | Wrong name or wrong instance | `data-products list`; check `attach` / `instance_id` |
292
+ | `AmbiguityError: Multiple data products match` | Same name on multiple instances | Use UUID or set `instance_id` in project.json |
293
+ | Empty `domains list` | New org / permissions | Create a domain in the Web UI (Governance) |
294
+
295
+ ---
296
+
297
+ ## Next steps
298
+
299
+ | Resource | Description |
300
+ | -------- | ----------- |
301
+ | [Getting Started](./getting-started.md) | Login, init, attach, generate |
302
+ | [Quick Reference](./quick-reference.md) | CLI + SDK cheat sheet |
303
+ | [Code-first CLI](./code-first-cli.md) | TypeScript workflow modules + `loxtep deploy` |
304
+ | [Event Replay Cookbook](./event-replay-cookbook.md) | Replay and reprocess |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loxtep/sdk",
3
- "version": "0.7.14",
3
+ "version": "0.7.17",
4
4
  "description": "Loxtep SDK for Node.js — the Enterprise Context Layer: data products, workflows, projects, queues, and machine-usable context for AI",
5
5
  "author": "Loxtep <engineering@loxtep.io>",
6
6
  "homepage": "https://loxtep.io",