@ftschopp/dynatable-core 1.2.4 → 1.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/CHANGELOG.md +14 -0
- package/README.md +1 -3
- package/dist/builders/batch-get/create-batch-get-builder.d.ts.map +1 -1
- package/dist/builders/batch-get/create-batch-get-builder.js +4 -8
- package/dist/builders/batch-get/types.d.ts +2 -3
- package/dist/builders/batch-get/types.d.ts.map +1 -1
- package/dist/builders/query/create-query-builder.d.ts +1 -1
- package/dist/builders/query/create-query-builder.d.ts.map +1 -1
- package/dist/builders/query/create-query-builder.js +35 -10
- package/dist/builders/shared/operators.d.ts.map +1 -1
- package/dist/builders/shared/operators.js +8 -0
- package/dist/builders/shared/types.d.ts +1 -0
- package/dist/builders/shared/types.d.ts.map +1 -1
- package/dist/builders/update/create-update-builder.d.ts +8 -2
- package/dist/builders/update/create-update-builder.d.ts.map +1 -1
- package/dist/builders/update/create-update-builder.js +45 -16
- package/dist/builders/update/types.d.ts +13 -0
- package/dist/builders/update/types.d.ts.map +1 -1
- package/dist/core/types.d.ts +0 -1
- package/dist/core/types.d.ts.map +1 -1
- package/dist/entity/create-entity-api.d.ts.map +1 -1
- package/dist/entity/create-entity-api.js +8 -4
- package/dist/utils/model-utils.d.ts +28 -0
- package/dist/utils/model-utils.d.ts.map +1 -1
- package/dist/utils/model-utils.js +34 -1
- package/package.json +1 -1
- package/src/builders/batch-get/README.md +9 -64
- package/src/builders/batch-get/create-batch-get-builder.ts +5 -10
- package/src/builders/batch-get/types.ts +2 -3
- package/src/builders/query/create-query-builder.test.ts +204 -0
- package/src/builders/query/create-query-builder.ts +51 -10
- package/src/builders/shared/operators.ts +8 -0
- package/src/builders/shared/types.ts +1 -0
- package/src/builders/update/create-update-builder.test.ts +197 -0
- package/src/builders/update/create-update-builder.ts +72 -19
- package/src/builders/update/types.ts +14 -0
- package/src/core/types.test.ts +0 -2
- package/src/core/types.ts +0 -1
- package/src/entity/create-entity-api.ts +8 -4
- package/src/utils/model-utils.test.ts +91 -1
- package/src/utils/model-utils.ts +54 -0
- package/tests/integration/instagram-clone.integration.test.ts +23 -4
- package/tests/integration/pagination-timestamps.integration.test.ts +1 -2
- package/tests/integration/transactions.integration.test.ts +0 -1
|
@@ -98,7 +98,6 @@ const InstagramSchema = {
|
|
|
98
98
|
},
|
|
99
99
|
},
|
|
100
100
|
params: {
|
|
101
|
-
isoDates: true,
|
|
102
101
|
timestamps: true,
|
|
103
102
|
},
|
|
104
103
|
} as const;
|
|
@@ -251,15 +250,20 @@ describe('Should test dbParams function builder', () => {
|
|
|
251
250
|
.where((attr, op) => op.eq(attr.username, 'juanca'))
|
|
252
251
|
.dbParams();
|
|
253
252
|
|
|
254
|
-
// After query builder fix: username -> pk, and value gets template applied
|
|
253
|
+
// After query builder fix: username -> pk, and value gets template applied.
|
|
254
|
+
// Entity API auto-injects a `_type = <modelName>` filter so that queries on
|
|
255
|
+
// shared partition keys don't return items of other entities.
|
|
255
256
|
expect(params).toEqual({
|
|
256
257
|
TableName: 'InstagramClone',
|
|
257
258
|
KeyConditionExpression: '#PK = :username_0',
|
|
259
|
+
FilterExpression: '#_type = :_type',
|
|
258
260
|
ExpressionAttributeNames: {
|
|
259
261
|
'#PK': 'PK',
|
|
262
|
+
'#_type': '_type',
|
|
260
263
|
},
|
|
261
264
|
ExpressionAttributeValues: {
|
|
262
265
|
':username_0': 'UP#juanca', // Template applied: UP#${username}
|
|
266
|
+
':_type': 'Photo',
|
|
263
267
|
},
|
|
264
268
|
});
|
|
265
269
|
|
|
@@ -267,6 +271,7 @@ describe('Should test dbParams function builder', () => {
|
|
|
267
271
|
expect(params.KeyConditionExpression).toMatch(/#PK = :username_\d+/);
|
|
268
272
|
expect(params.ExpressionAttributeNames).toEqual({
|
|
269
273
|
'#PK': 'PK',
|
|
274
|
+
'#_type': '_type',
|
|
270
275
|
});
|
|
271
276
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain('UP#juanca');
|
|
272
277
|
});
|
|
@@ -279,23 +284,27 @@ describe('Should test dbParams function builder', () => {
|
|
|
279
284
|
expect(params).toEqual({
|
|
280
285
|
TableName: 'InstagramClone',
|
|
281
286
|
KeyConditionExpression: '#PK = :username_0',
|
|
282
|
-
FilterExpression: '#likesCount > :likesCount_1',
|
|
287
|
+
FilterExpression: '(#likesCount > :likesCount_1) AND (#_type = :_type)',
|
|
283
288
|
ExpressionAttributeNames: {
|
|
284
289
|
'#likesCount': 'likesCount',
|
|
285
290
|
'#PK': 'PK',
|
|
291
|
+
'#_type': '_type',
|
|
286
292
|
},
|
|
287
293
|
ExpressionAttributeValues: {
|
|
288
294
|
':likesCount_1': 0,
|
|
289
295
|
':username_0': 'UP#juanca',
|
|
296
|
+
':_type': 'Photo',
|
|
290
297
|
},
|
|
291
298
|
});
|
|
292
299
|
|
|
293
300
|
expect(params.TableName).toBe('InstagramClone');
|
|
294
301
|
expect(params.KeyConditionExpression).toMatch(/#PK = :username_\d+/);
|
|
295
302
|
expect(params.FilterExpression).toMatch(/#likesCount > :likesCount_\d+/);
|
|
303
|
+
expect(params.FilterExpression).toMatch(/#_type = :_type/);
|
|
296
304
|
expect(params.ExpressionAttributeNames).toEqual({
|
|
297
305
|
'#PK': 'PK',
|
|
298
306
|
'#likesCount': 'likesCount',
|
|
307
|
+
'#_type': '_type',
|
|
299
308
|
});
|
|
300
309
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain('UP#juanca');
|
|
301
310
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain(0);
|
|
@@ -311,11 +320,14 @@ describe('Should test dbParams function builder', () => {
|
|
|
311
320
|
expect(params).toEqual({
|
|
312
321
|
TableName: 'InstagramClone',
|
|
313
322
|
KeyConditionExpression: '#PK = :username_0',
|
|
323
|
+
FilterExpression: '#_type = :_type',
|
|
314
324
|
ExpressionAttributeNames: {
|
|
315
325
|
'#PK': 'PK',
|
|
326
|
+
'#_type': '_type',
|
|
316
327
|
},
|
|
317
328
|
ExpressionAttributeValues: {
|
|
318
329
|
':username_0': 'UP#juanca',
|
|
330
|
+
':_type': 'Photo',
|
|
319
331
|
},
|
|
320
332
|
Limit: 10,
|
|
321
333
|
ScanIndexForward: false,
|
|
@@ -345,16 +357,19 @@ describe('Should test dbParams function builder', () => {
|
|
|
345
357
|
expect(params).toEqual({
|
|
346
358
|
TableName: 'InstagramClone',
|
|
347
359
|
KeyConditionExpression: '#PK = :photoId_0',
|
|
360
|
+
FilterExpression: '#_type = :_type',
|
|
348
361
|
ExpressionAttributeNames: {
|
|
349
362
|
'#PK': 'PK',
|
|
363
|
+
'#_type': '_type',
|
|
350
364
|
},
|
|
351
365
|
ExpressionAttributeValues: {
|
|
352
366
|
':photoId_0': 'PL#photo123', // Template applied: PL#${photoId}
|
|
367
|
+
':_type': 'Like',
|
|
353
368
|
},
|
|
354
369
|
});
|
|
355
370
|
expect(params.TableName).toBe('InstagramClone');
|
|
356
371
|
expect(params.KeyConditionExpression).toMatch(/#PK = :photoId_\d+/);
|
|
357
|
-
expect(params.ExpressionAttributeNames).toEqual({ '#PK': 'PK' });
|
|
372
|
+
expect(params.ExpressionAttributeNames).toEqual({ '#PK': 'PK', '#_type': '_type' });
|
|
358
373
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain('PL#photo123');
|
|
359
374
|
});
|
|
360
375
|
|
|
@@ -373,10 +388,12 @@ describe('Should test dbParams function builder', () => {
|
|
|
373
388
|
expect(params.FilterExpression).toMatch(
|
|
374
389
|
/\(#likesCount > :likesCount_\d+\) OR \(#commentCount > :commentCount_\d+\)/
|
|
375
390
|
);
|
|
391
|
+
expect(params.FilterExpression).toMatch(/#_type = :_type/);
|
|
376
392
|
expect(params.ExpressionAttributeNames).toEqual({
|
|
377
393
|
'#PK': 'PK',
|
|
378
394
|
'#likesCount': 'likesCount',
|
|
379
395
|
'#commentCount': 'commentCount',
|
|
396
|
+
'#_type': '_type',
|
|
380
397
|
});
|
|
381
398
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain('UP#juanca');
|
|
382
399
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain(100);
|
|
@@ -402,10 +419,12 @@ describe('Should test dbParams function builder', () => {
|
|
|
402
419
|
/\(#likesCount > :likesCount_\d+\) AND \(#commentCount < :commentCount_\d+\)/
|
|
403
420
|
);
|
|
404
421
|
expect(params.FilterExpression).toMatch(/OR/);
|
|
422
|
+
expect(params.FilterExpression).toMatch(/#_type = :_type/);
|
|
405
423
|
expect(params.ExpressionAttributeNames).toEqual({
|
|
406
424
|
'#PK': 'PK',
|
|
407
425
|
'#likesCount': 'likesCount',
|
|
408
426
|
'#commentCount': 'commentCount',
|
|
427
|
+
'#_type': '_type',
|
|
409
428
|
});
|
|
410
429
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain('UP#juanca');
|
|
411
430
|
expect(Object.values(params.ExpressionAttributeValues || {})).toContain(100);
|
|
@@ -42,8 +42,7 @@ describe('Pagination and Timestamps Integration Tests', () => {
|
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
44
|
params: {
|
|
45
|
-
|
|
46
|
-
timestamps: true, // Enable automatic timestamps
|
|
45
|
+
timestamps: true, // Enable automatic timestamps (stored as ISO strings)
|
|
47
46
|
},
|
|
48
47
|
} as const;
|
|
49
48
|
|