@rushdb/javascript-sdk 1.3.2 → 1.4.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.
@@ -1,10 +1,38 @@
1
- import { RestApiProxy } from '../api/rest-api-proxy.js';
2
- export declare class Transaction extends RestApiProxy {
1
+ /**
2
+ * Represents a database transaction that groups multiple operations.
3
+ * Transactions ensure that a series of operations are executed atomically,
4
+ * meaning either all operations succeed or none of them are applied.
5
+ *
6
+ * Use transactions when you need to perform multiple related operations
7
+ * that should be treated as a single unit of work. For example, creating
8
+ * related records, updating multiple records, or performing operations
9
+ * that need to be rolled back if any part fails.
10
+ */
11
+ export declare class Transaction {
3
12
  readonly id: string;
13
+ /**
14
+ * Creates a new Transaction instance.
15
+ * Typically, you should not create Transaction instances directly.
16
+ * Instead, use the tx.begin() method from a RushDB instance.
17
+ *
18
+ * @param id - The transaction ID provided by the database
19
+ */
4
20
  constructor(id: string);
21
+ /**
22
+ * Rolls back (cancels) all operations performed within this transaction.
23
+ * Use this when an error occurs or when you want to undo changes.
24
+ *
25
+ * @returns Promise resolving to the result of the rollback operation
26
+ */
5
27
  rollback(): Promise<import("../index.node.js").ApiResponse<{
6
28
  message: string;
7
29
  }>>;
30
+ /**
31
+ * Commits (applies) all operations performed within this transaction.
32
+ * This finalizes all changes made within the transaction.
33
+ *
34
+ * @returns Promise resolving to the result of the commit operation
35
+ */
8
36
  commit(): Promise<import("../index.node.js").ApiResponse<{
9
37
  message: string;
10
38
  }>>;
@@ -10,6 +10,14 @@ export type State = {
10
10
  debug: boolean;
11
11
  timeout: number;
12
12
  token?: string;
13
+ initialized: boolean;
14
+ serverSettings?: {
15
+ selfHosted: boolean;
16
+ dashboardUrl: string;
17
+ googleOAuthEnabled: boolean;
18
+ githubOAuthEnabled: boolean;
19
+ customDB?: boolean;
20
+ };
13
21
  } & Partial<ApiConnectionConfig>;
14
22
  export type Logger = (payload: any) => void;
15
23
  export type SDKConfig = {
@@ -1,6 +1,6 @@
1
- import type { FlattenTypes, MaybePromise } from './utils.js';
1
+ import type { FlattenTypes } from './utils.js';
2
2
  import type { DatetimeObject, PropertyType, PropertyValue } from './value.js';
3
- export type SchemaDefaultValue<T extends PropertyType = PropertyType> = MaybePromise<PropertyValue<T>>;
3
+ export type SchemaDefaultValue<T extends PropertyType = PropertyType> = PropertyValue<T> | (() => PropertyValue<T>) | (() => Promise<PropertyValue<T>>);
4
4
  export type SchemaField<T extends PropertyType = PropertyType> = {
5
5
  default?: SchemaDefaultValue<T>;
6
6
  multiple?: boolean;
@@ -1,5 +1,4 @@
1
1
  import type { PropertyValue } from './value';
2
- export type MaybePromise<T = any> = () => Promise<T> | T;
3
2
  export type RequireAtLeastOne<T> = {
4
3
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
5
4
  }[keyof T];
package/package.json CHANGED
@@ -33,7 +33,7 @@
33
33
  "rushdb"
34
34
  ],
35
35
  "license": "Apache-2.0",
36
- "version": "1.3.2",
36
+ "version": "1.4.0",
37
37
  "type": "module",
38
38
  "files": [
39
39
  "dist"
@@ -1,6 +0,0 @@
1
- import type { RestAPI } from './api.js';
2
- export declare class RestApiProxy {
3
- protected apiProxy: RestAPI;
4
- constructor();
5
- init(api: RestAPI): void;
6
- }