@fadhilp/stateql 0.2.0 → 0.3.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.
- package/README.md +14 -1
- package/dist/src/cli.js +7 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/response-data.js +2 -0
- package/dist/src/stateql.d.ts +15 -2
- package/dist/src/stateql.js +302 -55
- package/dist/src/store.d.ts +44 -9
- package/dist/src/store.js +437 -91
- package/dist/src/types.d.ts +49 -0
- package/package.json +1 -1
package/dist/src/store.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface ResultRecord {
|
|
|
48
48
|
export interface OperationRecord {
|
|
49
49
|
id: string;
|
|
50
50
|
session_id: string;
|
|
51
|
+
actor_id: string;
|
|
51
52
|
connection_id: string;
|
|
52
53
|
fingerprint: string;
|
|
53
54
|
sql: string;
|
|
@@ -65,6 +66,7 @@ export interface OperationRecord {
|
|
|
65
66
|
export interface TransactionRecord {
|
|
66
67
|
id: string;
|
|
67
68
|
session_id: string;
|
|
69
|
+
owner_actor_id: string;
|
|
68
70
|
connection_id: string;
|
|
69
71
|
state: string;
|
|
70
72
|
isolation_level: string;
|
|
@@ -75,6 +77,7 @@ export interface TransactionRecord {
|
|
|
75
77
|
export interface PlanRecord {
|
|
76
78
|
id: string;
|
|
77
79
|
session_id: string;
|
|
80
|
+
owner_actor_id: string;
|
|
78
81
|
connection_id: string;
|
|
79
82
|
sql: string;
|
|
80
83
|
parameters: string;
|
|
@@ -86,12 +89,14 @@ export interface PlanRecord {
|
|
|
86
89
|
allow_destructive: number;
|
|
87
90
|
expires_at: string;
|
|
88
91
|
applied_operation_id: string | null;
|
|
92
|
+
claim_token: string | null;
|
|
89
93
|
created_at: string;
|
|
90
94
|
}
|
|
91
95
|
export interface HistoryRecord {
|
|
92
96
|
id: string;
|
|
93
97
|
timestamp: string;
|
|
94
98
|
session_id: string;
|
|
99
|
+
actor_id: string;
|
|
95
100
|
command: string;
|
|
96
101
|
handle: string | null;
|
|
97
102
|
executed: number;
|
|
@@ -99,6 +104,11 @@ export interface HistoryRecord {
|
|
|
99
104
|
success: number;
|
|
100
105
|
error_code: string | null;
|
|
101
106
|
}
|
|
107
|
+
export interface SessionMemberRecord {
|
|
108
|
+
session_id: string;
|
|
109
|
+
actor_id: string;
|
|
110
|
+
attached_at: string;
|
|
111
|
+
}
|
|
102
112
|
export declare class StateStore {
|
|
103
113
|
private readonly now;
|
|
104
114
|
readonly db: DatabaseSync;
|
|
@@ -106,11 +116,17 @@ export declare class StateStore {
|
|
|
106
116
|
close(): void;
|
|
107
117
|
nextId(prefix: string): string;
|
|
108
118
|
ensureSession(name?: string): SessionRecord;
|
|
119
|
+
bootstrapSession(name: string, actorId: string, ensureLegacyMembership: boolean): SessionRecord;
|
|
109
120
|
createSession(name: string): SessionRecord;
|
|
121
|
+
isSessionMember(sessionId: string, actorId: string): boolean;
|
|
122
|
+
linkActor(sessionId: string, requestingActorId: string, actorId: string): "linked" | "already_linked" | "actor_conflict" | "denied";
|
|
123
|
+
unlinkActor(sessionId: string, requestingActorId: string, actorId: string): "unlinked" | "not_linked" | "owns_transaction" | "denied";
|
|
124
|
+
listActors(sessionId: string): SessionMemberRecord[];
|
|
125
|
+
resolveActor(actorId: string): SessionRecord | undefined;
|
|
110
126
|
getSession(idOrName: string): SessionRecord | undefined;
|
|
111
127
|
getSessionByName(name: string): SessionRecord | undefined;
|
|
112
128
|
listSessions(): SessionRecord[];
|
|
113
|
-
closeSession(sessionId: string):
|
|
129
|
+
closeSession(sessionId: string, actorId: string): boolean;
|
|
114
130
|
addProfile(input: {
|
|
115
131
|
name: string;
|
|
116
132
|
target?: string;
|
|
@@ -122,16 +138,17 @@ export declare class StateStore {
|
|
|
122
138
|
removeProfile(name: string): boolean;
|
|
123
139
|
addConnection(input: {
|
|
124
140
|
sessionId: string;
|
|
141
|
+
actorId: string;
|
|
125
142
|
name: string;
|
|
126
143
|
driver: Driver;
|
|
127
144
|
databaseName: string;
|
|
128
145
|
source: string;
|
|
129
146
|
secretEnv?: string;
|
|
130
147
|
readOnly: boolean;
|
|
131
|
-
}): ConnectionRecord;
|
|
148
|
+
}): ConnectionRecord | undefined;
|
|
132
149
|
getConnection(id: string): ConnectionRecord | undefined;
|
|
133
150
|
activeConnection(session: SessionRecord): ConnectionRecord | undefined;
|
|
134
|
-
disconnect(sessionId: string):
|
|
151
|
+
disconnect(sessionId: string, actorId: string): boolean;
|
|
135
152
|
bumpVersion(connectionId: string): string;
|
|
136
153
|
saveResult(input: {
|
|
137
154
|
sessionId: string;
|
|
@@ -153,6 +170,7 @@ export declare class StateStore {
|
|
|
153
170
|
setAlias(sessionId: string, name: string, resultId: string): void;
|
|
154
171
|
saveOperation(input: {
|
|
155
172
|
sessionId: string;
|
|
173
|
+
actorId: string;
|
|
156
174
|
connectionId: string;
|
|
157
175
|
fingerprint: string;
|
|
158
176
|
sql: string;
|
|
@@ -174,6 +192,7 @@ export declare class StateStore {
|
|
|
174
192
|
}): OperationRecord | undefined;
|
|
175
193
|
reserveOperation(input: {
|
|
176
194
|
sessionId: string;
|
|
195
|
+
actorId: string;
|
|
177
196
|
connectionId: string;
|
|
178
197
|
fingerprint: string;
|
|
179
198
|
sql: string;
|
|
@@ -187,24 +206,26 @@ export declare class StateStore {
|
|
|
187
206
|
}): {
|
|
188
207
|
operation?: OperationRecord;
|
|
189
208
|
previous?: OperationRecord;
|
|
209
|
+
denied?: "membership" | "transaction";
|
|
190
210
|
};
|
|
191
211
|
finishOperation(operationId: string, affectedRows: number, stateVersion: string): OperationRecord;
|
|
192
212
|
failOperation(operationId: string): void;
|
|
193
213
|
markOperationOutcomeUnknown(operationId: string): void;
|
|
194
214
|
createTransaction(input: {
|
|
195
215
|
sessionId: string;
|
|
216
|
+
actorId: string;
|
|
196
217
|
connectionId: string;
|
|
197
218
|
isolation: string;
|
|
198
|
-
|
|
199
|
-
}): TransactionRecord;
|
|
219
|
+
}): TransactionRecord | undefined;
|
|
200
220
|
getTransaction(id: string): TransactionRecord | undefined;
|
|
201
221
|
transactionOperations(transactionId: string): OperationRecord[];
|
|
202
|
-
markTransactionCommitting(transactionId: string): boolean;
|
|
203
|
-
markTransactionOutcomeUnknown(transactionId: string, sessionId: string): void;
|
|
204
|
-
finishTransaction(transactionId: string, sessionId: string,
|
|
222
|
+
markTransactionCommitting(transactionId: string, sessionId: string, actorId: string): boolean;
|
|
223
|
+
markTransactionOutcomeUnknown(transactionId: string, sessionId: string, actorId: string): void;
|
|
224
|
+
finishTransaction(transactionId: string, sessionId: string, actorId: string, state: "rolled_back" | "failed"): boolean;
|
|
205
225
|
commitTransactionMetadata(input: {
|
|
206
226
|
transactionId: string;
|
|
207
227
|
sessionId: string;
|
|
228
|
+
actorId: string;
|
|
208
229
|
connectionId: string;
|
|
209
230
|
operations: Array<{
|
|
210
231
|
id: string;
|
|
@@ -213,6 +234,7 @@ export declare class StateStore {
|
|
|
213
234
|
}): string;
|
|
214
235
|
savePlan(input: {
|
|
215
236
|
sessionId: string;
|
|
237
|
+
ownerActorId: string;
|
|
216
238
|
connectionId: string;
|
|
217
239
|
sql: string;
|
|
218
240
|
parameters: SqlParameters;
|
|
@@ -225,9 +247,21 @@ export declare class StateStore {
|
|
|
225
247
|
expiresAt: string;
|
|
226
248
|
}): PlanRecord;
|
|
227
249
|
getPlan(id: string): PlanRecord | undefined;
|
|
228
|
-
|
|
250
|
+
claimPlan(planId: string, sessionId: string, actorId: string, claimToken: string): PlanRecord | undefined;
|
|
251
|
+
releasePlanClaim(planId: string, claimToken: string): void;
|
|
252
|
+
finishPlannedOperation(input: {
|
|
253
|
+
planId: string;
|
|
254
|
+
claimToken: string;
|
|
255
|
+
operationId: string;
|
|
256
|
+
connectionId: string;
|
|
257
|
+
affectedRows: number;
|
|
258
|
+
}): {
|
|
259
|
+
operation: OperationRecord;
|
|
260
|
+
stateVersion: string;
|
|
261
|
+
};
|
|
229
262
|
addHistory(input: {
|
|
230
263
|
sessionId: string;
|
|
264
|
+
actorId: string;
|
|
231
265
|
command: string;
|
|
232
266
|
handle?: string;
|
|
233
267
|
executed: boolean;
|
|
@@ -244,4 +278,5 @@ export declare class StateStore {
|
|
|
244
278
|
private deleteExpiredData;
|
|
245
279
|
private recoverStaleCommittingTransactions;
|
|
246
280
|
private migrate;
|
|
281
|
+
private addColumn;
|
|
247
282
|
}
|