@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
package/dist/index.js CHANGED
@@ -13,4 +13,5 @@ export * from './types/index.js';
13
13
  export * from './codegen/index.js';
14
14
  export * from './skills/index.js';
15
15
  export * from './authoring/index.js';
16
+ export { buildSdkIngestBundle } from './lib/sdk-ingest-bundle.js';
16
17
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Build SDK ingest workflow bundle files (connector + connection + source data product).
3
+ */
4
+ export interface SdkIngestBundleParams {
5
+ organization_id: string;
6
+ project_id: string;
7
+ domain_id: string;
8
+ connector_id: string;
9
+ data_product_name: string;
10
+ workflow_name?: string;
11
+ user_id?: string;
12
+ workflow_id?: string;
13
+ connection_id?: string;
14
+ data_product_id?: string;
15
+ }
16
+ export interface SdkIngestBundleResult {
17
+ workflow_id: string;
18
+ connection_id: string;
19
+ data_product_id: string;
20
+ data_product_name: string;
21
+ files: Record<string, Record<string, unknown>>;
22
+ }
23
+ export declare function buildSdkIngestBundle(params: SdkIngestBundleParams): SdkIngestBundleResult;
24
+ //# sourceMappingURL=sdk-ingest-bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-ingest-bundle.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-ingest-bundle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAChD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,qBAAqB,CAqEzF"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Build SDK ingest workflow bundle files (connector + connection + source data product).
3
+ */
4
+ import { randomUUID } from 'node:crypto';
5
+ export function buildSdkIngestBundle(params) {
6
+ const workflowId = params.workflow_id ?? randomUUID();
7
+ const connectionId = params.connection_id ?? randomUUID();
8
+ const dataProductId = params.data_product_id ?? randomUUID();
9
+ const now = new Date().toISOString();
10
+ const workflowName = params.workflow_name ?? 'SDK App Events Ingest';
11
+ const files = {
12
+ 'workflow.json': {
13
+ workflow_id: workflowId,
14
+ organization_id: params.organization_id,
15
+ project_id: params.project_id,
16
+ name: workflowName,
17
+ workflow_type: 'ingestion',
18
+ domain_id: params.domain_id,
19
+ status: 'active',
20
+ configuration: {},
21
+ metadata: { ingestion_method: 'sdk' },
22
+ created_at: now,
23
+ updated_at: now,
24
+ },
25
+ [`connections/${connectionId}.json`]: {
26
+ connection_id: connectionId,
27
+ organization_id: params.organization_id,
28
+ project_id: params.project_id,
29
+ workflow_id: workflowId,
30
+ connector_id: params.connector_id,
31
+ key: 'sdk-input',
32
+ name: 'SDK Input',
33
+ type: 'sdk',
34
+ status: 'active',
35
+ configuration: {
36
+ sdk_type: 'nodejs',
37
+ event_type: params.data_product_name,
38
+ },
39
+ created_at: now,
40
+ updated_at: now,
41
+ },
42
+ [`data-products/${dataProductId}.json`]: {
43
+ data_product_id: dataProductId,
44
+ organization_id: params.organization_id,
45
+ project_id: params.project_id,
46
+ workflow_id: workflowId,
47
+ upstream_entity_id: connectionId,
48
+ upstream_entity_type: 'connections',
49
+ domain_id: params.domain_id,
50
+ name: params.data_product_name,
51
+ kind: 'source',
52
+ status: 'draft',
53
+ owner: params.user_id ? { user_id: params.user_id } : {},
54
+ governance: {
55
+ classification: 'internal',
56
+ pii_fields: [],
57
+ compliance_requirements: [],
58
+ tags: [],
59
+ },
60
+ metadata: {},
61
+ created_at: now,
62
+ updated_at: now,
63
+ },
64
+ };
65
+ return {
66
+ workflow_id: workflowId,
67
+ connection_id: connectionId,
68
+ data_product_id: dataProductId,
69
+ data_product_name: params.data_product_name,
70
+ files,
71
+ };
72
+ }
73
+ //# sourceMappingURL=sdk-ingest-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk-ingest-bundle.js","sourceRoot":"","sources":["../../src/lib/sdk-ingest-bundle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuBzC,MAAM,UAAU,oBAAoB,CAAC,MAA6B;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,IAAI,UAAU,EAAE,CAAC;IACtD,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,IAAI,UAAU,EAAE,CAAC;IAC1D,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,IAAI,UAAU,EAAE,CAAC;IAC7D,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,YAAY,GAAG,MAAM,CAAC,aAAa,IAAI,uBAAuB,CAAC;IAErE,MAAM,KAAK,GAA4C;QACrD,eAAe,EAAE;YACf,WAAW,EAAE,UAAU;YACvB,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,IAAI,EAAE,YAAY;YAClB,aAAa,EAAE,WAAW;YAC1B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,QAAQ;YAChB,aAAa,EAAE,EAAE;YACjB,QAAQ,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE;YACrC,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB;QACD,CAAC,eAAe,YAAY,OAAO,CAAC,EAAE;YACpC,aAAa,EAAE,YAAY;YAC3B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,GAAG,EAAE,WAAW;YAChB,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,QAAQ;YAChB,aAAa,EAAE;gBACb,QAAQ,EAAE,QAAQ;gBAClB,UAAU,EAAE,MAAM,CAAC,iBAAiB;aACrC;YACD,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB;QACD,CAAC,iBAAiB,aAAa,OAAO,CAAC,EAAE;YACvC,eAAe,EAAE,aAAa;YAC9B,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,WAAW,EAAE,UAAU;YACvB,kBAAkB,EAAE,YAAY;YAChC,oBAAoB,EAAE,aAAa;YACnC,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,IAAI,EAAE,MAAM,CAAC,iBAAiB;YAC9B,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;YACxD,UAAU,EAAE;gBACV,cAAc,EAAE,UAAU;gBAC1B,UAAU,EAAE,EAAE;gBACd,uBAAuB,EAAE,EAAE;gBAC3B,IAAI,EAAE,EAAE;aACT;YACD,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB;KACF,CAAC;IAEF,OAAO;QACL,WAAW,EAAE,UAAU;QACvB,aAAa,EAAE,YAAY;QAC3B,eAAe,EAAE,aAAa;QAC9B,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,KAAK;KACN,CAAC;AACJ,CAAC"}
@@ -5,10 +5,10 @@ deploy to a runtime instance — without using the Studio UI as your source of
5
5
  truth.
6
6
 
7
7
  Start with the [Getting Started Guide](./getting-started.md) if you have not
8
- yet run `login`, `init`, `attach`, and `generate`.
8
+ yet run `login`, `init`, and `attach`.
9
9
 
10
- For **application code** that calls platform APIs or streams events after
11
- deploy, use `LoxtepClient.fromWorkspace()` (see Getting Started, Step 7–8).
10
+ **Sending events from your app without authoring workflow modules first?**
11
+ Use [SDK-first ingest](./sdk-first-ingest.md) instead of this guide.
12
12
 
13
13
  ---
14
14
 
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Greenfield SDK ingest — one-shot provision via CLI (preferred) or bundle JSON for manual save.
4
+ *
5
+ * Run from your Loxtep workspace root (after login, init, attach):
6
+ *
7
+ * pnpm exec loxtep ingest provision --name app-events
8
+ *
9
+ * Or generate bundle JSON only:
10
+ *
11
+ * node node_modules/@loxtep/sdk/docs/examples/generate-ingest-bundle.mjs
12
+ * pnpm exec loxtep bundle save --dry-run
13
+ * pnpm exec loxtep bundle save
14
+ */
15
+
16
+ import { LoxtepClient, buildSdkIngestBundle } from '@loxtep/sdk';
17
+ import { randomUUID } from 'node:crypto';
18
+ import { writeFileSync, mkdirSync } from 'node:fs';
19
+ import { join } from 'node:path';
20
+
21
+ const DATA_PRODUCT_NAME = process.env.LOXTEP_DATA_PRODUCT_NAME ?? 'app-events';
22
+ const WORKFLOW_NAME = process.env.LOXTEP_WORKFLOW_NAME ?? 'SDK App Events Ingest';
23
+ const AUTO_SAVE = process.env.LOXTEP_AUTO_SAVE === '1';
24
+
25
+ async function main() {
26
+ const client = await LoxtepClient.fromWorkspace();
27
+
28
+ const user = await client.session.get_current_user();
29
+ const organizationId = user.organization_id ?? client.organization_id;
30
+ const projectId = client.project_id;
31
+ const instanceId = client.instance_id;
32
+
33
+ if (!organizationId || !projectId) {
34
+ console.error(
35
+ 'Missing organization_id or project_id. Run from a workspace after `loxtep init`.'
36
+ );
37
+ process.exit(1);
38
+ }
39
+ if (!instanceId) {
40
+ console.error('Missing instance_id. Run `loxtep attach --instance <id>` first.');
41
+ process.exit(1);
42
+ }
43
+
44
+ let domainId = process.env.LOXTEP_DOMAIN_ID;
45
+ if (!domainId) {
46
+ const domains = await client.define.domains.list({ page_size: 20 });
47
+ const items = domains.items ?? [];
48
+ if (items.length === 0) {
49
+ console.error(
50
+ 'No domains found. Create one in the Web UI (Governance → Domains) or set LOXTEP_DOMAIN_ID.'
51
+ );
52
+ process.exit(1);
53
+ }
54
+ domainId = items[0].domain_id;
55
+ console.error(`Using domain: ${items[0].name} (${domainId})`);
56
+ }
57
+
58
+ console.error('Creating SDK connector…');
59
+ const connector = await client.connect.connectors.create({
60
+ connector_type: 'sdk',
61
+ metadata: { name: 'SDK Connector', created_by: 'generate-ingest-bundle' },
62
+ });
63
+
64
+ const bundle = buildSdkIngestBundle({
65
+ organization_id: organizationId,
66
+ project_id: projectId,
67
+ domain_id: domainId,
68
+ connector_id: connector.connector_id,
69
+ data_product_name: DATA_PRODUCT_NAME,
70
+ workflow_name: WORKFLOW_NAME,
71
+ user_id: user.user_id,
72
+ workflow_id: randomUUID(),
73
+ connection_id: randomUUID(),
74
+ data_product_id: randomUUID(),
75
+ });
76
+
77
+ mkdirSync('.loxtep', { recursive: true });
78
+ const outPath = join('.loxtep', 'sdk-ingest-bundle.json');
79
+ writeFileSync(outPath, JSON.stringify({ project_id: projectId, files: bundle.files }, null, 2));
80
+
81
+ console.log(
82
+ JSON.stringify(
83
+ {
84
+ connector_id: connector.connector_id,
85
+ workflow_id: bundle.workflow_id,
86
+ data_product_id: bundle.data_product_id,
87
+ data_product_name: bundle.data_product_name,
88
+ bundle_path: outPath,
89
+ },
90
+ null,
91
+ 2
92
+ )
93
+ );
94
+
95
+ if (AUTO_SAVE) {
96
+ console.error('Saving workflow bundle (LOXTEP_AUTO_SAVE=1)…');
97
+ const saveResult = await client.build.workflows.save_workflow_bundle(projectId, {
98
+ files: bundle.files,
99
+ dry_run: false,
100
+ });
101
+ console.error('Deploying…');
102
+ const deployResult = await client.build.workflows.deploy({
103
+ project_id: projectId,
104
+ instance_id: instanceId,
105
+ });
106
+ console.log(JSON.stringify({ save: saveResult, deploy: deployResult }, null, 2));
107
+ console.error(`
108
+ Provisioned. Write events:
109
+ LOXTEP_DATA_PRODUCT_NAME=${DATA_PRODUCT_NAME} node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
110
+ `);
111
+ return;
112
+ }
113
+
114
+ console.error(`
115
+ Next steps (no MCP required)
116
+ ────────────────────────────
117
+ Preferred — one command:
118
+ pnpm exec loxtep ingest provision --name ${DATA_PRODUCT_NAME}
119
+
120
+ Or save the generated bundle:
121
+ pnpm exec loxtep bundle save --dry-run --file ${outPath}
122
+ pnpm exec loxtep bundle save --file ${outPath}
123
+ pnpm exec loxtep workflows deploy --project-id ${projectId} --instance-id ${instanceId}
124
+
125
+ Write events:
126
+ LOXTEP_DATA_PRODUCT_NAME=${DATA_PRODUCT_NAME} node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
127
+ `);
128
+ }
129
+
130
+ main().catch(err => {
131
+ console.error(err instanceof Error ? err.message : err);
132
+ process.exit(1);
133
+ });
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Write sample events to a deployed source data product via get_writer.
4
+ *
5
+ * Prerequisites: login, init, attach, SDK ingest workflow deployed (see sdk-first-ingest.md).
6
+ *
7
+ * node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
8
+ *
9
+ * Env:
10
+ * LOXTEP_DATA_PRODUCT_NAME default: app-events
11
+ */
12
+
13
+ import { LoxtepClient } from '@loxtep/sdk';
14
+
15
+ const DATA_PRODUCT_NAME = process.env.LOXTEP_DATA_PRODUCT_NAME ?? 'app-events';
16
+
17
+ async function main() {
18
+ const client = await LoxtepClient.fromWorkspace();
19
+
20
+ console.error(`Opening writer for data product "${DATA_PRODUCT_NAME}"…`);
21
+ const writer = await client.get_writer(DATA_PRODUCT_NAME);
22
+
23
+ const events = [
24
+ {
25
+ event_id: `evt_${Date.now()}_1`,
26
+ occurred_at: new Date().toISOString(),
27
+ payload: { source: 'write-events.mjs', action: 'example_write', index: 1 },
28
+ },
29
+ {
30
+ event_id: `evt_${Date.now()}_2`,
31
+ occurred_at: new Date().toISOString(),
32
+ payload: { source: 'write-events.mjs', action: 'example_write', index: 2 },
33
+ },
34
+ ];
35
+
36
+ for (const event of events) {
37
+ writer.write(event);
38
+ console.log(JSON.stringify({ written: event.event_id }));
39
+ }
40
+
41
+ await writer.close();
42
+ console.error('Writer closed — events flushed.');
43
+ }
44
+
45
+ main().catch(err => {
46
+ const message = err instanceof Error ? err.message : String(err);
47
+ console.error(message);
48
+ if (/not deployed/i.test(message)) {
49
+ console.error(
50
+ '\nDeploy an SDK ingestion workflow first. See nodejs/docs/sdk-first-ingest.md'
51
+ );
52
+ }
53
+ process.exit(1);
54
+ });
@@ -1,9 +1,13 @@
1
1
  # SDK Getting Started Guide
2
2
 
3
3
  Get from zero to a working Loxtep workspace: authenticate, scaffold a project,
4
- attach to a runtime instance, and generate typed constants. Stream read/write
5
- comes **after** you deploy a workflow that publishes a data product.
4
+ attach to a runtime instance, **provision your first source data product**, and
5
+ write events with `get_writer`.
6
6
 
7
+ > **SDK-first ingest (login → init → attach → write):**
8
+ > [SDK-first ingest](./sdk-first-ingest.md) — the primary path when your app
9
+ > sends events via the SDK (no SaaS connector first).
10
+ >
7
11
  > **Other paths:** [Code-first CLI](./code-first-cli.md) (`init → attach →
8
12
  > generate → test → deploy`), [Agent-first MCP](https://github.com/LoxtepInc/loxtep-plugins-skills),
9
13
  > or the **Web UI** at [app.loxtep.io](https://app.loxtep.io).
@@ -17,9 +21,10 @@ comes **after** you deploy a workflow that publishes a data product.
17
21
  - [Step 3: Scaffold a Workspace](#step-3-scaffold-a-workspace)
18
22
  - [Step 4: Attach to an Instance](#step-4-attach-to-an-instance)
19
23
  - [Step 5: Generate Typed Constants](#step-5-generate-typed-constants)
20
- - [Step 6: Explore the Platform](#step-6-explore-the-platform)
21
- - [Step 7: Use the SDK in Application Code](#step-7-use-the-sdk-in-application-code)
22
- - [Step 8: Write and Read Events (after deploy)](#step-8-write-and-read-events-after-deploy)
24
+ - [Step 6: Your first data product (SDK ingest)](#step-6-your-first-data-product-sdk-ingest)
25
+ - [Step 7: Explore the platform (optional)](#step-7-explore-the-platform-optional)
26
+ - [Step 8: Use the SDK in application code](#step-8-use-the-sdk-in-application-code)
27
+ - [Step 9: Write and read events](#step-9-write-and-read-events)
23
28
  - [Troubleshooting](#troubleshooting)
24
29
  - [Next Steps](#next-steps)
25
30
 
@@ -77,10 +82,20 @@ export LOXTEP_AUTH_TOKEN="your-jwt-token"
77
82
 
78
83
  ## Step 3: Scaffold a Workspace
79
84
 
85
+ Log in **before** `init` so the CLI registers a real platform project (not a
86
+ local-only id that breaks `attach` / `generate` later):
87
+
80
88
  ```bash
81
89
  pnpm exec loxtep init
82
90
  ```
83
91
 
92
+ Bind an **existing** org project instead of creating one:
93
+
94
+ ```bash
95
+ pnpm exec loxtep init --project-id <project-uuid>
96
+ pnpm exec loxtep projects list # discover UUIDs
97
+ ```
98
+
84
99
  Optional starter template:
85
100
 
86
101
  ```bash
@@ -91,12 +106,35 @@ This creates:
91
106
 
92
107
  | Path | Purpose |
93
108
  | --- | --- |
94
- | `.loxtep/project.json` | Project identity; updated by `attach` |
109
+ | `.loxtep/project.json` | **Project identity** includes `project_id` (UUID) registered on the platform |
95
110
  | `workflows/` | Workflow modules you author and deploy |
96
111
  | `connectors/`, `domains/`, `data-products/` | Code-first resource folders |
97
112
 
98
- `init` can run before or after `login`. Platform project registration happens
99
- when you're authenticated; local scaffolding always succeeds.
113
+ ### What is a project?
114
+
115
+ A **project** is your Loxtep workspace on the platform: the container for
116
+ workflows, connectors, and deploy targets. `init` registers one in your org and
117
+ writes its `project_id` into `.loxtep/project.json`. Most CLI commands read
118
+ that file automatically when you run them from the workspace directory.
119
+
120
+ To see your current project id:
121
+
122
+ ```bash
123
+ pnpm exec loxtep config list
124
+ # or
125
+ cat .loxtep/project.json
126
+ ```
127
+
128
+ To list every project in your organization (for example, if you skipped `init`
129
+ or work outside the scaffolded folder):
130
+
131
+ ```bash
132
+ pnpm exec loxtep projects list
133
+ ```
134
+
135
+ If you ran `init` before logging in and have a stale `proj_local_*` id in
136
+ `.loxtep/project.json`, run `loxtep login` then `loxtep init` again — it
137
+ registers a platform project and replaces the local id.
100
138
 
101
139
  ---
102
140
 
@@ -125,20 +163,58 @@ products, connectors, domains, queues, workflows). Re-run after platform changes
125
163
 
126
164
  ---
127
165
 
128
- ## Step 6: Explore the Platform
166
+ ## Step 6: Your first data product (SDK ingest)
167
+
168
+ After `attach`, the usual greenfield goal is: **provision a source data product
169
+ on your instance, then call `get_writer` from your app.**
170
+
171
+ `get_writer` needs **deployment metadata** (queues and bots created at deploy
172
+ time). Creating a catalog row alone is not enough.
173
+
174
+ **Recommended:** follow **[SDK-first ingest](./sdk-first-ingest.md)** end to end.
175
+ Short version:
129
176
 
130
177
  ```bash
178
+ pnpm exec loxtep domains list
179
+
180
+ # One command: SDK connector + workflow bundle + deploy (no MCP)
181
+ pnpm exec loxtep ingest provision --name app-events
182
+
131
183
  pnpm exec loxtep data-products list
132
- pnpm exec loxtep workflows list --project-id <project-id>
184
+ node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
185
+ ```
186
+
187
+ Do **not** expect `pnpm exec loxtep data-products create` alone to enable
188
+ streaming — it registers catalog metadata without runtime bindings.
189
+
190
+ ---
191
+
192
+ ## Step 7: Explore the platform (optional)
193
+
194
+ Run these **from your workspace directory** (where `.loxtep/project.json` lives)
195
+ after Steps 3–4:
196
+
197
+ ```bash
198
+ pnpm exec loxtep config list # confirms project_id + instance_id
199
+ pnpm exec loxtep data-products list # org-wide catalog
200
+ pnpm exec loxtep workflows list # uses project_id from project.json
133
201
  pnpm exec loxtep domains list
134
202
  ```
135
203
 
136
- On a new account, **data products may be empty** until you create and deploy
137
- workflows (CLI, MCP, or Web UI). That's expected — don't call `get_writer` yet.
204
+ If you are not in a scaffolded workspace, list projects first and pass an id
205
+ explicitly:
206
+
207
+ ```bash
208
+ pnpm exec loxtep projects list
209
+ pnpm exec loxtep workflows list --project-id <project-id-from-list>
210
+ ```
211
+
212
+ On a new account, **data products may be empty** until you complete
213
+ [Step 6](#step-6-your-first-data-product-sdk-ingest). That's expected.
138
214
 
139
215
  ---
140
216
 
141
- ## Step 7: Use the SDK in Application Code
217
+ ## Step 8: Use the SDK in application code
142
218
 
143
219
  Prefer workspace auto-config instead of hand-building `api_url` and tokens:
144
220
 
@@ -164,33 +240,22 @@ const instances = await client.workspace.instances.list();
164
240
 
165
241
  ---
166
242
 
167
- ## Step 8: Write and Read Events (after deploy)
168
-
169
- `get_writer` and `get_reader` resolve queue, bot, and stream configuration from
170
- **deployment metadata**. They only work for data products that exist **and** are
171
- deployed on your attached instance.
172
-
173
- 1. Author a workflow under `workflows/` (see [Code-first CLI](./code-first-cli.md)).
174
- 2. `pnpm exec loxtep deploy`
175
- 3. Confirm the data product name:
176
-
177
- ```bash
178
- pnpm exec loxtep data-products list
179
- ```
243
+ ## Step 9: Write and read events
180
244
 
181
- 4. Stream from application code:
245
+ After [Step 6](#step-6-your-first-data-product-sdk-ingest), stream from
246
+ application code:
182
247
 
183
248
  ```typescript
184
249
  const client = await LoxtepClient.fromWorkspace();
185
250
 
186
- const writer = await client.get_writer('orders'); // use your deployed name
251
+ const writer = await client.get_writer('app-events'); // name from Step 6 / data-products list
187
252
  writer.write({
188
253
  order_id: 'ord_1',
189
254
  total: 99.5,
190
255
  });
191
256
  await writer.close();
192
257
 
193
- const reader = await client.get_reader('orders', {
258
+ const reader = await client.get_reader('app-events', {
194
259
  bot_id: 'my-app-reader',
195
260
  });
196
261
  for await (const event of reader) {
@@ -273,6 +338,7 @@ data product UUID instead of a name.
273
338
 
274
339
  | Resource | Description |
275
340
  |----------|-------------|
341
+ | [SDK-first ingest](./sdk-first-ingest.md) | Greenfield: provision + `get_writer` |
276
342
  | [Code-first CLI guide](./code-first-cli.md) | Workflow modules, `test`, `deploy` |
277
343
  | [Quick Reference Card](./quick-reference.md) | Cheat sheet for common operations |
278
344
  | [Event Replay Cookbook](./event-replay-cookbook.md) | Replay and reprocess historical events |
@@ -1,8 +1,8 @@
1
1
  # SDK Quick Reference Card
2
2
 
3
3
  Concise cheat sheet for common Loxtep SDK operations (Node.js).
4
- For full walkthroughs, see the [Getting Started Guide](./getting-started.md)
5
- or [Code-first CLI guide](./code-first-cli.md).
4
+ For full walkthroughs, see [SDK-first ingest](./sdk-first-ingest.md),
5
+ [Getting Started Guide](./getting-started.md), or [Code-first CLI guide](./code-first-cli.md).
6
6
 
7
7
  ---
8
8
 
@@ -183,10 +183,24 @@ const hits = await client.query.catalog.search({ query: 'orders' });
183
183
  Workspace lifecycle (requires `loxtep init` first — see [Code-first CLI guide](./code-first-cli.md)):
184
184
 
185
185
  ```bash
186
- pnpm exec loxtep init [--template shopify-orders]
187
186
  pnpm exec loxtep login
188
- pnpm exec loxtep attach --instance prod
187
+ pnpm exec loxtep init
188
+ pnpm exec loxtep attach --instance <instance-id>
189
189
  pnpm exec loxtep generate
190
+ ```
191
+
192
+ **SDK-first ingest** (after attach — see [SDK-first ingest](./sdk-first-ingest.md)):
193
+
194
+ ```bash
195
+ pnpm exec loxtep domains list
196
+ node node_modules/@loxtep/sdk/docs/examples/generate-ingest-bundle.mjs
197
+ pnpm exec loxtep workflows deploy --project-id <id> --instance-id <id>
198
+ node node_modules/@loxtep/sdk/docs/examples/write-events.mjs
199
+ ```
200
+
201
+ Code-first workflow modules:
202
+
203
+ ```bash
190
204
  pnpm exec loxtep test my-module --event ./events/sample.json
191
205
  pnpm exec loxtep deploy
192
206
  ```