@revenexx/app-sdk 2.1.0 → 2.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/README.md +68 -6
- package/dist/{chunk-TLWWVUJ4.js → chunk-ZTTYOJYU.js} +166 -1
- package/dist/{chunk-TLWWVUJ4.js.map → chunk-ZTTYOJYU.js.map} +1 -1
- package/dist/{errors-CkBo_7bc.d.cts → errors-CjuqA3DC.d.cts} +10 -0
- package/dist/{errors-CkBo_7bc.d.ts → errors-CjuqA3DC.d.ts} +10 -0
- package/dist/index.cjs +164 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +49 -5
- package/dist/index.js.map +1 -1
- package/dist/router/index.cjs +175 -6
- package/dist/router/index.cjs.map +1 -1
- package/dist/router/index.d.cts +12 -2
- package/dist/router/index.d.ts +12 -2
- package/dist/router/index.js +22 -8
- package/dist/router/index.js.map +1 -1
- package/package.json +1 -1
package/dist/router/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as SettingsDefaults, l as ReadOptions, n as ResolvedSettings, r as SettingsSnapshot, u as WriteOptions, t as SettingsWriteResult, q as SettingsReader, p as SettingsOptions, e as BackdatingOptions, Q as Query, R as Row, P as Page, s as SettingsSource } from '../errors-
|
|
2
|
-
export { L as BACKDATING_FIELD, N as BACKDATING_INVALID, T as BACKDATING_SETTING, B as BackdatingEntity, U as BackdatingSource, D as DEFAULT_GATEWAY_ENDPOINT, f as DEFAULT_SETTINGS_ERROR_TTL_MS, g as DEFAULT_SETTINGS_TIMEOUT_MS, h as DEFAULT_SETTINGS_TTL_MS, H as HttpError, k as HttpErrorOptions, M as MAX_MONTHS_BACK, m as Refusal, v as backdated, V as backdatingAllowed, w as backdatingDb, X as badRequest, x as clock, Y as conflict, y as createSettings, Z as forbidden, z as isHttpError, _ as notFound, G as now, I as parseBackdate, J as refusalOf, K as runAt } from '../errors-
|
|
1
|
+
import { o as SettingsDefaults, l as ReadOptions, n as ResolvedSettings, r as SettingsSnapshot, u as WriteOptions, t as SettingsWriteResult, q as SettingsReader, p as SettingsOptions, e as BackdatingOptions, Q as Query, R as Row, P as Page, s as SettingsSource } from '../errors-CjuqA3DC.cjs';
|
|
2
|
+
export { L as BACKDATING_FIELD, N as BACKDATING_INVALID, T as BACKDATING_SETTING, B as BackdatingEntity, U as BackdatingSource, D as DEFAULT_GATEWAY_ENDPOINT, f as DEFAULT_SETTINGS_ERROR_TTL_MS, g as DEFAULT_SETTINGS_TIMEOUT_MS, h as DEFAULT_SETTINGS_TTL_MS, H as HttpError, k as HttpErrorOptions, M as MAX_MONTHS_BACK, m as Refusal, v as backdated, V as backdatingAllowed, w as backdatingDb, X as badRequest, x as clock, Y as conflict, y as createSettings, Z as forbidden, z as isHttpError, _ as notFound, G as now, I as parseBackdate, J as refusalOf, K as runAt } from '../errors-CjuqA3DC.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Who is acting — the person behind a request, as the platform established
|
|
@@ -401,6 +401,16 @@ interface CrudOptions {
|
|
|
401
401
|
column: string;
|
|
402
402
|
repo?: Pick<RepoLike, 'get'>;
|
|
403
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Columns the App keeps itself — a status only an action route moves, a
|
|
406
|
+
* counter, a flag the seed sets. A record read and sent back with `PUT`
|
|
407
|
+
* repeats them: a value equal to the stored one (compared by the column's
|
|
408
|
+
* type) is dropped, any other is `400 read_only_field` naming it in
|
|
409
|
+
* `details.field`. Stored generated columns (`generated` in schema.json) are
|
|
410
|
+
* dropped whatever they say, without being named.
|
|
411
|
+
* `POST` is not affected: a create has no stored value to compare with.
|
|
412
|
+
*/
|
|
413
|
+
readOnly?: string[];
|
|
404
414
|
/** Path param for the row id (default `id`). */
|
|
405
415
|
idParam?: string;
|
|
406
416
|
/** Pagination bounds for list (defaults: 50, max 200). */
|
package/dist/router/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as SettingsDefaults, l as ReadOptions, n as ResolvedSettings, r as SettingsSnapshot, u as WriteOptions, t as SettingsWriteResult, q as SettingsReader, p as SettingsOptions, e as BackdatingOptions, Q as Query, R as Row, P as Page, s as SettingsSource } from '../errors-
|
|
2
|
-
export { L as BACKDATING_FIELD, N as BACKDATING_INVALID, T as BACKDATING_SETTING, B as BackdatingEntity, U as BackdatingSource, D as DEFAULT_GATEWAY_ENDPOINT, f as DEFAULT_SETTINGS_ERROR_TTL_MS, g as DEFAULT_SETTINGS_TIMEOUT_MS, h as DEFAULT_SETTINGS_TTL_MS, H as HttpError, k as HttpErrorOptions, M as MAX_MONTHS_BACK, m as Refusal, v as backdated, V as backdatingAllowed, w as backdatingDb, X as badRequest, x as clock, Y as conflict, y as createSettings, Z as forbidden, z as isHttpError, _ as notFound, G as now, I as parseBackdate, J as refusalOf, K as runAt } from '../errors-
|
|
1
|
+
import { o as SettingsDefaults, l as ReadOptions, n as ResolvedSettings, r as SettingsSnapshot, u as WriteOptions, t as SettingsWriteResult, q as SettingsReader, p as SettingsOptions, e as BackdatingOptions, Q as Query, R as Row, P as Page, s as SettingsSource } from '../errors-CjuqA3DC.js';
|
|
2
|
+
export { L as BACKDATING_FIELD, N as BACKDATING_INVALID, T as BACKDATING_SETTING, B as BackdatingEntity, U as BackdatingSource, D as DEFAULT_GATEWAY_ENDPOINT, f as DEFAULT_SETTINGS_ERROR_TTL_MS, g as DEFAULT_SETTINGS_TIMEOUT_MS, h as DEFAULT_SETTINGS_TTL_MS, H as HttpError, k as HttpErrorOptions, M as MAX_MONTHS_BACK, m as Refusal, v as backdated, V as backdatingAllowed, w as backdatingDb, X as badRequest, x as clock, Y as conflict, y as createSettings, Z as forbidden, z as isHttpError, _ as notFound, G as now, I as parseBackdate, J as refusalOf, K as runAt } from '../errors-CjuqA3DC.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Who is acting — the person behind a request, as the platform established
|
|
@@ -401,6 +401,16 @@ interface CrudOptions {
|
|
|
401
401
|
column: string;
|
|
402
402
|
repo?: Pick<RepoLike, 'get'>;
|
|
403
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Columns the App keeps itself — a status only an action route moves, a
|
|
406
|
+
* counter, a flag the seed sets. A record read and sent back with `PUT`
|
|
407
|
+
* repeats them: a value equal to the stored one (compared by the column's
|
|
408
|
+
* type) is dropped, any other is `400 read_only_field` naming it in
|
|
409
|
+
* `details.field`. Stored generated columns (`generated` in schema.json) are
|
|
410
|
+
* dropped whatever they say, without being named.
|
|
411
|
+
* `POST` is not affected: a create has no stored value to compare with.
|
|
412
|
+
*/
|
|
413
|
+
readOnly?: string[];
|
|
404
414
|
/** Path param for the row id (default `id`). */
|
|
405
415
|
idParam?: string;
|
|
406
416
|
/** Pagination bounds for list (defaults: 50, max 200). */
|
package/dist/router/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
clock,
|
|
20
20
|
conflict,
|
|
21
21
|
createSettings,
|
|
22
|
+
createdFields,
|
|
22
23
|
describedEntity,
|
|
23
24
|
flagColumns,
|
|
24
25
|
forbidden,
|
|
@@ -32,9 +33,12 @@ import {
|
|
|
32
33
|
refusalBody,
|
|
33
34
|
refusalOf,
|
|
34
35
|
requestedMoment,
|
|
36
|
+
roundTripped,
|
|
35
37
|
runAt,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
trashRoundTripped,
|
|
39
|
+
updateFields,
|
|
40
|
+
withoutNullTrash
|
|
41
|
+
} from "../chunk-ZTTYOJYU.js";
|
|
38
42
|
|
|
39
43
|
// src/instrument.ts
|
|
40
44
|
var started = false;
|
|
@@ -462,6 +466,10 @@ function mountCrud(app, repo, opts) {
|
|
|
462
466
|
trash: guardsTrash(opts.trash, described?.trash, opts.columns),
|
|
463
467
|
external_id: opts.external_id === true || described?.external_id === true
|
|
464
468
|
};
|
|
469
|
+
const shape = {
|
|
470
|
+
pk: described?.pk,
|
|
471
|
+
columns: opts.columns ?? described?.columns
|
|
472
|
+
};
|
|
465
473
|
if (enabled.has("list")) {
|
|
466
474
|
app.get(base, async (c) => {
|
|
467
475
|
assertKnownKeys(c.query, opts, flags);
|
|
@@ -493,9 +501,11 @@ function mountCrud(app, repo, opts) {
|
|
|
493
501
|
if (enabled.has("create")) {
|
|
494
502
|
app.post(base, async (c) => {
|
|
495
503
|
if (isList(c.body)) throw oneRecordRefusal();
|
|
496
|
-
|
|
504
|
+
const body = flags.trash ? withoutNullTrash(c.body) : c.body;
|
|
505
|
+
assertNoTrashFields(flags, body);
|
|
506
|
+
const fields = createdFields(shape, body ?? {}, c.tenant);
|
|
497
507
|
await assertParentExists(c, opts.parent);
|
|
498
|
-
const data = { ...
|
|
508
|
+
const data = { ...fields, ...parentWhere(c, opts.parent) };
|
|
499
509
|
return c.json(await repo.create(data), 201);
|
|
500
510
|
});
|
|
501
511
|
}
|
|
@@ -508,11 +518,15 @@ function mountCrud(app, repo, opts) {
|
|
|
508
518
|
if (enabled.has("update")) {
|
|
509
519
|
app.put(idTemplate, async (c) => {
|
|
510
520
|
if (isList(c.body)) throw oneRecordRefusal();
|
|
511
|
-
assertNoTrashFields(flags, c.body);
|
|
512
|
-
const { id } = await fetchOwned(repo, c, opts);
|
|
521
|
+
assertNoTrashFields(flags, flags.trash ? withoutNullTrash(c.body) : c.body);
|
|
522
|
+
const { id, row } = await fetchOwned(repo, c, opts);
|
|
523
|
+
const body = flags.trash ? trashRoundTripped(c.body, row) : c.body;
|
|
524
|
+
assertNoTrashFields(flags, body);
|
|
513
525
|
if (updateFields(c.body).length === 0) throw new HttpError(400, EMPTY_UPDATE_MESSAGE, void 0, { code: "empty_update" });
|
|
514
|
-
const
|
|
515
|
-
|
|
526
|
+
const fields = await roundTripped(shape, id, body, { stored: () => row, readOnly: opts.readOnly });
|
|
527
|
+
if (opts.parent) delete fields[opts.parent.column];
|
|
528
|
+
if (updateFields(fields).length === 0) return c.json(row);
|
|
529
|
+
return c.json(await repo.update(id, fields));
|
|
516
530
|
});
|
|
517
531
|
}
|
|
518
532
|
if (enabled.has("delete")) {
|