@softr/sdk 1.1.2-alpha.0 → 1.2.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/CHANGELOG.md +6 -0
- package/dist/action.d.ts +41 -3
- package/dist/action.js +13 -3
- package/dist/auth/session.js +14 -1
- package/dist/datasource/enforced-filter.js +15 -2
- package/dist/datasource/record.d.ts +1 -0
- package/dist/datasource/record.js +59 -8
- package/dist/formatting.d.ts +3 -3
- package/dist/mcp.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/pwa.d.ts +2 -2
- package/package.json +10 -34
- package/skills/softr-sdk/SKILL.md +1 -1
- package/skills/softr-sdk/ai/SKILL.md +1 -1
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/charts-and-metrics/SKILL.md +1 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/file-uploads/SKILL.md +1 -1
- package/skills/softr-sdk/formatting/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +1 -1
- package/skills/softr-sdk/mcp/SKILL.md +1 -1
- package/skills/softr-sdk/push-notifications/SKILL.md +1 -1
- package/skills/softr-sdk/pwa/SKILL.md +1 -1
- package/skills/softr-sdk/record-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/record-queries/SKILL.md +1 -1
- package/skills/softr-sdk/region-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/skills/softr-sdk/workflows/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @softr/sdk
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `defineMutation` takes an optional `filter` with its `filterFields` on an update or a delete. `ds.update` and `ds.delete` first check that the record matches the filter. A record that does not match throws "not found", and nothing is written. An update cannot list in `fields` a field that its filter compares with a user token.
|
|
8
|
+
|
|
3
9
|
## 1.1.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/action.d.ts
CHANGED
|
@@ -71,7 +71,7 @@ type DatasourceResource = {
|
|
|
71
71
|
datasourceId: SoftrDatasourceId;
|
|
72
72
|
operation: ActionOperation;
|
|
73
73
|
fields?: Record<string, string>;
|
|
74
|
-
/** The fields that the filter reads, by alias.
|
|
74
|
+
/** The fields that the filter reads, by alias. Only `fields` are read or written. */
|
|
75
75
|
filterFields?: Record<string, string>;
|
|
76
76
|
/** The enforced filter, keyed by alias, with its tokens unresolved. */
|
|
77
77
|
filter?: FilterCriteria;
|
|
@@ -112,6 +112,16 @@ type DeleteDeclaration<TId extends string, TDatasource$1> = {
|
|
|
112
112
|
fields?: never;
|
|
113
113
|
permissions: ActionPermissions;
|
|
114
114
|
};
|
|
115
|
+
type FilterDeclaration<TId extends string, TDatasource$1 extends SoftrDatasourceId, TFilterFields extends Record<string, string>> = {
|
|
116
|
+
/** The fields that `filter` reads, by alias. A user can write them only if `fields` lists them too. */
|
|
117
|
+
filterFields?: TFilterFields;
|
|
118
|
+
filter?: EnforcedFilter<{
|
|
119
|
+
id: TId;
|
|
120
|
+
datasourceId: TDatasource$1;
|
|
121
|
+
operation: "read";
|
|
122
|
+
fields: NoInfer<TFilterFields>;
|
|
123
|
+
}>;
|
|
124
|
+
};
|
|
115
125
|
/**
|
|
116
126
|
* Declares a read: which datasource, which fields participate, and who may run it.
|
|
117
127
|
*
|
|
@@ -160,6 +170,14 @@ declare function defineQuery<const TId extends string, const TDatasource$1 exten
|
|
|
160
170
|
*
|
|
161
171
|
* The argument must be a static object.
|
|
162
172
|
*
|
|
173
|
+
* An update or delete can have a `filter`, with the same operators and tokens as in
|
|
174
|
+
* `defineQuery`. Its keys are aliases of `filterFields`. Before each write, `ds` reads the record
|
|
175
|
+
* through the filter. A record that does not match gives a "not found" error, and nothing is
|
|
176
|
+
* written. A condition on a user token matches no record for a visitor who is signed out.
|
|
177
|
+
*
|
|
178
|
+
* An update cannot write a field that its filter compares with a user token, such as an owner.
|
|
179
|
+
* Otherwise a user could give the record to another user.
|
|
180
|
+
*
|
|
163
181
|
* @example
|
|
164
182
|
* const closeOrder = defineMutation({
|
|
165
183
|
* id: "closeOrder",
|
|
@@ -180,14 +198,34 @@ declare function defineQuery<const TId extends string, const TDatasource$1 exten
|
|
|
180
198
|
* })
|
|
181
199
|
*
|
|
182
200
|
* await ds.delete(removeOrder, { id })
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* const editMyRequest = defineMutation({
|
|
204
|
+
* id: "editMyRequest",
|
|
205
|
+
* datasourceId: "8f14e45f-ceea-467a-9d0b-2c1a0e3b5d77",
|
|
206
|
+
* operation: "update",
|
|
207
|
+
* fields: { title: "V1StGXR8", details: "Xp2dLh6v" },
|
|
208
|
+
* filterFields: { requesterEmail: "Z7pQm4Kd" },
|
|
209
|
+
* filter: { requesterEmail: { is: "{USER:::EMAIL}" } },
|
|
210
|
+
* permissions: { userGroupTypes: ["LOGGED_IN_USERS"] },
|
|
211
|
+
* })
|
|
183
212
|
*/
|
|
184
|
-
declare function defineMutation<const TId extends string, const TDatasource$1 extends SoftrDatasourceId, const
|
|
213
|
+
declare function defineMutation<const TId extends string, const TDatasource$1 extends SoftrDatasourceId, const TFields$1 extends Record<string, FieldIdOf<TDatasource$1, "update">>, const TFilterFields extends Record<string, ReadFieldIdOf<TDatasource$1>> = Record<never, never>>(definition: WriteDeclaration<TId, TDatasource$1, "update", TFields$1> & FilterDeclaration<TId, TDatasource$1, TFilterFields>): DatasourceAction<{
|
|
214
|
+
id: TId;
|
|
215
|
+
datasourceId: TDatasource$1;
|
|
216
|
+
operation: "update";
|
|
217
|
+
fields: TFields$1;
|
|
218
|
+
}>;
|
|
219
|
+
declare function defineMutation<const TId extends string, const TDatasource$1 extends SoftrDatasourceId, const TOperation$1 extends "create" | "update", const TFields$1 extends Record<string, FieldIdOf<TDatasource$1, TOperation$1>>>(definition: WriteDeclaration<TId, TDatasource$1, TOperation$1, TFields$1> & {
|
|
220
|
+
filterFields?: never;
|
|
221
|
+
filter?: never;
|
|
222
|
+
}): DatasourceAction<{
|
|
185
223
|
id: TId;
|
|
186
224
|
datasourceId: TDatasource$1;
|
|
187
225
|
operation: TOperation$1;
|
|
188
226
|
fields: TFields$1;
|
|
189
227
|
}>;
|
|
190
|
-
declare function defineMutation<const TId extends string, const TDatasource$1 extends SoftrDatasourceId
|
|
228
|
+
declare function defineMutation<const TId extends string, const TDatasource$1 extends SoftrDatasourceId, const TFilterFields extends Record<string, ReadFieldIdOf<TDatasource$1>> = Record<never, never>>(definition: DeleteDeclaration<TId, TDatasource$1> & FilterDeclaration<TId, TDatasource$1, TFilterFields>): DatasourceAction<{
|
|
191
229
|
id: TId;
|
|
192
230
|
datasourceId: TDatasource$1;
|
|
193
231
|
operation: "delete";
|
package/dist/action.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "./assertions.js";
|
|
2
|
-
import { buildEnforcedFilter } from "./datasource/enforced-filter.js";
|
|
2
|
+
import { aliasesComparedWithUser, buildEnforcedFilter } from "./datasource/enforced-filter.js";
|
|
3
3
|
|
|
4
4
|
//#region src/action.ts
|
|
5
5
|
function defineQuery(definition) {
|
|
@@ -19,14 +19,24 @@ function defineQuery(definition) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
function defineMutation(definition) {
|
|
22
|
-
const { id, datasourceId, operation, fields, permissions } = definition;
|
|
22
|
+
const { id, datasourceId, operation, fields, filterFields, filter, permissions } = definition;
|
|
23
|
+
assert(filter === void 0 === (filterFields === void 0), () => `defineMutation "${id}": declare filter and filterFields together. The filter names aliases of filterFields.`);
|
|
24
|
+
assert(filter === void 0 || operation === "update" || operation === "delete", () => `defineMutation "${id}": a ${operation} mutation takes no filter. Only an update or a delete has one.`);
|
|
25
|
+
const enforced = filter === void 0 ? void 0 : buildEnforcedFilter(filter, Object.keys(filterFields ?? {}));
|
|
26
|
+
if (operation === "update" && enforced !== void 0) for (const [alias, token] of aliasesComparedWithUser(enforced.filterConditionGroup)) {
|
|
27
|
+
const fieldId = filterFields?.[alias];
|
|
28
|
+
const written = Object.entries(fields ?? {}).find(([, writtenId]) => writtenId === fieldId);
|
|
29
|
+
assert(written === void 0, () => `defineMutation "${id}": "${written?.[0]}" in fields writes ${fieldId}, and the filter compares that field with "${token}". A user could then give the record to another user. Remove "${written?.[0]}" from fields. If some users must reassign records, declare a separate mutation for them, with its own permissions and without this filter.`);
|
|
30
|
+
}
|
|
23
31
|
return {
|
|
24
32
|
id,
|
|
25
33
|
resource: {
|
|
26
34
|
type: "DATASOURCE",
|
|
27
35
|
datasourceId,
|
|
28
36
|
operation,
|
|
29
|
-
fields
|
|
37
|
+
fields,
|
|
38
|
+
filterFields,
|
|
39
|
+
filter: enforced
|
|
30
40
|
},
|
|
31
41
|
permissions
|
|
32
42
|
};
|
package/dist/auth/session.js
CHANGED
|
@@ -58,6 +58,19 @@ function readStandInUser() {
|
|
|
58
58
|
scope.user ??= makePlatform(sessionConfig().applicationId).session(scope.token).then((result) => result.ok ? result.data.user : panic(result.message));
|
|
59
59
|
return scope.user;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The visitor, fetched from the platform now and not from the 5-minute session
|
|
63
|
+
* cache. A write checks its filter with this visitor. So a user who just lost a
|
|
64
|
+
* value, for example a team, cannot write through the old one.
|
|
65
|
+
*/
|
|
66
|
+
async function readFreshUser() {
|
|
67
|
+
const standIn$1 = readStandInUser();
|
|
68
|
+
if (standIn$1 !== void 0) return standIn$1;
|
|
69
|
+
const token = readSessionToken();
|
|
70
|
+
if (token === null) return null;
|
|
71
|
+
const result = await makePlatform(sessionConfig().applicationId).session(token);
|
|
72
|
+
return result.ok ? result.data.user : panic(result.message);
|
|
73
|
+
}
|
|
61
74
|
/** The platform token this request carries, or `null`. */
|
|
62
75
|
function readSessionToken() {
|
|
63
76
|
const scope = standIn.getStore();
|
|
@@ -228,4 +241,4 @@ function openEnvelope(raw, purpose) {
|
|
|
228
241
|
}
|
|
229
242
|
|
|
230
243
|
//#endregion
|
|
231
|
-
export { clearPendingAuth, clearSession, clearSessionData, makePendingAuthCookie, makeSessionDataCookie, makeSessionTokenCookie, readPendingAuthToken, readSessionData, readSessionToken, readStandInUser, withSessionToken };
|
|
244
|
+
export { clearPendingAuth, clearSession, clearSessionData, makePendingAuthCookie, makeSessionDataCookie, makeSessionTokenCookie, readFreshUser, readPendingAuthToken, readSessionData, readSessionToken, readStandInUser, withSessionToken };
|
|
@@ -32,7 +32,7 @@ function buildEnforcedFilter(declared, aliases) {
|
|
|
32
32
|
return value.map(toConstructable);
|
|
33
33
|
}
|
|
34
34
|
function conditions(alias, value) {
|
|
35
|
-
assert(aliases.includes(alias), () => `the filter names "${alias}", which is not one of
|
|
35
|
+
assert(aliases.includes(alias), () => `the filter names "${alias}", which is not one of filterFields`);
|
|
36
36
|
assert(isObject(value) && Object.keys(value).length > 0, () => `"${alias}" in the filter needs at least one operator`);
|
|
37
37
|
const chain = makeChain(alias);
|
|
38
38
|
return Object.entries(value).map(([operator, argument]) => {
|
|
@@ -60,6 +60,19 @@ function buildEnforcedFilter(declared, aliases) {
|
|
|
60
60
|
function readsVisitor(group$1) {
|
|
61
61
|
return values(group$1).some((value) => typeof value === "string" && USER_TOKEN.test(value));
|
|
62
62
|
}
|
|
63
|
+
/** Each alias that the filter compares with a user token, with the first such token. */
|
|
64
|
+
function aliasesComparedWithUser(group$1) {
|
|
65
|
+
const compared = /* @__PURE__ */ new Map();
|
|
66
|
+
visit(group$1);
|
|
67
|
+
return compared;
|
|
68
|
+
function visit({ filters, filterGroups }) {
|
|
69
|
+
for (const filter of filters) {
|
|
70
|
+
const token = (Array.isArray(filter.value) ? filter.value : [filter.value]).find((value) => typeof value === "string" && USER_TOKEN.test(value));
|
|
71
|
+
if (token !== void 0 && !compared.has(filter.subject)) compared.set(filter.subject, token);
|
|
72
|
+
}
|
|
73
|
+
filterGroups.forEach(visit);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
63
76
|
/**
|
|
64
77
|
* The part of the filter that can match rows for this visitor, or `null` when no part can.
|
|
65
78
|
*
|
|
@@ -124,4 +137,4 @@ function isObject(value) {
|
|
|
124
137
|
}
|
|
125
138
|
|
|
126
139
|
//#endregion
|
|
127
|
-
export { buildEnforcedFilter, filterForVisitor, readsVisitor };
|
|
140
|
+
export { aliasesComparedWithUser, buildEnforcedFilter, filterForVisitor, readsVisitor };
|
|
@@ -3,7 +3,7 @@ import { softrApiUrl } from "../softr-api.js";
|
|
|
3
3
|
import { fetch } from "../fetch.js";
|
|
4
4
|
import { softrConfig } from "../softr-config.js";
|
|
5
5
|
import { readUserTimezone } from "../cookies.js";
|
|
6
|
-
import { readSessionToken, readStandInUser } from "../auth/session.js";
|
|
6
|
+
import { readFreshUser, readSessionToken, readStandInUser } from "../auth/session.js";
|
|
7
7
|
import { andGroups, buildFilterCriteria, buildOrderBy, dealiasFilterCriteria, dealiasOrderBy } from "./filter.js";
|
|
8
8
|
import { andAll, makeFieldSet, makeSortSet } from "./fields.js";
|
|
9
9
|
import { filterForVisitor, readsVisitor } from "./enforced-filter.js";
|
|
@@ -211,6 +211,7 @@ async function createRecord(action, options) {
|
|
|
211
211
|
method: "POST",
|
|
212
212
|
headers: {
|
|
213
213
|
"Content-Type": "application/json",
|
|
214
|
+
"X-User-Timezone": readUserTimezone() ?? "UTC",
|
|
214
215
|
Authorization: `Bearer ${readSessionToken()}`,
|
|
215
216
|
...refererHeader()
|
|
216
217
|
},
|
|
@@ -234,13 +235,16 @@ async function createRecord(action, options) {
|
|
|
234
235
|
*/
|
|
235
236
|
async function updateRecord(action, options) {
|
|
236
237
|
if (!options.id) throw new Error(`datasource update: id must not be empty`);
|
|
237
|
-
const
|
|
238
|
+
const target = resolveTarget(action, "update");
|
|
239
|
+
const { actionId, select } = target;
|
|
240
|
+
await requireFilterMatch(target, options.id, "update");
|
|
238
241
|
const data = options.data;
|
|
239
242
|
const rawFields = dealiasData(data, select);
|
|
240
243
|
const res = await fetch(`${dsUrl(actionId)}/records/${options.id}`, {
|
|
241
244
|
method: "PATCH",
|
|
242
245
|
headers: {
|
|
243
246
|
"Content-Type": "application/json",
|
|
247
|
+
"X-User-Timezone": readUserTimezone() ?? "UTC",
|
|
244
248
|
Authorization: `Bearer ${readSessionToken()}`,
|
|
245
249
|
...refererHeader()
|
|
246
250
|
},
|
|
@@ -260,10 +264,13 @@ async function updateRecord(action, options) {
|
|
|
260
264
|
* await ds.delete(removePost, { id: "record-id" })
|
|
261
265
|
*/
|
|
262
266
|
async function deleteRecord(action, options) {
|
|
263
|
-
const
|
|
267
|
+
const target = resolveTarget(action, "delete");
|
|
268
|
+
const { actionId } = target;
|
|
269
|
+
await requireFilterMatch(target, options.id, "delete");
|
|
264
270
|
const res = await fetch(`${dsUrl(actionId)}/records/${options.id}`, {
|
|
265
271
|
method: "DELETE",
|
|
266
272
|
headers: {
|
|
273
|
+
"X-User-Timezone": readUserTimezone() ?? "UTC",
|
|
267
274
|
Authorization: `Bearer ${readSessionToken()}`,
|
|
268
275
|
...refererHeader()
|
|
269
276
|
}
|
|
@@ -283,17 +290,62 @@ function resolveTarget(subject, operation) {
|
|
|
283
290
|
};
|
|
284
291
|
}
|
|
285
292
|
/**
|
|
293
|
+
* The id suffix of the READ action that app-sync declares for each mutation with a filter.
|
|
294
|
+
*
|
|
295
|
+
* Never change it. App-sync ships with the pod, and an app keeps the SDK version it pinned, so the
|
|
296
|
+
* two can differ in age and still must agree.
|
|
297
|
+
*/
|
|
298
|
+
const FILTER_CHECK_SUFFIX = "__check";
|
|
299
|
+
/**
|
|
300
|
+
* Before an update or a delete, reads the record through the mutation's filter. It reads with the
|
|
301
|
+
* READ action that app-sync declares for the mutation, because the datasource refuses a read through
|
|
302
|
+
* a write action. A record that does not match throws "not found", and the caller sends no write.
|
|
303
|
+
*
|
|
304
|
+
* The record can still change between this read and the write. Another request can change a field
|
|
305
|
+
* that the filter reads, and a date token can pass midnight. Only the fields that the filter
|
|
306
|
+
* compares with a user token stay out of reach of this mutation, because `defineMutation` keeps
|
|
307
|
+
* them out of `fields`.
|
|
308
|
+
*/
|
|
309
|
+
async function requireFilterMatch(target, id, operation) {
|
|
310
|
+
if (target.filter === void 0) return;
|
|
311
|
+
const check = {
|
|
312
|
+
actionId: `${target.actionId}${FILTER_CHECK_SUFFIX}`,
|
|
313
|
+
select: {},
|
|
314
|
+
filterFields: target.filterFields,
|
|
315
|
+
filter: target.filter
|
|
316
|
+
};
|
|
317
|
+
const notFound = () => /* @__PURE__ */ new Error(`datasource ${operation} failed for action "${target.actionId}": record "${id}" not found`);
|
|
318
|
+
const filterCriteria = await readFilterCriteria(check, [], readFreshUser);
|
|
319
|
+
if (filterCriteria === null) throw notFound();
|
|
320
|
+
const res = await fetch(`${dsUrl(check.actionId)}/records/${id}`, {
|
|
321
|
+
method: "POST",
|
|
322
|
+
headers: {
|
|
323
|
+
"Content-Type": "application/json",
|
|
324
|
+
"X-User-Timezone": readUserTimezone() ?? "UTC",
|
|
325
|
+
Authorization: `Bearer ${readSessionToken()}`,
|
|
326
|
+
...refererHeader()
|
|
327
|
+
},
|
|
328
|
+
body: JSON.stringify({
|
|
329
|
+
options: { userLocale: "en-US" },
|
|
330
|
+
filterCriteria
|
|
331
|
+
})
|
|
332
|
+
});
|
|
333
|
+
if (res.status === 404) throw notFound();
|
|
334
|
+
if (!res.ok) throw new Error(`datasource ${operation} failed for action "${target.actionId}": ${await describeFailure(res)}`);
|
|
335
|
+
if (await res.text() === "") throw notFound();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
286
338
|
* The filter a read sends: the query's enforced filter, with its tokens, AND the `where`
|
|
287
339
|
* filters. `null` when the enforced filter matches no rows for this visitor. The read then sends
|
|
288
340
|
* no request and returns nothing.
|
|
289
341
|
*/
|
|
290
|
-
async function readFilterCriteria(target, filters) {
|
|
342
|
+
async function readFilterCriteria(target, filters, readUser = async () => readStandInUser() ?? readSoftrContext().user) {
|
|
291
343
|
const groups = [];
|
|
292
344
|
const enforced = target.filter?.filterConditionGroup;
|
|
293
345
|
if (enforced !== void 0) {
|
|
294
|
-
const forVisitor = readsVisitor(enforced) ? filterForVisitor(enforced, await
|
|
346
|
+
const forVisitor = readsVisitor(enforced) ? filterForVisitor(enforced, toVisitor(await readUser())) : enforced;
|
|
295
347
|
if (forVisitor === null) return null;
|
|
296
|
-
groups.push(dealias(forVisitor, requireDefined(target.filterFields, "
|
|
348
|
+
groups.push(dealias(forVisitor, requireDefined(target.filterFields, "an action with a filter declares filterFields")));
|
|
297
349
|
}
|
|
298
350
|
const requested = filters.length ? buildFilterCriteria(andAll(filters)).filterConditionGroup : void 0;
|
|
299
351
|
if (requested !== void 0) groups.push(dealias(requested, target.select));
|
|
@@ -303,8 +355,7 @@ async function readFilterCriteria(target, filters) {
|
|
|
303
355
|
return requireDefined(dealiasFilterCriteria({ filterConditionGroup: group }, aliases).filterConditionGroup);
|
|
304
356
|
}
|
|
305
357
|
}
|
|
306
|
-
|
|
307
|
-
const user = await (readStandInUser() ?? readSoftrContext().user);
|
|
358
|
+
function toVisitor(user) {
|
|
308
359
|
if (user === null) return null;
|
|
309
360
|
const properties = user.properties;
|
|
310
361
|
const aliasOf = new Map(Object.entries(softrConfig().user?.properties ?? {}).map(([alias, fieldId]) => [fieldId, alias]));
|
package/dist/formatting.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react0 from "react";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/formatting.d.ts
|
|
@@ -96,7 +96,7 @@ declare function FormattingScope({
|
|
|
96
96
|
/** A BCP 47 locale, such as `de-DE`. It drops the app's fixed date format inside the scope. */
|
|
97
97
|
locale?: string;
|
|
98
98
|
children?: ReactNode;
|
|
99
|
-
}):
|
|
99
|
+
}): react0.FunctionComponentElement<react0.ProviderProps<Scope>>;
|
|
100
100
|
/**
|
|
101
101
|
* A date in the app's format, safe to render on the server. A timestamp whose
|
|
102
102
|
* zone is not known yet renders `fallback` until the browser supplies it, so
|
|
@@ -118,6 +118,6 @@ declare function FormattedDate({
|
|
|
118
118
|
time?: boolean;
|
|
119
119
|
/** What renders while the visitor's zone is unknown. */
|
|
120
120
|
fallback?: ReactNode;
|
|
121
|
-
}):
|
|
121
|
+
}): react0.FunctionComponentElement<react0.FragmentProps> | null;
|
|
122
122
|
//#endregion
|
|
123
123
|
export { DateOptions, DateParts, DateSeparator, DateValue, FixedDateFormat, FormattedDate, Formatting, FormattingScope, WeekDay, formatDate, formatDateTime, formatNumber, useFormatting };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DatasourceAction } from "./action.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _tanstack_react_start8 from "@tanstack/react-start";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
|
5
5
|
|
|
@@ -31,6 +31,6 @@ type SoftrMcpOptions = {
|
|
|
31
31
|
* ],
|
|
32
32
|
* }))
|
|
33
33
|
*/
|
|
34
|
-
declare function softrMcpMiddleware(options?: SoftrMcpOptions):
|
|
34
|
+
declare function softrMcpMiddleware(options?: SoftrMcpOptions): _tanstack_react_start8.RequestMiddlewareAfterServer<{}, undefined, undefined>;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { softrMcpMiddleware };
|
package/dist/package.js
CHANGED
package/dist/pwa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react4 from "react";
|
|
2
2
|
import "@tanstack/react-start";
|
|
3
3
|
|
|
4
4
|
//#region src/pwa.d.ts
|
|
@@ -23,7 +23,7 @@ import "@tanstack/react-start";
|
|
|
23
23
|
* )
|
|
24
24
|
* }
|
|
25
25
|
*/
|
|
26
|
-
declare function SoftrPwaHead():
|
|
26
|
+
declare function SoftrPwaHead(): react4.FunctionComponentElement<react4.FragmentProps>;
|
|
27
27
|
type PwaPlatform = "ios" | "android" | "desktop";
|
|
28
28
|
type PwaInstall = {
|
|
29
29
|
available: false;
|
package/package.json
CHANGED
|
@@ -1,38 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softr/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"./server": {
|
|
15
|
-
"types": "./dist/server.d.ts",
|
|
16
|
-
"import": "./dist/server.js"
|
|
17
|
-
},
|
|
18
|
-
"./vite": {
|
|
19
|
-
"types": "./dist/vite.d.ts",
|
|
20
|
-
"import": "./dist/vite.js"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"bin": {
|
|
24
|
-
"softr-sdk": "./dist/cli.js"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist",
|
|
28
|
-
"schema",
|
|
29
|
-
"skills",
|
|
30
|
-
"!skills/_artifacts",
|
|
31
|
-
"CHANGELOG.md"
|
|
32
|
-
],
|
|
33
|
-
"publishConfig": {
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
6
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
|
7
|
+
"./client": { "types": "./dist/client.d.ts", "import": "./dist/client.js" },
|
|
8
|
+
"./server": { "types": "./dist/server.d.ts", "import": "./dist/server.js" },
|
|
9
|
+
"./vite": { "types": "./dist/vite.d.ts", "import": "./dist/vite.js" }
|
|
10
|
+
},
|
|
11
|
+
"bin": { "softr-sdk": "./dist/cli.js" },
|
|
12
|
+
"files": ["dist", "schema", "skills", "!skills/_artifacts", "CHANGELOG.md"],
|
|
13
|
+
"publishConfig": { "access": "public" },
|
|
36
14
|
"scripts": {
|
|
37
15
|
"build": "tsdown",
|
|
38
16
|
"test": "node --import ./src/test-utils/setup.ts --test",
|
|
@@ -64,9 +42,7 @@
|
|
|
64
42
|
"optional": true
|
|
65
43
|
}
|
|
66
44
|
},
|
|
67
|
-
"keywords": [
|
|
68
|
-
"tanstack-intent"
|
|
69
|
-
],
|
|
45
|
+
"keywords": ["tanstack-intent"],
|
|
70
46
|
"intent": {
|
|
71
47
|
"version": 1,
|
|
72
48
|
"repo": "@softr/sdk",
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
metadata:
|
|
14
14
|
type: sub-skill
|
|
15
15
|
library: softr-sdk
|
|
16
|
-
library_version: 1.
|
|
16
|
+
library_version: 1.2.0
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
**Boundary.** `ai` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineAiAction` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.
|
|
12
|
+
library_version: 1.2.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `auth` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.
|
|
12
|
+
library_version: 1.2.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.
|
|
10
|
+
library_version: 1.2.0
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `upload` lives on `@softr/sdk/server` and runs inside server functions. `useFileUpload` and `FileItem` live on `@softr/sdk` and run in components. `FileAttachment` comes from `@softr/sdk` and can be imported anywhere.
|
|
@@ -7,7 +7,7 @@ description: >-
|
|
|
7
7
|
metadata:
|
|
8
8
|
type: sub-skill
|
|
9
9
|
library: softr-sdk
|
|
10
|
-
library_version: 1.
|
|
10
|
+
library_version: 1.2.0
|
|
11
11
|
---
|
|
12
12
|
|
|
13
13
|
**Boundary.** `integration` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineIntegration` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.
|
|
12
|
+
library_version: 1.2.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `softrMcpMiddleware` lives on `@softr/sdk` and is registered once, in `src/start.ts`. The actions you hand it are the same `defineQuery` / `defineMutation` values the app's own pages use — declared wherever they already live, not duplicated for MCP.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.
|
|
12
|
+
library_version: 1.2.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineMutation` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -10,7 +10,7 @@ description: >-
|
|
|
10
10
|
metadata:
|
|
11
11
|
type: sub-skill
|
|
12
12
|
library: softr-sdk
|
|
13
|
-
library_version: 1.
|
|
13
|
+
library_version: 1.2.0
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
**Boundary.** `ds` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler or a server-side route hook — importing it into a component fails the build. The same holds for any helper that calls `ds`: declare it inside the handler. A function at module level that calls `ds` keeps the server-only import in the browser bundle, and every page stops loading until it moves. `defineQuery` and every type come from `@softr/sdk` and can be imported anywhere.
|
|
@@ -9,7 +9,7 @@ description: >-
|
|
|
9
9
|
metadata:
|
|
10
10
|
type: sub-skill
|
|
11
11
|
library: softr-sdk
|
|
12
|
-
library_version: 1.
|
|
12
|
+
library_version: 1.2.0
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
**Boundary.** `workflow` lives on `@softr/sdk/server` and runs only inside a `createServerFn` handler — importing it into a component fails the build. `defineWorkflow` and every type come from `@softr/sdk` and can be imported anywhere.
|