@proteinjs/db-driver-spanner 1.12.3 → 1.14.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/test/index.d.ts.map +1 -1
- package/dist/generated/test/index.js +3 -1
- package/dist/generated/test/index.js.map +1 -1
- package/dist/src/SpannerConfig.d.ts +22 -0
- package/dist/src/SpannerConfig.d.ts.map +1 -1
- package/dist/src/SpannerDriver.d.ts +56 -9
- package/dist/src/SpannerDriver.d.ts.map +1 -1
- package/dist/src/SpannerDriver.js +229 -35
- package/dist/src/SpannerDriver.js.map +1 -1
- package/dist/src/SpannerLivenessMonitor.d.ts +25 -0
- package/dist/src/SpannerLivenessMonitor.d.ts.map +1 -1
- package/dist/src/SpannerLivenessMonitor.js +59 -4
- package/dist/src/SpannerLivenessMonitor.js.map +1 -1
- package/dist/test/ServiceUpdateVerbs.test.d.ts +2 -0
- package/dist/test/ServiceUpdateVerbs.test.d.ts.map +1 -0
- package/dist/test/ServiceUpdateVerbs.test.js +325 -0
- package/dist/test/ServiceUpdateVerbs.test.js.map +1 -0
- package/dist/test/SessionPoolExhaustion.test.d.ts +2 -0
- package/dist/test/SessionPoolExhaustion.test.d.ts.map +1 -0
- package/dist/test/SessionPoolExhaustion.test.js +230 -0
- package/dist/test/SessionPoolExhaustion.test.js.map +1 -0
- package/dist/test/SessionRecordTableQuery.test.d.ts +2 -0
- package/dist/test/SessionRecordTableQuery.test.d.ts.map +1 -0
- package/dist/test/SessionRecordTableQuery.test.js +185 -0
- package/dist/test/SessionRecordTableQuery.test.js.map +1 -0
- package/dist/test/SpannerLivenessMonitor.test.js +65 -0
- package/dist/test/SpannerLivenessMonitor.test.js.map +1 -1
- package/dist/test/SpannerOperationDeadline.test.d.ts +2 -0
- package/dist/test/SpannerOperationDeadline.test.d.ts.map +1 -0
- package/dist/test/SpannerOperationDeadline.test.js +227 -0
- package/dist/test/SpannerOperationDeadline.test.js.map +1 -0
- package/dist/test/TransactionSafety.test.d.ts +2 -0
- package/dist/test/TransactionSafety.test.d.ts.map +1 -0
- package/dist/test/TransactionSafety.test.js +325 -0
- package/dist/test/TransactionSafety.test.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/util/serviceUpdateVerbsTestTables.d.ts +45 -0
- package/dist/test/util/serviceUpdateVerbsTestTables.d.ts.map +1 -0
- package/dist/test/util/serviceUpdateVerbsTestTables.js +100 -0
- package/dist/test/util/serviceUpdateVerbsTestTables.js.map +1 -0
- package/generated/index.ts +6 -9
- package/generated/test/index.ts +9 -10
- package/package.json +7 -6
- package/src/SpannerConfig.ts +22 -0
- package/src/SpannerDriver.ts +215 -28
- package/src/SpannerLivenessMonitor.ts +73 -5
- package/test/ServiceUpdateVerbs.test.ts +188 -0
- package/test/SessionPoolExhaustion.test.ts +127 -0
- package/test/SessionRecordTableQuery.test.ts +118 -0
- package/test/SpannerLivenessMonitor.test.ts +70 -0
- package/test/SpannerOperationDeadline.test.ts +156 -0
- package/test/TransactionSafety.test.ts +157 -0
- package/test/index.ts +1 -0
- package/test/util/serviceUpdateVerbsTestTables.ts +55 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var db_1 = require("@proteinjs/db");
|
|
55
|
+
var db_transaction_context_1 = require("@proteinjs/db-transaction-context");
|
|
56
|
+
var db_driver_spanner_1 = require("@proteinjs/db-driver-spanner");
|
|
57
|
+
var getDropTestTable_1 = require("./util/getDropTestTable");
|
|
58
|
+
var SpannerEmulatorProvisioner_1 = require("./util/SpannerEmulatorProvisioner");
|
|
59
|
+
require("../generated/test/index");
|
|
60
|
+
var SafetyEmployeeTestTable = /** @class */ (function (_super) {
|
|
61
|
+
__extends(SafetyEmployeeTestTable, _super);
|
|
62
|
+
function SafetyEmployeeTestTable() {
|
|
63
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
64
|
+
_this.name = 'db_test_txn_safety_employee';
|
|
65
|
+
_this.columns = (0, db_1.withRecordColumns)({
|
|
66
|
+
name: new db_1.StringColumn('name'),
|
|
67
|
+
department: new db_1.StringColumn('department'),
|
|
68
|
+
});
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
return SafetyEmployeeTestTable;
|
|
72
|
+
}(db_1.Table));
|
|
73
|
+
var employeeTable = new SafetyEmployeeTestTable();
|
|
74
|
+
// Local table — not in any reflection source graph, so thread getTable explicitly.
|
|
75
|
+
var getTable = function () { return employeeTable; };
|
|
76
|
+
var spannerConfig = {
|
|
77
|
+
projectId: 'proteinjs-test',
|
|
78
|
+
instanceName: 'proteinjs-test',
|
|
79
|
+
databaseName: 'test',
|
|
80
|
+
};
|
|
81
|
+
var spannerDriver = new db_driver_spanner_1.SpannerDriver(spannerConfig, getTable);
|
|
82
|
+
/**
|
|
83
|
+
* The STATELESS transaction contract (plans/DB_PERF_PLAN.md P2, superseding the
|
|
84
|
+
* construction-time-binding guard): Db instances carry no transaction state — every operation
|
|
85
|
+
* resolves the ambient transaction (AsyncLocalStorage) at call time. Inside a transaction body
|
|
86
|
+
* every Db rides the transaction, whenever it was constructed; outside, every Db uses the
|
|
87
|
+
* pool. The one escape shape — work spawned inside a body that outlives the transaction while
|
|
88
|
+
* holding its context — fails loudly by name (the ended-context tombstone).
|
|
89
|
+
*/
|
|
90
|
+
describe('Transaction safety (stateless contract)', function () {
|
|
91
|
+
var dropTable = (0, getDropTestTable_1.getDropTestTable)(spannerDriver);
|
|
92
|
+
// Constructed at describe scope, BEFORE any transaction — under the old construction-time
|
|
93
|
+
// binding this instance was the "stale Db" hazard; now it must simply ride whatever ambient
|
|
94
|
+
// transaction is active at call time.
|
|
95
|
+
var preconstructedDb = new db_1.Db(spannerDriver, getTable, new db_transaction_context_1.TransactionContext());
|
|
96
|
+
var txnDb = new db_1.Db(spannerDriver, getTable, new db_transaction_context_1.TransactionContext());
|
|
97
|
+
beforeAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0: return [4 /*yield*/, SpannerEmulatorProvisioner_1.SpannerEmulatorProvisioner.ensureProvisioned(spannerConfig)];
|
|
101
|
+
case 1:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [4 /*yield*/, spannerDriver.createDbIfNotExists()];
|
|
104
|
+
case 2:
|
|
105
|
+
_a.sent();
|
|
106
|
+
return [4 /*yield*/, spannerDriver.getTableManager().loadTable(employeeTable)];
|
|
107
|
+
case 3:
|
|
108
|
+
_a.sent();
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); }, 60000);
|
|
113
|
+
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0: return [4 /*yield*/, dropTable(employeeTable)];
|
|
117
|
+
case 1:
|
|
118
|
+
_a.sent();
|
|
119
|
+
return [4 /*yield*/, SpannerEmulatorProvisioner_1.SpannerEmulatorProvisioner.release()];
|
|
120
|
+
case 2:
|
|
121
|
+
_a.sent();
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); }, 60000);
|
|
126
|
+
test('a PRE-CONSTRUCTED Db rides the ambient transaction: its reads see the txn write, and the txn commits', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
127
|
+
var employee, inserted, committed;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
employee = {
|
|
132
|
+
name: 'TxnSafetyRides',
|
|
133
|
+
department: 'Engineering',
|
|
134
|
+
};
|
|
135
|
+
return [4 /*yield*/, txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
136
|
+
var emp, seenInside;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0: return [4 /*yield*/, txnDb.insert(employeeTable, employee)];
|
|
140
|
+
case 1:
|
|
141
|
+
emp = _a.sent();
|
|
142
|
+
return [4 /*yield*/, preconstructedDb.query(employeeTable, { id: emp.id })];
|
|
143
|
+
case 2:
|
|
144
|
+
seenInside = _a.sent();
|
|
145
|
+
expect(seenInside.length).toBe(1);
|
|
146
|
+
return [2 /*return*/, emp];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}); })];
|
|
150
|
+
case 1:
|
|
151
|
+
inserted = _a.sent();
|
|
152
|
+
return [4 /*yield*/, preconstructedDb.query(employeeTable, { id: inserted.id })];
|
|
153
|
+
case 2:
|
|
154
|
+
committed = _a.sent();
|
|
155
|
+
expect(committed.length).toBe(1);
|
|
156
|
+
return [4 /*yield*/, txnDb.delete(employeeTable, { id: inserted.id })];
|
|
157
|
+
case 3:
|
|
158
|
+
_a.sent();
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); }, 30000);
|
|
163
|
+
test('a Db constructed INSIDE a transaction, used after commit, cleanly uses the pool and sees committed state', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var escapedDb, inserted, seen;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0: return [4 /*yield*/, txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
escapedDb = new db_1.Db(spannerDriver, getTable, new db_transaction_context_1.TransactionContext());
|
|
172
|
+
return [4 /*yield*/, escapedDb.insert(employeeTable, { name: 'TxnSafetyAfterCommit' })];
|
|
173
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}); })];
|
|
177
|
+
case 1:
|
|
178
|
+
inserted = _a.sent();
|
|
179
|
+
return [4 /*yield*/, escapedDb.query(employeeTable, { id: inserted.id })];
|
|
180
|
+
case 2:
|
|
181
|
+
seen = _a.sent();
|
|
182
|
+
expect(seen.length).toBe(1);
|
|
183
|
+
return [4 /*yield*/, escapedDb.delete(employeeTable, { id: inserted.id })];
|
|
184
|
+
case 3:
|
|
185
|
+
_a.sent();
|
|
186
|
+
return [2 /*return*/];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}); }, 30000);
|
|
190
|
+
test('atomicity through ANY instance: a rollback takes the pre-constructed Db write with it', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
191
|
+
var after;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0: return [4 /*yield*/, expect(txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
// If this insert did NOT ride the transaction it would self-commit in its own
|
|
199
|
+
// transaction and survive the rollback below — the exact decay a severed ambient
|
|
200
|
+
// resolution produces (a commit-path assertion can't see it; this one can).
|
|
201
|
+
return [4 /*yield*/, preconstructedDb.insert(employeeTable, { name: 'TxnSafetyAtomic' })];
|
|
202
|
+
case 1:
|
|
203
|
+
// If this insert did NOT ride the transaction it would self-commit in its own
|
|
204
|
+
// transaction and survive the rollback below — the exact decay a severed ambient
|
|
205
|
+
// resolution produces (a commit-path assertion can't see it; this one can).
|
|
206
|
+
_a.sent();
|
|
207
|
+
throw new Error('force-rollback');
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); })).rejects.toThrow('force-rollback')];
|
|
211
|
+
case 1:
|
|
212
|
+
_a.sent();
|
|
213
|
+
return [4 /*yield*/, preconstructedDb.query(employeeTable, { name: 'TxnSafetyAtomic' })];
|
|
214
|
+
case 2:
|
|
215
|
+
after = _a.sent();
|
|
216
|
+
expect(after.length).toBe(0);
|
|
217
|
+
return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}); }, 30000);
|
|
221
|
+
test('nested transactions throw, from ANY instance', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
|
+
return __generator(this, function (_a) {
|
|
223
|
+
switch (_a.label) {
|
|
224
|
+
case 0: return [4 /*yield*/, expect(txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
switch (_a.label) {
|
|
227
|
+
case 0: return [4 /*yield*/, preconstructedDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
228
|
+
return [2 /*return*/, 'never-runs'];
|
|
229
|
+
}); }); })];
|
|
230
|
+
case 1:
|
|
231
|
+
_a.sent();
|
|
232
|
+
return [2 /*return*/];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}); })).rejects.toThrow(/already running in this context/)];
|
|
236
|
+
case 1:
|
|
237
|
+
_a.sent();
|
|
238
|
+
return [2 /*return*/];
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}); }, 30000);
|
|
242
|
+
test('two concurrent transactions on ONE shared instance commit independently', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
243
|
+
var _a, a, b, seen;
|
|
244
|
+
return __generator(this, function (_b) {
|
|
245
|
+
switch (_b.label) {
|
|
246
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
247
|
+
txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
248
|
+
switch (_a.label) {
|
|
249
|
+
case 0: return [4 /*yield*/, txnDb.insert(employeeTable, { name: 'TxnSafetyConcurrentA' })];
|
|
250
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
251
|
+
}
|
|
252
|
+
}); }); }),
|
|
253
|
+
txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
254
|
+
switch (_a.label) {
|
|
255
|
+
case 0: return [4 /*yield*/, txnDb.insert(employeeTable, { name: 'TxnSafetyConcurrentB' })];
|
|
256
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
257
|
+
}
|
|
258
|
+
}); }); }),
|
|
259
|
+
])];
|
|
260
|
+
case 1:
|
|
261
|
+
_a = _b.sent(), a = _a[0], b = _a[1];
|
|
262
|
+
return [4 /*yield*/, txnDb.query(employeeTable, new db_1.QueryBuilderFactory()
|
|
263
|
+
.createQueryBuilder(employeeTable)
|
|
264
|
+
.condition({ field: 'id', operator: 'IN', value: [a.id, b.id] }))];
|
|
265
|
+
case 2:
|
|
266
|
+
seen = _b.sent();
|
|
267
|
+
expect(seen.length).toBe(2);
|
|
268
|
+
return [4 /*yield*/, txnDb.delete(employeeTable, { id: a.id })];
|
|
269
|
+
case 3:
|
|
270
|
+
_b.sent();
|
|
271
|
+
return [4 /*yield*/, txnDb.delete(employeeTable, { id: b.id })];
|
|
272
|
+
case 4:
|
|
273
|
+
_b.sent();
|
|
274
|
+
return [2 /*return*/];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}); }, 30000);
|
|
278
|
+
test('tombstone: work that escapes a finished transaction fails loudly by name', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
279
|
+
var releaseEscape, escapeGate, escapedOp;
|
|
280
|
+
return __generator(this, function (_a) {
|
|
281
|
+
switch (_a.label) {
|
|
282
|
+
case 0:
|
|
283
|
+
escapeGate = new Promise(function (resolve) { return (releaseEscape = resolve); });
|
|
284
|
+
return [4 /*yield*/, txnDb.runTransaction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
285
|
+
return __generator(this, function (_a) {
|
|
286
|
+
// Spawned inside the body, NOT awaited by it — it captures the transaction's async
|
|
287
|
+
// context and outlives the transaction.
|
|
288
|
+
escapedOp = (function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
289
|
+
return __generator(this, function (_a) {
|
|
290
|
+
switch (_a.label) {
|
|
291
|
+
case 0: return [4 /*yield*/, escapeGate];
|
|
292
|
+
case 1:
|
|
293
|
+
_a.sent();
|
|
294
|
+
return [4 /*yield*/, txnDb.query(employeeTable, { name: 'TxnSafetyEscapee' })];
|
|
295
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}); })();
|
|
299
|
+
return [2 /*return*/];
|
|
300
|
+
});
|
|
301
|
+
}); })];
|
|
302
|
+
case 1:
|
|
303
|
+
_a.sent();
|
|
304
|
+
releaseEscape();
|
|
305
|
+
return [4 /*yield*/, expect(escapedOp).rejects.toThrow(/transaction that already ended/)];
|
|
306
|
+
case 2:
|
|
307
|
+
_a.sent();
|
|
308
|
+
return [2 /*return*/];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}); }, 30000);
|
|
312
|
+
test('queries outside any transaction are plain pool reads', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
313
|
+
var seen;
|
|
314
|
+
return __generator(this, function (_a) {
|
|
315
|
+
switch (_a.label) {
|
|
316
|
+
case 0: return [4 /*yield*/, preconstructedDb.query(employeeTable, { name: 'TxnSafetyNoTxn' })];
|
|
317
|
+
case 1:
|
|
318
|
+
seen = _a.sent();
|
|
319
|
+
expect(seen.length).toBe(0);
|
|
320
|
+
return [2 /*return*/];
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}); }, 30000);
|
|
324
|
+
});
|
|
325
|
+
//# sourceMappingURL=TransactionSafety.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionSafety.test.js","sourceRoot":"","sources":["../../test/TransactionSafety.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAwG;AACxG,4EAAuE;AACvE,kEAA6D;AAC7D,4DAA2D;AAC3D,gFAA+E;AAC/E,mCAAiC;AAOjC;IAAsC,2CAAqB;IAA3D;QAAA,qEAMC;QALC,UAAI,GAAG,6BAA6B,CAAC;QACrC,aAAO,GAAG,IAAA,sBAAiB,EAAiB;YAC1C,IAAI,EAAE,IAAI,iBAAY,CAA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d.ts
CHANGED
package/dist/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../test/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../test/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC"}
|
package/dist/test/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./util/getDropTestTable"), exports);
|
|
18
18
|
__exportStar(require("./util/SpannerEmulatorProvisioner"), exports);
|
|
19
|
+
__exportStar(require("./util/serviceUpdateVerbsTestTables"), exports);
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../test/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oEAAkD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../test/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,oEAAkD;AAClD,sEAAoD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Record, ReferenceArray, Table } from '@proteinjs/db';
|
|
2
|
+
/**
|
|
3
|
+
* Tables for `ServiceUpdateVerbs.test.ts` (the service-path RMW update verbs:
|
|
4
|
+
* `updateArrayMembership` / `updatePreserving`).
|
|
5
|
+
*
|
|
6
|
+
* Defined here rather than in the test file so the reflection build registers them as `Table`
|
|
7
|
+
* loadables — `tableByName` (which the db-service singleton and the `Table` wire serializer both
|
|
8
|
+
* resolve through) must be able to find them for the test's RPC-boundary simulation.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Mutable stand-in for the ambient caller identity a scoped column reads (in production, the
|
|
12
|
+
* session's user id). Tests reassign `current` to act as different callers.
|
|
13
|
+
*/
|
|
14
|
+
export declare const serviceVerbsScopeContext: {
|
|
15
|
+
current: string;
|
|
16
|
+
};
|
|
17
|
+
export type ServiceVerbsDocBody = {
|
|
18
|
+
content?: string;
|
|
19
|
+
style?: {
|
|
20
|
+
color?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export interface ServiceVerbsDoc extends Record {
|
|
24
|
+
title: string;
|
|
25
|
+
scope?: string;
|
|
26
|
+
/** Self-referencing children list — the reference-array shape membership ops target. */
|
|
27
|
+
members?: ReferenceArray<ServiceVerbsDoc>;
|
|
28
|
+
/** Plain-JSON column with sub-path ownership split across writers (content vs style). */
|
|
29
|
+
body?: ServiceVerbsDocBody;
|
|
30
|
+
}
|
|
31
|
+
/** Mirrors the generic scoped-record mechanism: scope forced on insert, immutable, injected into every non-system query. */
|
|
32
|
+
export declare class ServiceVerbsDocTable extends Table<ServiceVerbsDoc> {
|
|
33
|
+
name: string;
|
|
34
|
+
columns: {
|
|
35
|
+
id: import("@proteinjs/db").Column<string, any>;
|
|
36
|
+
created: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
37
|
+
updated: import("@proteinjs/db").Column<import("moment").Moment, any>;
|
|
38
|
+
} & {} & {
|
|
39
|
+
title: import("@proteinjs/db").Column<string, any>;
|
|
40
|
+
scope: import("@proteinjs/db").Column<string | undefined, any>;
|
|
41
|
+
members: import("@proteinjs/db").Column<ReferenceArray<ServiceVerbsDoc> | undefined, any>;
|
|
42
|
+
body: import("@proteinjs/db").Column<ServiceVerbsDocBody | undefined, any>;
|
|
43
|
+
} & {};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=serviceUpdateVerbsTestTables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceUpdateVerbsTestTables.d.ts","sourceRoot":"","sources":["../../../test/util/serviceUpdateVerbsTestTables.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,cAAc,EAGd,KAAK,EAEN,MAAM,eAAe,CAAC;AAEvB;;;;;;;GAOG;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;CAAyB,CAAC;AAE/D,MAAM,MAAM,mBAAmB,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAEnF,MAAM,WAAW,eAAgB,SAAQ,MAAM;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,OAAO,CAAC,EAAE,cAAc,CAAC,eAAe,CAAC,CAAC;IAC1C,yFAAyF;IACzF,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,4HAA4H;AAC5H,qBAAa,oBAAqB,SAAQ,KAAK,CAAC,eAAe,CAAC;IACvD,IAAI,SAAsC;IAC1C,OAAO;;;;;;;;;WAcX;CACJ"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.ServiceVerbsDocTable = exports.serviceVerbsScopeContext = void 0;
|
|
55
|
+
var db_1 = require("@proteinjs/db");
|
|
56
|
+
/**
|
|
57
|
+
* Tables for `ServiceUpdateVerbs.test.ts` (the service-path RMW update verbs:
|
|
58
|
+
* `updateArrayMembership` / `updatePreserving`).
|
|
59
|
+
*
|
|
60
|
+
* Defined here rather than in the test file so the reflection build registers them as `Table`
|
|
61
|
+
* loadables — `tableByName` (which the db-service singleton and the `Table` wire serializer both
|
|
62
|
+
* resolve through) must be able to find them for the test's RPC-boundary simulation.
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* Mutable stand-in for the ambient caller identity a scoped column reads (in production, the
|
|
66
|
+
* session's user id). Tests reassign `current` to act as different callers.
|
|
67
|
+
*/
|
|
68
|
+
exports.serviceVerbsScopeContext = { current: 'scope-a' };
|
|
69
|
+
/** Mirrors the generic scoped-record mechanism: scope forced on insert, immutable, injected into every non-system query. */
|
|
70
|
+
var ServiceVerbsDocTable = /** @class */ (function (_super) {
|
|
71
|
+
__extends(ServiceVerbsDocTable, _super);
|
|
72
|
+
function ServiceVerbsDocTable() {
|
|
73
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
74
|
+
_this.name = 'db_test_service_update_verbs_doc';
|
|
75
|
+
_this.columns = (0, db_1.withRecordColumns)({
|
|
76
|
+
title: new db_1.StringColumn('title'),
|
|
77
|
+
scope: new db_1.StringColumn('scope', {
|
|
78
|
+
defaultValue: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
79
|
+
return [2 /*return*/, exports.serviceVerbsScopeContext.current];
|
|
80
|
+
}); }); },
|
|
81
|
+
forceDefaultValue: function (runAsSystem) { return !runAsSystem; },
|
|
82
|
+
immutable: function (runAsSystem) { return !runAsSystem; },
|
|
83
|
+
addToQuery: function (qb, runAsSystem) { return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
if (!runAsSystem) {
|
|
86
|
+
qb.condition({ field: 'scope', operator: 'IN', value: [exports.serviceVerbsScopeContext.current] });
|
|
87
|
+
}
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
});
|
|
90
|
+
}); },
|
|
91
|
+
}),
|
|
92
|
+
members: new db_1.ReferenceArrayColumn('members', 'db_test_service_update_verbs_doc', false),
|
|
93
|
+
body: new db_1.ObjectColumn('body'),
|
|
94
|
+
});
|
|
95
|
+
return _this;
|
|
96
|
+
}
|
|
97
|
+
return ServiceVerbsDocTable;
|
|
98
|
+
}(db_1.Table));
|
|
99
|
+
exports.ServiceVerbsDocTable = ServiceVerbsDocTable;
|
|
100
|
+
//# sourceMappingURL=serviceUpdateVerbsTestTables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceUpdateVerbsTestTables.js","sourceRoot":"","sources":["../../../test/util/serviceUpdateVerbsTestTables.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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