@lunnoa/client 1.4.0 → 1.5.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";
@@ -1104,6 +1122,35 @@ 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(options = {}) {
1133
+ return this.http.get("/api/tables", {
1134
+ query: { projectId: options.projectId }
1135
+ });
1136
+ }
1137
+ /** Returns a single table by ID, including columns and rows. */
1138
+ get(id) {
1139
+ return this.http.get(`/api/tables/${id}`);
1140
+ }
1141
+ /** Returns a single table by its workspace slug, including columns and rows. */
1142
+ getBySlug(slug) {
1143
+ return this.http.get(`/api/tables/slug/${slug}`);
1144
+ }
1145
+ /**
1146
+ * Creates or updates a table by workspace slug. Omitted columns or rows
1147
+ * keep their current value. Marks `managedByCode` by default.
1148
+ */
1149
+ upsertBySlug(input) {
1150
+ return this.http.post("/api/tables/upsert", { body: input });
1151
+ }
1152
+ };
1153
+
1107
1154
  // src/resources/approvals.ts
1108
1155
  var ApprovalsResource = class {
1109
1156
  constructor(http) {
@@ -2088,6 +2135,8 @@ var LunnoaClient = class {
2088
2135
  approvals;
2089
2136
  entities;
2090
2137
  entityTypes;
2138
+ /** Small reference / lookup tables (rows stored inline; use entities for transactional data). */
2139
+ tables;
2091
2140
  knowledge;
2092
2141
  queues;
2093
2142
  queueItems;
@@ -2111,6 +2160,7 @@ var LunnoaClient = class {
2111
2160
  this.workflows = new WorkflowsResource(this.http, this.executions);
2112
2161
  this.entities = new EntitiesResource(this.http);
2113
2162
  this.entityTypes = new EntityTypesResource(this.http);
2163
+ this.tables = new TablesResource(this.http);
2114
2164
  this.knowledge = new KnowledgeResource(this.http);
2115
2165
  this.queues = new QueuesResource(this.http);
2116
2166
  this.queueItems = new QueueItemsResource(this.http);
@@ -2148,7 +2198,8 @@ function resolveClient(props) {
2148
2198
  }
2149
2199
  return createBrowserClient({
2150
2200
  baseUrl: options.baseUrl,
2151
- tokenStore: options.tokenStore,
2201
+ // SSR (e.g. Next.js) has no localStorage; the browser builds its own client on hydration.
2202
+ tokenStore: options.tokenStore ?? (typeof window === "undefined" ? createMemoryTokenStore() : void 0),
2152
2203
  autoRefresh: options.autoRefresh,
2153
2204
  fetch: options.fetch,
2154
2205
  headers: options.headers