@bitblit/ratchet-aws 4.0.113-alpha → 4.0.116-alpha

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.
Files changed (119) hide show
  1. package/lib/cloudwatch/cloud-watch-log-group-ratchet.d.ts +1 -0
  2. package/lib/cloudwatch/cloud-watch-logs-ratchet.d.ts +1 -0
  3. package/lib/cloudwatch/cloud-watch-metrics-ratchet.d.ts +1 -0
  4. package/lib/daemon/daemon-like.d.ts +1 -1
  5. package/lib/daemon/daemon-util.d.ts +2 -2
  6. package/lib/daemon/daemon.d.ts +1 -1
  7. package/lib/dynamodb/dynamo-ratchet.d.ts +1 -0
  8. package/lib/ec2/ec2-ratchet.d.ts +4 -2
  9. package/lib/index.d.ts +78 -1
  10. package/lib/index.mjs +10 -0
  11. package/lib/index.mjs.map +1 -0
  12. package/lib/route53/route-53-ratchet.d.ts +1 -0
  13. package/lib/s3/s3-cache-ratchet.d.ts +3 -2
  14. package/lib/s3/s3-cache-to-local-disk-ratchet.d.ts +1 -1
  15. package/lib/ses/mailer.d.ts +1 -0
  16. package/lib/sns/sns-ratchet.d.ts +1 -0
  17. package/package.json +25 -84
  18. package/lib/batch/aws-batch-background-processor.js +0 -45
  19. package/lib/batch/aws-batch-background-processor.spec.js +0 -15
  20. package/lib/batch/aws-batch-ratchet.js +0 -55
  21. package/lib/batch/aws-batch-ratchet.spec.js +0 -33
  22. package/lib/build/ratchet-aws-info.js +0 -14
  23. package/lib/cache/dynamo-db-storage-provider.js +0 -109
  24. package/lib/cache/s3-storage-provider.js +0 -43
  25. package/lib/cache/simple-cache-object-wrapper.js +0 -1
  26. package/lib/cache/simple-cache-read-options.js +0 -1
  27. package/lib/cache/simple-cache-storage-provider.js +0 -1
  28. package/lib/cache/simple-cache.js +0 -64
  29. package/lib/cache/simple-cache.spec.js +0 -67
  30. package/lib/cloudwatch/cloud-watch-log-group-ratchet.js +0 -71
  31. package/lib/cloudwatch/cloud-watch-log-group-ratchet.spec.js +0 -19
  32. package/lib/cloudwatch/cloud-watch-logs-ratchet.js +0 -170
  33. package/lib/cloudwatch/cloud-watch-logs-ratchet.spec.js +0 -84
  34. package/lib/cloudwatch/cloud-watch-metrics-ratchet.js +0 -54
  35. package/lib/cloudwatch/cloud-watch-metrics-ratchet.spec.js +0 -23
  36. package/lib/daemon/daemon-like.js +0 -1
  37. package/lib/daemon/daemon-process-create-options.js +0 -1
  38. package/lib/daemon/daemon-process-state-public-token.js +0 -1
  39. package/lib/daemon/daemon-process-state.js +0 -1
  40. package/lib/daemon/daemon-util.js +0 -148
  41. package/lib/daemon/daemon-util.spec.js +0 -79
  42. package/lib/daemon/daemon.js +0 -128
  43. package/lib/dao/prototype-dao-config.js +0 -1
  44. package/lib/dao/prototype-dao-db.js +0 -1
  45. package/lib/dao/prototype-dao-provider.js +0 -1
  46. package/lib/dao/prototype-dao.js +0 -88
  47. package/lib/dao/prototype-dao.spec.js +0 -26
  48. package/lib/dao/s3-prototype-dao-provider.js +0 -26
  49. package/lib/dao/s3-simple-dao.js +0 -76
  50. package/lib/dao/simple-dao-item.js +0 -1
  51. package/lib/dynamodb/dynamo-ratchet-like.js +0 -1
  52. package/lib/dynamodb/dynamo-ratchet.js +0 -666
  53. package/lib/dynamodb/dynamo-ratchet.spec.js +0 -156
  54. package/lib/dynamodb/dynamo-table-ratchet.js +0 -88
  55. package/lib/dynamodb/hash-spreader.js +0 -65
  56. package/lib/dynamodb/hash-spreader.spec.js +0 -17
  57. package/lib/ec2/ec2-ratchet.js +0 -107
  58. package/lib/ec2/ec2-ratchet.spec.js +0 -31
  59. package/lib/environment/cascade-environment-service-provider.js +0 -24
  60. package/lib/environment/env-var-environment-service-provider.js +0 -30
  61. package/lib/environment/environment-service-config.js +0 -1
  62. package/lib/environment/environment-service-provider.js +0 -1
  63. package/lib/environment/environment-service.js +0 -50
  64. package/lib/environment/environment-service.spec.js +0 -22
  65. package/lib/environment/fixed-environment-service-provider.js +0 -21
  66. package/lib/environment/s3-environment-service-provider.js +0 -27
  67. package/lib/environment/ssm-environment-service-provider.js +0 -59
  68. package/lib/expiring-code/dynamo-expiring-code-provider.js +0 -24
  69. package/lib/expiring-code/expiring-code-params.js +0 -1
  70. package/lib/expiring-code/expiring-code-provider.js +0 -1
  71. package/lib/expiring-code/expiring-code-ratchet.js +0 -34
  72. package/lib/expiring-code/expiring-code-ratchet.spec.js +0 -7
  73. package/lib/expiring-code/expiring-code.js +0 -1
  74. package/lib/expiring-code/s3-expiring-code-provider.js +0 -48
  75. package/lib/expiring-code/s3-expiring-code-provider.spec.js +0 -46
  76. package/lib/iam/aws-credentials-ratchet.js +0 -18
  77. package/lib/index.js +0 -1
  78. package/lib/lambda/lambda-event-detector.js +0 -38
  79. package/lib/lambda/lambda-event-type-guards.js +0 -24
  80. package/lib/model/cloud-watch-metrics-minute-level-dynamo-count-request.js +0 -1
  81. package/lib/model/cloud-watch-metrics-unit.js +0 -30
  82. package/lib/model/dynamo/doc-put-item-command-input.js +0 -1
  83. package/lib/model/dynamo/doc-query-command-input.js +0 -1
  84. package/lib/model/dynamo/doc-scan-command-input.js +0 -1
  85. package/lib/model/dynamo/doc-update-item-command-input.js +0 -1
  86. package/lib/model/dynamo-count-result.js +0 -1
  87. package/lib/route53/route-53-ratchet.js +0 -55
  88. package/lib/runtime-parameter/cached-stored-runtime-parameter.js +0 -1
  89. package/lib/runtime-parameter/dynamo-runtime-parameter-provider.js +0 -36
  90. package/lib/runtime-parameter/dynamo-runtime-parameter-provider.spec.js +0 -49
  91. package/lib/runtime-parameter/global-variable-override-runtime-parameter-provider.js +0 -51
  92. package/lib/runtime-parameter/global-variable-override-runtime-parameter-provider.spec.js +0 -37
  93. package/lib/runtime-parameter/memory-runtime-parameter-provider.js +0 -27
  94. package/lib/runtime-parameter/runtime-parameter-provider.js +0 -1
  95. package/lib/runtime-parameter/runtime-parameter-ratchet.js +0 -71
  96. package/lib/runtime-parameter/runtime-parameter-ratchet.spec.js +0 -39
  97. package/lib/runtime-parameter/stored-runtime-parameter.js +0 -1
  98. package/lib/s3/s3-cache-ratchet.js +0 -330
  99. package/lib/s3/s3-cache-ratchet.spec.js +0 -97
  100. package/lib/s3/s3-cache-to-local-disk-ratchet.js +0 -105
  101. package/lib/s3/s3-cache-to-local-dist-ratchet.spec.js +0 -22
  102. package/lib/s3/s3-location-sync-ratchet.js +0 -140
  103. package/lib/s3/s3-ratchet.js +0 -22
  104. package/lib/s3/s3-ratchet.spec.js +0 -20
  105. package/lib/ses/email-attachment.js +0 -1
  106. package/lib/ses/mailer-config.js +0 -1
  107. package/lib/ses/mailer-like.js +0 -1
  108. package/lib/ses/mailer.js +0 -206
  109. package/lib/ses/mailer.spec.js +0 -104
  110. package/lib/ses/ratchet-template-renderer.js +0 -1
  111. package/lib/ses/ready-to-send-email.js +0 -1
  112. package/lib/ses/remote-handlebars-template-renderer.js +0 -78
  113. package/lib/ses/resolved-ready-to-send-email.js +0 -1
  114. package/lib/sns/sns-ratchet.js +0 -45
  115. package/lib/sns/sns-ratchet.spec.js +0 -17
  116. package/lib/sync-lock/dynamo-db-sync-lock.js +0 -69
  117. package/lib/sync-lock/dynamo-db-sync-lock.spec.js +0 -30
  118. package/lib/sync-lock/memory-sync-lock.js +0 -35
  119. package/lib/sync-lock/sync-lock-provider.js +0 -1
@@ -1,69 +0,0 @@
1
- import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
2
- import { RequireRatchet } from '@bitblit/ratchet-common/lib/lang/require-ratchet.js';
3
- import { StringRatchet } from '@bitblit/ratchet-common/lib/lang/string-ratchet.js';
4
- import { PutItemCommand } from '@aws-sdk/client-dynamodb';
5
- export class DynamoDbSyncLock {
6
- ratchet;
7
- tableName;
8
- constructor(ratchet, tableName) {
9
- this.ratchet = ratchet;
10
- this.tableName = tableName;
11
- RequireRatchet.notNullOrUndefined(ratchet, 'ratchet');
12
- RequireRatchet.notNullOrUndefined(StringRatchet.trimToNull(this.tableName), 'tableName');
13
- }
14
- async acquireLock(lockKey, expirationSeconds = 30) {
15
- let rval = false;
16
- if (!!lockKey && !!expirationSeconds) {
17
- const nowSeconds = Math.floor(new Date().getTime() / 1000);
18
- const row = {
19
- lockingKey: lockKey,
20
- timestamp: nowSeconds,
21
- expires: nowSeconds + expirationSeconds,
22
- };
23
- const params = {
24
- Item: row,
25
- ReturnConsumedCapacity: 'TOTAL',
26
- TableName: this.tableName,
27
- ConditionExpression: 'attribute_not_exists(lockingKey)',
28
- };
29
- try {
30
- const pio = await this.ratchet.getDDB().send(new PutItemCommand(params));
31
- rval = true;
32
- }
33
- catch (err) {
34
- if (String(err).indexOf('ConditionalCheckFailedException') > -1) {
35
- Logger.silly('Unable to acquire lock on %s', lockKey);
36
- }
37
- }
38
- }
39
- return rval;
40
- }
41
- async releaseLock(lockKey) {
42
- if (StringRatchet.trimToNull(lockKey)) {
43
- try {
44
- const dio = await this.ratchet.simpleDelete(this.tableName, { lockingKey: lockKey });
45
- Logger.silly('Released lock %s : %s', lockKey, dio);
46
- }
47
- catch (err) {
48
- Logger.warn('Failed to release lock key : %s : %s', lockKey, err, err);
49
- }
50
- }
51
- }
52
- async clearExpiredSyncLocks() {
53
- const nowSeconds = Math.floor(new Date().getTime() / 1000);
54
- const scan = {
55
- TableName: this.tableName,
56
- FilterExpression: 'expires < :now',
57
- ExpressionAttributeValues: {
58
- ':now': nowSeconds,
59
- },
60
- };
61
- const vals = await this.ratchet.fullyExecuteScan(scan);
62
- const keysOnly = vals.map((v) => {
63
- const next = { lockingKey: v['lockingKey'] };
64
- return next;
65
- });
66
- const removed = await this.ratchet.deleteAllInBatches(this.tableName, keysOnly, 25);
67
- return removed;
68
- }
69
- }
@@ -1,30 +0,0 @@
1
- import { DynamoDbSyncLock } from './dynamo-db-sync-lock.js';
2
- import { Logger } from '@bitblit/ratchet-common/lib/logger/logger.js';
3
- import { JestRatchet } from '@bitblit/ratchet-jest/lib/jest/jest-ratchet.js';
4
- import { jest } from '@jest/globals';
5
- let mockDR;
6
- describe('#syncLockService', () => {
7
- beforeEach(() => {
8
- mockDR = JestRatchet.mock(jest.fn);
9
- });
10
- xit('should test sync locks', async () => {
11
- const svc = new DynamoDbSyncLock(mockDR, 'test-table');
12
- const lockTestValue = 'SYNC_LOCK_TEST';
13
- const aq1 = await svc.acquireLock(lockTestValue);
14
- expect(aq1).toBe(true);
15
- const aq2 = await svc.acquireLock(lockTestValue);
16
- expect(aq2).toBe(false);
17
- await svc.releaseLock(lockTestValue);
18
- const aq3 = await svc.acquireLock(lockTestValue);
19
- expect(aq3).toBe(true);
20
- await svc.releaseLock(lockTestValue);
21
- });
22
- it('should clear expired sync locks', async () => {
23
- mockDR.fullyExecuteScan.mockResolvedValue([{ lockingKey: 'aa' }, { lockingKey: 'ab' }]);
24
- mockDR.deleteAllInBatches.mockResolvedValue(2);
25
- const svc = new DynamoDbSyncLock(mockDR, 'test-table');
26
- const res = await svc.clearExpiredSyncLocks();
27
- Logger.info('Got : %s', res);
28
- expect(res).toEqual(2);
29
- });
30
- });
@@ -1,35 +0,0 @@
1
- import { StringRatchet } from '@bitblit/ratchet-common/lib/lang/string-ratchet.js';
2
- export class MemorySyncLock {
3
- _locks = new Map();
4
- constructor() { }
5
- async acquireLock(lockKey, expirationSeconds = 30) {
6
- let rval = false;
7
- if (StringRatchet.trimToNull(lockKey)) {
8
- const now = Date.now();
9
- const val = this._locks.get(lockKey);
10
- if (!val || val < now) {
11
- this._locks.set(lockKey, now + expirationSeconds * 1000);
12
- rval = true;
13
- }
14
- }
15
- return rval;
16
- }
17
- async releaseLock(lockKey) {
18
- if (StringRatchet.trimToNull(lockKey)) {
19
- this._locks.delete(lockKey);
20
- }
21
- }
22
- async clearExpiredSyncLocks() {
23
- const toRemove = [];
24
- const now = Date.now();
25
- this._locks.forEach((v, k) => {
26
- if (v < now) {
27
- toRemove.push(k);
28
- }
29
- });
30
- toRemove.forEach((k) => {
31
- this._locks.delete(k);
32
- });
33
- return toRemove.length;
34
- }
35
- }
@@ -1 +0,0 @@
1
- export {};