diff --git a/packages/askar/src/storage/AskarStorageService.ts b/packages/askar/src/storage/AskarStorageService.ts index e7c96399c2..cdf537745d 100644 --- a/packages/askar/src/storage/AskarStorageService.ts +++ b/packages/askar/src/storage/AskarStorageService.ts @@ -21,6 +21,8 @@ export class AskarStorageService implements StorageService assertAskarWallet(agentContext.wallet) const session = agentContext.wallet.session + record.updatedAt = new Date() + const value = JsonTransformer.serialize(record) const tags = transformFromRecordTagValues(record.getTags()) as Record @@ -40,6 +42,8 @@ export class AskarStorageService implements StorageService assertAskarWallet(agentContext.wallet) const session = agentContext.wallet.session + record.updatedAt = new Date() + const value = JsonTransformer.serialize(record) const tags = transformFromRecordTagValues(record.getTags()) as Record diff --git a/packages/askar/src/storage/__tests__/AskarStorageService.test.ts b/packages/askar/src/storage/__tests__/AskarStorageService.test.ts index 1ba1bf329f..2208cde944 100644 --- a/packages/askar/src/storage/__tests__/AskarStorageService.test.ts +++ b/packages/askar/src/storage/__tests__/AskarStorageService.test.ts @@ -14,6 +14,8 @@ import { AskarWallet } from '../../wallet/AskarWallet' import { AskarStorageService } from '../AskarStorageService' import { askarQueryFromSearchQuery } from '../utils' +const startDate = Date.now() + describe('AskarStorageService', () => { let wallet: AskarWallet let storageService: AskarStorageService @@ -127,6 +129,11 @@ describe('AskarStorageService', () => { expect(record).toEqual(found) }) + + it('updatedAt should have a new value after a save', async () => { + const record = await insertRecord({ id: 'test-id' }) + expect(record.updatedAt?.getTime()).toBeGreaterThan(startDate) + }) }) describe('getById()', () => { @@ -165,6 +172,11 @@ describe('AskarStorageService', () => { const retrievedRecord = await storageService.getById(agentContext, TestRecord, record.id) expect(retrievedRecord).toEqual(record) }) + + it('updatedAt should have a new value after an update', async () => { + const record = await insertRecord({ id: 'test-id' }) + expect(record.updatedAt?.getTime()).toBeGreaterThan(startDate) + }) }) describe('delete()', () => { diff --git a/packages/core/jest.config.ts b/packages/core/jest.config.ts index 55c67d70a6..22e2708f18 100644 --- a/packages/core/jest.config.ts +++ b/packages/core/jest.config.ts @@ -4,6 +4,8 @@ import base from '../../jest.config.base' import packageJson from './package.json' +process.env.TZ = 'GMT' + const config: Config.InitialOptions = { ...base, name: packageJson.name, diff --git a/packages/core/src/storage/IndyStorageService.ts b/packages/core/src/storage/IndyStorageService.ts index 452ef555c1..bd71d1701f 100644 --- a/packages/core/src/storage/IndyStorageService.ts +++ b/packages/core/src/storage/IndyStorageService.ts @@ -138,6 +138,8 @@ export class IndyStorageService> implements public async save(agentContext: AgentContext, record: T) { assertIndyWallet(agentContext.wallet) + record.updatedAt = new Date() + const value = JsonTransformer.serialize(record) const tags = this.transformFromRecordTagValues(record.getTags()) as Record @@ -157,6 +159,8 @@ export class IndyStorageService> implements public async update(agentContext: AgentContext, record: T): Promise { assertIndyWallet(agentContext.wallet) + record.updatedAt = new Date() + const value = JsonTransformer.serialize(record) const tags = this.transformFromRecordTagValues(record.getTags()) as Record diff --git a/packages/core/src/storage/__tests__/IndyStorageService.test.ts b/packages/core/src/storage/__tests__/IndyStorageService.test.ts index bd61553b08..b517641408 100644 --- a/packages/core/src/storage/__tests__/IndyStorageService.test.ts +++ b/packages/core/src/storage/__tests__/IndyStorageService.test.ts @@ -5,11 +5,14 @@ import type * as Indy from 'indy-sdk' import { agentDependencies, getAgentConfig, getAgentContext } from '../../../tests/helpers' import { SigningProviderRegistry } from '../../crypto/signing-provider' import { RecordDuplicateError, RecordNotFoundError } from '../../error' +import { sleep } from '../../utils/sleep' import { IndyWallet } from '../../wallet/IndyWallet' import { IndyStorageService } from '../IndyStorageService' import { TestRecord } from './TestRecord' +const startDate = Date.now() + describe('IndyStorageService', () => { let wallet: IndyWallet let indy: typeof Indy @@ -113,6 +116,12 @@ describe('IndyStorageService', () => { expect(record).toEqual(found) }) + + it('After a save the record should have update the updatedAt property', async () => { + const time = startDate + const record = await insertRecord({ id: 'test-updatedAt' }) + expect(record.updatedAt?.getTime()).toBeGreaterThan(time) + }) }) describe('getById()', () => { @@ -151,6 +160,18 @@ describe('IndyStorageService', () => { const retrievedRecord = await storageService.getById(agentContext, TestRecord, record.id) expect(retrievedRecord).toEqual(record) }) + + it('After a record has been updated it should have updated the updatedAT property', async () => { + const time = startDate + const record = await insertRecord({ id: 'test-id' }) + + record.replaceTags({ ...record.getTags(), foo: 'bar' }) + record.foo = 'foobaz' + await storageService.update(agentContext, record) + + const retrievedRecord = await storageService.getById(agentContext, TestRecord, record.id) + expect(retrievedRecord.createdAt.getTime()).toBeGreaterThan(time) + }) }) describe('delete()', () => { diff --git a/packages/core/src/storage/migration/__tests__/__snapshots__/0.1.test.ts.snap b/packages/core/src/storage/migration/__tests__/__snapshots__/0.1.test.ts.snap index 241611490a..8fe31caafb 100644 --- a/packages/core/src/storage/migration/__tests__/__snapshots__/0.1.test.ts.snap +++ b/packages/core/src/storage/migration/__tests__/__snapshots__/0.1.test.ts.snap @@ -56,6 +56,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "10-4e4f-41d9-94c4-f49351b811f1": Object { @@ -112,6 +113,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "11-4e4f-41d9-94c4-f49351b811f1": Object { @@ -151,6 +153,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "12-4e4f-41d9-94c4-f49351b811f1": Object { @@ -191,6 +194,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "2-4e4f-41d9-94c4-f49351b811f1": Object { @@ -230,6 +234,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "3-4e4f-41d9-94c4-f49351b811f1": Object { @@ -270,6 +275,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "4-4e4f-41d9-94c4-f49351b811f1": Object { @@ -326,6 +332,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5-4e4f-41d9-94c4-f49351b811f1": Object { @@ -365,6 +372,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "574b2a37-1db1-4af1-a3bf-35c6cb9e1d7a": Object { @@ -410,6 +418,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5f2b7bc7-edfd-47e7-a1d4-aae050df2c4a": Object { @@ -471,6 +480,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "6-4e4f-41d9-94c4-f49351b811f1": Object { @@ -511,6 +521,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7-4e4f-41d9-94c4-f49351b811f1": Object { @@ -567,6 +578,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "8-4e4f-41d9-94c4-f49351b811f1": Object { @@ -606,6 +618,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "9-4e4f-41d9-94c4-f49351b811f1": Object { @@ -646,6 +659,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -657,6 +671,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "ad644d8a-48a2-4c55-b46d-7a7f1a9278c7": Object { @@ -702,6 +717,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "c7e0a752-7f1c-41c0-b0ae-a68c2d97ca8c": Object { @@ -763,6 +779,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -832,6 +849,7 @@ Object { "reuseConnectionId": undefined, "role": "receiver", "state": "done", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "2-4e4f-41d9-94c4-f49351b811f1": Object { @@ -896,6 +914,7 @@ Object { "reuseConnectionId": undefined, "role": "sender", "state": "done", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "3-4e4f-41d9-94c4-f49351b811f1": Object { @@ -960,6 +979,7 @@ Object { "reuseConnectionId": undefined, "role": "sender", "state": "done", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "4-4e4f-41d9-94c4-f49351b811f1": Object { @@ -1024,6 +1044,7 @@ Object { "reuseConnectionId": undefined, "role": "receiver", "state": "done", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5-4e4f-41d9-94c4-f49351b811f1": Object { @@ -1088,6 +1109,7 @@ Object { "reuseConnectionId": undefined, "role": "receiver", "state": "done", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "6-4e4f-41d9-94c4-f49351b811f1": Object { @@ -1147,6 +1169,7 @@ Object { "reuseConnectionId": undefined, "role": "sender", "state": "await-response", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7-4e4f-41d9-94c4-f49351b811f1": Object { @@ -1211,6 +1234,7 @@ Object { "reuseConnectionId": undefined, "role": "sender", "state": "await-response", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7781341d-be29-441b-9b79-4a957d8c6d37": Object { @@ -1244,6 +1268,7 @@ Object { "theirDid": "did:peer:1zQmc3BZoTinpVaG3oZ4PmRVN4JMdNZGCmPkS6smmTNLnvEZ", "theirLabel": "Agent: PopulateWallet2", "threadId": "a0c0e4d2-1501-42a2-a09b-7d5adc90b353", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "8f4908ee-15ad-4058-9106-eda26eae735c": Object { @@ -1277,6 +1302,7 @@ Object { "theirDid": "did:peer:1zQmeHpGaZ48DnAP2k3KntXB1vmd8MgLEdcb4EQzqWJDHcbX", "theirLabel": "Agent: PopulateWallet2", "threadId": "fe287ec6-711b-4582-bb2b-d155aee86e61", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "9383d8e5-c002-4aae-8300-4a21384c919e": Object { @@ -1309,6 +1335,7 @@ Object { "theirDid": "did:peer:1zQmXYj3nNwsF37WXXdb8XkCAtsTCBpJJbsLKPPGfi2PWCTU", "theirLabel": "Agent: PopulateWallet2", "threadId": "0b2f1133-ced9-49f1-83a1-eb6ba1c24cdf", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -1320,6 +1347,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "b65c2ccd-277c-4140-9d87-c8dd30e7a98c": Object { @@ -1349,6 +1377,7 @@ Object { "outOfBandId": "7-4e4f-41d9-94c4-f49351b811f1", "role": "responder", "state": "invitation-sent", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "da518433-0e55-4b74-a05b-aa75c1095a99": Object { @@ -1382,6 +1411,7 @@ Object { "theirDid": "did:peer:1zQmadmBfngrYSWhYYxZ24fpW29iwhKhQ6CB6euLabbSK6ga", "theirLabel": "Agent: PopulateWallet2", "threadId": "6eeb6a80-cd75-491d-b2e0-7bae65ced1c3", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmP96nW6vbNjzwPt19z1NYqhnAfgnAFqfLHcktkmdUFzhT": Object { @@ -1455,6 +1485,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmPbGa8KDwyjcw9UgwCCgJMV7jU5kKCyvBuwFVc88WxA56": Object { @@ -1528,6 +1559,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmRAfQ6J5qk4qcbHyoStFVkhusazLT9xQcFhdC9dhhQ1cJ": Object { @@ -1601,6 +1633,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmSMBVNMDrh7fyE8bkAmk1ZatshjinpsEqPA3nx8JYjuKb": Object { @@ -1674,6 +1707,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmXYj3nNwsF37WXXdb8XkCAtsTCBpJJbsLKPPGfi2PWCTU": Object { @@ -1747,6 +1781,7 @@ Object { }, }, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmZ2tdw35SaLncSHhf9zBv3e9QmJmLErZRSLsDdYowPHXy": Object { @@ -1820,6 +1855,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQma8LpnJ22GxQdyASV5jP6psacAGtJ6ytk4pVayYp4erRf": Object { @@ -1893,6 +1929,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmadmBfngrYSWhYYxZ24fpW29iwhKhQ6CB6euLabbSK6ga": Object { @@ -1966,6 +2003,7 @@ Object { }, }, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmc3BZoTinpVaG3oZ4PmRVN4JMdNZGCmPkS6smmTNLnvEZ": Object { @@ -2039,6 +2077,7 @@ Object { }, }, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmcXZepLE55VGCMELEFjMd4nKrzp3GGyRR3r3MYermagui": Object { @@ -2112,6 +2151,7 @@ Object { }, }, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmduuYkxRKJuVyvDqttdd9eDfBwDnF1DAU5FFQo4whx7Uw": Object { @@ -2185,6 +2225,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmeHpGaZ48DnAP2k3KntXB1vmd8MgLEdcb4EQzqWJDHcbX": Object { @@ -2258,6 +2299,7 @@ Object { }, }, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "did:peer:1zQmfDAtfDZcK4trJBsvVTXrBx9uaLCHSUZH9X2LFaAd3JKv": Object { @@ -2331,6 +2373,7 @@ Object { }, }, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "e3f9bc2b-f0a1-4a2c-ab81-2f0a3488c199": Object { @@ -2364,6 +2407,7 @@ Object { "theirDid": "did:peer:1zQmcXZepLE55VGCMELEFjMd4nKrzp3GGyRR3r3MYermagui", "theirLabel": "Agent: PopulateWallet2", "threadId": "daf3372c-1ee2-4246-a1f4-f62f54f7d68b", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "ee88e2e1-e27e-46a6-a910-f87690109e32": Object { @@ -2393,6 +2437,7 @@ Object { "role": "requester", "state": "request-sent", "theirLabel": "Agent: PopulateWallet2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -2454,6 +2499,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "10-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2510,6 +2556,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "11-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2549,6 +2596,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "12-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2589,6 +2637,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "2-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2628,6 +2677,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "3-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2668,6 +2718,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "4-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2724,6 +2775,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2763,6 +2815,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "574b2a37-1db1-4af1-a3bf-35c6cb9e1d7a": Object { @@ -2808,6 +2861,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5f2b7bc7-edfd-47e7-a1d4-aae050df2c4a": Object { @@ -2869,6 +2923,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "6-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2909,6 +2964,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7-4e4f-41d9-94c4-f49351b811f1": Object { @@ -2965,6 +3021,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "8-4e4f-41d9-94c4-f49351b811f1": Object { @@ -3004,6 +3061,7 @@ Object { }, "metadata": Object {}, "role": "sender", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "9-4e4f-41d9-94c4-f49351b811f1": Object { @@ -3044,6 +3102,7 @@ Object { }, "metadata": Object {}, "role": "receiver", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -3055,6 +3114,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "ad644d8a-48a2-4c55-b46d-7a7f1a9278c7": Object { @@ -3100,6 +3160,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "c7e0a752-7f1c-41c0-b0ae-a68c2d97ca8c": Object { @@ -3161,6 +3222,7 @@ Object { "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -3191,6 +3253,7 @@ Object { ], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7f14c1ec-514c-49b2-a00b-04af7e600060": Object { @@ -3216,6 +3279,7 @@ Object { ], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "802ef124-36b7-490f-b152-e9d090ddf073": Object { @@ -3238,6 +3302,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -3249,6 +3314,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "a29b39fb-f030-41ac-b6e1-ed7f3f6a05cd": Object { @@ -3271,6 +3337,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -3301,6 +3368,7 @@ Object { ], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7f14c1ec-514c-49b2-a00b-04af7e600060": Object { @@ -3326,6 +3394,7 @@ Object { ], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "802ef124-36b7-490f-b152-e9d090ddf073": Object { @@ -3348,6 +3417,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -3359,6 +3429,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "a29b39fb-f030-41ac-b6e1-ed7f3f6a05cd": Object { @@ -3381,6 +3452,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -3411,6 +3483,7 @@ Object { ], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7f14c1ec-514c-49b2-a00b-04af7e600060": Object { @@ -3436,6 +3509,7 @@ Object { ], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "802ef124-36b7-490f-b152-e9d090ddf073": Object { @@ -3458,6 +3532,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -3469,6 +3544,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "a29b39fb-f030-41ac-b6e1-ed7f3f6a05cd": Object { @@ -3491,6 +3567,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -3521,6 +3598,7 @@ Object { ], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7f14c1ec-514c-49b2-a00b-04af7e600060": Object { @@ -3546,6 +3624,7 @@ Object { ], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "802ef124-36b7-490f-b152-e9d090ddf073": Object { @@ -3568,6 +3647,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "e9aeea8f-2c7a-4fd0-9353-f8b5b76094e7", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -3579,6 +3659,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.2", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "a29b39fb-f030-41ac-b6e1-ed7f3f6a05cd": Object { @@ -3601,6 +3682,7 @@ Object { "routingKeys": Array [], "state": "granted", "threadId": "a401880b-8129-4ed9-bcaa-57d0e38026cd", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } diff --git a/packages/core/src/storage/migration/__tests__/__snapshots__/0.2.test.ts.snap b/packages/core/src/storage/migration/__tests__/__snapshots__/0.2.test.ts.snap index a56e8065c1..8d76122ef4 100644 --- a/packages/core/src/storage/migration/__tests__/__snapshots__/0.2.test.ts.snap +++ b/packages/core/src/storage/migration/__tests__/__snapshots__/0.2.test.ts.snap @@ -122,6 +122,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.3.1", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "ea840186-3c77-45f4-a2e6-349811ad8994": Object { @@ -302,6 +303,7 @@ Object { "id": "1-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "2-4e4f-41d9-94c4-f49351b811f1": Object { @@ -364,6 +366,7 @@ Object { "id": "2-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "3-4e4f-41d9-94c4-f49351b811f1": Object { @@ -426,6 +429,7 @@ Object { "id": "3-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "4-4e4f-41d9-94c4-f49351b811f1": Object { @@ -490,6 +494,7 @@ Object { "id": "4-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5-4e4f-41d9-94c4-f49351b811f1": Object { @@ -552,6 +557,7 @@ Object { "id": "5-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "6-4e4f-41d9-94c4-f49351b811f1": Object { @@ -614,6 +620,7 @@ Object { "id": "6-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7-4e4f-41d9-94c4-f49351b811f1": Object { @@ -676,6 +683,7 @@ Object { "id": "7-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "8-4e4f-41d9-94c4-f49351b811f1": Object { @@ -738,6 +746,7 @@ Object { "id": "8-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -749,6 +758,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.3.1", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } @@ -876,6 +886,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.3.1", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "ea840186-3c77-45f4-a2e6-349811ad8994": Object { diff --git a/packages/core/src/storage/migration/__tests__/__snapshots__/0.3.test.ts.snap b/packages/core/src/storage/migration/__tests__/__snapshots__/0.3.test.ts.snap index 8169373e57..d75c5d4c22 100644 --- a/packages/core/src/storage/migration/__tests__/__snapshots__/0.3.test.ts.snap +++ b/packages/core/src/storage/migration/__tests__/__snapshots__/0.3.test.ts.snap @@ -64,6 +64,7 @@ Object { "id": "1-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "2-4e4f-41d9-94c4-f49351b811f1": Object { @@ -126,6 +127,7 @@ Object { "id": "2-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "3-4e4f-41d9-94c4-f49351b811f1": Object { @@ -188,6 +190,7 @@ Object { "id": "3-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "4-4e4f-41d9-94c4-f49351b811f1": Object { @@ -252,6 +255,7 @@ Object { "id": "4-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "5-4e4f-41d9-94c4-f49351b811f1": Object { @@ -314,6 +318,7 @@ Object { "id": "5-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "6-4e4f-41d9-94c4-f49351b811f1": Object { @@ -376,6 +381,7 @@ Object { "id": "6-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "7-4e4f-41d9-94c4-f49351b811f1": Object { @@ -438,6 +444,7 @@ Object { "id": "7-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "received", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "8-4e4f-41d9-94c4-f49351b811f1": Object { @@ -500,6 +507,7 @@ Object { "id": "8-4e4f-41d9-94c4-f49351b811f1", "metadata": Object {}, "role": "created", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, "STORAGE_VERSION_RECORD_ID": Object { @@ -511,6 +519,7 @@ Object { "id": "STORAGE_VERSION_RECORD_ID", "metadata": Object {}, "storageVersion": "0.3.1", + "updatedAt": "2022-01-21T22:50:20.522Z", }, }, } diff --git a/packages/core/src/storage/migration/__tests__/__snapshots__/backup.test.ts.snap b/packages/core/src/storage/migration/__tests__/__snapshots__/backup.test.ts.snap index 04765793f5..676480ae59 100644 --- a/packages/core/src/storage/migration/__tests__/__snapshots__/backup.test.ts.snap +++ b/packages/core/src/storage/migration/__tests__/__snapshots__/backup.test.ts.snap @@ -39,6 +39,7 @@ Array [ "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-03-21T22:50:20.522Z", }, Object { "_tags": Object { @@ -94,6 +95,7 @@ Array [ "protocolVersion": "v1", "state": "done", "threadId": "578e73da-c3be-43d4-949b-7aadfd5a6eae", + "updatedAt": "2022-03-21T22:50:20.522Z", }, Object { "_tags": Object { @@ -132,6 +134,7 @@ Array [ "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-03-21T22:50:20.522Z", }, Object { "_tags": Object { @@ -187,6 +190,7 @@ Array [ "protocolVersion": "v1", "state": "done", "threadId": "e2c2194c-6ac6-4b27-9030-18887c79b5eb", + "updatedAt": "2022-03-21T22:50:20.522Z", }, ] `; diff --git a/tests/InMemoryStorageService.ts b/tests/InMemoryStorageService.ts index cd4415a2e5..0b2a73ebb4 100644 --- a/tests/InMemoryStorageService.ts +++ b/tests/InMemoryStorageService.ts @@ -35,6 +35,7 @@ export class InMemoryStorageService implement /** @inheritDoc */ public async save(agentContext: AgentContext, record: T) { + record.updatedAt = new Date() const value = JsonTransformer.toJSON(record) if (this.records[record.id]) { @@ -51,6 +52,7 @@ export class InMemoryStorageService implement /** @inheritDoc */ public async update(agentContext: AgentContext, record: T): Promise { + record.updatedAt = new Date() const value = JsonTransformer.toJSON(record) delete value._tags