@bitblit/ratchet-aws 4.0.115-alpha → 4.0.119-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 (122) hide show
  1. package/lib/build/ratchet-aws-info.d.ts +1 -1
  2. package/lib/cloudwatch/cloud-watch-log-group-ratchet.d.ts +1 -0
  3. package/lib/cloudwatch/cloud-watch-logs-ratchet.d.ts +1 -0
  4. package/lib/cloudwatch/cloud-watch-metrics-ratchet.d.ts +2 -1
  5. package/lib/daemon/daemon-like.d.ts +1 -1
  6. package/lib/daemon/daemon-process-state-public-token.d.ts +1 -1
  7. package/lib/daemon/daemon-util.d.ts +2 -2
  8. package/lib/daemon/daemon.d.ts +2 -2
  9. package/lib/dynamodb/dynamo-ratchet.d.ts +1 -0
  10. package/lib/ec2/ec2-ratchet.d.ts +4 -2
  11. package/lib/index.d.ts +78 -1
  12. package/lib/index.mjs +11 -0
  13. package/lib/index.mjs.map +1 -0
  14. package/lib/model/cloud-watch-metrics-minute-level-dynamo-count-request.d.ts +1 -1
  15. package/lib/route53/route-53-ratchet.d.ts +1 -0
  16. package/lib/s3/s3-cache-ratchet.d.ts +3 -2
  17. package/lib/s3/s3-cache-to-local-disk-ratchet.d.ts +1 -1
  18. package/lib/ses/mailer.d.ts +1 -0
  19. package/lib/sns/sns-ratchet.d.ts +1 -0
  20. package/package.json +33 -103
  21. package/lib/batch/aws-batch-background-processor.js +0 -45
  22. package/lib/batch/aws-batch-background-processor.spec.js +0 -15
  23. package/lib/batch/aws-batch-ratchet.js +0 -55
  24. package/lib/batch/aws-batch-ratchet.spec.js +0 -33
  25. package/lib/build/ratchet-aws-info.js +0 -14
  26. package/lib/cache/dynamo-db-storage-provider.js +0 -109
  27. package/lib/cache/s3-storage-provider.js +0 -43
  28. package/lib/cache/simple-cache-object-wrapper.js +0 -1
  29. package/lib/cache/simple-cache-read-options.js +0 -1
  30. package/lib/cache/simple-cache-storage-provider.js +0 -1
  31. package/lib/cache/simple-cache.js +0 -64
  32. package/lib/cache/simple-cache.spec.js +0 -67
  33. package/lib/cloudwatch/cloud-watch-log-group-ratchet.js +0 -71
  34. package/lib/cloudwatch/cloud-watch-log-group-ratchet.spec.js +0 -19
  35. package/lib/cloudwatch/cloud-watch-logs-ratchet.js +0 -170
  36. package/lib/cloudwatch/cloud-watch-logs-ratchet.spec.js +0 -84
  37. package/lib/cloudwatch/cloud-watch-metrics-ratchet.js +0 -54
  38. package/lib/cloudwatch/cloud-watch-metrics-ratchet.spec.js +0 -23
  39. package/lib/daemon/daemon-like.js +0 -1
  40. package/lib/daemon/daemon-process-create-options.js +0 -1
  41. package/lib/daemon/daemon-process-state-public-token.js +0 -1
  42. package/lib/daemon/daemon-process-state.js +0 -1
  43. package/lib/daemon/daemon-util.js +0 -148
  44. package/lib/daemon/daemon-util.spec.js +0 -79
  45. package/lib/daemon/daemon.js +0 -128
  46. package/lib/dao/prototype-dao-config.js +0 -1
  47. package/lib/dao/prototype-dao-db.js +0 -1
  48. package/lib/dao/prototype-dao-provider.js +0 -1
  49. package/lib/dao/prototype-dao.js +0 -88
  50. package/lib/dao/prototype-dao.spec.js +0 -26
  51. package/lib/dao/s3-prototype-dao-provider.js +0 -26
  52. package/lib/dao/s3-simple-dao.js +0 -76
  53. package/lib/dao/simple-dao-item.js +0 -1
  54. package/lib/dynamodb/dynamo-ratchet-like.js +0 -1
  55. package/lib/dynamodb/dynamo-ratchet.js +0 -666
  56. package/lib/dynamodb/dynamo-ratchet.spec.js +0 -156
  57. package/lib/dynamodb/dynamo-table-ratchet.js +0 -88
  58. package/lib/dynamodb/hash-spreader.js +0 -65
  59. package/lib/dynamodb/hash-spreader.spec.js +0 -17
  60. package/lib/ec2/ec2-ratchet.js +0 -107
  61. package/lib/ec2/ec2-ratchet.spec.js +0 -31
  62. package/lib/environment/cascade-environment-service-provider.js +0 -24
  63. package/lib/environment/env-var-environment-service-provider.js +0 -30
  64. package/lib/environment/environment-service-config.js +0 -1
  65. package/lib/environment/environment-service-provider.js +0 -1
  66. package/lib/environment/environment-service.js +0 -50
  67. package/lib/environment/environment-service.spec.js +0 -22
  68. package/lib/environment/fixed-environment-service-provider.js +0 -21
  69. package/lib/environment/s3-environment-service-provider.js +0 -27
  70. package/lib/environment/ssm-environment-service-provider.js +0 -59
  71. package/lib/expiring-code/dynamo-expiring-code-provider.js +0 -24
  72. package/lib/expiring-code/expiring-code-params.js +0 -1
  73. package/lib/expiring-code/expiring-code-provider.js +0 -1
  74. package/lib/expiring-code/expiring-code-ratchet.js +0 -34
  75. package/lib/expiring-code/expiring-code-ratchet.spec.js +0 -7
  76. package/lib/expiring-code/expiring-code.js +0 -1
  77. package/lib/expiring-code/s3-expiring-code-provider.js +0 -48
  78. package/lib/expiring-code/s3-expiring-code-provider.spec.js +0 -46
  79. package/lib/iam/aws-credentials-ratchet.js +0 -18
  80. package/lib/index.js +0 -1
  81. package/lib/lambda/lambda-event-detector.js +0 -38
  82. package/lib/lambda/lambda-event-type-guards.js +0 -24
  83. package/lib/model/cloud-watch-metrics-minute-level-dynamo-count-request.js +0 -1
  84. package/lib/model/cloud-watch-metrics-unit.js +0 -30
  85. package/lib/model/dynamo/doc-put-item-command-input.js +0 -1
  86. package/lib/model/dynamo/doc-query-command-input.js +0 -1
  87. package/lib/model/dynamo/doc-scan-command-input.js +0 -1
  88. package/lib/model/dynamo/doc-update-item-command-input.js +0 -1
  89. package/lib/model/dynamo-count-result.js +0 -1
  90. package/lib/route53/route-53-ratchet.js +0 -55
  91. package/lib/runtime-parameter/cached-stored-runtime-parameter.js +0 -1
  92. package/lib/runtime-parameter/dynamo-runtime-parameter-provider.js +0 -36
  93. package/lib/runtime-parameter/dynamo-runtime-parameter-provider.spec.js +0 -49
  94. package/lib/runtime-parameter/global-variable-override-runtime-parameter-provider.js +0 -51
  95. package/lib/runtime-parameter/global-variable-override-runtime-parameter-provider.spec.js +0 -37
  96. package/lib/runtime-parameter/memory-runtime-parameter-provider.js +0 -27
  97. package/lib/runtime-parameter/runtime-parameter-provider.js +0 -1
  98. package/lib/runtime-parameter/runtime-parameter-ratchet.js +0 -71
  99. package/lib/runtime-parameter/runtime-parameter-ratchet.spec.js +0 -39
  100. package/lib/runtime-parameter/stored-runtime-parameter.js +0 -1
  101. package/lib/s3/s3-cache-ratchet.js +0 -330
  102. package/lib/s3/s3-cache-ratchet.spec.js +0 -97
  103. package/lib/s3/s3-cache-to-local-disk-ratchet.js +0 -105
  104. package/lib/s3/s3-cache-to-local-dist-ratchet.spec.js +0 -22
  105. package/lib/s3/s3-location-sync-ratchet.js +0 -140
  106. package/lib/s3/s3-ratchet.js +0 -22
  107. package/lib/s3/s3-ratchet.spec.js +0 -20
  108. package/lib/ses/email-attachment.js +0 -1
  109. package/lib/ses/mailer-config.js +0 -1
  110. package/lib/ses/mailer-like.js +0 -1
  111. package/lib/ses/mailer.js +0 -206
  112. package/lib/ses/mailer.spec.js +0 -104
  113. package/lib/ses/ratchet-template-renderer.js +0 -1
  114. package/lib/ses/ready-to-send-email.js +0 -1
  115. package/lib/ses/remote-handlebars-template-renderer.js +0 -78
  116. package/lib/ses/resolved-ready-to-send-email.js +0 -1
  117. package/lib/sns/sns-ratchet.js +0 -45
  118. package/lib/sns/sns-ratchet.spec.js +0 -17
  119. package/lib/sync-lock/dynamo-db-sync-lock.js +0 -69
  120. package/lib/sync-lock/dynamo-db-sync-lock.spec.js +0 -30
  121. package/lib/sync-lock/memory-sync-lock.js +0 -35
  122. 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 {};