exponential-sdk 1.24.0 → 1.26.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/README.md +61 -0
- package/dist/index.d.ts +484 -2
- package/dist/index.js +105 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1137,6 +1137,88 @@ var PagesApi = class {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
};
|
|
1139
1139
|
|
|
1140
|
+
// src/databases.ts
|
|
1141
|
+
var DatabasesApi = class {
|
|
1142
|
+
constructor(client) {
|
|
1143
|
+
this.client = client;
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Create a database on a page with a title property. Then put its
|
|
1147
|
+
* `marker` into the page body (`pages.update` with the body plus the
|
|
1148
|
+
* marker on its own line) so the page shows it.
|
|
1149
|
+
*/
|
|
1150
|
+
async create(input) {
|
|
1151
|
+
return await this.client.database.create.mutate(input);
|
|
1152
|
+
}
|
|
1153
|
+
/** One database: definition, view, row count and holding page. */
|
|
1154
|
+
async get(id) {
|
|
1155
|
+
return await this.client.database.get.query({ id });
|
|
1156
|
+
}
|
|
1157
|
+
/** The databases a page holds, detached ones included, with row counts. */
|
|
1158
|
+
async list(pageId) {
|
|
1159
|
+
return await this.client.database.list.query({ pageId });
|
|
1160
|
+
}
|
|
1161
|
+
/** Rename, or replace the saved view whole. */
|
|
1162
|
+
async update(input) {
|
|
1163
|
+
return await this.client.database.update.mutate(input);
|
|
1164
|
+
}
|
|
1165
|
+
/** Delete the database and every row with it. Removing the block from the page only detaches; this is the delete. */
|
|
1166
|
+
async delete(id) {
|
|
1167
|
+
return await this.client.database.delete.mutate({ id });
|
|
1168
|
+
}
|
|
1169
|
+
// ── Properties ─────────────────────────────────────────────────────────────
|
|
1170
|
+
/** Add a property. New select options get ids and palette colours; the column goes last in the view. */
|
|
1171
|
+
async addProperty(input) {
|
|
1172
|
+
return await this.client.database.addProperty.mutate(input);
|
|
1173
|
+
}
|
|
1174
|
+
/** Rename, describe, retype or re-option a property. Ids stay; no row is rewritten. */
|
|
1175
|
+
async updateProperty(input) {
|
|
1176
|
+
return await this.client.database.updateProperty.mutate(input);
|
|
1177
|
+
}
|
|
1178
|
+
/** Remove a property (by id or name) from the schema and view. Never the title. */
|
|
1179
|
+
async removeProperty(databaseId, propertyId) {
|
|
1180
|
+
return await this.client.database.removeProperty.mutate({ id: databaseId, propertyId });
|
|
1181
|
+
}
|
|
1182
|
+
/** Set the column order; `propertyIds` must name every property exactly once. */
|
|
1183
|
+
async reorderProperties(databaseId, propertyIds) {
|
|
1184
|
+
return await this.client.database.reorderProperties.mutate({ id: databaseId, propertyIds });
|
|
1185
|
+
}
|
|
1186
|
+
// ── Rows ───────────────────────────────────────────────────────────────────
|
|
1187
|
+
/** The rows through the saved view (or `options.view`), paged by cursor. */
|
|
1188
|
+
async listRows(databaseId, options = {}) {
|
|
1189
|
+
return await this.client.database.listRows.query({ id: databaseId, ...options });
|
|
1190
|
+
}
|
|
1191
|
+
/** Add a row with typed values. Placed where the holding page is. */
|
|
1192
|
+
async createRow(databaseId, values = {}, options = {}) {
|
|
1193
|
+
return await this.client.database.createRow.mutate({ id: databaseId, values, ...options });
|
|
1194
|
+
}
|
|
1195
|
+
/** Write some of a row's values; cells not named are kept, `null` clears one. Records a revision on the row page. */
|
|
1196
|
+
async updateRow(rowId, values, options = {}) {
|
|
1197
|
+
return await this.client.database.updateRow.mutate({ rowId, values, ...options });
|
|
1198
|
+
}
|
|
1199
|
+
/** Delete a row — the page and its search chunks. */
|
|
1200
|
+
async deleteRow(rowId) {
|
|
1201
|
+
return await this.client.database.deleteRow.mutate({ rowId });
|
|
1202
|
+
}
|
|
1203
|
+
// ── CSV import ─────────────────────────────────────────────────────────────
|
|
1204
|
+
/**
|
|
1205
|
+
* Type a CSV against the database before anything is created: columns
|
|
1206
|
+
* resolved through `mapping` (or suggested by header name), every row
|
|
1207
|
+
* checked, each cell that does not fit named. Writes nothing.
|
|
1208
|
+
*/
|
|
1209
|
+
async previewCsv(databaseId, csv, mapping) {
|
|
1210
|
+
return await this.client.database.previewCsv.mutate({ id: databaseId, csv, ...mapping ? { mapping } : {} });
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* Import a CSV: new columns become properties, then every row with no
|
|
1214
|
+
* cell error becomes a row with a `create` revision; the rest are reported
|
|
1215
|
+
* and left uncreated. Up to 2,000 rows a time.
|
|
1216
|
+
*/
|
|
1217
|
+
async commitCsv(databaseId, csv, mapping, options = {}) {
|
|
1218
|
+
return await this.client.database.commitCsv.mutate({ id: databaseId, csv, mapping, ...options });
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1140
1222
|
// src/resources.ts
|
|
1141
1223
|
var ResourcesApi = class {
|
|
1142
1224
|
constructor(client) {
|
|
@@ -1149,9 +1231,23 @@ var ResourcesApi = class {
|
|
|
1149
1231
|
const result = await this.client.resource.create.mutate(input);
|
|
1150
1232
|
return result.resource;
|
|
1151
1233
|
}
|
|
1152
|
-
|
|
1234
|
+
async get(id) {
|
|
1235
|
+
const result = await this.client.resource.get.query({ id });
|
|
1236
|
+
return result.resource;
|
|
1237
|
+
}
|
|
1238
|
+
async update(id, input) {
|
|
1239
|
+
const result = await this.client.resource.update.mutate({ id, ...input });
|
|
1240
|
+
return result.resource;
|
|
1241
|
+
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Save a link to the Reading list: a `bookmark` in `to_read`, not embedded.
|
|
1244
|
+
*
|
|
1245
|
+
* `tags` are added to the ones the link already has. The server dedupes by
|
|
1246
|
+
* URL and would replace the set on re-save, so the link is saved untagged
|
|
1247
|
+
* (which leaves existing tags alone) and the union written after.
|
|
1248
|
+
*/
|
|
1153
1249
|
async save(input) {
|
|
1154
|
-
|
|
1250
|
+
const resource = await this.create({
|
|
1155
1251
|
title: input.title?.trim() || hostnameOf(input.url) || input.url,
|
|
1156
1252
|
url: input.url,
|
|
1157
1253
|
description: input.note,
|
|
@@ -1160,6 +1256,10 @@ var ResourcesApi = class {
|
|
|
1160
1256
|
generateEmbeddings: false,
|
|
1161
1257
|
workspaceId: input.workspaceId
|
|
1162
1258
|
});
|
|
1259
|
+
const existing = resource.tags ?? [];
|
|
1260
|
+
const added = (input.tags ?? []).filter((t) => !existing.includes(t));
|
|
1261
|
+
if (added.length === 0) return resource;
|
|
1262
|
+
return await this.update(resource.id, { tags: [...existing, ...added] });
|
|
1163
1263
|
}
|
|
1164
1264
|
async setReadStatus(id, readStatus) {
|
|
1165
1265
|
return await this.client.resource.setReadStatus.mutate({ id, readStatus });
|
|
@@ -1548,6 +1648,7 @@ var ExponentialClient = class {
|
|
|
1548
1648
|
this.areas = new AreasApi(this.client);
|
|
1549
1649
|
this.meetings = new MeetingsApi(this.client);
|
|
1550
1650
|
this.pages = new PagesApi(this.client);
|
|
1651
|
+
this.databases = new DatabasesApi(this.client);
|
|
1551
1652
|
this.resources = new ResourcesApi(this.client);
|
|
1552
1653
|
this.requirements = new RequirementsApi(this.client);
|
|
1553
1654
|
this.scopes = new ScopesApi(this.client);
|
|
@@ -1579,6 +1680,8 @@ var ExponentialClient = class {
|
|
|
1579
1680
|
areas;
|
|
1580
1681
|
meetings;
|
|
1581
1682
|
pages;
|
|
1683
|
+
/** Databases — typed tables inside pages (ADR-0078). */
|
|
1684
|
+
databases;
|
|
1582
1685
|
resources;
|
|
1583
1686
|
requirements;
|
|
1584
1687
|
scopes;
|