@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.cjs CHANGED
@@ -7,6 +7,24 @@ var ai = require('ai');
7
7
  // src/react/auth.tsx
8
8
 
9
9
  // src/auth/token-store.ts
10
+ function createMemoryTokenStore(initial) {
11
+ let accessToken = null;
12
+ let refreshToken = null;
13
+ return {
14
+ getAccessToken: () => accessToken,
15
+ getRefreshToken: () => refreshToken,
16
+ setTokens: (tokens) => {
17
+ accessToken = tokens.accessToken;
18
+ if (tokens.refreshToken !== void 0) {
19
+ refreshToken = tokens.refreshToken;
20
+ }
21
+ },
22
+ clear: () => {
23
+ accessToken = null;
24
+ refreshToken = null;
25
+ }
26
+ };
27
+ }
10
28
  function createLocalStorageTokenStore(options = {}) {
11
29
  const accessTokenKey = options.accessTokenKey ?? "accessToken";
12
30
  const refreshTokenKey = options.refreshTokenKey ?? "refreshToken";
@@ -1106,6 +1124,35 @@ var EntityTypesResource = class {
1106
1124
  }
1107
1125
  };
1108
1126
 
1127
+ // src/resources/tables.ts
1128
+ var TablesResource = class {
1129
+ constructor(http) {
1130
+ this.http = http;
1131
+ }
1132
+ http;
1133
+ /** Lists tables in the API key's workspace (without columns and rows). */
1134
+ list(options = {}) {
1135
+ return this.http.get("/api/tables", {
1136
+ query: { projectId: options.projectId }
1137
+ });
1138
+ }
1139
+ /** Returns a single table by ID, including columns and rows. */
1140
+ get(id) {
1141
+ return this.http.get(`/api/tables/${id}`);
1142
+ }
1143
+ /** Returns a single table by its workspace slug, including columns and rows. */
1144
+ getBySlug(slug) {
1145
+ return this.http.get(`/api/tables/slug/${slug}`);
1146
+ }
1147
+ /**
1148
+ * Creates or updates a table by workspace slug. Omitted columns or rows
1149
+ * keep their current value. Marks `managedByCode` by default.
1150
+ */
1151
+ upsertBySlug(input) {
1152
+ return this.http.post("/api/tables/upsert", { body: input });
1153
+ }
1154
+ };
1155
+
1109
1156
  // src/resources/approvals.ts
1110
1157
  var ApprovalsResource = class {
1111
1158
  constructor(http) {
@@ -2090,6 +2137,8 @@ var LunnoaClient = class {
2090
2137
  approvals;
2091
2138
  entities;
2092
2139
  entityTypes;
2140
+ /** Small reference / lookup tables (rows stored inline; use entities for transactional data). */
2141
+ tables;
2093
2142
  knowledge;
2094
2143
  queues;
2095
2144
  queueItems;
@@ -2113,6 +2162,7 @@ var LunnoaClient = class {
2113
2162
  this.workflows = new WorkflowsResource(this.http, this.executions);
2114
2163
  this.entities = new EntitiesResource(this.http);
2115
2164
  this.entityTypes = new EntityTypesResource(this.http);
2165
+ this.tables = new TablesResource(this.http);
2116
2166
  this.knowledge = new KnowledgeResource(this.http);
2117
2167
  this.queues = new QueuesResource(this.http);
2118
2168
  this.queueItems = new QueueItemsResource(this.http);
@@ -2150,7 +2200,8 @@ function resolveClient(props) {
2150
2200
  }
2151
2201
  return createBrowserClient({
2152
2202
  baseUrl: options.baseUrl,
2153
- tokenStore: options.tokenStore,
2203
+ // SSR (e.g. Next.js) has no localStorage; the browser builds its own client on hydration.
2204
+ tokenStore: options.tokenStore ?? (typeof window === "undefined" ? createMemoryTokenStore() : void 0),
2154
2205
  autoRefresh: options.autoRefresh,
2155
2206
  fetch: options.fetch,
2156
2207
  headers: options.headers