@lunnoa/client 1.4.0 → 2.0.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/dist/react.js CHANGED
@@ -5,6 +5,24 @@ import { DefaultChatTransport } from 'ai';
5
5
  // src/react/auth.tsx
6
6
 
7
7
  // src/auth/token-store.ts
8
+ function createMemoryTokenStore(initial) {
9
+ let accessToken = null;
10
+ let refreshToken = null;
11
+ return {
12
+ getAccessToken: () => accessToken,
13
+ getRefreshToken: () => refreshToken,
14
+ setTokens: (tokens) => {
15
+ accessToken = tokens.accessToken;
16
+ if (tokens.refreshToken !== void 0) {
17
+ refreshToken = tokens.refreshToken;
18
+ }
19
+ },
20
+ clear: () => {
21
+ accessToken = null;
22
+ refreshToken = null;
23
+ }
24
+ };
25
+ }
8
26
  function createLocalStorageTokenStore(options = {}) {
9
27
  const accessTokenKey = options.accessTokenKey ?? "accessToken";
10
28
  const refreshTokenKey = options.refreshTokenKey ?? "refreshToken";
@@ -682,12 +700,12 @@ var AgentsResource = class {
682
700
  });
683
701
  }
684
702
  /**
685
- * Upsert an agent by project-scoped slug.
703
+ * Upsert an agent by slug inside the workspace on the API key.
686
704
  * Prefer the CLI (`npx @lunnoa/client agents deploy`) for happy-path deploy.
687
705
  */
688
- upsertBySlug(projectId, body, options) {
706
+ upsertBySlug(body, options) {
689
707
  const payload = "kind" in body && body.kind === "agent" ? agentDefinitionToUpsert(body, options) : body;
690
- return this.http.post(`/api/projects/${projectId}/agents/upsert`, {
708
+ return this.http.post("/api/agents/upsert", {
691
709
  body: payload
692
710
  });
693
711
  }
@@ -1104,6 +1122,33 @@ var EntityTypesResource = class {
1104
1122
  }
1105
1123
  };
1106
1124
 
1125
+ // src/resources/tables.ts
1126
+ var TablesResource = class {
1127
+ constructor(http) {
1128
+ this.http = http;
1129
+ }
1130
+ http;
1131
+ /** Lists tables in the API key's workspace (without columns and rows). */
1132
+ list() {
1133
+ return this.http.get("/api/tables");
1134
+ }
1135
+ /** Returns a single table by ID, including columns and rows. */
1136
+ get(id) {
1137
+ return this.http.get(`/api/tables/${id}`);
1138
+ }
1139
+ /** Returns a single table by its workspace slug, including columns and rows. */
1140
+ getBySlug(slug) {
1141
+ return this.http.get(`/api/tables/slug/${slug}`);
1142
+ }
1143
+ /**
1144
+ * Creates or updates a table by workspace slug. Omitted columns or rows
1145
+ * keep their current value. Marks `managedByCode` by default.
1146
+ */
1147
+ upsertBySlug(input) {
1148
+ return this.http.post("/api/tables/upsert", { body: input });
1149
+ }
1150
+ };
1151
+
1107
1152
  // src/resources/approvals.ts
1108
1153
  var ApprovalsResource = class {
1109
1154
  constructor(http) {
@@ -1505,30 +1550,6 @@ var KnowledgeResource = class {
1505
1550
  }
1506
1551
  };
1507
1552
 
1508
- // src/resources/projects.ts
1509
- var ProjectsResource = class {
1510
- constructor(http) {
1511
- this.http = http;
1512
- }
1513
- http;
1514
- /** Lists projects in the workspace, most recently updated first. */
1515
- list(options) {
1516
- return this.http.get("/api/projects", {
1517
- query: serializeListQuery(options)
1518
- });
1519
- }
1520
- /** Returns a single project. */
1521
- get(projectId, options) {
1522
- return this.http.get(`/api/projects/${projectId}`, {
1523
- query: serializeListQuery(options)
1524
- });
1525
- }
1526
- /** Creates a project. */
1527
- create(data) {
1528
- return this.http.post("/api/projects", { body: data });
1529
- }
1530
- };
1531
-
1532
1553
  // src/resources/queue-items.ts
1533
1554
  var QueueItemsResource = class {
1534
1555
  constructor(http) {
@@ -1808,7 +1829,7 @@ var RunsResource = class {
1808
1829
  * Start a linear multi-step ad-hoc Execution.
1809
1830
  *
1810
1831
  * Accepts a `defineWorkflow` result, a step array, or an explicit
1811
- * `{ steps, projectId?, name? }` payload.
1832
+ * `{ steps, name? }` payload.
1812
1833
  */
1813
1834
  start(input) {
1814
1835
  const options = normalizeStartRunInput(input);
@@ -2026,15 +2047,14 @@ var WorkflowsResource = class {
2026
2047
  });
2027
2048
  }
2028
2049
  /**
2029
- * Upsert a workflow by project-scoped slug from a linear step list.
2050
+ * Upsert a workflow by slug inside the workspace on the API key.
2030
2051
  * Prefer the CLI (`npx @lunnoa/client workflows deploy`) for happy-path deploy.
2031
2052
  */
2032
- upsertBySlug(projectId, body) {
2053
+ upsertBySlug(body) {
2033
2054
  const payload = "kind" in body && body.kind === "workflow" ? workflowDefinitionToUpsert(body) : body;
2034
- return this.http.post(
2035
- `/api/projects/${projectId}/workflows/upsert`,
2036
- { body: payload }
2037
- );
2055
+ return this.http.post("/api/workflows/upsert", {
2056
+ body: payload
2057
+ });
2038
2058
  }
2039
2059
  /**
2040
2060
  * Starts a new execution of the workflow with the given trigger inputs.
@@ -2088,13 +2108,14 @@ var LunnoaClient = class {
2088
2108
  approvals;
2089
2109
  entities;
2090
2110
  entityTypes;
2111
+ /** Small reference / lookup tables (rows stored inline; use entities for transactional data). */
2112
+ tables;
2091
2113
  knowledge;
2092
2114
  queues;
2093
2115
  queueItems;
2094
2116
  variables;
2095
2117
  scorecards;
2096
2118
  connections;
2097
- projects;
2098
2119
  workflowApps;
2099
2120
  discovery;
2100
2121
  constructor(options) {
@@ -2111,13 +2132,13 @@ var LunnoaClient = class {
2111
2132
  this.workflows = new WorkflowsResource(this.http, this.executions);
2112
2133
  this.entities = new EntitiesResource(this.http);
2113
2134
  this.entityTypes = new EntityTypesResource(this.http);
2135
+ this.tables = new TablesResource(this.http);
2114
2136
  this.knowledge = new KnowledgeResource(this.http);
2115
2137
  this.queues = new QueuesResource(this.http);
2116
2138
  this.queueItems = new QueueItemsResource(this.http);
2117
2139
  this.variables = new VariablesResource(this.http);
2118
2140
  this.scorecards = new ScorecardsResource(this.http);
2119
2141
  this.connections = new ConnectionsResource(this.http);
2120
- this.projects = new ProjectsResource(this.http);
2121
2142
  this.discovery = new DiscoveryResource(this.http);
2122
2143
  }
2123
2144
  };
@@ -2148,7 +2169,8 @@ function resolveClient(props) {
2148
2169
  }
2149
2170
  return createBrowserClient({
2150
2171
  baseUrl: options.baseUrl,
2151
- tokenStore: options.tokenStore,
2172
+ // SSR (e.g. Next.js) has no localStorage; the browser builds its own client on hydration.
2173
+ tokenStore: options.tokenStore ?? (typeof window === "undefined" ? createMemoryTokenStore() : void 0),
2152
2174
  autoRefresh: options.autoRefresh,
2153
2175
  fetch: options.fetch,
2154
2176
  headers: options.headers