@proteinjs/db-ui 1.9.4 → 1.10.1
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 +20 -0
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/src/form/RecordForm.d.ts.map +1 -1
- package/dist/src/form/RecordForm.js +98 -19
- package/dist/src/form/RecordForm.js.map +1 -1
- package/dist/src/form/customizations/MigrationRecordFormCustomization.d.ts +5 -0
- package/dist/src/form/customizations/MigrationRecordFormCustomization.d.ts.map +1 -1
- package/dist/src/form/customizations/MigrationRecordFormCustomization.js +72 -0
- package/dist/src/form/customizations/MigrationRecordFormCustomization.js.map +1 -1
- package/dist/src/table/RecordTable.d.ts.map +1 -1
- package/dist/src/table/RecordTable.js +7 -1
- package/dist/src/table/RecordTable.js.map +1 -1
- package/dist/src/tableDisplayName.d.ts +9 -0
- package/dist/src/tableDisplayName.d.ts.map +1 -0
- package/dist/src/tableDisplayName.js +31 -0
- package/dist/src/tableDisplayName.js.map +1 -0
- package/dist/test/recordFormInteractions.test.d.ts +5 -0
- package/dist/test/recordFormInteractions.test.d.ts.map +1 -0
- package/dist/test/recordFormInteractions.test.js +370 -0
- package/dist/test/recordFormInteractions.test.js.map +1 -0
- package/dist/test/recordTableDelete.test.d.ts +5 -0
- package/dist/test/recordTableDelete.test.d.ts.map +1 -0
- package/dist/test/recordTableDelete.test.js +254 -0
- package/dist/test/recordTableDelete.test.js.map +1 -0
- package/dist/test/tableDisplayName.test.d.ts +2 -0
- package/dist/test/tableDisplayName.test.d.ts.map +1 -0
- package/dist/test/tableDisplayName.test.js +50 -0
- package/dist/test/tableDisplayName.test.js.map +1 -0
- package/generated/index.ts +1 -1
- package/index.ts +2 -0
- package/jest.config.js +8 -1
- package/package.json +5 -4
- package/src/form/RecordForm.tsx +109 -22
- package/src/form/customizations/MigrationRecordFormCustomization.tsx +53 -1
- package/src/table/RecordTable.tsx +9 -1
- package/src/tableDisplayName.ts +28 -0
- package/test/recordFormInteractions.test.tsx +259 -0
- package/test/recordTableDelete.test.tsx +144 -0
- package/test/tableDisplayName.test.ts +40 -0
|
@@ -0,0 +1,254 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
65
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
/**
|
|
69
|
+
* @jest-environment jsdom
|
|
70
|
+
*
|
|
71
|
+
* RecordTable functional gaps (task #53 part 2):
|
|
72
|
+
* - item 2: bulk-delete routes through the confirmation dialog — the db delete only runs after
|
|
73
|
+
* the user confirms (the immediate bulk-delete repro).
|
|
74
|
+
* - item 6: the table titles as the plural human name ('Users'), not '<Name> Table'.
|
|
75
|
+
*/
|
|
76
|
+
var react_1 = __importDefault(require("react"));
|
|
77
|
+
var client_1 = require("react-dom/client");
|
|
78
|
+
var test_utils_1 = require("react-dom/test-utils");
|
|
79
|
+
var react_router_dom_1 = require("react-router-dom");
|
|
80
|
+
var react_query_1 = require("react-query");
|
|
81
|
+
var ui_1 = require("@proteinjs/ui");
|
|
82
|
+
var db_1 = require("@proteinjs/db");
|
|
83
|
+
var RecordTable_1 = require("../src/table/RecordTable");
|
|
84
|
+
var mockDb = {
|
|
85
|
+
delete: jest.fn(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
86
|
+
return [2 /*return*/, 1];
|
|
87
|
+
}); }); }),
|
|
88
|
+
};
|
|
89
|
+
jest.mock('@proteinjs/db', function () { return (__assign(__assign({}, jest.requireActual('@proteinjs/db')), { getDb: function () { return mockDb; } })); });
|
|
90
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
91
|
+
// jsdom has no IntersectionObserver (the table's infinite-scroll sentinel); a quiet stub is
|
|
92
|
+
// enough — these tests never page.
|
|
93
|
+
var StubIntersectionObserver = /** @class */ (function () {
|
|
94
|
+
function StubIntersectionObserver() {
|
|
95
|
+
}
|
|
96
|
+
StubIntersectionObserver.prototype.observe = function () { };
|
|
97
|
+
StubIntersectionObserver.prototype.unobserve = function () { };
|
|
98
|
+
StubIntersectionObserver.prototype.disconnect = function () { };
|
|
99
|
+
return StubIntersectionObserver;
|
|
100
|
+
}());
|
|
101
|
+
globalThis.IntersectionObserver = StubIntersectionObserver;
|
|
102
|
+
var UserTable = /** @class */ (function (_super) {
|
|
103
|
+
__extends(UserTable, _super);
|
|
104
|
+
function UserTable() {
|
|
105
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
106
|
+
_this.name = 'user';
|
|
107
|
+
_this.columns = (0, db_1.withRecordColumns)({
|
|
108
|
+
email: new db_1.StringColumn('email'),
|
|
109
|
+
});
|
|
110
|
+
return _this;
|
|
111
|
+
}
|
|
112
|
+
return UserTable;
|
|
113
|
+
}(db_1.Table));
|
|
114
|
+
var rows = [{ id: 'u-1', email: 'a@n3xa.io' }, { id: 'u-2', email: 'b@n3xa.io' }];
|
|
115
|
+
describe('RecordTable', function () {
|
|
116
|
+
var container;
|
|
117
|
+
var root;
|
|
118
|
+
beforeEach(function () {
|
|
119
|
+
jest.clearAllMocks();
|
|
120
|
+
container = document.createElement('div');
|
|
121
|
+
document.body.appendChild(container);
|
|
122
|
+
root = (0, client_1.createRoot)(container);
|
|
123
|
+
});
|
|
124
|
+
afterEach(function () {
|
|
125
|
+
(0, test_utils_1.act)(function () {
|
|
126
|
+
root.unmount();
|
|
127
|
+
});
|
|
128
|
+
container.remove();
|
|
129
|
+
});
|
|
130
|
+
var mount = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
131
|
+
var client, i;
|
|
132
|
+
var _a;
|
|
133
|
+
return __generator(this, function (_b) {
|
|
134
|
+
switch (_b.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
client = new react_query_1.QueryClient({ defaultOptions: { queries: { retry: false, cacheTime: 0 } } });
|
|
137
|
+
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
root.render(react_1.default.createElement(react_query_1.QueryClientProvider, { client: client },
|
|
140
|
+
react_1.default.createElement(react_router_dom_1.MemoryRouter, null,
|
|
141
|
+
react_1.default.createElement(RecordTable_1.RecordTable, { table: new UserTable(), tableLoader: new ui_1.StaticTableLoader(rows, undefined), columns: ['email'] }))));
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
});
|
|
144
|
+
}); })];
|
|
145
|
+
case 1:
|
|
146
|
+
_b.sent();
|
|
147
|
+
i = 0;
|
|
148
|
+
_b.label = 2;
|
|
149
|
+
case 2:
|
|
150
|
+
if (!(i < 5 && !((_a = document.body.textContent) === null || _a === void 0 ? void 0 : _a.includes('a@n3xa.io')))) return [3 /*break*/, 5];
|
|
151
|
+
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0: return [4 /*yield*/, Promise.resolve()];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); })];
|
|
161
|
+
case 3:
|
|
162
|
+
_b.sent();
|
|
163
|
+
_b.label = 4;
|
|
164
|
+
case 4:
|
|
165
|
+
i++;
|
|
166
|
+
return [3 /*break*/, 2];
|
|
167
|
+
case 5:
|
|
168
|
+
expect(document.body.textContent).toContain('a@n3xa.io');
|
|
169
|
+
return [2 /*return*/];
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}); };
|
|
173
|
+
var click = function (element) { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
switch (_a.label) {
|
|
176
|
+
case 0: return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
179
|
+
return [2 /*return*/];
|
|
180
|
+
});
|
|
181
|
+
}); })];
|
|
182
|
+
case 1:
|
|
183
|
+
_a.sent();
|
|
184
|
+
return [2 /*return*/];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
}); };
|
|
188
|
+
var dialog = function () { return document.querySelector('[role="dialog"]'); };
|
|
189
|
+
it('titles as the plural human name, not "<Name> Table" (item 6)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
switch (_a.label) {
|
|
192
|
+
case 0: return [4 /*yield*/, mount()];
|
|
193
|
+
case 1:
|
|
194
|
+
_a.sent();
|
|
195
|
+
expect(document.body.textContent).toContain('Users');
|
|
196
|
+
expect(document.body.textContent).not.toContain('User Table');
|
|
197
|
+
return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); });
|
|
201
|
+
it('bulk-delete acts only after the dialog confirms (the immediate bulk-delete repro, item 2)', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
202
|
+
var rowCheckbox, deleteButton, confirm;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0: return [4 /*yield*/, mount()];
|
|
206
|
+
case 1:
|
|
207
|
+
_a.sent();
|
|
208
|
+
rowCheckbox = document.querySelector('input[aria-label="Select row"]');
|
|
209
|
+
return [4 /*yield*/, click(rowCheckbox)];
|
|
210
|
+
case 2:
|
|
211
|
+
_a.sent();
|
|
212
|
+
deleteButton = document.querySelector('button[aria-label="Delete selected rows"]');
|
|
213
|
+
expect(deleteButton).not.toBeNull();
|
|
214
|
+
return [4 /*yield*/, click(deleteButton)];
|
|
215
|
+
case 3:
|
|
216
|
+
_a.sent();
|
|
217
|
+
expect(mockDb.delete).not.toHaveBeenCalled();
|
|
218
|
+
expect(dialog()).not.toBeNull();
|
|
219
|
+
expect(dialog().textContent).toContain('Delete 1 row?');
|
|
220
|
+
expect(dialog().textContent).toContain('Users');
|
|
221
|
+
confirm = Array.from(dialog().querySelectorAll('button')).find(function (b) { return b.textContent === 'Delete'; });
|
|
222
|
+
return [4 /*yield*/, click(confirm)];
|
|
223
|
+
case 4:
|
|
224
|
+
_a.sent();
|
|
225
|
+
expect(mockDb.delete).toHaveBeenCalledTimes(1);
|
|
226
|
+
return [2 /*return*/];
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}); });
|
|
230
|
+
it('cancel leaves the rows alone', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
231
|
+
var cancel;
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
switch (_a.label) {
|
|
234
|
+
case 0: return [4 /*yield*/, mount()];
|
|
235
|
+
case 1:
|
|
236
|
+
_a.sent();
|
|
237
|
+
return [4 /*yield*/, click(document.querySelector('input[aria-label="Select row"]'))];
|
|
238
|
+
case 2:
|
|
239
|
+
_a.sent();
|
|
240
|
+
return [4 /*yield*/, click(document.querySelector('button[aria-label="Delete selected rows"]'))];
|
|
241
|
+
case 3:
|
|
242
|
+
_a.sent();
|
|
243
|
+
cancel = Array.from(dialog().querySelectorAll('button')).find(function (b) { return b.textContent === 'Cancel'; });
|
|
244
|
+
return [4 /*yield*/, click(cancel)];
|
|
245
|
+
case 4:
|
|
246
|
+
_a.sent();
|
|
247
|
+
expect(mockDb.delete).not.toHaveBeenCalled();
|
|
248
|
+
expect(dialog()).toBeNull();
|
|
249
|
+
return [2 /*return*/];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}); });
|
|
253
|
+
});
|
|
254
|
+
//# sourceMappingURL=recordTableDelete.test.js.map
|
|
@@ -0,0 +1 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,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,WAAW,KAAK,QAAQ,EAA1B,CAA0B,CAAE,CAAC;oBACzG,qBAAM,KAAK,CAAC,MAAM,CAAC,EAAA;;oBAAnB,SAAmB,CAAC;oBAEpB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;oBAC7C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;;;;SAC7B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableDisplayName.test.d.ts","sourceRoot":"","sources":["../../test/tableDisplayName.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
var db_1 = require("@proteinjs/db");
|
|
19
|
+
var tableDisplayName_1 = require("../src/tableDisplayName");
|
|
20
|
+
function stubTable(name) {
|
|
21
|
+
return new (/** @class */ (function (_super) {
|
|
22
|
+
__extends(class_1, _super);
|
|
23
|
+
function class_1() {
|
|
24
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
+
_this.name = name;
|
|
26
|
+
_this.columns = (0, db_1.withRecordColumns)({ title: new db_1.StringColumn('title') });
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
return class_1;
|
|
30
|
+
}(db_1.Table)))();
|
|
31
|
+
}
|
|
32
|
+
describe('tableDisplayName', function () {
|
|
33
|
+
it('pluralizes single-word table names', function () {
|
|
34
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('user'))).toBe('Users');
|
|
35
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('session'))).toBe('Sessions');
|
|
36
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('migration'))).toBe('Migrations');
|
|
37
|
+
});
|
|
38
|
+
it('humanizes snake_case and pluralizes only the last word', function () {
|
|
39
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('access_grant'))).toBe('Access grants');
|
|
40
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('cached_thought'))).toBe('Cached thoughts');
|
|
41
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('usage_event'))).toBe('Usage events');
|
|
42
|
+
});
|
|
43
|
+
it('applies es/ies rules', function () {
|
|
44
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('mailbox'))).toBe('Mailboxes');
|
|
45
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('address'))).toBe('Addresses');
|
|
46
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('category'))).toBe('Categories');
|
|
47
|
+
expect((0, tableDisplayName_1.tableDisplayName)(stubTable('day'))).toBe('Days');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=tableDisplayName.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableDisplayName.test.js","sourceRoot":"","sources":["../../test/tableDisplayName.test.ts"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AAM,CAAC,IAAA,mCAAgB,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,CAAC,IAAA,mCAAgB,EAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjE,MAAM,CAAC,IAAA,mCAAgB,EAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnE,MAAM,CAAC,IAAA,mCAAgB,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/generated/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ import 'uuid';
|
|
|
16
16
|
/** Generate Source Graph */
|
|
17
17
|
|
|
18
18
|
const sourceGraph =
|
|
19
|
-
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-ui/QueryCursorLoader","value":{"packageName":"@proteinjs/db-ui","name":"QueryCursorLoader","filePath":"/home/runner/work/db/db/packages/ui/src/table/QueryCursorLoader.ts","qualifiedName":"@proteinjs/db-ui/QueryCursorLoader","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"reactQueryKeys","type":{"packageName":"@proteinjs/ui","name":"ReactQueryKeys","filePath":null,"qualifiedName":"@proteinjs/ui/ReactQueryKeys","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"pager","type":{"packageName":"","name":"CursorWindowPager<T>","filePath":null,"qualifiedName":"/CursorWindowPager<T>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"loadWindow","returnType":{"packageName":"","name":"Promise<CursorWindow<T>>","filePath":null,"qualifiedName":"/Promise<CursorWindow<T>>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"cursor","type":{"packageName":"","name":"CursorValue | null","filePath":null,"qualifiedName":"/CursorValue | null","typeParameters":null,"directParents":null}},{"name":"windowSize","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}}]}],"typeParameters":["/T extends Record"],"directParentInterfaces":[{"packageName":"@proteinjs/ui","name":"CursorLoader","filePath":null,"qualifiedName":"@proteinjs/ui/CursorLoader","properties":[],"methods":[],"typeParameters":["/T"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/ui/CursorLoader"},{"v":"@proteinjs/db-ui/QueryTableLoader","value":{"packageName":"@proteinjs/db-ui","name":"QueryTableLoader","filePath":"/home/runner/work/db/db/packages/ui/src/table/QueryTableLoader.ts","qualifiedName":"@proteinjs/db-ui/QueryTableLoader","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"rowCountQb","type":{"packageName":"","name":"QueryBuilder<T>","filePath":null,"qualifiedName":"/QueryBuilder<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"paginationQb","type":{"packageName":"","name":"QueryBuilder<T>","filePath":null,"qualifiedName":"/QueryBuilder<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"reactQueryKeys","type":{"packageName":"","name":"TableLoader<T>[\'reactQueryKeys\']","filePath":null,"qualifiedName":"/TableLoader<T>[\'reactQueryKeys\']","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"table","type":{"packageName":"","name":"Table<T>","filePath":null,"qualifiedName":"/Table<T>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"query","type":{"packageName":"","name":"Query<T>","filePath":null,"qualifiedName":"/Query<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"sort","type":{"packageName":"","name":"SortCriteria<T>[]","filePath":null,"qualifiedName":"/SortCriteria<T>[]","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"queryOptions","type":{"packageName":"","name":"QueryOptions<T>","filePath":null,"qualifiedName":"/QueryOptions<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"load","returnType":{"packageName":"","name":"Promise<RowWindow<T>>","filePath":null,"qualifiedName":"/Promise<RowWindow<T>>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"startIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"endIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"skipRowCount","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]}],"typeParameters":["/T extends Record"],"directParentInterfaces":[{"packageName":"@proteinjs/ui","name":"TableLoader","filePath":null,"qualifiedName":"@proteinjs/ui/TableLoader","properties":[],"methods":[],"typeParameters":["/T"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/ui/TableLoader"},{"v":"@proteinjs/db-ui/RecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/RecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"record","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]},{"name":"getFieldLayout","returnType":{"packageName":"","name":"string[] | string[][]","filePath":null,"qualifiedName":"/string[] | string[][]","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"record","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}},{"name":"defaultFieldLayout","type":{"packageName":"","name":"string[] | string[][]","filePath":null,"qualifiedName":"/string[] | string[][]","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/reflection","name":"Loadable","filePath":null,"qualifiedName":"@proteinjs/reflection/Loadable","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/reflection/Loadable"},{"v":"@proteinjs/db-ui/hashGeneratorPage","value":{"packageName":"@proteinjs/db-ui","name":"hashGeneratorPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/HashGeneratorPage.tsx","qualifiedName":"@proteinjs/db-ui/hashGeneratorPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/ui/Page"},{"v":"@proteinjs/db-ui/recordFormPage","value":{"packageName":"@proteinjs/db-ui","name":"recordFormPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordFormPage.tsx","qualifiedName":"@proteinjs/db-ui/recordFormPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/recordTablePage","value":{"packageName":"@proteinjs/db-ui","name":"recordTablePage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordTablePage.tsx","qualifiedName":"@proteinjs/db-ui/recordTablePage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/tablesPage","value":{"packageName":"@proteinjs/db-ui","name":"tablesPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/TablesPage.tsx","qualifiedName":"@proteinjs/db-ui/tablesPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/uuidGeneratorPage","value":{"packageName":"@proteinjs/db-ui","name":"uuidGeneratorPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/UuidGeneratorPage.tsx","qualifiedName":"@proteinjs/db-ui/uuidGeneratorPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/SpecificTableProps"},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"MigrationRecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/customizations/MigrationRecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/MigrationRecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"migration","type":{"packageName":"@proteinjs/db","name":"Migration","filePath":null,"qualifiedName":"@proteinjs/db/Migration","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":null,"qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[]}],"sourceType":2}}],"edges":[{"v":"@proteinjs/db-ui/QueryCursorLoader","w":"@proteinjs/ui/CursorLoader","value":"implements interface"},{"v":"@proteinjs/db-ui/QueryTableLoader","w":"@proteinjs/ui/TableLoader","value":"implements interface"},{"v":"@proteinjs/db-ui/RecordFormCustomization","w":"@proteinjs/reflection/Loadable","value":"implements interface"},{"v":"@proteinjs/db-ui/hashGeneratorPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/recordFormPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/recordTablePage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/tablesPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/uuidGeneratorPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","w":"@proteinjs/db-ui/RecordFormCustomization","value":"extends class"}]}';
|
|
19
|
+
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-ui/QueryCursorLoader","value":{"packageName":"@proteinjs/db-ui","name":"QueryCursorLoader","filePath":"/home/runner/work/db/db/packages/ui/src/table/QueryCursorLoader.ts","qualifiedName":"@proteinjs/db-ui/QueryCursorLoader","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"reactQueryKeys","type":{"packageName":"@proteinjs/ui","name":"ReactQueryKeys","filePath":null,"qualifiedName":"@proteinjs/ui/ReactQueryKeys","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"pager","type":{"packageName":"","name":"CursorWindowPager<T>","filePath":null,"qualifiedName":"/CursorWindowPager<T>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"loadWindow","returnType":{"packageName":"","name":"Promise<CursorWindow<T>>","filePath":null,"qualifiedName":"/Promise<CursorWindow<T>>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"cursor","type":{"packageName":"","name":"CursorValue | null","filePath":null,"qualifiedName":"/CursorValue | null","typeParameters":null,"directParents":null}},{"name":"windowSize","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}}]}],"typeParameters":["/T extends Record"],"directParentInterfaces":[{"packageName":"@proteinjs/ui","name":"CursorLoader","filePath":null,"qualifiedName":"@proteinjs/ui/CursorLoader","properties":[],"methods":[],"typeParameters":["/T"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/ui/CursorLoader"},{"v":"@proteinjs/db-ui/QueryTableLoader","value":{"packageName":"@proteinjs/db-ui","name":"QueryTableLoader","filePath":"/home/runner/work/db/db/packages/ui/src/table/QueryTableLoader.ts","qualifiedName":"@proteinjs/db-ui/QueryTableLoader","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"rowCountQb","type":{"packageName":"","name":"QueryBuilder<T>","filePath":null,"qualifiedName":"/QueryBuilder<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"paginationQb","type":{"packageName":"","name":"QueryBuilder<T>","filePath":null,"qualifiedName":"/QueryBuilder<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"reactQueryKeys","type":{"packageName":"","name":"TableLoader<T>[\'reactQueryKeys\']","filePath":null,"qualifiedName":"/TableLoader<T>[\'reactQueryKeys\']","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"},{"name":"table","type":{"packageName":"","name":"Table<T>","filePath":null,"qualifiedName":"/Table<T>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"query","type":{"packageName":"","name":"Query<T>","filePath":null,"qualifiedName":"/Query<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"sort","type":{"packageName":"","name":"SortCriteria<T>[]","filePath":null,"qualifiedName":"/SortCriteria<T>[]","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"queryOptions","type":{"packageName":"","name":"QueryOptions<T>","filePath":null,"qualifiedName":"/QueryOptions<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"load","returnType":{"packageName":"","name":"Promise<RowWindow<T>>","filePath":null,"qualifiedName":"/Promise<RowWindow<T>>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"startIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"endIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"skipRowCount","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}}]}],"typeParameters":["/T extends Record"],"directParentInterfaces":[{"packageName":"@proteinjs/ui","name":"TableLoader","filePath":null,"qualifiedName":"@proteinjs/ui/TableLoader","properties":[],"methods":[],"typeParameters":["/T"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/ui/TableLoader"},{"v":"@proteinjs/db-ui/RecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/RecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"record","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]},{"name":"getFieldLayout","returnType":{"packageName":"","name":"string[] | string[][]","filePath":null,"qualifiedName":"/string[] | string[][]","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"record","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}},{"name":"defaultFieldLayout","type":{"packageName":"","name":"string[] | string[][]","filePath":null,"qualifiedName":"/string[] | string[][]","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/reflection","name":"Loadable","filePath":null,"qualifiedName":"@proteinjs/reflection/Loadable","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/reflection/Loadable"},{"v":"@proteinjs/db-ui/hashGeneratorPage","value":{"packageName":"@proteinjs/db-ui","name":"hashGeneratorPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/HashGeneratorPage.tsx","qualifiedName":"@proteinjs/db-ui/hashGeneratorPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/ui/Page"},{"v":"@proteinjs/db-ui/recordFormPage","value":{"packageName":"@proteinjs/db-ui","name":"recordFormPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordFormPage.tsx","qualifiedName":"@proteinjs/db-ui/recordFormPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/recordTablePage","value":{"packageName":"@proteinjs/db-ui","name":"recordTablePage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordTablePage.tsx","qualifiedName":"@proteinjs/db-ui/recordTablePage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/tablesPage","value":{"packageName":"@proteinjs/db-ui","name":"tablesPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/TablesPage.tsx","qualifiedName":"@proteinjs/db-ui/tablesPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/uuidGeneratorPage","value":{"packageName":"@proteinjs/db-ui","name":"uuidGeneratorPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/UuidGeneratorPage.tsx","qualifiedName":"@proteinjs/db-ui/uuidGeneratorPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/SpecificTableProps"},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"MigrationRecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/customizations/MigrationRecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/MigrationRecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"migration","type":{"packageName":"@proteinjs/db","name":"Migration","filePath":null,"qualifiedName":"@proteinjs/db/Migration","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]},{"name":"setRetired","returnType":null,"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private","parameters":[{"name":"migration","type":{"packageName":"@proteinjs/db","name":"Migration","filePath":null,"qualifiedName":"@proteinjs/db/Migration","typeParameters":null,"directParents":null}},{"name":"retired","type":{"packageName":"","name":"boolean","filePath":null,"qualifiedName":"/boolean","typeParameters":null,"directParents":null}},{"name":"fields","type":{"packageName":"@proteinjs/ui","name":"Fields","filePath":null,"qualifiedName":"@proteinjs/ui/Fields","typeParameters":null,"directParents":null}},{"name":"formButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":null,"qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[]}],"sourceType":2}}],"edges":[{"v":"@proteinjs/db-ui/QueryCursorLoader","w":"@proteinjs/ui/CursorLoader","value":"implements interface"},{"v":"@proteinjs/db-ui/QueryTableLoader","w":"@proteinjs/ui/TableLoader","value":"implements interface"},{"v":"@proteinjs/db-ui/RecordFormCustomization","w":"@proteinjs/reflection/Loadable","value":"implements interface"},{"v":"@proteinjs/db-ui/hashGeneratorPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/recordFormPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/recordTablePage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/tablesPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/uuidGeneratorPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","w":"@proteinjs/db-ui/RecordFormCustomization","value":"extends class"}]}';
|
|
20
20
|
|
|
21
21
|
/** Generate Source Links */
|
|
22
22
|
|
package/index.ts
CHANGED
package/jest.config.js
CHANGED
|
@@ -8,10 +8,17 @@ module.exports = {
|
|
|
8
8
|
testEnvironment: 'node',
|
|
9
9
|
moduleNameMapper: {
|
|
10
10
|
// The symlinked @proteinjs/ui carries its own react tree. Pin the singletons to THIS
|
|
11
|
-
// package's copies so jest loads one React (hooks) — the util-ui precedent.
|
|
11
|
+
// package's copies so jest loads one React (hooks) — the util-ui precedent. react-router
|
|
12
|
+
// and react-query are pinned for the same reason: their contexts (Router, QueryClient)
|
|
13
|
+
// must be the same module instance in the test and inside @proteinjs/ui components.
|
|
12
14
|
'^react$': '<rootDir>/node_modules/react',
|
|
13
15
|
'^react/(.*)$': '<rootDir>/node_modules/react/$1',
|
|
14
16
|
'^react-dom$': '<rootDir>/node_modules/react-dom',
|
|
15
17
|
'^react-dom/(.*)$': '<rootDir>/node_modules/react-dom/$1',
|
|
18
|
+
'^react-router$': '<rootDir>/node_modules/react-router',
|
|
19
|
+
'^react-router-dom$': '<rootDir>/node_modules/react-router-dom',
|
|
20
|
+
'^react-query$': '<rootDir>/node_modules/react-query',
|
|
21
|
+
// jsdom tests resolve uuid's browser field (ESM, unparseable by jest); pin the CJS build.
|
|
22
|
+
'^uuid$': '<rootDir>/node_modules/uuid/dist/index.js',
|
|
16
23
|
},
|
|
17
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proteinjs/db-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Db ui components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@emotion/styled": "11.11.0",
|
|
27
27
|
"@mui/icons-material": "5.14.11",
|
|
28
28
|
"@mui/material": "5.14.11",
|
|
29
|
-
"@proteinjs/db": "^1.
|
|
29
|
+
"@proteinjs/db": "^1.34.0",
|
|
30
30
|
"@proteinjs/reflection": "^1.1.12",
|
|
31
|
-
"@proteinjs/ui": "^4.
|
|
31
|
+
"@proteinjs/ui": "^4.9.0",
|
|
32
32
|
"@proteinjs/util": "^1.6.1",
|
|
33
33
|
"moment": "2.29.4",
|
|
34
34
|
"react": "18.2.0",
|
|
@@ -49,10 +49,11 @@
|
|
|
49
49
|
"eslint-config-prettier": "9.1.0",
|
|
50
50
|
"eslint-plugin-prettier": "5.1.3",
|
|
51
51
|
"jest": "29.7.0",
|
|
52
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
52
53
|
"ts-jest": "29.1.1",
|
|
53
54
|
"typescript": "5.2.2"
|
|
54
55
|
},
|
|
55
56
|
"main": "./dist/generated/index.js",
|
|
56
57
|
"types": "./dist/generated/index.d.ts",
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "7a301275151aee8040fd52e15e3fe950a6863783"
|
|
58
59
|
}
|