@elizaos/plugin-sql 2.0.0-beta.1 → 2.0.11-beta.7
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/LICENSE +21 -0
- package/README.md +87 -304
- package/package.json +24 -12
- package/src/dist/base.d.ts +0 -1152
- package/src/dist/browser/index.browser.d.ts +0 -2
- package/src/dist/browser/index.browser.js +0 -26781
- package/src/dist/browser/index.browser.js.map +0 -72
- package/src/dist/browser/index.d.ts +0 -2
- package/src/dist/cjs/index.d.ts +0 -2
- package/src/dist/cjs/index.node.cjs +0 -9154
- package/src/dist/cjs/index.node.cjs.map +0 -70
- package/src/dist/cjs/index.node.d.cts +0 -2
- package/src/dist/connector-credential-store.d.ts +0 -48
- package/src/dist/drizzle/index.d.ts +0 -1
- package/src/dist/drizzle/index.js +0 -1
- package/src/dist/index.d.ts +0 -4
- package/src/dist/index.js +0 -2
- package/src/dist/index.node.d.ts +0 -20
- package/src/dist/migration-service.d.ts +0 -17
- package/src/dist/migrations.d.ts +0 -15
- package/src/dist/node/index.d.ts +0 -2
- package/src/dist/node/index.node.d.ts +0 -2
- package/src/dist/node/index.node.js +0 -9175
- package/src/dist/node/index.node.js.map +0 -70
- package/src/dist/pg/adapter.d.ts +0 -42
- package/src/dist/pg/manager.d.ts +0 -17
- package/src/dist/pglite/adapter.d.ts +0 -24
- package/src/dist/pglite/errors.d.ts +0 -20
- package/src/dist/pglite/manager.d.ts +0 -32
- package/src/dist/rls.d.ts +0 -13
- package/src/dist/runtime-migrator/crypto-utils.d.ts +0 -25
- package/src/dist/runtime-migrator/drizzle-adapters/database-introspector.d.ts +0 -58
- package/src/dist/runtime-migrator/drizzle-adapters/diff-calculator.d.ts +0 -77
- package/src/dist/runtime-migrator/drizzle-adapters/snapshot-generator.d.ts +0 -21
- package/src/dist/runtime-migrator/drizzle-adapters/sql-generator.d.ts +0 -38
- package/src/dist/runtime-migrator/extension-manager.d.ts +0 -6
- package/src/dist/runtime-migrator/index.d.ts +0 -8
- package/src/dist/runtime-migrator/runtime-migrator.d.ts +0 -95
- package/src/dist/runtime-migrator/schema-transformer.d.ts +0 -18
- package/src/dist/runtime-migrator/storage/journal-storage.d.ts +0 -10
- package/src/dist/runtime-migrator/storage/migration-tracker.d.ts +0 -13
- package/src/dist/runtime-migrator/storage/snapshot-storage.d.ts +0 -9
- package/src/dist/runtime-migrator/types.d.ts +0 -157
- package/src/dist/schema/agent.d.ts +0 -344
- package/src/dist/schema/approvalRequests.d.ts +0 -277
- package/src/dist/schema/authAuditEvent.d.ts +0 -153
- package/src/dist/schema/authBootstrapJti.d.ts +0 -49
- package/src/dist/schema/authIdentity.d.ts +0 -121
- package/src/dist/schema/authOwnerBinding.d.ts +0 -168
- package/src/dist/schema/authOwnerLoginToken.d.ts +0 -122
- package/src/dist/schema/authSession.d.ts +0 -225
- package/src/dist/schema/cache.d.ts +0 -97
- package/src/dist/schema/channel.d.ts +0 -177
- package/src/dist/schema/channelParticipant.d.ts +0 -41
- package/src/dist/schema/component.d.ts +0 -163
- package/src/dist/schema/connectorAccounts.d.ts +0 -981
- package/src/dist/schema/embedding.d.ts +0 -204
- package/src/dist/schema/entity.d.ts +0 -125
- package/src/dist/schema/entityIdentity.d.ts +0 -577
- package/src/dist/schema/index.d.ts +0 -35
- package/src/dist/schema/index.js +0 -1
- package/src/dist/schema/log.d.ts +0 -114
- package/src/dist/schema/longTermMemories.d.ts +0 -254
- package/src/dist/schema/memory.d.ts +0 -185
- package/src/dist/schema/memoryAccessLogs.d.ts +0 -109
- package/src/dist/schema/message.d.ts +0 -194
- package/src/dist/schema/messageServer.d.ts +0 -126
- package/src/dist/schema/messageServerAgent.d.ts +0 -41
- package/src/dist/schema/pairingAllowlist.d.ts +0 -113
- package/src/dist/schema/pairingRequest.d.ts +0 -147
- package/src/dist/schema/participant.d.ts +0 -114
- package/src/dist/schema/relationship.d.ts +0 -156
- package/src/dist/schema/room.d.ts +0 -195
- package/src/dist/schema/server.d.ts +0 -64
- package/src/dist/schema/sessionSummaries.d.ts +0 -273
- package/src/dist/schema/tasks.d.ts +0 -225
- package/src/dist/schema/types.d.ts +0 -68
- package/src/dist/schema/world.d.ts +0 -114
- package/src/dist/services/advanced-memory-storage.d.ts +0 -36
- package/src/dist/stores/connectorAccount.store.d.ts +0 -64
- package/src/dist/stores/types.d.ts +0 -25
- package/src/dist/types.d.ts +0 -13
- package/src/dist/utils/string-to-uuid.d.ts +0 -2
- package/src/dist/utils.d.ts +0 -4
- package/src/dist/utils.node.d.ts +0 -4
package/src/dist/pg/adapter.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type Agent, type Component, type Entity, type Memory, type UUID } from "@elizaos/core";
|
|
2
|
-
import type { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import type { Pool } from "pg";
|
|
4
|
-
import { BaseDrizzleAdapter } from "../base";
|
|
5
|
-
import { type EmbeddingDimensionColumn } from "../schema/embedding";
|
|
6
|
-
import type { PostgresConnectionManager } from "./manager";
|
|
7
|
-
export declare class PgDatabaseAdapter extends BaseDrizzleAdapter {
|
|
8
|
-
protected embeddingDimension: EmbeddingDimensionColumn;
|
|
9
|
-
private manager;
|
|
10
|
-
constructor(agentId: UUID, manager: PostgresConnectionManager, _schema?: Record<string, unknown>);
|
|
11
|
-
getManager(): PostgresConnectionManager;
|
|
12
|
-
withEntityContext<T>(entityId: UUID | null, callback: (tx: NodePgDatabase) => Promise<T>): Promise<T>;
|
|
13
|
-
getEntityByIds(entityIds: UUID[]): Promise<Entity[] | null>;
|
|
14
|
-
getMemoriesByServerId(_params: {
|
|
15
|
-
serverId: UUID;
|
|
16
|
-
count?: number;
|
|
17
|
-
}): Promise<Memory[]>;
|
|
18
|
-
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
19
|
-
protected withDatabase<T>(operation: () => Promise<T>): Promise<T>;
|
|
20
|
-
init(): Promise<void>;
|
|
21
|
-
isReady(): Promise<boolean>;
|
|
22
|
-
close(): Promise<void>;
|
|
23
|
-
getConnection(): Promise<NodePgDatabase>;
|
|
24
|
-
getRawConnection(): Pool;
|
|
25
|
-
createAgent(agent: Agent): Promise<boolean>;
|
|
26
|
-
getAgent(agentId: UUID): Promise<Agent | null>;
|
|
27
|
-
updateAgent(agentId: UUID, agent: Partial<Agent>): Promise<boolean>;
|
|
28
|
-
deleteAgent(agentId: UUID): Promise<boolean>;
|
|
29
|
-
createEntities(entities: Entity[]): Promise<UUID[]>;
|
|
30
|
-
getEntitiesByIds(entityIds: UUID[]): Promise<Entity[]>;
|
|
31
|
-
updateEntity(entity: Entity): Promise<void>;
|
|
32
|
-
createMemory(memory: Memory, tableName: string): Promise<UUID>;
|
|
33
|
-
getMemoryById(memoryId: UUID): Promise<Memory | null>;
|
|
34
|
-
updateMemory(memory: Partial<Memory> & {
|
|
35
|
-
id: UUID;
|
|
36
|
-
}): Promise<boolean>;
|
|
37
|
-
deleteMemory(memoryId: UUID): Promise<void>;
|
|
38
|
-
createComponent(component: Component): Promise<boolean>;
|
|
39
|
-
getComponent(entityId: UUID, type: string, worldId?: UUID, sourceEntityId?: UUID): Promise<Component | null>;
|
|
40
|
-
updateComponent(component: Component): Promise<void>;
|
|
41
|
-
deleteComponent(componentId: UUID): Promise<void>;
|
|
42
|
-
}
|
package/src/dist/pg/manager.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type UUID } from "@elizaos/core";
|
|
2
|
-
import { type NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
-
import { Pool, type PoolClient } from "pg";
|
|
4
|
-
export declare class PostgresConnectionManager {
|
|
5
|
-
private pool;
|
|
6
|
-
private db;
|
|
7
|
-
private closePromise;
|
|
8
|
-
private shuttingDown;
|
|
9
|
-
constructor(connectionString: string, rlsServerId?: string);
|
|
10
|
-
getDatabase(): NodePgDatabase;
|
|
11
|
-
getConnection(): Pool;
|
|
12
|
-
isShuttingDown(): boolean;
|
|
13
|
-
getClient(): Promise<PoolClient>;
|
|
14
|
-
testConnection(): Promise<boolean>;
|
|
15
|
-
withEntityContext<T>(entityId: UUID | null, callback: (tx: NodePgDatabase) => Promise<T>): Promise<T>;
|
|
16
|
-
close(): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { PGlite } from "@electric-sql/pglite";
|
|
2
|
-
import { type Agent, type Entity, type Memory, type UUID } from "@elizaos/core";
|
|
3
|
-
import { type PgliteDatabase } from "drizzle-orm/pglite";
|
|
4
|
-
import { BaseDrizzleAdapter } from "../base";
|
|
5
|
-
import { type EmbeddingDimensionColumn } from "../schema/embedding";
|
|
6
|
-
import type { PGliteClientManager } from "./manager";
|
|
7
|
-
export declare class PgliteDatabaseAdapter extends BaseDrizzleAdapter {
|
|
8
|
-
private manager;
|
|
9
|
-
protected embeddingDimension: EmbeddingDimensionColumn;
|
|
10
|
-
constructor(agentId: UUID, manager: PGliteClientManager);
|
|
11
|
-
withEntityContext<T>(_entityId: UUID | null, callback: (tx: PgliteDatabase) => Promise<T>): Promise<T>;
|
|
12
|
-
getEntityByIds(entityIds: UUID[]): Promise<Entity[] | null>;
|
|
13
|
-
getMemoriesByServerId(_params: {
|
|
14
|
-
serverId: UUID;
|
|
15
|
-
count?: number;
|
|
16
|
-
}): Promise<Memory[]>;
|
|
17
|
-
ensureAgentExists(agent: Partial<Agent>): Promise<Agent>;
|
|
18
|
-
protected withDatabase<T>(operation: () => Promise<T>): Promise<T>;
|
|
19
|
-
init(): Promise<void>;
|
|
20
|
-
isReady(): Promise<boolean>;
|
|
21
|
-
close(): Promise<void>;
|
|
22
|
-
getConnection(): Promise<PgliteDatabase>;
|
|
23
|
-
getRawConnection(): PGlite;
|
|
24
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const PGLITE_ERROR_CODES: {
|
|
2
|
-
readonly ACTIVE_LOCK: "ELIZA_PGLITE_DATA_DIR_IN_USE";
|
|
3
|
-
readonly CORRUPT_DATA: "ELIZA_PGLITE_CORRUPT_DATA";
|
|
4
|
-
readonly MANUAL_RESET_REQUIRED: "ELIZA_PGLITE_MANUAL_RESET_REQUIRED";
|
|
5
|
-
};
|
|
6
|
-
export type PgliteErrorCode = (typeof PGLITE_ERROR_CODES)[keyof typeof PGLITE_ERROR_CODES];
|
|
7
|
-
export declare class PgliteInitError extends Error {
|
|
8
|
-
readonly code: PgliteErrorCode;
|
|
9
|
-
readonly dataDir?: string;
|
|
10
|
-
constructor(code: PgliteErrorCode, message: string, options?: {
|
|
11
|
-
cause?: unknown;
|
|
12
|
-
dataDir?: string;
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export declare function createPgliteInitError(code: PgliteErrorCode, message: string, options?: {
|
|
16
|
-
cause?: unknown;
|
|
17
|
-
dataDir?: string;
|
|
18
|
-
}): PgliteInitError;
|
|
19
|
-
export declare function getPgliteErrorCode(err: unknown): PgliteErrorCode | null;
|
|
20
|
-
export declare function isFatalPgliteErrorCode(code: unknown): code is PgliteErrorCode;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PGlite, type PGliteOptions } from "@electric-sql/pglite";
|
|
2
|
-
import type { IDatabaseClientManager } from "../types";
|
|
3
|
-
export declare class PGliteClientManager implements IDatabaseClientManager<PGlite> {
|
|
4
|
-
private client;
|
|
5
|
-
private options;
|
|
6
|
-
private shuttingDown;
|
|
7
|
-
private initialized;
|
|
8
|
-
private initializePromise;
|
|
9
|
-
private lockFd;
|
|
10
|
-
private lockPath;
|
|
11
|
-
constructor(options: PGliteOptions);
|
|
12
|
-
getConnection(): PGlite;
|
|
13
|
-
isShuttingDown(): boolean;
|
|
14
|
-
isInitialized(): boolean;
|
|
15
|
-
initialize(): Promise<void>;
|
|
16
|
-
close(): Promise<void>;
|
|
17
|
-
private setupShutdownHandlers;
|
|
18
|
-
private createClient;
|
|
19
|
-
private getDataDir;
|
|
20
|
-
private isFileBackedDataDir;
|
|
21
|
-
private getDataDirLockPath;
|
|
22
|
-
private getLockPid;
|
|
23
|
-
private isPidRunning;
|
|
24
|
-
private acquireDataDirLockIfNeeded;
|
|
25
|
-
private releaseDataDirLock;
|
|
26
|
-
private getErrorText;
|
|
27
|
-
private reconcilePglitePidFile;
|
|
28
|
-
private createActiveLockError;
|
|
29
|
-
private createManualResetRequiredError;
|
|
30
|
-
private queryMigrationsSchema;
|
|
31
|
-
private initializeInternal;
|
|
32
|
-
}
|
package/src/dist/rls.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type IDatabaseAdapter } from "@elizaos/core";
|
|
2
|
-
export declare function installRLSFunctions(adapter: IDatabaseAdapter): Promise<void>;
|
|
3
|
-
export declare function getOrCreateRlsServer(adapter: IDatabaseAdapter, serverId: string): Promise<string>;
|
|
4
|
-
export declare function setServerContext(adapter: IDatabaseAdapter, serverId: string): Promise<void>;
|
|
5
|
-
export declare function assignAgentToServer(adapter: IDatabaseAdapter, agentId: string, serverId: string): Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Apply RLS to all tables by calling PostgreSQL function
|
|
8
|
-
*/
|
|
9
|
-
export declare function applyRLSToNewTables(adapter: IDatabaseAdapter): Promise<void>;
|
|
10
|
-
export declare function uninstallRLS(adapter: IDatabaseAdapter): Promise<void>;
|
|
11
|
-
export declare function installEntityRLS(adapter: IDatabaseAdapter): Promise<void>;
|
|
12
|
-
export declare function applyEntityRLSToAllTables(adapter: IDatabaseAdapter): Promise<void>;
|
|
13
|
-
export declare function uninstallEntityRLS(adapter: IDatabaseAdapter): Promise<void>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser-compatible crypto utilities
|
|
3
|
-
* Uses the Web Crypto API which is available in both browsers and Node.js
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Simple synchronous hash function for change detection
|
|
7
|
-
* This is NOT cryptographic - it's just for comparing snapshots
|
|
8
|
-
* Uses djb2 hash algorithm for speed and simplicity
|
|
9
|
-
*/
|
|
10
|
-
export declare function simpleHash(str: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* Create a longer hash by combining multiple passes
|
|
13
|
-
* This provides better distribution for larger inputs
|
|
14
|
-
*/
|
|
15
|
-
export declare function extendedHash(str: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Async SHA-256 hash using Web Crypto API
|
|
18
|
-
* Works in both browsers and Node.js (v15+)
|
|
19
|
-
*/
|
|
20
|
-
export declare function sha256Async(data: string): Promise<string>;
|
|
21
|
-
/**
|
|
22
|
-
* Generate a stable bigint from a string for advisory lock IDs
|
|
23
|
-
* Uses a simple hash that produces consistent results across runs
|
|
24
|
-
*/
|
|
25
|
-
export declare function stringToBigInt(str: string): bigint;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { DrizzleDB, SchemaSnapshot } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* Introspect the current database state and generate a snapshot
|
|
4
|
-
* This is used when no previous snapshot exists for a plugin
|
|
5
|
-
* to capture the existing database state before migrations
|
|
6
|
-
*/
|
|
7
|
-
export declare class DatabaseIntrospector {
|
|
8
|
-
private db;
|
|
9
|
-
constructor(db: DrizzleDB);
|
|
10
|
-
/**
|
|
11
|
-
* Introspect all tables in the database and generate a snapshot
|
|
12
|
-
* @param schemaName - Schema to introspect (default: 'public')
|
|
13
|
-
* @returns Schema snapshot of current database state
|
|
14
|
-
*/
|
|
15
|
-
introspectSchema(schemaName?: string): Promise<SchemaSnapshot>;
|
|
16
|
-
/**
|
|
17
|
-
* Get all tables in a schema
|
|
18
|
-
*/
|
|
19
|
-
private getTables;
|
|
20
|
-
/**
|
|
21
|
-
* Get columns for a table
|
|
22
|
-
*/
|
|
23
|
-
private getColumns;
|
|
24
|
-
/**
|
|
25
|
-
* Get indexes for a table
|
|
26
|
-
*/
|
|
27
|
-
private getIndexes;
|
|
28
|
-
/**
|
|
29
|
-
* Get foreign keys for a table
|
|
30
|
-
*/
|
|
31
|
-
private getForeignKeys;
|
|
32
|
-
/**
|
|
33
|
-
* Get primary keys for a table
|
|
34
|
-
*/
|
|
35
|
-
private getPrimaryKeys;
|
|
36
|
-
/**
|
|
37
|
-
* Get unique constraints for a table
|
|
38
|
-
*/
|
|
39
|
-
private getUniqueConstraints;
|
|
40
|
-
/**
|
|
41
|
-
* Get check constraints for a table
|
|
42
|
-
*/
|
|
43
|
-
private getCheckConstraints;
|
|
44
|
-
/**
|
|
45
|
-
* Get enums in a schema
|
|
46
|
-
*/
|
|
47
|
-
private getEnums;
|
|
48
|
-
/**
|
|
49
|
-
* Parse default value for a column
|
|
50
|
-
*/
|
|
51
|
-
private parseDefault;
|
|
52
|
-
/**
|
|
53
|
-
* Check if tables exist for a plugin by checking if any tables exist in its schema
|
|
54
|
-
* @param pluginName - Name of the plugin
|
|
55
|
-
* @returns True if tables exist, false otherwise
|
|
56
|
-
*/
|
|
57
|
-
hasExistingTables(pluginName: string): Promise<boolean>;
|
|
58
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { SchemaCheckConstraint, SchemaColumn, SchemaForeignKey, SchemaIndex, SchemaSnapshot, SchemaUniqueConstraint } from "../types";
|
|
2
|
-
export interface ColumnChanges {
|
|
3
|
-
typeChanged?: boolean;
|
|
4
|
-
prevType?: string;
|
|
5
|
-
newType?: string;
|
|
6
|
-
nullabilityChanged?: boolean;
|
|
7
|
-
wasNullable?: boolean;
|
|
8
|
-
isNullable?: boolean;
|
|
9
|
-
defaultChanged?: boolean;
|
|
10
|
-
prevDefault?: string | number | boolean;
|
|
11
|
-
newDefault?: string | number | boolean;
|
|
12
|
-
from?: SchemaColumn;
|
|
13
|
-
to?: SchemaColumn;
|
|
14
|
-
}
|
|
15
|
-
export interface TableChanges {
|
|
16
|
-
columnsAdded: string[];
|
|
17
|
-
columnsDeleted: string[];
|
|
18
|
-
columnsModified: string[];
|
|
19
|
-
}
|
|
20
|
-
export interface SchemaDiff {
|
|
21
|
-
tables: {
|
|
22
|
-
created: string[];
|
|
23
|
-
deleted: string[];
|
|
24
|
-
modified: Array<{
|
|
25
|
-
name: string;
|
|
26
|
-
changes: TableChanges;
|
|
27
|
-
}>;
|
|
28
|
-
};
|
|
29
|
-
columns: {
|
|
30
|
-
added: Array<{
|
|
31
|
-
table: string;
|
|
32
|
-
column: string;
|
|
33
|
-
definition: SchemaColumn;
|
|
34
|
-
}>;
|
|
35
|
-
deleted: Array<{
|
|
36
|
-
table: string;
|
|
37
|
-
column: string;
|
|
38
|
-
}>;
|
|
39
|
-
modified: Array<{
|
|
40
|
-
table: string;
|
|
41
|
-
column: string;
|
|
42
|
-
changes: ColumnChanges;
|
|
43
|
-
}>;
|
|
44
|
-
};
|
|
45
|
-
indexes: {
|
|
46
|
-
created: SchemaIndex[];
|
|
47
|
-
deleted: SchemaIndex[];
|
|
48
|
-
altered: Array<{
|
|
49
|
-
old: SchemaIndex;
|
|
50
|
-
new: SchemaIndex;
|
|
51
|
-
}>;
|
|
52
|
-
};
|
|
53
|
-
foreignKeys: {
|
|
54
|
-
created: SchemaForeignKey[];
|
|
55
|
-
deleted: SchemaForeignKey[];
|
|
56
|
-
altered: Array<{
|
|
57
|
-
old: SchemaForeignKey;
|
|
58
|
-
new: SchemaForeignKey;
|
|
59
|
-
}>;
|
|
60
|
-
};
|
|
61
|
-
uniqueConstraints: {
|
|
62
|
-
created: SchemaUniqueConstraint[];
|
|
63
|
-
deleted: SchemaUniqueConstraint[];
|
|
64
|
-
};
|
|
65
|
-
checkConstraints: {
|
|
66
|
-
created: SchemaCheckConstraint[];
|
|
67
|
-
deleted: SchemaCheckConstraint[];
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Calculate the difference between two snapshots
|
|
72
|
-
*/
|
|
73
|
-
export declare function calculateDiff(previousSnapshot: SchemaSnapshot | null, currentSnapshot: SchemaSnapshot): Promise<SchemaDiff>;
|
|
74
|
-
/**
|
|
75
|
-
* Check if a diff has any changes
|
|
76
|
-
*/
|
|
77
|
-
export declare function hasDiffChanges(diff: SchemaDiff): boolean;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { SchemaSnapshot } from "../types";
|
|
2
|
-
type DrizzleSchema = Record<string, unknown>;
|
|
3
|
-
/**
|
|
4
|
-
* Generate a snapshot from a Drizzle schema
|
|
5
|
-
* This is a port of Drizzle's pgSerializer.generatePgSnapshot
|
|
6
|
-
*/
|
|
7
|
-
export declare function generateSnapshot(schema: DrizzleSchema): Promise<SchemaSnapshot>;
|
|
8
|
-
/**
|
|
9
|
-
* Calculate hash of a snapshot for change detection
|
|
10
|
-
* Uses a browser-compatible hash function
|
|
11
|
-
*/
|
|
12
|
-
export declare function hashSnapshot(snapshot: SchemaSnapshot): string;
|
|
13
|
-
/**
|
|
14
|
-
* Create an empty snapshot for initial migration
|
|
15
|
-
*/
|
|
16
|
-
export declare function createEmptySnapshot(): SchemaSnapshot;
|
|
17
|
-
/**
|
|
18
|
-
* Compare two snapshots and detect if there are changes
|
|
19
|
-
*/
|
|
20
|
-
export declare function hasChanges(previousSnapshot: SchemaSnapshot | null, currentSnapshot: SchemaSnapshot): boolean;
|
|
21
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { SchemaSnapshot } from "../types";
|
|
2
|
-
import type { SchemaDiff } from "./diff-calculator";
|
|
3
|
-
/**
|
|
4
|
-
* Data loss detection result
|
|
5
|
-
* Based on Drizzle's pgPushUtils approach
|
|
6
|
-
*/
|
|
7
|
-
export interface DataLossCheck {
|
|
8
|
-
hasDataLoss: boolean;
|
|
9
|
-
tablesToRemove: string[];
|
|
10
|
-
columnsToRemove: string[];
|
|
11
|
-
tablesToTruncate: string[];
|
|
12
|
-
typeChanges: Array<{
|
|
13
|
-
table: string;
|
|
14
|
-
column: string;
|
|
15
|
-
from: string;
|
|
16
|
-
to: string;
|
|
17
|
-
}>;
|
|
18
|
-
warnings: string[];
|
|
19
|
-
requiresConfirmation: boolean;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Check for potential data loss in schema changes
|
|
23
|
-
* Based on Drizzle's pgSuggestions function
|
|
24
|
-
*/
|
|
25
|
-
export declare function checkForDataLoss(diff: SchemaDiff): DataLossCheck;
|
|
26
|
-
/**
|
|
27
|
-
* Generate SQL statements from a schema diff
|
|
28
|
-
* This follows Drizzle's approach: create all tables first, then add foreign keys
|
|
29
|
-
*/
|
|
30
|
-
export declare function generateMigrationSQL(previousSnapshot: SchemaSnapshot | null, currentSnapshot: SchemaSnapshot, diff?: SchemaDiff): Promise<string[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Generate SQL for renaming a table
|
|
33
|
-
*/
|
|
34
|
-
export declare function generateRenameTableSQL(oldName: string, newName: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Generate SQL for renaming a column
|
|
37
|
-
*/
|
|
38
|
-
export declare function generateRenameColumnSQL(table: string, oldName: string, newName: string): string;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { calculateDiff, hasDiffChanges, type SchemaDiff, } from "./drizzle-adapters/diff-calculator";
|
|
2
|
-
export { createEmptySnapshot, generateSnapshot, hasChanges, hashSnapshot, } from "./drizzle-adapters/snapshot-generator";
|
|
3
|
-
export { generateMigrationSQL, generateRenameColumnSQL, generateRenameTableSQL, } from "./drizzle-adapters/sql-generator";
|
|
4
|
-
export { RuntimeMigrator } from "./runtime-migrator";
|
|
5
|
-
export { JournalStorage } from "./storage/journal-storage";
|
|
6
|
-
export { MigrationTracker } from "./storage/migration-tracker";
|
|
7
|
-
export { SnapshotStorage } from "./storage/snapshot-storage";
|
|
8
|
-
export * from "./types";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { type DataLossCheck } from "./drizzle-adapters/sql-generator";
|
|
2
|
-
import type { DrizzleDB, RuntimeMigrationOptions } from "./types";
|
|
3
|
-
export declare class RuntimeMigrator {
|
|
4
|
-
private db;
|
|
5
|
-
private migrationTracker;
|
|
6
|
-
private journalStorage;
|
|
7
|
-
private snapshotStorage;
|
|
8
|
-
private extensionManager;
|
|
9
|
-
private introspector;
|
|
10
|
-
constructor(db: DrizzleDB);
|
|
11
|
-
/**
|
|
12
|
-
* Get expected schema name for a plugin
|
|
13
|
-
* @elizaos/plugin-sql uses 'public' schema (core application)
|
|
14
|
-
* All other plugins should use namespaced schemas
|
|
15
|
-
*/
|
|
16
|
-
private getExpectedSchemaName;
|
|
17
|
-
/**
|
|
18
|
-
* Ensure all schemas used in the snapshot exist
|
|
19
|
-
*/
|
|
20
|
-
private ensureSchemasExist;
|
|
21
|
-
/**
|
|
22
|
-
* Validate schema usage and provide warnings
|
|
23
|
-
*/
|
|
24
|
-
private validateSchemaUsage;
|
|
25
|
-
/**
|
|
26
|
-
* Generate a stable advisory lock ID from plugin name
|
|
27
|
-
* PostgreSQL advisory locks use bigint, so we need to hash the plugin name
|
|
28
|
-
* and convert to a stable bigint value
|
|
29
|
-
* Uses browser-compatible hashing
|
|
30
|
-
*/
|
|
31
|
-
private getAdvisoryLockId;
|
|
32
|
-
/**
|
|
33
|
-
* Validate that a value is a valid PostgreSQL bigint
|
|
34
|
-
* PostgreSQL bigint range: -9223372036854775808 to 9223372036854775807
|
|
35
|
-
*/
|
|
36
|
-
private validateBigInt;
|
|
37
|
-
/**
|
|
38
|
-
* Detect if a connection string represents a real PostgreSQL database
|
|
39
|
-
* (not PGLite, in-memory, or other non-PostgreSQL databases)
|
|
40
|
-
*/
|
|
41
|
-
private isRealPostgresDatabase;
|
|
42
|
-
/**
|
|
43
|
-
* Initialize migration system - create necessary tables
|
|
44
|
-
* @throws Error if table creation fails
|
|
45
|
-
*/
|
|
46
|
-
initialize(): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Run migrations for a plugin/schema
|
|
49
|
-
* @param pluginName - Plugin identifier
|
|
50
|
-
* @param schema - Drizzle schema object
|
|
51
|
-
* @param options - Migration options (verbose, force, dryRun, allowDataLoss)
|
|
52
|
-
* @throws Error if destructive migrations blocked or migration fails
|
|
53
|
-
*/
|
|
54
|
-
migrate(pluginName: string, schema: Record<string, unknown>, options?: RuntimeMigrationOptions): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Execute migration in a transaction
|
|
57
|
-
*/
|
|
58
|
-
private executeMigration;
|
|
59
|
-
/**
|
|
60
|
-
* Generate migration tag (like 0000_jazzy_shard)
|
|
61
|
-
*/
|
|
62
|
-
private generateMigrationTag;
|
|
63
|
-
/**
|
|
64
|
-
* Get migration status for a plugin
|
|
65
|
-
* @param pluginName - Plugin identifier
|
|
66
|
-
* @returns Migration history and current state
|
|
67
|
-
*/
|
|
68
|
-
getStatus(pluginName: string): Promise<{
|
|
69
|
-
hasRun: boolean;
|
|
70
|
-
lastMigration: {
|
|
71
|
-
id: number;
|
|
72
|
-
hash: string;
|
|
73
|
-
created_at: string;
|
|
74
|
-
} | null;
|
|
75
|
-
journal: {
|
|
76
|
-
version: string;
|
|
77
|
-
dialect: string;
|
|
78
|
-
entries: unknown[];
|
|
79
|
-
} | null;
|
|
80
|
-
snapshots: number;
|
|
81
|
-
}>;
|
|
82
|
-
/**
|
|
83
|
-
* Reset migrations for a plugin (dangerous - for development only)
|
|
84
|
-
* @param pluginName - Plugin identifier
|
|
85
|
-
* @warning Deletes all migration history - use only in development
|
|
86
|
-
*/
|
|
87
|
-
reset(pluginName: string): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Check if a migration would cause data loss without executing it
|
|
90
|
-
* @param pluginName - Plugin identifier
|
|
91
|
-
* @param schema - Drizzle schema to check
|
|
92
|
-
* @returns Data loss analysis or null if no changes
|
|
93
|
-
*/
|
|
94
|
-
checkMigration(pluginName: string, schema: Record<string, unknown>): Promise<DataLossCheck | null>;
|
|
95
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type DrizzleSchema = Record<string, unknown>;
|
|
2
|
-
/**
|
|
3
|
-
* Transform a plugin's schema to use the appropriate namespace
|
|
4
|
-
*
|
|
5
|
-
* @elizaos/plugin-sql uses 'public' schema (no transformation)
|
|
6
|
-
* Other plugins get their tables wrapped in a namespaced schema
|
|
7
|
-
*/
|
|
8
|
-
export declare function transformPluginSchema(pluginName: string, schema: DrizzleSchema): DrizzleSchema;
|
|
9
|
-
/**
|
|
10
|
-
* Derive a valid PostgreSQL schema name from a plugin name
|
|
11
|
-
*/
|
|
12
|
-
export declare function deriveSchemaName(pluginName: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Create a namespaced schema helper for plugins
|
|
15
|
-
* This is what plugins should ideally use to define their tables
|
|
16
|
-
*/
|
|
17
|
-
export declare function createPluginSchema(pluginName: string): import("drizzle-orm/pg-core").PgSchema<string>;
|
|
18
|
-
export {};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DrizzleDB, Journal, JournalEntry } from "../types";
|
|
2
|
-
export declare class JournalStorage {
|
|
3
|
-
private db;
|
|
4
|
-
constructor(db: DrizzleDB);
|
|
5
|
-
loadJournal(pluginName: string): Promise<Journal | null>;
|
|
6
|
-
saveJournal(pluginName: string, journal: Journal): Promise<void>;
|
|
7
|
-
addEntry(pluginName: string, entry: JournalEntry): Promise<void>;
|
|
8
|
-
getNextIdx(pluginName: string): Promise<number>;
|
|
9
|
-
updateJournal(pluginName: string, idx: number, tag: string, breakpoints?: boolean): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DrizzleDB } from "../types";
|
|
2
|
-
export declare class MigrationTracker {
|
|
3
|
-
private db;
|
|
4
|
-
constructor(db: DrizzleDB);
|
|
5
|
-
ensureSchema(): Promise<void>;
|
|
6
|
-
ensureTables(): Promise<void>;
|
|
7
|
-
getLastMigration(pluginName: string): Promise<{
|
|
8
|
-
id: number;
|
|
9
|
-
hash: string;
|
|
10
|
-
created_at: string;
|
|
11
|
-
} | null>;
|
|
12
|
-
recordMigration(pluginName: string, hash: string, createdAt: number): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { DrizzleDB, SchemaSnapshot } from "../types";
|
|
2
|
-
export declare class SnapshotStorage {
|
|
3
|
-
private db;
|
|
4
|
-
constructor(db: DrizzleDB);
|
|
5
|
-
saveSnapshot(pluginName: string, idx: number, snapshot: SchemaSnapshot): Promise<void>;
|
|
6
|
-
loadSnapshot(pluginName: string, idx: number): Promise<SchemaSnapshot | null>;
|
|
7
|
-
getLatestSnapshot(pluginName: string): Promise<SchemaSnapshot | null>;
|
|
8
|
-
getAllSnapshots(pluginName: string): Promise<SchemaSnapshot[]>;
|
|
9
|
-
}
|