@revenexx/app-sdk 0.6.0 → 0.7.1

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.
@@ -1,111 +0,0 @@
1
- /**
2
- * Shared runtime types. The generated per-App client (emitted by
3
- * @revenexx/app-sdk-cli) layers strongly-typed entity interfaces on top of
4
- * these loose runtime shapes.
5
- */
6
- type FilterOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'in' | 'is';
7
- type Scalar = string | number | boolean | null;
8
- /** A PostgREST filter: equality, an `in` list, or an explicit operator. */
9
- type Filter = Scalar | Scalar[] | {
10
- op: FilterOp;
11
- value: unknown;
12
- };
13
- /**
14
- * The query object is the one interface shared by every adapter: remote/runtime
15
- * serialise it to a PostgREST querystring, mock applies it in memory — so App
16
- * code is identical regardless of where the data lives.
17
- */
18
- interface Query<T = Record<string, unknown>> {
19
- where?: Partial<Record<keyof T & string, Filter>> & Record<string, Filter>;
20
- select?: (keyof T & string)[] | string[];
21
- order?: string;
22
- limit?: number;
23
- offset?: number;
24
- }
25
- type Op = 'list' | 'get' | 'create' | 'update' | 'delete';
26
- interface ColumnDef {
27
- type: string;
28
- pk?: boolean;
29
- notNull?: boolean;
30
- default?: string | null;
31
- check?: string;
32
- }
33
- /** A generated entity descriptor: maps an App entity to its real table + ops. */
34
- interface Entity {
35
- name: string;
36
- table: string;
37
- pk: string;
38
- columns?: Record<string, ColumnDef>;
39
- ops?: Op[] | Set<Op>;
40
- }
41
- type Row = Record<string, unknown>;
42
- /** A page of rows plus the total count of matching rows (ignoring limit/offset). */
43
- interface Page<T = Row> {
44
- items: T[];
45
- total: number;
46
- limit?: number;
47
- offset?: number;
48
- }
49
- /**
50
- * The data-plane contract. Implement this to add a new backend (e.g. GraphQL,
51
- * a local SQLite file) and register it with `registerAdapter`.
52
- *
53
- * `page` is optional: adapters that can report a total (PostgREST `count=exact`,
54
- * an in-memory store) implement it; others fall back to `list` only.
55
- */
56
- interface Adapter {
57
- readonly kind: string;
58
- list(entity: Entity, query?: Query): Promise<Row[]>;
59
- get(entity: Entity, id: string | number): Promise<Row | null>;
60
- create(entity: Entity, data: Row): Promise<Row>;
61
- update(entity: Entity, id: string | number, patch: Row): Promise<Row>;
62
- remove(entity: Entity, id: string | number): Promise<void>;
63
- page?(entity: Entity, query?: Query): Promise<Page>;
64
- }
65
-
66
- /**
67
- * The one error representation every layer of the SDK agrees on.
68
- *
69
- * `HttpError` used to live in `./router/router.ts`. It moved here so the data
70
- * adapters can raise it too: an adapter that knows a PostgREST failure is a
71
- * duplicate key can say "409" without the router having to guess from a
72
- * message string.
73
- *
74
- * Two fields exist purely to keep internal database detail out of responses:
75
- * - `message` / `details` are the *client-facing* payload — always safe,
76
- * never derived from a database error body.
77
- * - `serverDetail` is the raw diagnosis. The router logs it and drops it; it
78
- * is never serialised into a response.
79
- */
80
- interface HttpErrorOptions {
81
- /** Stable machine-readable code (e.g. `unique_violation`). Safe to expose. */
82
- code?: string;
83
- /**
84
- * Raw diagnosis for server-side logs and traces only — may contain table and
85
- * constraint names. Never included in the HTTP response.
86
- */
87
- serverDetail?: unknown;
88
- }
89
- /** Throw inside a handler (or an adapter) to answer with a specific HTTP status. */
90
- declare class HttpError extends Error {
91
- readonly status: number;
92
- readonly details?: unknown;
93
- readonly code?: string;
94
- readonly serverDetail?: unknown;
95
- /**
96
- * Structural marker. `dist/index.cjs` and `dist/router/index.cjs` are separate
97
- * bundles, so an error thrown by the data client and caught by the router is
98
- * an instance of a *different* copy of this class — `instanceof` would be
99
- * false. Everything checks this flag via `isHttpError` instead.
100
- */
101
- readonly __isHttpError: true;
102
- constructor(status: number, message: string, details?: unknown, options?: HttpErrorOptions);
103
- }
104
- /** Duck-typed `instanceof HttpError` — survives the bundle split (see above). */
105
- declare function isHttpError(err: unknown): err is HttpError;
106
- declare const notFound: (message?: string) => HttpError;
107
- declare const badRequest: (message?: string, details?: unknown) => HttpError;
108
- declare const forbidden: (message?: string) => HttpError;
109
- declare const conflict: (message?: string) => HttpError;
110
-
111
- export { type Adapter as A, type ColumnDef as C, type Entity as E, type Filter as F, HttpError as H, type Op as O, type Page as P, type Query as Q, type Row as R, type Scalar as S, type FilterOp as a, type HttpErrorOptions as b, badRequest as c, conflict as d, forbidden as f, isHttpError as i, notFound as n };
@@ -1,111 +0,0 @@
1
- /**
2
- * Shared runtime types. The generated per-App client (emitted by
3
- * @revenexx/app-sdk-cli) layers strongly-typed entity interfaces on top of
4
- * these loose runtime shapes.
5
- */
6
- type FilterOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'in' | 'is';
7
- type Scalar = string | number | boolean | null;
8
- /** A PostgREST filter: equality, an `in` list, or an explicit operator. */
9
- type Filter = Scalar | Scalar[] | {
10
- op: FilterOp;
11
- value: unknown;
12
- };
13
- /**
14
- * The query object is the one interface shared by every adapter: remote/runtime
15
- * serialise it to a PostgREST querystring, mock applies it in memory — so App
16
- * code is identical regardless of where the data lives.
17
- */
18
- interface Query<T = Record<string, unknown>> {
19
- where?: Partial<Record<keyof T & string, Filter>> & Record<string, Filter>;
20
- select?: (keyof T & string)[] | string[];
21
- order?: string;
22
- limit?: number;
23
- offset?: number;
24
- }
25
- type Op = 'list' | 'get' | 'create' | 'update' | 'delete';
26
- interface ColumnDef {
27
- type: string;
28
- pk?: boolean;
29
- notNull?: boolean;
30
- default?: string | null;
31
- check?: string;
32
- }
33
- /** A generated entity descriptor: maps an App entity to its real table + ops. */
34
- interface Entity {
35
- name: string;
36
- table: string;
37
- pk: string;
38
- columns?: Record<string, ColumnDef>;
39
- ops?: Op[] | Set<Op>;
40
- }
41
- type Row = Record<string, unknown>;
42
- /** A page of rows plus the total count of matching rows (ignoring limit/offset). */
43
- interface Page<T = Row> {
44
- items: T[];
45
- total: number;
46
- limit?: number;
47
- offset?: number;
48
- }
49
- /**
50
- * The data-plane contract. Implement this to add a new backend (e.g. GraphQL,
51
- * a local SQLite file) and register it with `registerAdapter`.
52
- *
53
- * `page` is optional: adapters that can report a total (PostgREST `count=exact`,
54
- * an in-memory store) implement it; others fall back to `list` only.
55
- */
56
- interface Adapter {
57
- readonly kind: string;
58
- list(entity: Entity, query?: Query): Promise<Row[]>;
59
- get(entity: Entity, id: string | number): Promise<Row | null>;
60
- create(entity: Entity, data: Row): Promise<Row>;
61
- update(entity: Entity, id: string | number, patch: Row): Promise<Row>;
62
- remove(entity: Entity, id: string | number): Promise<void>;
63
- page?(entity: Entity, query?: Query): Promise<Page>;
64
- }
65
-
66
- /**
67
- * The one error representation every layer of the SDK agrees on.
68
- *
69
- * `HttpError` used to live in `./router/router.ts`. It moved here so the data
70
- * adapters can raise it too: an adapter that knows a PostgREST failure is a
71
- * duplicate key can say "409" without the router having to guess from a
72
- * message string.
73
- *
74
- * Two fields exist purely to keep internal database detail out of responses:
75
- * - `message` / `details` are the *client-facing* payload — always safe,
76
- * never derived from a database error body.
77
- * - `serverDetail` is the raw diagnosis. The router logs it and drops it; it
78
- * is never serialised into a response.
79
- */
80
- interface HttpErrorOptions {
81
- /** Stable machine-readable code (e.g. `unique_violation`). Safe to expose. */
82
- code?: string;
83
- /**
84
- * Raw diagnosis for server-side logs and traces only — may contain table and
85
- * constraint names. Never included in the HTTP response.
86
- */
87
- serverDetail?: unknown;
88
- }
89
- /** Throw inside a handler (or an adapter) to answer with a specific HTTP status. */
90
- declare class HttpError extends Error {
91
- readonly status: number;
92
- readonly details?: unknown;
93
- readonly code?: string;
94
- readonly serverDetail?: unknown;
95
- /**
96
- * Structural marker. `dist/index.cjs` and `dist/router/index.cjs` are separate
97
- * bundles, so an error thrown by the data client and caught by the router is
98
- * an instance of a *different* copy of this class — `instanceof` would be
99
- * false. Everything checks this flag via `isHttpError` instead.
100
- */
101
- readonly __isHttpError: true;
102
- constructor(status: number, message: string, details?: unknown, options?: HttpErrorOptions);
103
- }
104
- /** Duck-typed `instanceof HttpError` — survives the bundle split (see above). */
105
- declare function isHttpError(err: unknown): err is HttpError;
106
- declare const notFound: (message?: string) => HttpError;
107
- declare const badRequest: (message?: string, details?: unknown) => HttpError;
108
- declare const forbidden: (message?: string) => HttpError;
109
- declare const conflict: (message?: string) => HttpError;
110
-
111
- export { type Adapter as A, type ColumnDef as C, type Entity as E, type Filter as F, HttpError as H, type Op as O, type Page as P, type Query as Q, type Row as R, type Scalar as S, type FilterOp as a, type HttpErrorOptions as b, badRequest as c, conflict as d, forbidden as f, isHttpError as i, notFound as n };