tantan-typeorm-gs 1.0.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/LICENSE +21 -0
- package/README.md +31 -0
- package/bun.lock +300 -0
- package/docs/authentication.md +118 -0
- package/docs/configuration.md +680 -0
- package/docs/contributing.md +177 -0
- package/docs/crud.md +351 -0
- package/docs/custom-client.md +165 -0
- package/docs/development.md +243 -0
- package/docs/entities.md +502 -0
- package/docs/find-options.md +296 -0
- package/docs/google-cloud.md +101 -0
- package/docs/installation.md +51 -0
- package/docs/integration-testing.md +178 -0
- package/docs/limitations.md +223 -0
- package/docs/pagination.md +384 -0
- package/docs/performance.md +171 -0
- package/docs/security.md +153 -0
- package/docs/sorting.md +0 -0
- package/docs/supported-features.md +310 -0
- package/docs/synchronization.md +203 -0
- package/package.json +43 -0
- package/src/client/index.ts +589 -0
- package/src/core/data-source.ts +47 -0
- package/src/core/driver.ts +290 -0
- package/src/core/error.ts +144 -0
- package/src/core/memory.ts +152 -0
- package/src/core/query/interpreter.ts +949 -0
- package/src/core/query/runner.ts +1297 -0
- package/src/core/query/types.ts +155 -0
- package/src/core/schema-builder.ts +64 -0
- package/src/core/types.ts +113 -0
- package/src/core/utils.ts +13 -0
- package/src/index.ts +3 -0
- package/tantan-typeorm-gs.code-workspace +8 -0
- package/test/base/0001-data-source.test.ts +252 -0
- package/test/base/0002-operator.test.ts +616 -0
- package/test/base/0003-select.test.ts +281 -0
- package/test/base/0004-aggregate.test.ts +213 -0
- package/test/base/0005-transcation.test.ts +1566 -0
- package/test/base/0006-relation.test.ts +1611 -0
- package/test/base/0007-logging.test.ts +182 -0
- package/test/base/0008-soft-delete.test.ts +649 -0
- package/test/google-sheets/0001-client.test.ts +1705 -0
- package/test/google-sheets/0002-worksheet-management.test.ts +408 -0
- package/test/google-sheets/0003-data-source.test.ts +1935 -0
- package/test/google-sheets/0004-transactions.test.ts +952 -0
- package/test/google-sheets/0005-operator.test.ts +1124 -0
- package/test/google-sheets/0006-object-criteria.test.ts +283 -0
- package/test/google-sheets/0007-performance.test.ts +532 -0
- package/test/public-api.test.ts +34 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { Memory } from '../../src/core/memory';
|
|
3
|
+
|
|
4
|
+
describe(
|
|
5
|
+
'Worksheet Management',
|
|
6
|
+
() =>
|
|
7
|
+
{
|
|
8
|
+
test(
|
|
9
|
+
'should detect existing worksheet',
|
|
10
|
+
async () =>
|
|
11
|
+
{
|
|
12
|
+
const client =
|
|
13
|
+
new Memory({
|
|
14
|
+
users: [],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(
|
|
18
|
+
await client.hasSheet('users'),
|
|
19
|
+
).toBe(true);
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
test(
|
|
24
|
+
'should return false for non-existing worksheet',
|
|
25
|
+
async () =>
|
|
26
|
+
{
|
|
27
|
+
const client =
|
|
28
|
+
new Memory();
|
|
29
|
+
|
|
30
|
+
expect(
|
|
31
|
+
await client.hasSheet('users'),
|
|
32
|
+
).toBe(false);
|
|
33
|
+
},
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
test(
|
|
37
|
+
'should create worksheet',
|
|
38
|
+
async () =>
|
|
39
|
+
{
|
|
40
|
+
const client =
|
|
41
|
+
new Memory();
|
|
42
|
+
|
|
43
|
+
expect(
|
|
44
|
+
await client.hasSheet('users'),
|
|
45
|
+
).toBe(false);
|
|
46
|
+
|
|
47
|
+
await client.createSheet('users');
|
|
48
|
+
|
|
49
|
+
expect(
|
|
50
|
+
await client.hasSheet('users'),
|
|
51
|
+
).toBe(true);
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
test(
|
|
56
|
+
'should not duplicate existing worksheet',
|
|
57
|
+
async () =>
|
|
58
|
+
{
|
|
59
|
+
const client =
|
|
60
|
+
new Memory({
|
|
61
|
+
users: [],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
await client.createSheet('users');
|
|
65
|
+
|
|
66
|
+
expect(
|
|
67
|
+
await client.hasSheet('users'),
|
|
68
|
+
).toBe(true);
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
test(
|
|
73
|
+
'should create worksheet with empty headers',
|
|
74
|
+
async () =>
|
|
75
|
+
{
|
|
76
|
+
const client =
|
|
77
|
+
new Memory();
|
|
78
|
+
|
|
79
|
+
await client.createSheet('users');
|
|
80
|
+
|
|
81
|
+
expect(
|
|
82
|
+
await client.getHeaders('users'),
|
|
83
|
+
).toEqual([]);
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
test(
|
|
88
|
+
'should create worksheet with empty rows',
|
|
89
|
+
async () =>
|
|
90
|
+
{
|
|
91
|
+
const client =
|
|
92
|
+
new Memory();
|
|
93
|
+
|
|
94
|
+
await client.createSheet('users');
|
|
95
|
+
|
|
96
|
+
expect(
|
|
97
|
+
await client.getRows('users'),
|
|
98
|
+
).toEqual([]);
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
test(
|
|
103
|
+
'should rename worksheet',
|
|
104
|
+
async () =>
|
|
105
|
+
{
|
|
106
|
+
const client =
|
|
107
|
+
new Memory({
|
|
108
|
+
users: [
|
|
109
|
+
{
|
|
110
|
+
id: 1,
|
|
111
|
+
name: 'John',
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
await client.insertHeaders(
|
|
117
|
+
'users',
|
|
118
|
+
[
|
|
119
|
+
'id',
|
|
120
|
+
'name',
|
|
121
|
+
],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
await client.renameSheet(
|
|
125
|
+
'users',
|
|
126
|
+
'customers',
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(
|
|
130
|
+
await client.hasSheet('users'),
|
|
131
|
+
).toBe(false);
|
|
132
|
+
|
|
133
|
+
expect(
|
|
134
|
+
await client.hasSheet('customers'),
|
|
135
|
+
).toBe(true);
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
test(
|
|
140
|
+
'should preserve worksheet data when renamed',
|
|
141
|
+
async () =>
|
|
142
|
+
{
|
|
143
|
+
const client =
|
|
144
|
+
new Memory({
|
|
145
|
+
users: [
|
|
146
|
+
{
|
|
147
|
+
id: 1,
|
|
148
|
+
name: 'John',
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
await client.insertHeaders(
|
|
154
|
+
'users',
|
|
155
|
+
[
|
|
156
|
+
'id',
|
|
157
|
+
'name',
|
|
158
|
+
],
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
await client.renameSheet(
|
|
162
|
+
'users',
|
|
163
|
+
'customers',
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
expect(
|
|
167
|
+
await client.getHeaders('customers'),
|
|
168
|
+
).toEqual([
|
|
169
|
+
'id',
|
|
170
|
+
'name',
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
expect(
|
|
174
|
+
await client.getRows('customers'),
|
|
175
|
+
).toEqual([
|
|
176
|
+
{
|
|
177
|
+
id: 1,
|
|
178
|
+
name: 'John',
|
|
179
|
+
},
|
|
180
|
+
]);
|
|
181
|
+
},
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
test(
|
|
185
|
+
'should delete worksheet',
|
|
186
|
+
async () =>
|
|
187
|
+
{
|
|
188
|
+
const client =
|
|
189
|
+
new Memory({
|
|
190
|
+
users: [],
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
expect(
|
|
194
|
+
await client.hasSheet('users'),
|
|
195
|
+
).toBe(true);
|
|
196
|
+
|
|
197
|
+
await client.deleteSheet('users');
|
|
198
|
+
|
|
199
|
+
expect(
|
|
200
|
+
await client.hasSheet('users'),
|
|
201
|
+
).toBe(false);
|
|
202
|
+
},
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
test(
|
|
206
|
+
'should remove worksheet data when deleted',
|
|
207
|
+
async () =>
|
|
208
|
+
{
|
|
209
|
+
const client =
|
|
210
|
+
new Memory({
|
|
211
|
+
users: [
|
|
212
|
+
{
|
|
213
|
+
id: 1,
|
|
214
|
+
name: 'John',
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await client.insertHeaders(
|
|
220
|
+
'users',
|
|
221
|
+
[
|
|
222
|
+
'id',
|
|
223
|
+
'name',
|
|
224
|
+
],
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
await client.deleteSheet('users');
|
|
228
|
+
|
|
229
|
+
expect(
|
|
230
|
+
await client.getHeaders('users'),
|
|
231
|
+
).toEqual([]);
|
|
232
|
+
|
|
233
|
+
expect(
|
|
234
|
+
await client.getRows('users'),
|
|
235
|
+
).toEqual([]);
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
test(
|
|
240
|
+
'should get worksheet metadata',
|
|
241
|
+
async () =>
|
|
242
|
+
{
|
|
243
|
+
const client =
|
|
244
|
+
new Memory({
|
|
245
|
+
users: [],
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const metadata =
|
|
249
|
+
await client.getSheetMetadata('users');
|
|
250
|
+
|
|
251
|
+
expect(metadata).toEqual({
|
|
252
|
+
sheetId: expect.any(Number),
|
|
253
|
+
title: 'users',
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
test(
|
|
259
|
+
'should return null for non-existing worksheet metadata',
|
|
260
|
+
async () =>
|
|
261
|
+
{
|
|
262
|
+
const client =
|
|
263
|
+
new Memory();
|
|
264
|
+
|
|
265
|
+
const metadata =
|
|
266
|
+
await client.getSheetMetadata('users');
|
|
267
|
+
|
|
268
|
+
expect(metadata).toBeNull();
|
|
269
|
+
},
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
test(
|
|
273
|
+
'should reject invalid worksheet name when creating',
|
|
274
|
+
async () =>
|
|
275
|
+
{
|
|
276
|
+
const client =
|
|
277
|
+
new Memory();
|
|
278
|
+
|
|
279
|
+
await expect(
|
|
280
|
+
client.createSheet('users:test'),
|
|
281
|
+
).rejects.toThrow(
|
|
282
|
+
'Worksheet name contains invalid characters.',
|
|
283
|
+
);
|
|
284
|
+
},
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
test(
|
|
288
|
+
'should reject worksheet name longer than 100 characters',
|
|
289
|
+
async () =>
|
|
290
|
+
{
|
|
291
|
+
const client =
|
|
292
|
+
new Memory();
|
|
293
|
+
|
|
294
|
+
const sheetName =
|
|
295
|
+
'a'.repeat(101);
|
|
296
|
+
|
|
297
|
+
await expect(
|
|
298
|
+
client.createSheet(sheetName),
|
|
299
|
+
).rejects.toThrow(
|
|
300
|
+
'Worksheet name cannot exceed 100 characters.',
|
|
301
|
+
);
|
|
302
|
+
},
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
test(
|
|
306
|
+
'should reject invalid worksheet name when renaming',
|
|
307
|
+
async () =>
|
|
308
|
+
{
|
|
309
|
+
const client =
|
|
310
|
+
new Memory({
|
|
311
|
+
users: [],
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
await expect(
|
|
315
|
+
client.renameSheet(
|
|
316
|
+
'users',
|
|
317
|
+
'users:test',
|
|
318
|
+
),
|
|
319
|
+
).rejects.toThrow(
|
|
320
|
+
'Worksheet name contains invalid characters.',
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
test(
|
|
326
|
+
'should support worksheet name with spaces',
|
|
327
|
+
async () =>
|
|
328
|
+
{
|
|
329
|
+
const client =
|
|
330
|
+
new Memory();
|
|
331
|
+
|
|
332
|
+
await client.createSheet(
|
|
333
|
+
'User Data',
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
expect(
|
|
337
|
+
await client.hasSheet(
|
|
338
|
+
'User Data',
|
|
339
|
+
),
|
|
340
|
+
).toBe(true);
|
|
341
|
+
},
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
test(
|
|
345
|
+
'should support worksheet name with apostrophe',
|
|
346
|
+
async () =>
|
|
347
|
+
{
|
|
348
|
+
const client =
|
|
349
|
+
new Memory();
|
|
350
|
+
|
|
351
|
+
await client.createSheet(
|
|
352
|
+
"User's Data",
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
expect(
|
|
356
|
+
await client.hasSheet(
|
|
357
|
+
"User's Data",
|
|
358
|
+
),
|
|
359
|
+
).toBe(true);
|
|
360
|
+
},
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
test(
|
|
364
|
+
'should preserve worksheet data with special characters',
|
|
365
|
+
async () =>
|
|
366
|
+
{
|
|
367
|
+
const client =
|
|
368
|
+
new Memory();
|
|
369
|
+
|
|
370
|
+
const sheetName =
|
|
371
|
+
'User Data';
|
|
372
|
+
|
|
373
|
+
await client.createSheet(
|
|
374
|
+
sheetName,
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
await client.insertHeaders(
|
|
378
|
+
sheetName,
|
|
379
|
+
[
|
|
380
|
+
'id',
|
|
381
|
+
'name',
|
|
382
|
+
],
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
await client.insertRows(
|
|
386
|
+
sheetName,
|
|
387
|
+
[
|
|
388
|
+
{
|
|
389
|
+
id: 1,
|
|
390
|
+
name: 'John',
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
expect(
|
|
396
|
+
await client.getRows(
|
|
397
|
+
sheetName,
|
|
398
|
+
),
|
|
399
|
+
).toEqual([
|
|
400
|
+
{
|
|
401
|
+
id: 1,
|
|
402
|
+
name: 'John',
|
|
403
|
+
},
|
|
404
|
+
]);
|
|
405
|
+
},
|
|
406
|
+
);
|
|
407
|
+
},
|
|
408
|
+
);
|