@rebasepro/types 0.16.0 → 0.16.1-canary.g041c925

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.
Files changed (53) hide show
  1. package/dist/call_context.d.ts +5 -5
  2. package/dist/controllers/auth_state.d.ts +1 -1
  3. package/dist/controllers/client.d.ts +22 -9
  4. package/dist/controllers/collection_registry.d.ts +2 -2
  5. package/dist/controllers/data.d.ts +4 -12
  6. package/dist/controllers/data_driver.d.ts +7 -7
  7. package/dist/controllers/email.d.ts +54 -2
  8. package/dist/controllers/index.d.ts +8 -9
  9. package/dist/controllers/storage.d.ts +4 -4
  10. package/dist/index.d.ts +5 -5
  11. package/dist/index.es.js +429 -3
  12. package/dist/index.es.js.map +1 -1
  13. package/dist/types/admin_block.d.ts +1 -1
  14. package/dist/types/auth_adapter.d.ts +18 -9
  15. package/dist/types/backend.d.ts +23 -10
  16. package/dist/types/collection_contract.d.ts +1 -1
  17. package/dist/types/collections.d.ts +16 -9
  18. package/dist/types/component_ref.d.ts +3 -2
  19. package/dist/types/cron.d.ts +1 -25
  20. package/dist/types/data_source.d.ts +1 -1
  21. package/dist/types/database_adapter.d.ts +5 -5
  22. package/dist/types/entities.d.ts +1 -1
  23. package/dist/types/entity_callbacks.d.ts +4 -4
  24. package/dist/types/index.d.ts +32 -29
  25. package/dist/types/project_manifest.d.ts +132 -27
  26. package/dist/types/properties.d.ts +58 -6
  27. package/dist/types/relations.d.ts +1 -1
  28. package/dist/types/resource_kinds.d.ts +174 -0
  29. package/dist/types/resources.d.ts +197 -0
  30. package/dist/types/schema_editing.d.ts +127 -0
  31. package/dist/types/schema_version.d.ts +1 -1
  32. package/dist/types/security_rules.d.ts +1 -1
  33. package/dist/users/index.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/src/controllers/client.ts +14 -1
  36. package/src/controllers/data.ts +0 -9
  37. package/src/controllers/email.ts +55 -2
  38. package/src/controllers/index.ts +0 -1
  39. package/src/controllers/storage.ts +4 -4
  40. package/src/types/admin_block.ts +1 -2
  41. package/src/types/auth_adapter.ts +18 -10
  42. package/src/types/backend.ts +18 -1
  43. package/src/types/collections.ts +9 -2
  44. package/src/types/component_ref.ts +3 -2
  45. package/src/types/cron.ts +0 -24
  46. package/src/types/index.ts +3 -0
  47. package/src/types/project_manifest.ts +139 -26
  48. package/src/types/properties.ts +54 -0
  49. package/src/types/resource_kinds.ts +309 -0
  50. package/src/types/resources.ts +368 -0
  51. package/src/types/schema_editing.ts +154 -0
  52. package/dist/controllers/database_admin.d.ts +0 -11
  53. package/src/controllers/database_admin.ts +0 -22
@@ -1,8 +1,8 @@
1
- import type { DataDriver } from "./controllers/data_driver";
2
- import type { StorageSource } from "./controllers/storage";
3
- import type { RebaseClient } from "./controllers/client";
4
- import type { RebaseSdkData } from "./controllers/data";
5
- import type { User } from "./users";
1
+ import type { DataDriver } from "./controllers/data_driver.js";
2
+ import type { StorageSource } from "./controllers/storage.js";
3
+ import type { RebaseClient } from "./controllers/client.js";
4
+ import type { RebaseSdkData } from "./controllers/data.js";
5
+ import type { User } from "./users/index.js";
6
6
  /**
7
7
  * Context that is provided to entity callbacks (hooks).
8
8
  * It contains only the dependencies that are available in both the frontend and the backend.
@@ -1,4 +1,4 @@
1
- import type { User } from "../users";
1
+ import type { User } from "../users/index.js";
2
2
  /**
3
3
  * The read-only slice of authentication state that property resolution needs.
4
4
  *
@@ -1,11 +1,11 @@
1
- import type { User } from "../users";
2
- import type { RebaseSdkData } from "./data";
3
- import type { EmailService } from "./email";
4
- import type { StorageSource } from "./storage";
5
- import type { CronJobStatus, CronJobLogEntry } from "../types/cron";
6
- import type { BackupInfo, BackupDestinationKind } from "../types/backup";
7
- import type { ApiKeysAPI } from "../types/api_keys";
8
- import type { StorageSourceDefinition } from "../types/storage_source";
1
+ import type { User } from "../users/index.js";
2
+ import type { RebaseSdkData } from "./data.js";
3
+ import type { EmailService } from "./email.js";
4
+ import type { StorageSource } from "./storage.js";
5
+ import type { CronJobStatus, CronJobLogEntry } from "../types/cron.js";
6
+ import type { BackupInfo, BackupDestinationKind } from "../types/backup.js";
7
+ import type { ApiKeysAPI } from "../types/api_keys.js";
8
+ import type { StorageSourceDefinition } from "../types/storage_source.js";
9
9
  /**
10
10
  * Event type for authentication state changes
11
11
  */
@@ -327,7 +327,7 @@ export interface RebaseClient<DB = unknown> {
327
327
  dataAsAdmin?: RebaseSdkData<DB>;
328
328
  /** Unified Authentication layer */
329
329
  auth: AuthClient;
330
- /** Unified Storage layer (default storage source, backward-compatible) */
330
+ /** Unified Storage layer — the default storage source. */
331
331
  storage?: StorageSource;
332
332
  /** Registry of all named storage sources for multi-backend support */
333
333
  storageRegistry?: StorageSourceRegistry;
@@ -443,6 +443,19 @@ export interface RebaseServerClient<DB = unknown> extends Omit<RebaseClient<DB>,
443
443
  * Execute raw SQL against the database. Always present server-side for SQL
444
444
  * engines. Values interpolated into the query should be passed via
445
445
  * `params`, referenced as `$1`, `$2`, … placeholders in the query text.
446
+ *
447
+ * **Runtime note.** This is the one accessor on this object that is not
448
+ * portable. It runs on the database owner connection over a TCP socket, so
449
+ * it is available wherever the framework holds that connection — every Node
450
+ * deployment, self-hosted or managed — and not on a host that has no
451
+ * sockets and no business holding owner credentials.
452
+ *
453
+ * Nothing about that is a problem for a Node deployment, and it is not a
454
+ * reason to avoid it there. It is a reason not to build a function's *only*
455
+ * data path on it if that function may later move: `c.get("driver")` and
456
+ * `rebase.dataAsAdmin` go over the same wire wherever they run. A function
457
+ * that genuinely needs raw SQL can ask `runtimeKey()` and degrade, rather
458
+ * than discovering it at the call.
446
459
  */
447
460
  sql(query: string, options?: {
448
461
  database?: string;
@@ -1,5 +1,5 @@
1
- import type { CollectionConfig } from "../types/collections";
2
- import type { EntityReference } from "../types/entities";
1
+ import type { CollectionConfig } from "../types/collections.js";
2
+ import type { EntityReference } from "../types/entities.js";
3
3
  /**
4
4
  * Controller that provides access to the registered entity collections.
5
5
  * @group Models
@@ -1,15 +1,7 @@
1
- import type { VectorSearchParams } from "./data_driver";
2
- import type { ComputedSortField, SearchMatch } from "../types/search";
3
- import { Entity, EntityValues } from "../types/entities";
4
- import { WhereFilterOp, FieldPath, FilterValues, OrderBySpec } from "../types/filter-operators";
5
- /**
6
- * Operator-blind filter value: whatever the column holds, a list of it, or null.
7
- *
8
- * @deprecated Superseded by {@link WhereValueFor}, which correlates the value
9
- * with the operator. Kept exported because it is public API and downstream code
10
- * annotates with it; every `where()` overload in this file uses `WhereValueFor`.
11
- */
12
- export type WhereValue<T> = T | T[] | null;
1
+ import type { VectorSearchParams } from "./data_driver.js";
2
+ import type { ComputedSortField, SearchMatch } from "../types/search.js";
3
+ import { Entity, EntityValues } from "../types/entities.js";
4
+ import { WhereFilterOp, FieldPath, FilterValues, OrderBySpec } from "../types/filter-operators.js";
13
5
  /**
14
6
  * The element type of an array column, and the column's own type otherwise.
15
7
  *
@@ -1,9 +1,9 @@
1
- import { RebaseApiError } from "../errors";
2
- import type { EntityStatus, EntityValues } from "../types/entities";
3
- import type { CollectionConfig, FilterValues } from "../types/collections";
4
- import type { OrderByTuple } from "../types/filter-operators";
5
- import type { RebaseCallContext } from "../call_context";
6
- import type { LogicalCondition } from "./data";
1
+ import { RebaseApiError } from "../errors.js";
2
+ import type { EntityStatus, EntityValues } from "../types/entities.js";
3
+ import type { CollectionConfig, FilterValues } from "../types/collections.js";
4
+ import type { OrderByTuple } from "../types/filter-operators.js";
5
+ import type { RebaseCallContext } from "../call_context.js";
6
+ import type { LogicalCondition } from "./data.js";
7
7
  /**
8
8
  * @internal
9
9
  */
@@ -384,7 +384,7 @@ export interface DataDriver {
384
384
  * @see DocumentAdmin
385
385
  * @see SchemaAdmin
386
386
  */
387
- admin?: import("../types/backend").DatabaseAdmin;
387
+ admin?: import("../types/backend.js").DatabaseAdmin;
388
388
  }
389
389
  /**
390
390
  * REST-optimised fetch service exposed by drivers that support
@@ -19,6 +19,50 @@ export interface EmailSendOptions {
19
19
  text?: string;
20
20
  /** Optional reply-to address. */
21
21
  replyTo?: string;
22
+ /**
23
+ * Additional headers, verbatim.
24
+ *
25
+ * The reason this exists is that several things a real sender must do are
26
+ * only expressible as headers, and without a passthrough an application had
27
+ * to choose between not doing them and not using this interface:
28
+ *
29
+ * - `List-Unsubscribe` and `List-Unsubscribe-Post`, which give a mail client
30
+ * its own one-click opt-out. The large providers weigh their presence when
31
+ * deciding whether bulk mail reaches an inbox at all.
32
+ * - `In-Reply-To` and `References`, without which a reply is a new thread.
33
+ *
34
+ * **Values are validated, not escaped.** A value containing CR or LF is
35
+ * rejected rather than sanitised, because a newline in a header value ends
36
+ * the header and starts a new one — so a field built from user input is an
37
+ * injection point for `Bcc:` and anything else. Rejecting is the only safe
38
+ * response: silently stripping the newline would deliver a message the
39
+ * caller did not write, and neither would tell them.
40
+ */
41
+ headers?: Record<string, string>;
42
+ }
43
+ /**
44
+ * What the provider reported about a message it accepted.
45
+ *
46
+ * Every field is optional because not every backend reports them: a custom
47
+ * `sendEmail` function that posts to an HTTP API may know nothing beyond "no
48
+ * error". An absent `messageId` therefore means "not reported", never "not
49
+ * sent" — the absence of an id is not a delivery failure, which is signalled by
50
+ * a thrown error.
51
+ */
52
+ export interface EmailSendResult {
53
+ /**
54
+ * The message's RFC 5322 Message-ID, **without** angle brackets.
55
+ *
56
+ * Stripped because this is an identifier to store and compare — against a
57
+ * reply's `In-Reply-To`, most often — and a value that sometimes carries
58
+ * brackets and sometimes does not is a bug waiting in every comparison.
59
+ * Re-add them when writing it into a header: `<${messageId}>`.
60
+ */
61
+ messageId?: string;
62
+ /** Recipients the provider accepted, when it says. */
63
+ accepted?: string[];
64
+ /** Recipients the provider refused, when it says. A non-empty list is not an error. */
65
+ rejected?: string[];
22
66
  }
23
67
  /**
24
68
  * Abstraction over an email delivery backend.
@@ -27,8 +71,16 @@ export interface EmailSendOptions {
27
71
  * provider — consumers only interact through this interface.
28
72
  */
29
73
  export interface EmailService {
30
- /** Send a single email. */
31
- send(options: EmailSendOptions): Promise<void>;
74
+ /**
75
+ * Send a single email.
76
+ *
77
+ * Resolves with what the provider reported (see {@link EmailSendResult});
78
+ * throws on failure. It returned `void` before 0.17: an application that
79
+ * sent a message had no way to learn the id the server assigned it, so
80
+ * threading a reply back to the message that prompted it was impossible
81
+ * through this interface. Callers that do not care may still ignore it.
82
+ */
83
+ send(options: EmailSendOptions): Promise<EmailSendResult>;
32
84
  /** Returns `true` when the service has valid credentials / is ready to send. */
33
85
  isConfigured(): boolean;
34
86
  /** Verify connection/credentials with the email provider. */
@@ -1,9 +1,8 @@
1
- export * from "./collection_registry";
2
- export * from "./auth_state";
3
- export * from "./data";
4
- export * from "./database_admin";
5
- export * from "./data_driver";
6
- export * from "./effective_role";
7
- export * from "./storage";
8
- export * from "./email";
9
- export * from "./client";
1
+ export * from "./collection_registry.js";
2
+ export * from "./auth_state.js";
3
+ export * from "./data.js";
4
+ export * from "./data_driver.js";
5
+ export * from "./effective_role.js";
6
+ export * from "./storage.js";
7
+ export * from "./email.js";
8
+ export * from "./client.js";
@@ -46,11 +46,11 @@ export interface UploadFileResult {
46
46
  /**
47
47
  * Fully qualified storage URL for the uploaded file.
48
48
  *
49
- * For example: `s3://my-bucket/path/to/file.png`.
50
- *
51
- * This is optional for backwards compatibility.
49
+ * For example: `s3://my-bucket/path/to/file.png`. Every controller in the
50
+ * framework returns one — S3, GCS and local alike — and a caller that stores
51
+ * the reference needs it, so it is part of the result rather than a maybe.
52
52
  */
53
- storageUrl?: string;
53
+ storageUrl: string;
54
54
  }
55
55
  /**
56
56
  * @group Models
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export * from "./errors";
2
- export * from "./call_context";
3
- export * from "./types";
4
- export * from "./controllers";
5
- export * from "./users";
1
+ export * from "./errors.js";
2
+ export * from "./call_context.js";
3
+ export * from "./types/index.js";
4
+ export * from "./controllers/index.js";
5
+ export * from "./users/index.js";