@rebasepro/types 0.16.0 → 0.16.1-canary.g0d7af95
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/call_context.d.ts +5 -5
- package/dist/controllers/auth_state.d.ts +1 -1
- package/dist/controllers/client.d.ts +22 -9
- package/dist/controllers/collection_registry.d.ts +2 -2
- package/dist/controllers/data.d.ts +4 -12
- package/dist/controllers/data_driver.d.ts +7 -7
- package/dist/controllers/email.d.ts +54 -2
- package/dist/controllers/index.d.ts +8 -9
- package/dist/controllers/storage.d.ts +4 -4
- package/dist/index.d.ts +5 -5
- package/dist/index.es.js +433 -3
- package/dist/index.es.js.map +1 -1
- package/dist/types/admin_block.d.ts +1 -1
- package/dist/types/auth_adapter.d.ts +18 -9
- package/dist/types/backend.d.ts +23 -10
- package/dist/types/collection_contract.d.ts +1 -1
- package/dist/types/collections.d.ts +34 -9
- package/dist/types/component_ref.d.ts +3 -2
- package/dist/types/cron.d.ts +1 -25
- package/dist/types/data_source.d.ts +1 -1
- package/dist/types/database_adapter.d.ts +5 -5
- package/dist/types/entities.d.ts +1 -1
- package/dist/types/entity_callbacks.d.ts +4 -4
- package/dist/types/index.d.ts +33 -29
- package/dist/types/indexes.d.ts +179 -0
- package/dist/types/project_manifest.d.ts +132 -27
- package/dist/types/properties.d.ts +58 -6
- package/dist/types/relations.d.ts +1 -1
- package/dist/types/resource_kinds.d.ts +189 -0
- package/dist/types/resources.d.ts +197 -0
- package/dist/types/schema_editing.d.ts +127 -0
- package/dist/types/schema_version.d.ts +1 -1
- package/dist/types/security_rules.d.ts +1 -1
- package/dist/types/storage_source.d.ts +27 -0
- package/dist/users/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/controllers/client.ts +14 -1
- package/src/controllers/data.ts +0 -9
- package/src/controllers/email.ts +55 -2
- package/src/controllers/index.ts +0 -1
- package/src/controllers/storage.ts +4 -4
- package/src/types/admin_block.ts +1 -2
- package/src/types/auth_adapter.ts +18 -10
- package/src/types/backend.ts +18 -1
- package/src/types/collections.ts +28 -2
- package/src/types/component_ref.ts +3 -2
- package/src/types/cron.ts +0 -24
- package/src/types/index.ts +4 -0
- package/src/types/indexes.ts +180 -0
- package/src/types/project_manifest.ts +139 -26
- package/src/types/properties.ts +54 -0
- package/src/types/resource_kinds.ts +324 -0
- package/src/types/resources.ts +368 -0
- package/src/types/schema_editing.ts +154 -0
- package/src/types/storage_source.ts +28 -0
- package/dist/controllers/database_admin.d.ts +0 -11
- package/src/controllers/database_admin.ts +0 -22
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary a live schema change is described in.
|
|
3
|
+
*
|
|
4
|
+
* Declared here, and nowhere else, because two packages that must not import
|
|
5
|
+
* each other both need it: `@rebasepro/server-postgres` decides what a change
|
|
6
|
+
* means and renders the files it needs, while `@rebasepro/server` commits those
|
|
7
|
+
* files and serves the routes. Neither can reach the other — the server is
|
|
8
|
+
* engine-agnostic by design — so the shared kernel holds the shapes and the
|
|
9
|
+
* driver is detected structurally through {@link SchemaEditingAdmin}.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here executes anything. These are the nouns.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* What a change will do to a live database.
|
|
16
|
+
*
|
|
17
|
+
* - `safe` — the boot-time ensure path expresses it, and the result matches the
|
|
18
|
+
* configuration.
|
|
19
|
+
* - `diverges` — the ensure path applies *something*, but the database will not
|
|
20
|
+
* match what the configuration declares, and nothing reports it. This is the
|
|
21
|
+
* category worth having: adding a required property to a populated table
|
|
22
|
+
* yields a nullable column, and adding a value to an existing enum yields
|
|
23
|
+
* nothing at all. Both read as success.
|
|
24
|
+
* - `needs-migration` — the ensure path cannot express it. Dropping anything,
|
|
25
|
+
* changing a type, moving a primary key.
|
|
26
|
+
*/
|
|
27
|
+
export type SchemaChangeVerdict = "safe" | "diverges" | "needs-migration";
|
|
28
|
+
|
|
29
|
+
export type SchemaChangeKind =
|
|
30
|
+
| "add-collection"
|
|
31
|
+
| "remove-collection"
|
|
32
|
+
| "add-property"
|
|
33
|
+
| "remove-property"
|
|
34
|
+
| "change-property-type"
|
|
35
|
+
| "rename-column"
|
|
36
|
+
| "add-enum-value"
|
|
37
|
+
| "remove-enum-value"
|
|
38
|
+
| "change-required"
|
|
39
|
+
| "change-primary-key";
|
|
40
|
+
|
|
41
|
+
export interface SchemaChange {
|
|
42
|
+
kind: SchemaChangeKind;
|
|
43
|
+
verdict: SchemaChangeVerdict;
|
|
44
|
+
/** Collection slug. */
|
|
45
|
+
collection: string;
|
|
46
|
+
/** Property name, where the change is to one. */
|
|
47
|
+
property?: string;
|
|
48
|
+
/** One line, specific: what changed and what it will do. */
|
|
49
|
+
detail: string;
|
|
50
|
+
/** What to do instead, when the verdict is not `safe`. */
|
|
51
|
+
remedy?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ClassifiedSchemaChanges {
|
|
55
|
+
changes: SchemaChange[];
|
|
56
|
+
/** The worst verdict present, or `safe` for an empty diff. */
|
|
57
|
+
verdict: SchemaChangeVerdict;
|
|
58
|
+
/** True only when every change is `safe` — the one case an editor may apply. */
|
|
59
|
+
applicable: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Where a project's generated schema artifacts live, relative to the **project**
|
|
64
|
+
* root — which is the repository root only when the project is the whole
|
|
65
|
+
* repository.
|
|
66
|
+
*
|
|
67
|
+
* Here rather than in the Postgres package because it is a contract, not an
|
|
68
|
+
* engine detail: `@rebasepro/server` has to derive these for a project in a
|
|
69
|
+
* subdirectory, and it cannot import a driver to do it.
|
|
70
|
+
*/
|
|
71
|
+
export interface SchemaCommitPaths {
|
|
72
|
+
/** Drizzle schema, imported by the backend. */
|
|
73
|
+
schemaFile: string;
|
|
74
|
+
/** Declarative DDL, what `db push` applies and Atlas diffs against. */
|
|
75
|
+
ddlFile: string;
|
|
76
|
+
policiesFile: string;
|
|
77
|
+
searchFile: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const DEFAULT_COMMIT_PATHS: SchemaCommitPaths = {
|
|
81
|
+
schemaFile: "backend/src/schema.generated.ts",
|
|
82
|
+
ddlFile: "drizzle/schema.sql",
|
|
83
|
+
policiesFile: "drizzle/policies.sql",
|
|
84
|
+
searchFile: "drizzle/search.sql"
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** One file the commit writes, as content rather than as a path on a disk. */
|
|
88
|
+
export interface SchemaChangeFile {
|
|
89
|
+
path: string;
|
|
90
|
+
contents: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Everything a change needs written and run.
|
|
95
|
+
*
|
|
96
|
+
* Computed without touching a disk or a network. The database is *read* — what
|
|
97
|
+
* a change means depends on what is already there, and a plan that guessed
|
|
98
|
+
* would be guessing about whether the statements it returns will be accepted.
|
|
99
|
+
*/
|
|
100
|
+
export interface SchemaChangePlan {
|
|
101
|
+
/** Every file the commit writes — collection source and generated artifacts. */
|
|
102
|
+
files: SchemaChangeFile[];
|
|
103
|
+
/** The additive DDL this change adds, in dependency order. */
|
|
104
|
+
statements: string[];
|
|
105
|
+
classified: ClassifiedSchemaChanges;
|
|
106
|
+
/** A commit message describing the change rather than announcing one. */
|
|
107
|
+
message: string;
|
|
108
|
+
/**
|
|
109
|
+
* Constraints the configuration asks for that these statements do not
|
|
110
|
+
* carry, and why.
|
|
111
|
+
*
|
|
112
|
+
* Almost always empty. When it is not, it is the part the person confirming
|
|
113
|
+
* needs to read: the change will apply, and the database will still not
|
|
114
|
+
* enforce something the configuration says — a required property over a
|
|
115
|
+
* table that already holds rows with no value for it. Optional so a plan
|
|
116
|
+
* from an engine that does not distinguish these cases stays valid.
|
|
117
|
+
*/
|
|
118
|
+
withheldConstraints?: WithheldSchemaConstraint[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A constraint a plan asks for and does not apply. */
|
|
122
|
+
export interface WithheldSchemaConstraint {
|
|
123
|
+
/** `schema.table.column`. */
|
|
124
|
+
target: string;
|
|
125
|
+
kind: "not-null";
|
|
126
|
+
/** What is in the way, naming the obstacle rather than the rule. */
|
|
127
|
+
reason: string;
|
|
128
|
+
/** What would make it applicable. */
|
|
129
|
+
remedy: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* An admin that can plan a schema change.
|
|
134
|
+
*
|
|
135
|
+
* Planning only. Applying is `executeSql`, which every SQL admin already has,
|
|
136
|
+
* and committing belongs to whatever holds the repository — keeping those three
|
|
137
|
+
* apart is what lets the same plan be committed locally on a developer's machine
|
|
138
|
+
* and through a GitHub App from a cloud tenant.
|
|
139
|
+
*
|
|
140
|
+
* @group Admin
|
|
141
|
+
*/
|
|
142
|
+
export interface SchemaEditingAdmin {
|
|
143
|
+
/**
|
|
144
|
+
* Decide what the change means and render everything it needs.
|
|
145
|
+
*
|
|
146
|
+
* Rejects when the change is not applicable, carrying the classification so
|
|
147
|
+
* a caller can say which change was the problem.
|
|
148
|
+
*/
|
|
149
|
+
planSchemaChange(
|
|
150
|
+
before: unknown[],
|
|
151
|
+
after: unknown[],
|
|
152
|
+
options?: { paths?: Partial<SchemaCommitPaths> }
|
|
153
|
+
): Promise<SchemaChangePlan>;
|
|
154
|
+
}
|
|
@@ -59,6 +59,34 @@ export interface StorageSourceDefinition {
|
|
|
59
59
|
*/
|
|
60
60
|
engine: string;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The credential set this source signs with, when several sources share one.
|
|
64
|
+
*
|
|
65
|
+
* ## What it is for
|
|
66
|
+
*
|
|
67
|
+
* Every binding a bucket needs is read per key — `S3_BUCKET__MEDIA`,
|
|
68
|
+
* `S3_ACCESS_KEY_ID__MEDIA`, and so on. That is right for the bucket *name*,
|
|
69
|
+
* which is different for every source by definition, and wrong for the
|
|
70
|
+
* credentials, which usually are not: fifteen buckets on one MinIO install
|
|
71
|
+
* meant fifteen copies of the same endpoint, access key and secret — ninety
|
|
72
|
+
* variables where eighteen would do, and one key rotation became fifteen
|
|
73
|
+
* paired edits where a single missed one fails at upload time with an opaque
|
|
74
|
+
* signing error.
|
|
75
|
+
*
|
|
76
|
+
* Naming an account here lets the *account-scoped* bindings fall back to
|
|
77
|
+
* `<BASE>__<ACCOUNT>` when no per-key value is set. The bucket name never
|
|
78
|
+
* falls back: it is what distinguishes one source from another.
|
|
79
|
+
*
|
|
80
|
+
* ## Why it does not fall back to the bare variable
|
|
81
|
+
*
|
|
82
|
+
* A source with no `account` reads only its own suffixed names, exactly as
|
|
83
|
+
* before — so every project that predates this is wire-identical. The
|
|
84
|
+
* unsuffixed `S3_ACCESS_KEY_ID` belongs to the *default* source, and letting
|
|
85
|
+
* a named bucket inherit it would mean a typo'd key silently signs with
|
|
86
|
+
* another source's credentials. Two forms, both explicit, opt-in.
|
|
87
|
+
*/
|
|
88
|
+
account?: string;
|
|
89
|
+
|
|
62
90
|
/**
|
|
63
91
|
* How the frontend reaches this storage. Defaults to `"server"`.
|
|
64
92
|
*
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module database_admin
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the capability-specific admin interfaces from `@rebasepro/types/backend`.
|
|
5
|
-
* This file is kept for backwards compatibility — new code should import from
|
|
6
|
-
* `@rebasepro/types` directly.
|
|
7
|
-
*
|
|
8
|
-
* @group Admin
|
|
9
|
-
*/
|
|
10
|
-
export type { SQLAdmin, DocumentAdmin, SchemaAdmin, DatabaseAdmin, HealthCheckResult } from "../types/backend";
|
|
11
|
-
export { isSQLAdmin, isDocumentAdmin, isSchemaAdmin } from "../types/backend";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module database_admin
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the capability-specific admin interfaces from `@rebasepro/types/backend`.
|
|
5
|
-
* This file is kept for backwards compatibility — new code should import from
|
|
6
|
-
* `@rebasepro/types` directly.
|
|
7
|
-
*
|
|
8
|
-
* @group Admin
|
|
9
|
-
*/
|
|
10
|
-
export type {
|
|
11
|
-
SQLAdmin,
|
|
12
|
-
DocumentAdmin,
|
|
13
|
-
SchemaAdmin,
|
|
14
|
-
DatabaseAdmin,
|
|
15
|
-
HealthCheckResult
|
|
16
|
-
} from "../types/backend";
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
isSQLAdmin,
|
|
20
|
-
isDocumentAdmin,
|
|
21
|
-
isSchemaAdmin
|
|
22
|
-
} from "../types/backend";
|