@geekmidas/constructs 10.0.0-alpha.20 → 10.0.0-alpha.21

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-AgQUMma6.d.mts","names":["Cache","CacheClient"],"sources":["../src/cache.ts"],"mappings":";;;;;UA6BiB;;;;;;;;EAQhB;;EAEA;;cAGYA,QAAM,0CACP,UAAU,OAAOC;mBAaV;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQA;;;;;mBAM9B;EAEjB,YACC,IAAI,cAAc,QACD,UAAS;EAc3B,WAAW;;;;;;;;;;;;UAuBG"}
@@ -0,0 +1,44 @@
1
+ import { n as Construct } from "./construct-interface-DIaTNKax.cjs";
2
+ import { Service } from "@geekmidas/services";
3
+ import { ConstructName, Declaration } from "@geekmidas/manifest";
4
+ import { Cache } from "@geekmidas/cache";
5
+ //#region src/cache.d.ts
6
+ interface CacheOptions {
7
+ /**
8
+ * The database this cache lives in.
9
+ *
10
+ * Set by `database.cache()` rather than written by hand — the point of the
11
+ * method is that the parent's id comes from the parent rather than from a
12
+ * string somebody has to keep in step.
13
+ */
14
+ of?: string;
15
+ /** The table entries are kept in. Defaults to `cache`. */
16
+ table?: string;
17
+ }
18
+ declare class Cache$1<TName extends string = string> implements Construct<TName, Cache> {
19
+ private readonly options;
20
+ readonly id: TName;
21
+ readonly service: Service<Uncapitalize<TName>, Cache>;
22
+ /**
23
+ * Declared once and read by both `declare()` and `connect()`, so the key the
24
+ * target publishes and the key the client reads cannot drift.
25
+ */
26
+ private readonly key;
27
+ constructor(id: ConstructName<TName>, options?: CacheOptions);
28
+ declare(): Declaration[];
29
+ /**
30
+ * Builds the client from the single URL the target supplied.
31
+ *
32
+ * Any credential travels in that URL's userinfo rather than in a second key,
33
+ * for the same reason a Postgres password does: an address and the thing that
34
+ * opens it are one fact, and splitting them is one more thing to keep in step.
35
+ *
36
+ * The scheme selects the driver, so this construct imports no provider and
37
+ * an app that caches in Postgres never resolves a Redis client. Whoever
38
+ * assembles the application registers the drivers its target needs.
39
+ */
40
+ private connect;
41
+ }
42
+ //#endregion
43
+ export { CacheOptions as n, Cache$1 as t };
44
+ //# sourceMappingURL=cache-obq0fOIM.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-obq0fOIM.d.cts","names":["Cache","CacheClient"],"sources":["../src/cache.ts"],"mappings":";;;;;UA6BiB;;;;;;;;EAQhB;;EAEA;;cAGYA,QAAM,0CACP,UAAU,OAAOC;mBAaV;WAXT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQA;;;;;mBAM9B;EAEjB,YACC,IAAI,cAAc,QACD,UAAS;EAc3B,WAAW;;;;;;;;;;;;UAuBG"}
package/dist/cache.d.cts CHANGED
@@ -1,43 +1,2 @@
1
- import { n as Construct } from "./construct-interface-DIaTNKax.cjs";
2
- import { Service } from "@geekmidas/services";
3
- import { ConstructName, Declaration } from "@geekmidas/manifest";
4
- import { Cache as Cache$1 } from "@geekmidas/cache";
5
- //#region src/cache.d.ts
6
- export interface CacheOptions {
7
- /**
8
- * The database this cache lives in.
9
- *
10
- * Set by `database.cache()` rather than written by hand — the point of the
11
- * method is that the parent's id comes from the parent rather than from a
12
- * string somebody has to keep in step.
13
- */
14
- of?: string;
15
- /** The table entries are kept in. Defaults to `cache`. */
16
- table?: string;
17
- }
18
- export declare class Cache<TName extends string = string> implements Construct<TName, Cache$1> {
19
- private readonly options;
20
- readonly id: TName;
21
- readonly service: Service<Uncapitalize<TName>, Cache$1>;
22
- /**
23
- * Declared once and read by both `declare()` and `connect()`, so the key the
24
- * target publishes and the key the client reads cannot drift.
25
- */
26
- private readonly key;
27
- constructor(id: ConstructName<TName>, options?: CacheOptions);
28
- declare(): Declaration[];
29
- /**
30
- * Builds the client from the single URL the target supplied.
31
- *
32
- * Any credential travels in that URL's userinfo rather than in a second key,
33
- * for the same reason a Postgres password does: an address and the thing that
34
- * opens it are one fact, and splitting them is one more thing to keep in step.
35
- *
36
- * The scheme selects the driver, so this construct imports no provider and
37
- * an app that caches in Postgres never resolves a Redis client. Whoever
38
- * assembles the application registers the drivers its target needs.
39
- */
40
- private connect;
41
- }
42
- //#endregion
43
- //# sourceMappingURL=cache.d.cts.map
1
+ import { n as CacheOptions, t as Cache } from "./cache-obq0fOIM.cjs";
2
+ export { Cache, CacheOptions };
package/dist/cache.d.mts CHANGED
@@ -1,43 +1,2 @@
1
- import { n as Construct } from "./construct-interface-Clz7_BwB.mjs";
2
- import { ConstructName, Declaration } from "@geekmidas/manifest";
3
- import { Cache as Cache$1 } from "@geekmidas/cache";
4
- import { Service } from "@geekmidas/services";
5
- //#region src/cache.d.ts
6
- export interface CacheOptions {
7
- /**
8
- * The database this cache lives in.
9
- *
10
- * Set by `database.cache()` rather than written by hand — the point of the
11
- * method is that the parent's id comes from the parent rather than from a
12
- * string somebody has to keep in step.
13
- */
14
- of?: string;
15
- /** The table entries are kept in. Defaults to `cache`. */
16
- table?: string;
17
- }
18
- export declare class Cache<TName extends string = string> implements Construct<TName, Cache$1> {
19
- private readonly options;
20
- readonly id: TName;
21
- readonly service: Service<Uncapitalize<TName>, Cache$1>;
22
- /**
23
- * Declared once and read by both `declare()` and `connect()`, so the key the
24
- * target publishes and the key the client reads cannot drift.
25
- */
26
- private readonly key;
27
- constructor(id: ConstructName<TName>, options?: CacheOptions);
28
- declare(): Declaration[];
29
- /**
30
- * Builds the client from the single URL the target supplied.
31
- *
32
- * Any credential travels in that URL's userinfo rather than in a second key,
33
- * for the same reason a Postgres password does: an address and the thing that
34
- * opens it are one fact, and splitting them is one more thing to keep in step.
35
- *
36
- * The scheme selects the driver, so this construct imports no provider and
37
- * an app that caches in Postgres never resolves a Redis client. Whoever
38
- * assembles the application registers the drivers its target needs.
39
- */
40
- private connect;
41
- }
42
- //#endregion
43
- //# sourceMappingURL=cache.d.mts.map
1
+ import { n as CacheOptions, t as Cache } from "./cache-AgQUMma6.mjs";
2
+ export { Cache, CacheOptions };
@@ -1,149 +1,2 @@
1
- import { n as Construct } from "../construct-interface-DIaTNKax.cjs";
2
- import { Cache } from "../cache.cjs";
3
- import { Service } from "@geekmidas/services";
4
- import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
5
- import { Kysely, KyselyConfig } from "kysely";
6
- //#region src/database/kysely.d.ts
7
- /**
8
- * Everything Kysely takes, plus what this construct declares.
9
- *
10
- * `dialect` is omitted because the construct owns it — it is built from the one
11
- * URL the adapter supplied, which is the whole point of the construct. The rest
12
- * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
13
- * straight through, so anything Kysely adds later arrives without being
14
- * tracked here.
15
- */
16
- export interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
17
- /**
18
- * The schema, pinned on both roles' `search_path`.
19
- *
20
- * Defaults to `app` — the role the schema plays, rather than a restatement
21
- * of the database's own name, which reads correctly beside `auth` and
22
- * `pgboss` and keeps the application off `public`.
23
- */
24
- schema?: string;
25
- /**
26
- * Provision the owner/runtime role split. Defaults to on.
27
- *
28
- * Off falls back to the cluster's master credential in both URLs, giving up
29
- * the DDL/DML split and putting credentials that can drop a table into the
30
- * function's environment. A deliberate downgrade, not a default.
31
- */
32
- roles?: boolean;
33
- /**
34
- * The Postgres major version to provision.
35
- *
36
- * Declared here so one statement reaches both targets. It was previously
37
- * set in two unrelated places — a container tag locally, nothing at all on
38
- * AWS (so Aurora chose) — which is how local came to run 18 while deployed
39
- * ran 17.7 with nothing recording the difference.
40
- *
41
- * Defaults to {@link DEFAULT_POSTGRES_VERSION}.
42
- */
43
- version?: PostgresVersion;
44
- }
45
- /** What makes a construct derived rather than a database in its own right. */
46
- interface DerivedFrom {
47
- kind: 'database-reader' | 'database-schema';
48
- of: string;
49
- schema?: string;
50
- }
51
- /**
52
- * @typeParam DB - the database's schema.
53
- * @typeParam TName - the canonical id. TypeScript has no partial
54
- * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
55
- * this at its default and the service key widens to `string`. `db` still types
56
- * through `.database()`, which infers from the service.
57
- */
58
- export declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
59
- private readonly options;
60
- readonly id: TName;
61
- readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
62
- /**
63
- * Declared once and read by both `declare()` and `connect()`, so the key the
64
- * build publishes and the key the client reads cannot drift.
65
- */
66
- private readonly config;
67
- private readonly schemaName;
68
- private readonly roles;
69
- private readonly version;
70
- private readonly derivedFrom?;
71
- constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
72
- declare(): Declaration[];
73
- /**
74
- * A read-only endpoint on this database.
75
- *
76
- * Read-only is enforced by the reader role's grants rather than by which
77
- * endpoint it resolves to, so falling back to the writer where no replica
78
- * exists is safe rather than a silently writable connection behind a name
79
- * that says reader. There is no `writer()`: the database *is* the writer, so
80
- * a replica can never be reached by accident.
81
- *
82
- * The return type is narrower than this class on purpose — see
83
- * {@link ReadOnlyDatabase}.
84
- */
85
- reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
86
- /**
87
- * A cache that lives in this database.
88
- *
89
- * The same strengthening `schema()` is over a second database: `new
90
- * Cache('Sessions')` says the app caches and leaves where to the deployment,
91
- * while this says it caches *here* — which is a fact about the application
92
- * and so belongs in its code.
93
- *
94
- * What it buys beyond being explicit: the table's schema and the role that
95
- * reaches it come from this database rather than from a second convention,
96
- * and the backend no longer has to guess which database "the database" meant
97
- * when an app declares two.
98
- *
99
- * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
100
- * is a key/value store, not a query builder, and typing it as the parent
101
- * would be a convenience that lies.
102
- */
103
- cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
104
- table?: string;
105
- }): Cache<TCache>;
106
- /**
107
- * A second schema in this database, with its own role(s) and its own URL —
108
- * so this database's role holds no grant on those tables at all.
109
- *
110
- * Typed separately because a tenant has its own tables: the point is that
111
- * `auth.selectFrom('sessions')` type-checks and
112
- * `orders.selectFrom('sessions')` does not.
113
- */
114
- schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
115
- /**
116
- * A connection as the *owner* role — the one that may create, alter and drop.
117
- *
118
- * A `Service` rather than part of the construct, and deliberately so: a
119
- * construct is what `.dependsOn()` accepts, and nothing should be able to
120
- * depend on this. A migrator asks for it by name; a handler cannot ask at
121
- * all, which is the security property the role split exists for.
122
- *
123
- * Falls back to the runtime URL where no owner URL was published — the
124
- * `roles: false` downgrade, where there is only one credential and it is the
125
- * cluster master's.
126
- */
127
- get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
128
- private connect;
129
- }
130
- /**
131
- * A database you may read through, and derive nothing from.
132
- *
133
- * A reader is terminal in the graph, and this is that fact in the type system.
134
- * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
135
- * parent, and there is no reader of a reader — so `orders.reader().cache(…)`
136
- * has always been illegal, but it type-checked and failed later at
137
- * `assertDerivations`. That is a long way round to learn that a read-only
138
- * endpoint cannot own a table something writes to.
139
- *
140
- * Omitting the three deriving methods rather than making them throw keeps the
141
- * failure where it costs least: the editor, on the line that wrote it.
142
- *
143
- * The result is deliberately not assignable back to `KyselyDatabase` — a
144
- * reader is not one, and anything that genuinely needs the writer should say
145
- * so.
146
- */
147
- export type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
148
- //#endregion
149
- //# sourceMappingURL=kysely.d.cts.map
1
+ import { n as KyselyDatabaseOptions, r as ReadOnlyDatabase, t as KyselyDatabase } from "../kysely-CXi49zc2.cjs";
2
+ export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase };
@@ -1,149 +1,2 @@
1
- import { n as Construct } from "../construct-interface-Clz7_BwB.mjs";
2
- import { Cache } from "../cache.mjs";
3
- import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
4
- import { Kysely, KyselyConfig } from "kysely";
5
- import { Service } from "@geekmidas/services";
6
- //#region src/database/kysely.d.ts
7
- /**
8
- * Everything Kysely takes, plus what this construct declares.
9
- *
10
- * `dialect` is omitted because the construct owns it — it is built from the one
11
- * URL the adapter supplied, which is the whole point of the construct. The rest
12
- * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
13
- * straight through, so anything Kysely adds later arrives without being
14
- * tracked here.
15
- */
16
- export interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
17
- /**
18
- * The schema, pinned on both roles' `search_path`.
19
- *
20
- * Defaults to `app` — the role the schema plays, rather than a restatement
21
- * of the database's own name, which reads correctly beside `auth` and
22
- * `pgboss` and keeps the application off `public`.
23
- */
24
- schema?: string;
25
- /**
26
- * Provision the owner/runtime role split. Defaults to on.
27
- *
28
- * Off falls back to the cluster's master credential in both URLs, giving up
29
- * the DDL/DML split and putting credentials that can drop a table into the
30
- * function's environment. A deliberate downgrade, not a default.
31
- */
32
- roles?: boolean;
33
- /**
34
- * The Postgres major version to provision.
35
- *
36
- * Declared here so one statement reaches both targets. It was previously
37
- * set in two unrelated places — a container tag locally, nothing at all on
38
- * AWS (so Aurora chose) — which is how local came to run 18 while deployed
39
- * ran 17.7 with nothing recording the difference.
40
- *
41
- * Defaults to {@link DEFAULT_POSTGRES_VERSION}.
42
- */
43
- version?: PostgresVersion;
44
- }
45
- /** What makes a construct derived rather than a database in its own right. */
46
- interface DerivedFrom {
47
- kind: 'database-reader' | 'database-schema';
48
- of: string;
49
- schema?: string;
50
- }
51
- /**
52
- * @typeParam DB - the database's schema.
53
- * @typeParam TName - the canonical id. TypeScript has no partial
54
- * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
55
- * this at its default and the service key widens to `string`. `db` still types
56
- * through `.database()`, which infers from the service.
57
- */
58
- export declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
59
- private readonly options;
60
- readonly id: TName;
61
- readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
62
- /**
63
- * Declared once and read by both `declare()` and `connect()`, so the key the
64
- * build publishes and the key the client reads cannot drift.
65
- */
66
- private readonly config;
67
- private readonly schemaName;
68
- private readonly roles;
69
- private readonly version;
70
- private readonly derivedFrom?;
71
- constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
72
- declare(): Declaration[];
73
- /**
74
- * A read-only endpoint on this database.
75
- *
76
- * Read-only is enforced by the reader role's grants rather than by which
77
- * endpoint it resolves to, so falling back to the writer where no replica
78
- * exists is safe rather than a silently writable connection behind a name
79
- * that says reader. There is no `writer()`: the database *is* the writer, so
80
- * a replica can never be reached by accident.
81
- *
82
- * The return type is narrower than this class on purpose — see
83
- * {@link ReadOnlyDatabase}.
84
- */
85
- reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
86
- /**
87
- * A cache that lives in this database.
88
- *
89
- * The same strengthening `schema()` is over a second database: `new
90
- * Cache('Sessions')` says the app caches and leaves where to the deployment,
91
- * while this says it caches *here* — which is a fact about the application
92
- * and so belongs in its code.
93
- *
94
- * What it buys beyond being explicit: the table's schema and the role that
95
- * reaches it come from this database rather than from a second convention,
96
- * and the backend no longer has to guess which database "the database" meant
97
- * when an app declares two.
98
- *
99
- * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
100
- * is a key/value store, not a query builder, and typing it as the parent
101
- * would be a convenience that lies.
102
- */
103
- cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
104
- table?: string;
105
- }): Cache<TCache>;
106
- /**
107
- * A second schema in this database, with its own role(s) and its own URL —
108
- * so this database's role holds no grant on those tables at all.
109
- *
110
- * Typed separately because a tenant has its own tables: the point is that
111
- * `auth.selectFrom('sessions')` type-checks and
112
- * `orders.selectFrom('sessions')` does not.
113
- */
114
- schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
115
- /**
116
- * A connection as the *owner* role — the one that may create, alter and drop.
117
- *
118
- * A `Service` rather than part of the construct, and deliberately so: a
119
- * construct is what `.dependsOn()` accepts, and nothing should be able to
120
- * depend on this. A migrator asks for it by name; a handler cannot ask at
121
- * all, which is the security property the role split exists for.
122
- *
123
- * Falls back to the runtime URL where no owner URL was published — the
124
- * `roles: false` downgrade, where there is only one credential and it is the
125
- * cluster master's.
126
- */
127
- get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
128
- private connect;
129
- }
130
- /**
131
- * A database you may read through, and derive nothing from.
132
- *
133
- * A reader is terminal in the graph, and this is that fact in the type system.
134
- * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
135
- * parent, and there is no reader of a reader — so `orders.reader().cache(…)`
136
- * has always been illegal, but it type-checked and failed later at
137
- * `assertDerivations`. That is a long way round to learn that a read-only
138
- * endpoint cannot own a table something writes to.
139
- *
140
- * Omitting the three deriving methods rather than making them throw keeps the
141
- * failure where it costs least: the editor, on the line that wrote it.
142
- *
143
- * The result is deliberately not assignable back to `KyselyDatabase` — a
144
- * reader is not one, and anything that genuinely needs the writer should say
145
- * so.
146
- */
147
- export type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
148
- //#endregion
149
- //# sourceMappingURL=kysely.d.mts.map
1
+ import { n as KyselyDatabaseOptions, r as ReadOnlyDatabase, t as KyselyDatabase } from "../kysely-D3-G5b0j.mjs";
2
+ export { KyselyDatabase, KyselyDatabaseOptions, ReadOnlyDatabase };
@@ -0,0 +1,150 @@
1
+ import { n as Construct } from "./construct-interface-DIaTNKax.cjs";
2
+ import { t as Cache } from "./cache-obq0fOIM.cjs";
3
+ import { Service } from "@geekmidas/services";
4
+ import { ConstructName, Declaration, PostgresVersion } from "@geekmidas/manifest";
5
+ import { Kysely, KyselyConfig } from "kysely";
6
+ //#region src/database/kysely.d.ts
7
+ /**
8
+ * Everything Kysely takes, plus what this construct declares.
9
+ *
10
+ * `dialect` is omitted because the construct owns it — it is built from the one
11
+ * URL the adapter supplied, which is the whole point of the construct. The rest
12
+ * of `KyselyConfig` (`plugins`, `log`) is the app's business and passes
13
+ * straight through, so anything Kysely adds later arrives without being
14
+ * tracked here.
15
+ */
16
+ interface KyselyDatabaseOptions extends Omit<KyselyConfig, 'dialect'> {
17
+ /**
18
+ * The schema, pinned on both roles' `search_path`.
19
+ *
20
+ * Defaults to `app` — the role the schema plays, rather than a restatement
21
+ * of the database's own name, which reads correctly beside `auth` and
22
+ * `pgboss` and keeps the application off `public`.
23
+ */
24
+ schema?: string;
25
+ /**
26
+ * Provision the owner/runtime role split. Defaults to on.
27
+ *
28
+ * Off falls back to the cluster's master credential in both URLs, giving up
29
+ * the DDL/DML split and putting credentials that can drop a table into the
30
+ * function's environment. A deliberate downgrade, not a default.
31
+ */
32
+ roles?: boolean;
33
+ /**
34
+ * The Postgres major version to provision.
35
+ *
36
+ * Declared here so one statement reaches both targets. It was previously
37
+ * set in two unrelated places — a container tag locally, nothing at all on
38
+ * AWS (so Aurora chose) — which is how local came to run 18 while deployed
39
+ * ran 17.7 with nothing recording the difference.
40
+ *
41
+ * Defaults to {@link DEFAULT_POSTGRES_VERSION}.
42
+ */
43
+ version?: PostgresVersion;
44
+ }
45
+ /** What makes a construct derived rather than a database in its own right. */
46
+ interface DerivedFrom {
47
+ kind: 'database-reader' | 'database-schema';
48
+ of: string;
49
+ schema?: string;
50
+ }
51
+ /**
52
+ * @typeParam DB - the database's schema.
53
+ * @typeParam TName - the canonical id. TypeScript has no partial
54
+ * type-argument inference, so `new KyselyDatabase<OrdersDB>('orders')` leaves
55
+ * this at its default and the service key widens to `string`. `db` still types
56
+ * through `.database()`, which infers from the service.
57
+ */
58
+ declare class KyselyDatabase<DB = unknown, TName extends string = string> implements Construct<TName, Kysely<DB>> {
59
+ private readonly options;
60
+ readonly id: TName;
61
+ readonly service: Service<Uncapitalize<TName>, Kysely<DB>>;
62
+ /**
63
+ * Declared once and read by both `declare()` and `connect()`, so the key the
64
+ * build publishes and the key the client reads cannot drift.
65
+ */
66
+ private readonly config;
67
+ private readonly schemaName;
68
+ private readonly roles;
69
+ private readonly version;
70
+ private readonly derivedFrom?;
71
+ constructor(id: ConstructName<TName>, options?: KyselyDatabaseOptions, derivedFrom?: DerivedFrom);
72
+ declare(): Declaration[];
73
+ /**
74
+ * A read-only endpoint on this database.
75
+ *
76
+ * Read-only is enforced by the reader role's grants rather than by which
77
+ * endpoint it resolves to, so falling back to the writer where no replica
78
+ * exists is safe rather than a silently writable connection behind a name
79
+ * that says reader. There is no `writer()`: the database *is* the writer, so
80
+ * a replica can never be reached by accident.
81
+ *
82
+ * The return type is narrower than this class on purpose — see
83
+ * {@link ReadOnlyDatabase}.
84
+ */
85
+ reader(): ReadOnlyDatabase<DB, `${TName}Reader`>;
86
+ /**
87
+ * A cache that lives in this database.
88
+ *
89
+ * The same strengthening `schema()` is over a second database: `new
90
+ * Cache('Sessions')` says the app caches and leaves where to the deployment,
91
+ * while this says it caches *here* — which is a fact about the application
92
+ * and so belongs in its code.
93
+ *
94
+ * What it buys beyond being explicit: the table's schema and the role that
95
+ * reaches it come from this database rather than from a second convention,
96
+ * and the backend no longer has to guess which database "the database" meant
97
+ * when an app declares two.
98
+ *
99
+ * A cache is not a `KyselyDatabase`, so this returns a `Cache` — the client
100
+ * is a key/value store, not a query builder, and typing it as the parent
101
+ * would be a convenience that lies.
102
+ */
103
+ cache<TCache extends string = `${TName}Cache`>(id?: ConstructName<TCache>, options?: {
104
+ table?: string;
105
+ }): Cache<TCache>;
106
+ /**
107
+ * A second schema in this database, with its own role(s) and its own URL —
108
+ * so this database's role holds no grant on those tables at all.
109
+ *
110
+ * Typed separately because a tenant has its own tables: the point is that
111
+ * `auth.selectFrom('sessions')` type-checks and
112
+ * `orders.selectFrom('sessions')` does not.
113
+ */
114
+ schema<TenantDB, TTenant extends string>(id: ConstructName<TTenant>, options?: KyselyDatabaseOptions): KyselyDatabase<TenantDB, TTenant>;
115
+ /**
116
+ * A connection as the *owner* role — the one that may create, alter and drop.
117
+ *
118
+ * A `Service` rather than part of the construct, and deliberately so: a
119
+ * construct is what `.dependsOn()` accepts, and nothing should be able to
120
+ * depend on this. A migrator asks for it by name; a handler cannot ask at
121
+ * all, which is the security property the role split exists for.
122
+ *
123
+ * Falls back to the runtime URL where no owner URL was published — the
124
+ * `roles: false` downgrade, where there is only one credential and it is the
125
+ * cluster master's.
126
+ */
127
+ get owner(): Service<`${Uncapitalize<TName>}Owner`, Kysely<DB>>;
128
+ private connect;
129
+ }
130
+ /**
131
+ * A database you may read through, and derive nothing from.
132
+ *
133
+ * A reader is terminal in the graph, and this is that fact in the type system.
134
+ * `DERIVES_FROM` gives `cache` and `database-schema` no `database-reader`
135
+ * parent, and there is no reader of a reader — so `orders.reader().cache(…)`
136
+ * has always been illegal, but it type-checked and failed later at
137
+ * `assertDerivations`. That is a long way round to learn that a read-only
138
+ * endpoint cannot own a table something writes to.
139
+ *
140
+ * Omitting the three deriving methods rather than making them throw keeps the
141
+ * failure where it costs least: the editor, on the line that wrote it.
142
+ *
143
+ * The result is deliberately not assignable back to `KyselyDatabase` — a
144
+ * reader is not one, and anything that genuinely needs the writer should say
145
+ * so.
146
+ */
147
+ type ReadOnlyDatabase<DB, TName extends string> = Omit<KyselyDatabase<DB, TName>, 'reader' | 'cache' | 'schema'>;
148
+ //#endregion
149
+ export { KyselyDatabaseOptions as n, ReadOnlyDatabase as r, KyselyDatabase as t };
150
+ //# sourceMappingURL=kysely-CXi49zc2.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-CXi49zc2.d.cts","names":[],"sources":["../src/database/kysely.ts"],"mappings":";;;;;;;;;;;;;;;UAwCiB,8BAA8B,KAAK;;;;;;;;EAQnD;;;;;;;;EAQA;;;;;;;;;;;EAWA,UAAU;;;UAID;EACT;EACA;EACA;;;;;;;;;cAUY,eAAe,cAAc,0CAC9B,UAAU,OAAO,OAAO;mBAiBjB;WAfT,IAAI;WACJ,SAAS,QAAQ,aAAa,QAAQ,OAAO;;;;;mBAMrC;mBACA;mBACA;mBACA;mBACA;EAEjB,YACC,IAAI,cAAc,QACD,UAAS,uBAC1B,cAAc;EAyBf,WAAW;;;;;;;;;;;;;EAqDX,UAAU,iBAAiB,OAAO;;;;;;;;;;;;;;;;;;EAyBlC,MAAM,2BAA2B,cAChC,KAAI,cAAc,SAClB;IAAW;MACT,MAAM;;;;;;;;;EAeT,OAAO,UAAU,wBAChB,IAAI,cAAc,UAClB,UAAS,wBACP,eAAe,UAAU;;;;;;;;;;;;;MAoBxB,SAAS,WAAW,aAAa,eAAe,OAAO;UAQ7C;;;;;;;;;;;;;;;;;;;KAkEH,iBAAiB,IAAI,wBAAwB,KACxD,eAAe,IAAI"}