@softr/sdk 0.0.25 → 0.0.26
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/action.d.ts +195 -0
- package/dist/action.js +21 -0
- package/dist/auth/isomorphic.d.ts +1 -2
- package/dist/auth/permissions.d.ts +7 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +639 -0
- package/dist/codegen/datasource-types.js +471 -0
- package/dist/codegen/softr-env.js +103 -0
- package/dist/codegen/user-groups.js +11 -0
- package/dist/core/integration.js +1 -1
- package/dist/datasource/chart.d.ts +196 -0
- package/dist/datasource/chart.js +289 -0
- package/dist/datasource/datasource.d.ts +16 -0
- package/dist/datasource/datasource.js +17 -0
- package/dist/datasource/fields.d.ts +122 -0
- package/dist/datasource/fields.js +82 -0
- package/dist/datasource/filter.d.ts +30 -0
- package/dist/datasource/filter.js +146 -0
- package/dist/datasource/record.d.ts +138 -0
- package/dist/datasource/record.js +258 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -2
- package/dist/package.js +5 -0
- package/dist/routes/visibility.d.ts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/package.json +2 -1
- package/skills/softr-sdk/SKILL.md +6 -2
- package/skills/softr-sdk/auth/SKILL.md +1 -1
- package/skills/softr-sdk/current-user/SKILL.md +1 -1
- package/skills/softr-sdk/data-mutations/SKILL.md +1 -1
- package/skills/softr-sdk/integrations/SKILL.md +140 -0
- package/skills/softr-sdk/reading-records/SKILL.md +1 -1
- package/skills/softr-sdk/routes-and-visibility/SKILL.md +1 -1
- package/dist/core/datasource.d.ts +0 -31
- package/dist/core/datasource.js +0 -226
- package/dist/core/query.d.ts +0 -354
- package/dist/core/query.js +0 -528
- package/dist/core/utils.js +0 -14
- package/dist/types.d.ts +0 -128
package/dist/core/query.js
DELETED
|
@@ -1,528 +0,0 @@
|
|
|
1
|
-
//#region src/core/query.ts
|
|
2
|
-
const INTERNAL_KIND = Symbol("KIND");
|
|
3
|
-
/**
|
|
4
|
-
* Query builder for filter queries. This exist to alleviate the (LLM?) mental overhead. API filter schema is a bit
|
|
5
|
-
* verbose and confusing, even when dealing with very basic queries. So to fall into the pit of success, aim here
|
|
6
|
-
* is to simplify filtering as much as possible.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* single filter
|
|
10
|
-
* ```tsx
|
|
11
|
-
* const query = q.text("title").contains("hello");
|
|
12
|
-
*
|
|
13
|
-
* const json = buildFilterCriteria(query);
|
|
14
|
-
* // result
|
|
15
|
-
* {
|
|
16
|
-
* "filterCriteria": {
|
|
17
|
-
* "filterConditionGroup": {
|
|
18
|
-
* "logicalOperator": "AND"
|
|
19
|
-
* "filterGroups": [{
|
|
20
|
-
* "logicalOperator": "AND",
|
|
21
|
-
* "filters": [{
|
|
22
|
-
* "subject": "title",
|
|
23
|
-
* "type": "TEXT",
|
|
24
|
-
* "operator": "CONTAINS",
|
|
25
|
-
* "value": "hello"
|
|
26
|
-
* }],
|
|
27
|
-
* }]
|
|
28
|
-
* }
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* combining multiple filters
|
|
36
|
-
* ```tsx
|
|
37
|
-
* const query = q.and(
|
|
38
|
-
* q.text("title").contains("hello"),
|
|
39
|
-
* q.number("views").is(100),
|
|
40
|
-
* q.or(
|
|
41
|
-
* q.text("author").is("John"),
|
|
42
|
-
* q.boolean("isPublished").is(true)
|
|
43
|
-
* )
|
|
44
|
-
* );
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
const q = {
|
|
48
|
-
select(mapping) {
|
|
49
|
-
return mapping;
|
|
50
|
-
},
|
|
51
|
-
and(...filters) {
|
|
52
|
-
return {
|
|
53
|
-
logicalOperator: "AND",
|
|
54
|
-
filters,
|
|
55
|
-
[INTERNAL_KIND]: "LOGICAL_GROUP"
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
or(...filters) {
|
|
59
|
-
return {
|
|
60
|
-
logicalOperator: "OR",
|
|
61
|
-
filters,
|
|
62
|
-
[INTERNAL_KIND]: "LOGICAL_GROUP"
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
text(subject) {
|
|
66
|
-
const filter = {
|
|
67
|
-
subject,
|
|
68
|
-
type: "TEXT",
|
|
69
|
-
[INTERNAL_KIND]: "FILTER"
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
is(value) {
|
|
73
|
-
return {
|
|
74
|
-
...filter,
|
|
75
|
-
operator: "IS",
|
|
76
|
-
value
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
isNot(value) {
|
|
80
|
-
return {
|
|
81
|
-
...filter,
|
|
82
|
-
operator: "IS_NOT",
|
|
83
|
-
value
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
contains(value) {
|
|
87
|
-
return {
|
|
88
|
-
...filter,
|
|
89
|
-
operator: "CONTAINS",
|
|
90
|
-
value
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
isOneOf(value) {
|
|
94
|
-
return {
|
|
95
|
-
...filter,
|
|
96
|
-
operator: "IS_ONE_OF",
|
|
97
|
-
value
|
|
98
|
-
};
|
|
99
|
-
},
|
|
100
|
-
isNoneOf(value) {
|
|
101
|
-
return {
|
|
102
|
-
...filter,
|
|
103
|
-
operator: "IS_NONE_OF",
|
|
104
|
-
value
|
|
105
|
-
};
|
|
106
|
-
},
|
|
107
|
-
startsWith(value) {
|
|
108
|
-
return {
|
|
109
|
-
...filter,
|
|
110
|
-
operator: "STARTS_WITH",
|
|
111
|
-
value
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
endsWith(value) {
|
|
115
|
-
return {
|
|
116
|
-
...filter,
|
|
117
|
-
operator: "ENDS_WITH",
|
|
118
|
-
value
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
hasAllOf(value) {
|
|
122
|
-
return {
|
|
123
|
-
...filter,
|
|
124
|
-
operator: "HAS_ALL_OF",
|
|
125
|
-
value
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
isEmpty() {
|
|
129
|
-
return {
|
|
130
|
-
...filter,
|
|
131
|
-
operator: "IS_EMPTY"
|
|
132
|
-
};
|
|
133
|
-
},
|
|
134
|
-
isNotEmpty() {
|
|
135
|
-
return {
|
|
136
|
-
...filter,
|
|
137
|
-
operator: "IS_NOT_EMPTY"
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
boolean(subject) {
|
|
143
|
-
const filter = {
|
|
144
|
-
subject,
|
|
145
|
-
type: "BOOLEAN",
|
|
146
|
-
[INTERNAL_KIND]: "FILTER"
|
|
147
|
-
};
|
|
148
|
-
return {
|
|
149
|
-
is(value) {
|
|
150
|
-
return {
|
|
151
|
-
...filter,
|
|
152
|
-
operator: "IS",
|
|
153
|
-
value
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
isNot(value) {
|
|
157
|
-
return {
|
|
158
|
-
...filter,
|
|
159
|
-
operator: "IS_NOT",
|
|
160
|
-
value
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
isEmpty() {
|
|
164
|
-
return {
|
|
165
|
-
...filter,
|
|
166
|
-
operator: "IS_EMPTY"
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
isNotEmpty() {
|
|
170
|
-
return {
|
|
171
|
-
...filter,
|
|
172
|
-
operator: "IS_NOT_EMPTY"
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
},
|
|
177
|
-
number(subject) {
|
|
178
|
-
const filter = {
|
|
179
|
-
subject,
|
|
180
|
-
type: "NUMERIC",
|
|
181
|
-
[INTERNAL_KIND]: "FILTER"
|
|
182
|
-
};
|
|
183
|
-
return {
|
|
184
|
-
is(value) {
|
|
185
|
-
return {
|
|
186
|
-
...filter,
|
|
187
|
-
operator: "IS",
|
|
188
|
-
value: value.toString()
|
|
189
|
-
};
|
|
190
|
-
},
|
|
191
|
-
isNot(value) {
|
|
192
|
-
return {
|
|
193
|
-
...filter,
|
|
194
|
-
operator: "IS_NOT",
|
|
195
|
-
value: value.toString()
|
|
196
|
-
};
|
|
197
|
-
},
|
|
198
|
-
gt(value) {
|
|
199
|
-
return {
|
|
200
|
-
...filter,
|
|
201
|
-
operator: "GT",
|
|
202
|
-
value: value.toString()
|
|
203
|
-
};
|
|
204
|
-
},
|
|
205
|
-
gte(value) {
|
|
206
|
-
return {
|
|
207
|
-
...filter,
|
|
208
|
-
operator: "GTE",
|
|
209
|
-
value: value.toString()
|
|
210
|
-
};
|
|
211
|
-
},
|
|
212
|
-
lt(value) {
|
|
213
|
-
return {
|
|
214
|
-
...filter,
|
|
215
|
-
operator: "LT",
|
|
216
|
-
value: value.toString()
|
|
217
|
-
};
|
|
218
|
-
},
|
|
219
|
-
lte(value) {
|
|
220
|
-
return {
|
|
221
|
-
...filter,
|
|
222
|
-
operator: "LTE",
|
|
223
|
-
value: value.toString()
|
|
224
|
-
};
|
|
225
|
-
},
|
|
226
|
-
between(start, end) {
|
|
227
|
-
return {
|
|
228
|
-
...filter,
|
|
229
|
-
operator: "BETWEEN",
|
|
230
|
-
value: [start.toString(), end.toString()]
|
|
231
|
-
};
|
|
232
|
-
},
|
|
233
|
-
isEmpty() {
|
|
234
|
-
return {
|
|
235
|
-
...filter,
|
|
236
|
-
operator: "IS_EMPTY"
|
|
237
|
-
};
|
|
238
|
-
},
|
|
239
|
-
isNotEmpty() {
|
|
240
|
-
return {
|
|
241
|
-
...filter,
|
|
242
|
-
operator: "IS_NOT_EMPTY"
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
},
|
|
247
|
-
array(subject) {
|
|
248
|
-
const filter = {
|
|
249
|
-
subject,
|
|
250
|
-
type: "ARRAY",
|
|
251
|
-
[INTERNAL_KIND]: "FILTER"
|
|
252
|
-
};
|
|
253
|
-
return {
|
|
254
|
-
is(value) {
|
|
255
|
-
return {
|
|
256
|
-
...filter,
|
|
257
|
-
operator: "IS",
|
|
258
|
-
value
|
|
259
|
-
};
|
|
260
|
-
},
|
|
261
|
-
isOneOf(value) {
|
|
262
|
-
return {
|
|
263
|
-
...filter,
|
|
264
|
-
operator: "IS_ONE_OF",
|
|
265
|
-
value
|
|
266
|
-
};
|
|
267
|
-
},
|
|
268
|
-
isNoneOf(value) {
|
|
269
|
-
return {
|
|
270
|
-
...filter,
|
|
271
|
-
operator: "IS_NONE_OF",
|
|
272
|
-
value
|
|
273
|
-
};
|
|
274
|
-
},
|
|
275
|
-
hasAllOf(value) {
|
|
276
|
-
return {
|
|
277
|
-
...filter,
|
|
278
|
-
operator: "HAS_ALL_OF",
|
|
279
|
-
value
|
|
280
|
-
};
|
|
281
|
-
},
|
|
282
|
-
isEmpty() {
|
|
283
|
-
return {
|
|
284
|
-
...filter,
|
|
285
|
-
operator: "IS_EMPTY"
|
|
286
|
-
};
|
|
287
|
-
},
|
|
288
|
-
isNotEmpty() {
|
|
289
|
-
return {
|
|
290
|
-
...filter,
|
|
291
|
-
operator: "IS_NOT_EMPTY"
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
},
|
|
296
|
-
date(subject) {
|
|
297
|
-
const filter = {
|
|
298
|
-
subject,
|
|
299
|
-
type: "DATE",
|
|
300
|
-
[INTERNAL_KIND]: "FILTER"
|
|
301
|
-
};
|
|
302
|
-
return {
|
|
303
|
-
is(value) {
|
|
304
|
-
return {
|
|
305
|
-
...filter,
|
|
306
|
-
operator: "IS",
|
|
307
|
-
value
|
|
308
|
-
};
|
|
309
|
-
},
|
|
310
|
-
isNot(value) {
|
|
311
|
-
return {
|
|
312
|
-
...filter,
|
|
313
|
-
operator: "IS_NOT",
|
|
314
|
-
value
|
|
315
|
-
};
|
|
316
|
-
},
|
|
317
|
-
gt(value) {
|
|
318
|
-
return {
|
|
319
|
-
...filter,
|
|
320
|
-
operator: "GT",
|
|
321
|
-
value
|
|
322
|
-
};
|
|
323
|
-
},
|
|
324
|
-
gte(value) {
|
|
325
|
-
return {
|
|
326
|
-
...filter,
|
|
327
|
-
operator: "GTE",
|
|
328
|
-
value
|
|
329
|
-
};
|
|
330
|
-
},
|
|
331
|
-
lt(value) {
|
|
332
|
-
return {
|
|
333
|
-
...filter,
|
|
334
|
-
operator: "LT",
|
|
335
|
-
value
|
|
336
|
-
};
|
|
337
|
-
},
|
|
338
|
-
lte(value) {
|
|
339
|
-
return {
|
|
340
|
-
...filter,
|
|
341
|
-
operator: "LTE",
|
|
342
|
-
value
|
|
343
|
-
};
|
|
344
|
-
},
|
|
345
|
-
between(start, end) {
|
|
346
|
-
return {
|
|
347
|
-
...filter,
|
|
348
|
-
operator: "BETWEEN",
|
|
349
|
-
value: [start, end]
|
|
350
|
-
};
|
|
351
|
-
},
|
|
352
|
-
isNotBetween(start, end) {
|
|
353
|
-
return {
|
|
354
|
-
...filter,
|
|
355
|
-
operator: "IS_NOT_BETWEEN",
|
|
356
|
-
value: [start, end]
|
|
357
|
-
};
|
|
358
|
-
},
|
|
359
|
-
isEmpty() {
|
|
360
|
-
return {
|
|
361
|
-
...filter,
|
|
362
|
-
operator: "IS_EMPTY"
|
|
363
|
-
};
|
|
364
|
-
},
|
|
365
|
-
isNotEmpty() {
|
|
366
|
-
return {
|
|
367
|
-
...filter,
|
|
368
|
-
operator: "IS_NOT_EMPTY"
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
},
|
|
373
|
-
asc(subject) {
|
|
374
|
-
return {
|
|
375
|
-
sortingField: subject,
|
|
376
|
-
sortType: "ASC",
|
|
377
|
-
[INTERNAL_KIND]: "ORDER_BY"
|
|
378
|
-
};
|
|
379
|
-
},
|
|
380
|
-
desc(subject) {
|
|
381
|
-
return {
|
|
382
|
-
sortingField: subject,
|
|
383
|
-
sortType: "DESC",
|
|
384
|
-
[INTERNAL_KIND]: "ORDER_BY"
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
/**
|
|
389
|
-
* Converts filter utility conditions to a format our backend supports
|
|
390
|
-
*
|
|
391
|
-
* @example
|
|
392
|
-
* ```tsx
|
|
393
|
-
* const query = q.text("title").contains("hello");
|
|
394
|
-
*
|
|
395
|
-
* const json = buildFilterCriteria(query);
|
|
396
|
-
* // result
|
|
397
|
-
* {
|
|
398
|
-
* "filterCriteria": {
|
|
399
|
-
* "filterConditionGroup": {
|
|
400
|
-
* "logicalOperator": "AND"
|
|
401
|
-
* "filterGroups": [{
|
|
402
|
-
* "logicalOperator": "AND",
|
|
403
|
-
* "filters": [{
|
|
404
|
-
* "subject": "title",
|
|
405
|
-
* "type": "TEXT",
|
|
406
|
-
* "operator": "CONTAINS",
|
|
407
|
-
* "value": "hello"
|
|
408
|
-
* }],
|
|
409
|
-
* }]
|
|
410
|
-
* }
|
|
411
|
-
* }
|
|
412
|
-
* }
|
|
413
|
-
*
|
|
414
|
-
* ```
|
|
415
|
-
*/
|
|
416
|
-
function buildFilterCriteria(input) {
|
|
417
|
-
if (!(INTERNAL_KIND in input)) throw new Error("Filters cannot be constructed manually. Use the 'q' helper.");
|
|
418
|
-
if (isFilter(input)) return { filterConditionGroup: {
|
|
419
|
-
logicalOperator: "AND",
|
|
420
|
-
filterGroups: [{
|
|
421
|
-
logicalOperator: "AND",
|
|
422
|
-
filters: [stripInternalKind(input)]
|
|
423
|
-
}]
|
|
424
|
-
} };
|
|
425
|
-
if (isFilterGroup(input)) {
|
|
426
|
-
if (input.filters.length === 0) return { filterConditionGroup: {
|
|
427
|
-
logicalOperator: input.logicalOperator,
|
|
428
|
-
filterGroups: []
|
|
429
|
-
} };
|
|
430
|
-
return { filterConditionGroup: {
|
|
431
|
-
logicalOperator: input.logicalOperator,
|
|
432
|
-
filterGroups: input.filters.map((inner) => {
|
|
433
|
-
if (isFilter(inner)) return {
|
|
434
|
-
logicalOperator: "AND",
|
|
435
|
-
filters: [stripInternalKind(inner)]
|
|
436
|
-
};
|
|
437
|
-
if (!inner.filters.every(isFilter)) throw new Error("Cannot nest filter groups more than three levels deep.");
|
|
438
|
-
return {
|
|
439
|
-
logicalOperator: inner.logicalOperator,
|
|
440
|
-
filters: inner.filters.map(stripInternalKind)
|
|
441
|
-
};
|
|
442
|
-
})
|
|
443
|
-
} };
|
|
444
|
-
}
|
|
445
|
-
throw new Error("Unknown filter kind: " + input[INTERNAL_KIND]);
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Converts order-by utility conditions to a format our backend supports
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
* single orderBy
|
|
452
|
-
* ```tsx
|
|
453
|
-
* const orderBy = buildOrderBy(q.asc("title"));
|
|
454
|
-
* // result: [{ sortingField: "title", sortType: "ASC" }]
|
|
455
|
-
* ```
|
|
456
|
-
*
|
|
457
|
-
* @example
|
|
458
|
-
* multiple orderBys
|
|
459
|
-
* ```tsx
|
|
460
|
-
* const orderBy = buildOrderBy([q.desc("createdAt"), q.asc("title")]);
|
|
461
|
-
* // result: [
|
|
462
|
-
* // { sortingField: "createdAt", sortType: "DESC" },
|
|
463
|
-
* // { sortingField: "title", sortType: "ASC" }
|
|
464
|
-
* // ]
|
|
465
|
-
* ```
|
|
466
|
-
*/
|
|
467
|
-
function buildOrderBy(input) {
|
|
468
|
-
const orderBys = Array.isArray(input) ? input : [input];
|
|
469
|
-
if (!orderBys.every((ob) => ob[INTERNAL_KIND] === "ORDER_BY")) throw new Error("orderBy conditions cannot be constructed manually. Use the 'q' helper.");
|
|
470
|
-
return orderBys.map((orderBy) => ({
|
|
471
|
-
sortingField: orderBy.sortingField,
|
|
472
|
-
sortType: orderBy.sortType
|
|
473
|
-
}));
|
|
474
|
-
}
|
|
475
|
-
function dealiasOrderBy(orderbys, aliases) {
|
|
476
|
-
return orderbys.map((orderBy) => {
|
|
477
|
-
const subject = aliases[orderBy.sortingField];
|
|
478
|
-
if (!subject) throw new Error(`Could not find an alias for subject "${orderBy.sortingField}"`);
|
|
479
|
-
return {
|
|
480
|
-
...orderBy,
|
|
481
|
-
sortingField: subject
|
|
482
|
-
};
|
|
483
|
-
});
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Replaces filter subjects with their aliased values.
|
|
487
|
-
*
|
|
488
|
-
* Throws an error if any filter subject does not have a corresponding alias in the provided mapping.
|
|
489
|
-
*
|
|
490
|
-
* @example
|
|
491
|
-
* ```tsx
|
|
492
|
-
* const criteria = buildFilterCriteria(q.text("name").contains("John"));
|
|
493
|
-
* const aliases = { name: "abcxy123" };
|
|
494
|
-
* const dealiased = dealiasFilterCriteria(criteria, aliases);
|
|
495
|
-
* // Result: filter subject is now "abcxyz123" instead of "name"
|
|
496
|
-
* ```
|
|
497
|
-
*/
|
|
498
|
-
function dealiasFilterCriteria(criteria, aliases) {
|
|
499
|
-
if (!criteria.filterConditionGroup) return criteria;
|
|
500
|
-
return { filterConditionGroup: {
|
|
501
|
-
...criteria.filterConditionGroup,
|
|
502
|
-
filterGroups: criteria.filterConditionGroup.filterGroups.map((group) => ({
|
|
503
|
-
...group,
|
|
504
|
-
filters: group.filters.map(dealiasFilter)
|
|
505
|
-
}))
|
|
506
|
-
} };
|
|
507
|
-
function dealiasFilter(filter) {
|
|
508
|
-
const subject = aliases[filter.subject];
|
|
509
|
-
if (!subject) throw new Error(`Could not find an alias for subject "${subject}"`);
|
|
510
|
-
return {
|
|
511
|
-
...filter,
|
|
512
|
-
subject
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
function stripInternalKind(item) {
|
|
517
|
-
const { [INTERNAL_KIND]: _,...rest } = item;
|
|
518
|
-
return rest;
|
|
519
|
-
}
|
|
520
|
-
function isFilterGroup(item) {
|
|
521
|
-
return item[INTERNAL_KIND] === "LOGICAL_GROUP";
|
|
522
|
-
}
|
|
523
|
-
function isFilter(item) {
|
|
524
|
-
return item[INTERNAL_KIND] === "FILTER";
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
//#endregion
|
|
528
|
-
export { buildFilterCriteria, buildOrderBy, dealiasFilterCriteria, dealiasOrderBy, q };
|
package/dist/core/utils.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/core/utils.ts
|
|
2
|
-
async function assertResponseOk(res, message) {
|
|
3
|
-
if (!res.ok) {
|
|
4
|
-
let fullMessage = `${message}: ${res.status}`;
|
|
5
|
-
if (process.env.NODE_ENV !== "production") {
|
|
6
|
-
const body = await res.text().catch(() => "");
|
|
7
|
-
if (body) fullMessage += `\n\n${body}`;
|
|
8
|
-
}
|
|
9
|
-
throw new Error(fullMessage);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { assertResponseOk };
|
package/dist/types.d.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { AnyConstructable, ConstructableOrderBy } from "./core/query.js";
|
|
2
|
-
import { SoftrUserGroupId } from "./auth/user.js";
|
|
3
|
-
|
|
4
|
-
//#region src/types.d.ts
|
|
5
|
-
interface SoftrUser {
|
|
6
|
-
id: string;
|
|
7
|
-
email: string;
|
|
8
|
-
name: string;
|
|
9
|
-
userGroupIds: Array<SoftrUserGroupId>;
|
|
10
|
-
}
|
|
11
|
-
interface DatasourcePermissions {
|
|
12
|
-
read: boolean;
|
|
13
|
-
create: boolean;
|
|
14
|
-
update: boolean;
|
|
15
|
-
delete: boolean;
|
|
16
|
-
}
|
|
17
|
-
interface SoftrPermissions {
|
|
18
|
-
datasources: Record<string, DatasourcePermissions>;
|
|
19
|
-
workflows: Record<string, boolean>;
|
|
20
|
-
}
|
|
21
|
-
interface SoftrMe {
|
|
22
|
-
user: SoftrUser | null;
|
|
23
|
-
permissions: SoftrPermissions;
|
|
24
|
-
}
|
|
25
|
-
type GetByIdOptions = {
|
|
26
|
-
id: string;
|
|
27
|
-
where?: never;
|
|
28
|
-
timeZone?: string;
|
|
29
|
-
select?: Record<string, string>;
|
|
30
|
-
};
|
|
31
|
-
type GetByWhereOptions = {
|
|
32
|
-
id?: never;
|
|
33
|
-
where: AnyConstructable;
|
|
34
|
-
timeZone?: string;
|
|
35
|
-
select?: Record<string, string>;
|
|
36
|
-
};
|
|
37
|
-
type GetOptions = GetByIdOptions | GetByWhereOptions;
|
|
38
|
-
interface ListOptions {
|
|
39
|
-
/**
|
|
40
|
-
* Maps human-readable aliases to Softr field IDs.
|
|
41
|
-
* When provided, returned fields are keyed by alias instead of raw field ID.
|
|
42
|
-
*/
|
|
43
|
-
select?: Record<string, string>;
|
|
44
|
-
where?: AnyConstructable;
|
|
45
|
-
orderBy?: ConstructableOrderBy | ConstructableOrderBy[];
|
|
46
|
-
/**
|
|
47
|
-
* Number of records to return per page. Defaults to 20, max 100.
|
|
48
|
-
*/
|
|
49
|
-
limit?: number;
|
|
50
|
-
/**
|
|
51
|
-
* Offset to start from. Pass the `nextOffset` from a previous result to paginate.
|
|
52
|
-
* Omit or pass `null` to start from the beginning.
|
|
53
|
-
*/
|
|
54
|
-
offset?: number | null;
|
|
55
|
-
/** Override the timezone for this request. */
|
|
56
|
-
timeZone?: string;
|
|
57
|
-
}
|
|
58
|
-
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
59
|
-
[key: string]: JsonValue;
|
|
60
|
-
};
|
|
61
|
-
interface SoftrRecord<T extends Record<string, JsonValue> = Record<string, JsonValue>> {
|
|
62
|
-
id: string;
|
|
63
|
-
fields: T;
|
|
64
|
-
}
|
|
65
|
-
interface ListResult<T extends SoftrRecord = SoftrRecord> {
|
|
66
|
-
records: T[];
|
|
67
|
-
total: number;
|
|
68
|
-
/** Offset to pass as `offset` in the next call, or `null` when there are no more pages. */
|
|
69
|
-
nextOffset: number | null;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Augment this interface in a generated datasource-types file to enable
|
|
73
|
-
* typed `ds.list()` / `ds.get()` return values per datasource ID.
|
|
74
|
-
* Maps datasource ID → raw field shape (keyed by field ID).
|
|
75
|
-
*/
|
|
76
|
-
interface DatasourceTypeMap {}
|
|
77
|
-
type AliasedFields<Sel extends Record<string, string>, Raw extends Record<string, JsonValue>> = { [K in keyof Sel]: Sel[K] extends keyof Raw ? Raw[Sel[K]] : JsonValue };
|
|
78
|
-
type RecordFieldsFor<Id extends string, Sel extends Record<string, string>> = Id extends keyof DatasourceTypeMap ? [keyof Sel] extends [never] ? DatasourceTypeMap[Id] : AliasedFields<Sel, DatasourceTypeMap[Id]> : Record<string, JsonValue>;
|
|
79
|
-
type AggregationFunction = 'SUM' | 'AVG' | 'MAX' | 'MIN' | 'COUNT' | 'DISTINCT';
|
|
80
|
-
interface MetricOptions {
|
|
81
|
-
select?: Record<string, string>;
|
|
82
|
-
where?: AnyConstructable;
|
|
83
|
-
aggregation: AggregationFunction;
|
|
84
|
-
/** Field alias (resolved via select) or raw field ID. Not required for COUNT. */
|
|
85
|
-
field?: string;
|
|
86
|
-
/** Override the timezone for this request. */
|
|
87
|
-
timeZone?: string;
|
|
88
|
-
}
|
|
89
|
-
interface MetricResult {
|
|
90
|
-
value: number | null;
|
|
91
|
-
executionTimestamp: Date;
|
|
92
|
-
}
|
|
93
|
-
interface ChartOptions {
|
|
94
|
-
select?: Record<string, string>;
|
|
95
|
-
where?: AnyConstructable;
|
|
96
|
-
/** Field alias (resolved via select) or raw field ID. */
|
|
97
|
-
groupBy: string | string[];
|
|
98
|
-
metrics: Record<string, {
|
|
99
|
-
field?: string;
|
|
100
|
-
aggregation: AggregationFunction;
|
|
101
|
-
}>;
|
|
102
|
-
orderBy?: ConstructableOrderBy;
|
|
103
|
-
/** Override the timezone for this request. */
|
|
104
|
-
timeZone?: string;
|
|
105
|
-
}
|
|
106
|
-
interface ChartResult {
|
|
107
|
-
data: Record<string, JsonValue>[];
|
|
108
|
-
executionTimestamp: Date;
|
|
109
|
-
}
|
|
110
|
-
interface CreateOptions {
|
|
111
|
-
/**
|
|
112
|
-
* Maps human-readable aliases to Softr field IDs.
|
|
113
|
-
* When provided, `data` keys are interpreted as aliases.
|
|
114
|
-
*/
|
|
115
|
-
select?: Record<string, string>;
|
|
116
|
-
data: Record<string, JsonValue>;
|
|
117
|
-
}
|
|
118
|
-
interface UpdateOptions {
|
|
119
|
-
id: string;
|
|
120
|
-
/**
|
|
121
|
-
* Maps human-readable aliases to Softr field IDs.
|
|
122
|
-
* When provided, `data` keys are interpreted as aliases.
|
|
123
|
-
*/
|
|
124
|
-
select?: Record<string, string>;
|
|
125
|
-
data: Record<string, JsonValue>;
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
export { AggregationFunction, ChartOptions, ChartResult, CreateOptions, DatasourcePermissions, DatasourceTypeMap, GetOptions, JsonValue, ListOptions, ListResult, MetricOptions, MetricResult, RecordFieldsFor, SoftrMe, SoftrPermissions, SoftrRecord, SoftrUser, UpdateOptions };
|