@casual-simulation/aux-records 3.4.6-alpha.14668890889 → 3.5.0-alpha.15119114602
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/AIController.js +835 -890
- package/AIController.js.map +1 -1
- package/AIHumeInterface.js +43 -54
- package/AIHumeInterface.js.map +1 -1
- package/AIOpenAIRealtimeInterface.js +60 -71
- package/AIOpenAIRealtimeInterface.js.map +1 -1
- package/AnthropicAIChatInterface.js +96 -142
- package/AnthropicAIChatInterface.js.map +1 -1
- package/AuthController.d.ts +3 -2
- package/AuthController.js +1907 -1933
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +1 -10
- package/BlockadeLabsGenerateSkyboxInterface.js +57 -72
- package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
- package/CachingConfigStore.js +30 -45
- package/CachingConfigStore.js.map +1 -1
- package/CachingPolicyStore.d.ts +8 -2
- package/CachingPolicyStore.js +108 -135
- package/CachingPolicyStore.js.map +1 -1
- package/ComIdConfig.d.ts +18 -18
- package/ComIdConfig.js.map +1 -1
- package/ConsoleAuthMessenger.js +7 -20
- package/ConsoleAuthMessenger.js.map +1 -1
- package/DataRecordsController.d.ts +2 -2
- package/DataRecordsController.js +369 -377
- package/DataRecordsController.js.map +1 -1
- package/DataRecordsStore.d.ts +1 -1
- package/DataRecordsStore.js +1 -1
- package/DataRecordsStore.js.map +1 -1
- package/EventRecordsController.js +226 -240
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.d.ts +13 -2
- package/FileRecordsController.js +458 -450
- package/FileRecordsController.js.map +1 -1
- package/GoogleAIChatInterface.js +133 -179
- package/GoogleAIChatInterface.js.map +1 -1
- package/LivekitController.js +43 -54
- package/LivekitController.js.map +1 -1
- package/LoomController.js +64 -75
- package/LoomController.js.map +1 -1
- package/MemoryAuthMessenger.js +10 -23
- package/MemoryAuthMessenger.js.map +1 -1
- package/MemoryCache.js +18 -35
- package/MemoryCache.js.map +1 -1
- package/MemoryFileRecordsLookup.js +105 -125
- package/MemoryFileRecordsLookup.js.map +1 -1
- package/MemoryModerationJobProvider.js +17 -30
- package/MemoryModerationJobProvider.js.map +1 -1
- package/MemoryRateLimiter.js +12 -27
- package/MemoryRateLimiter.js.map +1 -1
- package/MemoryStore.d.ts +18 -6
- package/MemoryStore.js +1879 -1997
- package/MemoryStore.js.map +1 -1
- package/MetricsStore.d.ts +2 -2
- package/ModerationController.js +186 -200
- package/ModerationController.js.map +1 -1
- package/OpenAIChatInterface.js +105 -135
- package/OpenAIChatInterface.js.map +1 -1
- package/OpenAIImageInterface.js +57 -51
- package/OpenAIImageInterface.js.map +1 -1
- package/PolicyController.d.ts +150 -10
- package/PolicyController.js +1546 -1299
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +110 -2
- package/PolicyStore.js +36 -1
- package/PolicyStore.js.map +1 -1
- package/PrivoClient.js +398 -435
- package/PrivoClient.js.map +1 -1
- package/RateLimitController.js +25 -36
- package/RateLimitController.js.map +1 -1
- package/RecordsClient.js +51 -74
- package/RecordsClient.js.map +1 -1
- package/RecordsController.d.ts +2 -42
- package/RecordsController.js +1026 -1182
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +196 -27
- package/RecordsServer.js +1701 -1343
- package/RecordsServer.js.map +1 -1
- package/RecordsStore.d.ts +1 -10
- package/RecordsStore.js.map +1 -1
- package/ServerConfig.d.ts +339 -195
- package/ServerConfig.js +13 -0
- package/ServerConfig.js.map +1 -1
- package/SloydInterface.js +62 -75
- package/SloydInterface.js.map +1 -1
- package/StabilityAIImageInterface.js +150 -167
- package/StabilityAIImageInterface.js.map +1 -1
- package/SubscriptionConfigBuilder.d.ts +6 -1
- package/SubscriptionConfigBuilder.js +22 -0
- package/SubscriptionConfigBuilder.js.map +1 -1
- package/SubscriptionConfiguration.d.ts +266 -169
- package/SubscriptionConfiguration.js +101 -79
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +2 -1
- package/SubscriptionController.js +643 -650
- package/SubscriptionController.js.map +1 -1
- package/SystemNotificationMessenger.d.ts +21 -4
- package/SystemNotificationMessenger.js +36 -30
- package/SystemNotificationMessenger.js.map +1 -1
- package/TestUtils.d.ts +9 -1
- package/TestUtils.js +105 -129
- package/TestUtils.js.map +1 -1
- package/Utils.d.ts +2 -16
- package/Utils.js +21 -22
- package/Utils.js.map +1 -1
- package/crud/CrudHelpers.js +17 -26
- package/crud/CrudHelpers.js.map +1 -1
- package/crud/CrudRecordsController.d.ts +1 -1
- package/crud/CrudRecordsController.js +259 -267
- package/crud/CrudRecordsController.js.map +1 -1
- package/crud/CrudRecordsControllerTests.js +174 -185
- package/crud/CrudRecordsControllerTests.js.map +1 -1
- package/crud/CrudRecordsStore.d.ts +7 -3
- package/crud/MemoryCrudRecordsStore.d.ts +4 -4
- package/crud/MemoryCrudRecordsStore.js +98 -118
- package/crud/MemoryCrudRecordsStore.js.map +1 -1
- package/crud/sub/MemorySubCrudRecordsStore.d.ts +24 -0
- package/crud/sub/MemorySubCrudRecordsStore.js +146 -0
- package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -0
- package/crud/sub/SubCrudRecordsController.d.ts +182 -0
- package/crud/sub/SubCrudRecordsController.js +360 -0
- package/crud/sub/SubCrudRecordsController.js.map +1 -0
- package/crud/sub/SubCrudRecordsControllerTests.d.ts +39 -0
- package/crud/sub/SubCrudRecordsControllerTests.js +821 -0
- package/crud/sub/SubCrudRecordsControllerTests.js.map +1 -0
- package/crud/sub/SubCrudRecordsStore.d.ts +95 -0
- package/{forms/index.js → crud/sub/SubCrudRecordsStore.js} +2 -2
- package/crud/sub/SubCrudRecordsStore.js.map +1 -0
- package/crud/sub/index.d.ts +3 -0
- package/crud/sub/index.js +20 -0
- package/{forms → crud/sub}/index.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/notifications/MemoryNotificationRecordsStore.js +189 -198
- package/notifications/MemoryNotificationRecordsStore.js.map +1 -1
- package/notifications/NotificationRecordsController.js +438 -460
- package/notifications/NotificationRecordsController.js.map +1 -1
- package/notifications/NotificationRecordsStore.d.ts +2 -1
- package/notifications/WebPushInterface.d.ts +0 -1
- package/notifications/WebPushInterface.js +0 -1
- package/notifications/WebPushInterface.js.map +1 -1
- package/package.json +6 -6
- package/packages/MemoryPackageRecordsStore.d.ts +10 -0
- package/packages/MemoryPackageRecordsStore.js +38 -0
- package/packages/MemoryPackageRecordsStore.js.map +1 -0
- package/packages/PackageRecordsController.d.ts +26 -0
- package/packages/PackageRecordsController.js +49 -0
- package/packages/PackageRecordsController.js.map +1 -0
- package/packages/PackageRecordsStore.d.ts +32 -0
- package/packages/PackageRecordsStore.js +19 -0
- package/packages/PackageRecordsStore.js.map +1 -0
- package/packages/index.d.ts +4 -0
- package/packages/index.js +21 -0
- package/packages/index.js.map +1 -0
- package/packages/version/MemoryPackageVersionRecordsStore.d.ts +21 -0
- package/packages/version/MemoryPackageVersionRecordsStore.js +177 -0
- package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -0
- package/packages/version/PackageVersionRecordsController.d.ts +144 -0
- package/packages/version/PackageVersionRecordsController.js +656 -0
- package/packages/version/PackageVersionRecordsController.js.map +1 -0
- package/packages/version/PackageVersionRecordsStore.d.ts +342 -0
- package/packages/version/PackageVersionRecordsStore.js +126 -0
- package/packages/version/PackageVersionRecordsStore.js.map +1 -0
- package/packages/version/index.d.ts +4 -0
- package/packages/version/index.js +21 -0
- package/packages/version/index.js.map +1 -0
- package/tracing/TracingDecorators.js +31 -40
- package/tracing/TracingDecorators.js.map +1 -1
- package/webhooks/MemoryWebhookRecordsStore.js +56 -72
- package/webhooks/MemoryWebhookRecordsStore.js.map +1 -1
- package/webhooks/WebhookEnvironment.d.ts +3 -3
- package/webhooks/WebhookRecordsController.d.ts +2 -1
- package/webhooks/WebhookRecordsController.js +389 -382
- package/webhooks/WebhookRecordsController.js.map +1 -1
- package/webhooks/WebhookRecordsStore.d.ts +2 -1
- package/websockets/InstRecordsStore.d.ts +50 -0
- package/websockets/InstRecordsStore.js +17 -0
- package/websockets/InstRecordsStore.js.map +1 -1
- package/websockets/MemoryTempInstRecordsStore.d.ts +5 -0
- package/websockets/MemoryTempInstRecordsStore.js +168 -179
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
- package/websockets/MemoryWebsocketConnectionStore.js +98 -135
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
- package/websockets/MemoryWebsocketMessenger.js +29 -48
- package/websockets/MemoryWebsocketMessenger.js.map +1 -1
- package/websockets/SplitInstRecordsStore.d.ts +4 -1
- package/websockets/SplitInstRecordsStore.js +167 -185
- package/websockets/SplitInstRecordsStore.js.map +1 -1
- package/websockets/TemporaryInstRecordsStore.d.ts +19 -1
- package/websockets/TemporaryInstRecordsStore.js +17 -0
- package/websockets/TemporaryInstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +147 -3
- package/websockets/WebsocketController.js +1735 -1391
- package/websockets/WebsocketController.js.map +1 -1
- package/websockets/index.d.ts +0 -1
- package/websockets/index.js +0 -1
- package/websockets/index.js.map +1 -1
- package/AAGUID.d.ts +0 -11
- package/AAGUID.js +0 -116
- package/AAGUID.js.map +0 -1
- package/AuthUtils.d.ts +0 -162
- package/AuthUtils.js +0 -327
- package/AuthUtils.js.map +0 -1
- package/forms/FormError.d.ts +0 -43
- package/forms/FormError.js +0 -56
- package/forms/FormError.js.map +0 -1
- package/forms/index.d.ts +0 -2
- package/websockets/Utils.d.ts +0 -33
- package/websockets/Utils.js +0 -82
- package/websockets/Utils.js.map +0 -1
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { createTestControllers, createTestRecordKey, createTestUser, } from '../TestUtils';
|
|
11
2
|
import { PRIVATE_MARKER, PUBLIC_READ_MARKER, } from '@casual-simulation/aux-common';
|
|
12
3
|
/**
|
|
@@ -14,48 +5,46 @@ import { PRIVATE_MARKER, PUBLIC_READ_MARKER, } from '@casual-simulation/aux-comm
|
|
|
14
5
|
* @param storeFactory The factory function that creates the store.
|
|
15
6
|
* @param controllerFactory The factory function that creates the controller.
|
|
16
7
|
*/
|
|
17
|
-
export function setupTestContext(storeFactory, controllerFactory) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
phoneNumber: null,
|
|
44
|
-
});
|
|
45
|
-
return {
|
|
46
|
-
services,
|
|
47
|
-
key,
|
|
48
|
-
manager,
|
|
49
|
-
otherUserId,
|
|
50
|
-
sessionKey,
|
|
51
|
-
store,
|
|
52
|
-
itemsStore,
|
|
53
|
-
subjectlessKey,
|
|
54
|
-
userId,
|
|
55
|
-
recordName,
|
|
56
|
-
connectionKey,
|
|
57
|
-
};
|
|
8
|
+
export async function setupTestContext(storeFactory, controllerFactory) {
|
|
9
|
+
const services = createTestControllers();
|
|
10
|
+
const store = services.store;
|
|
11
|
+
const itemsStore = storeFactory(services);
|
|
12
|
+
const policies = services.policies;
|
|
13
|
+
const recordName = 'testRecord';
|
|
14
|
+
const manager = controllerFactory({
|
|
15
|
+
policies,
|
|
16
|
+
store: itemsStore,
|
|
17
|
+
config: store,
|
|
18
|
+
}, services);
|
|
19
|
+
const user = await createTestUser(services, 'test@example.com');
|
|
20
|
+
const userId = user.userId;
|
|
21
|
+
const sessionKey = user.sessionKey;
|
|
22
|
+
const connectionKey = user.connectionKey;
|
|
23
|
+
const testRecordKey = await createTestRecordKey(services, userId, recordName, 'subjectfull');
|
|
24
|
+
const key = testRecordKey.recordKey;
|
|
25
|
+
const subjectlessRecordKey = await createTestRecordKey(services, userId, recordName, 'subjectless');
|
|
26
|
+
const subjectlessKey = subjectlessRecordKey.recordKey;
|
|
27
|
+
const otherUserId = 'otherUserId';
|
|
28
|
+
await store.saveUser({
|
|
29
|
+
id: otherUserId,
|
|
30
|
+
allSessionRevokeTimeMs: null,
|
|
31
|
+
currentLoginRequestId: null,
|
|
32
|
+
email: 'other@example.com',
|
|
33
|
+
phoneNumber: null,
|
|
58
34
|
});
|
|
35
|
+
return {
|
|
36
|
+
services,
|
|
37
|
+
key,
|
|
38
|
+
manager,
|
|
39
|
+
otherUserId,
|
|
40
|
+
sessionKey,
|
|
41
|
+
store,
|
|
42
|
+
itemsStore,
|
|
43
|
+
subjectlessKey,
|
|
44
|
+
userId,
|
|
45
|
+
recordName,
|
|
46
|
+
connectionKey,
|
|
47
|
+
};
|
|
59
48
|
}
|
|
60
49
|
/**
|
|
61
50
|
* Runs all of the common tests for a CRUD records controller.
|
|
@@ -80,8 +69,8 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
80
69
|
let sessionKey;
|
|
81
70
|
let otherUserId;
|
|
82
71
|
let recordName;
|
|
83
|
-
beforeEach(() =>
|
|
84
|
-
context =
|
|
72
|
+
beforeEach(async () => {
|
|
73
|
+
context = await setupTestContext(storeFactory, controllerFactory);
|
|
85
74
|
services = context.services;
|
|
86
75
|
store = context.store;
|
|
87
76
|
itemsStore = context.itemsStore;
|
|
@@ -95,17 +84,17 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
95
84
|
otherUserId = context.otherUserId;
|
|
96
85
|
recordName = context.recordName;
|
|
97
86
|
if (configureEnvironment) {
|
|
98
|
-
|
|
87
|
+
await configureEnvironment(context);
|
|
99
88
|
}
|
|
100
|
-
})
|
|
89
|
+
});
|
|
101
90
|
describe('recordItem()', () => {
|
|
102
91
|
describe('create', () => {
|
|
103
|
-
it('should store the item in the store', () =>
|
|
92
|
+
it('should store the item in the store', async () => {
|
|
104
93
|
const item = createTestItem({
|
|
105
94
|
address: 'address',
|
|
106
95
|
markers: [PUBLIC_READ_MARKER],
|
|
107
96
|
});
|
|
108
|
-
const result = (
|
|
97
|
+
const result = (await manager.recordItem({
|
|
109
98
|
recordKeyOrRecordName: recordName,
|
|
110
99
|
userId,
|
|
111
100
|
item,
|
|
@@ -116,10 +105,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
116
105
|
recordName: recordName,
|
|
117
106
|
address: 'address',
|
|
118
107
|
});
|
|
119
|
-
|
|
120
|
-
})
|
|
121
|
-
it('should reject the request if given an invalid key', () =>
|
|
122
|
-
const result = (
|
|
108
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
109
|
+
});
|
|
110
|
+
it('should reject the request if given an invalid key', async () => {
|
|
111
|
+
const result = (await manager.recordItem({
|
|
123
112
|
recordKeyOrRecordName: 'not_a_key',
|
|
124
113
|
userId,
|
|
125
114
|
item: createTestItem({
|
|
@@ -133,11 +122,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
133
122
|
errorCode: 'record_not_found',
|
|
134
123
|
errorMessage: expect.any(String),
|
|
135
124
|
});
|
|
136
|
-
|
|
137
|
-
})
|
|
125
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
126
|
+
});
|
|
138
127
|
if (allowRecordKeys) {
|
|
139
|
-
it('should support using a record key', () =>
|
|
140
|
-
const result = (
|
|
128
|
+
it('should support using a record key', async () => {
|
|
129
|
+
const result = (await manager.recordItem({
|
|
141
130
|
recordKeyOrRecordName: key,
|
|
142
131
|
userId: otherUserId,
|
|
143
132
|
item: createTestItem({
|
|
@@ -151,13 +140,13 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
151
140
|
recordName: recordName,
|
|
152
141
|
address: 'address',
|
|
153
142
|
});
|
|
154
|
-
|
|
143
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toEqual({
|
|
155
144
|
address: 'address',
|
|
156
145
|
markers: [PUBLIC_READ_MARKER],
|
|
157
146
|
});
|
|
158
|
-
})
|
|
159
|
-
it('should be able to use subjectless keys', () =>
|
|
160
|
-
const result = (
|
|
147
|
+
});
|
|
148
|
+
it('should be able to use subjectless keys', async () => {
|
|
149
|
+
const result = (await manager.recordItem({
|
|
161
150
|
recordKeyOrRecordName: subjectlessKey,
|
|
162
151
|
userId: otherUserId,
|
|
163
152
|
item: createTestItem({
|
|
@@ -171,15 +160,15 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
171
160
|
recordName: recordName,
|
|
172
161
|
address: 'address',
|
|
173
162
|
});
|
|
174
|
-
|
|
163
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toEqual({
|
|
175
164
|
address: 'address',
|
|
176
165
|
markers: [PUBLIC_READ_MARKER],
|
|
177
166
|
});
|
|
178
|
-
})
|
|
167
|
+
});
|
|
179
168
|
}
|
|
180
169
|
else {
|
|
181
|
-
it('should reject the request if record keys are not allowed', () =>
|
|
182
|
-
const result = (
|
|
170
|
+
it('should reject the request if record keys are not allowed', async () => {
|
|
171
|
+
const result = (await manager.recordItem({
|
|
183
172
|
recordKeyOrRecordName: key,
|
|
184
173
|
userId: otherUserId,
|
|
185
174
|
item: createTestItem({
|
|
@@ -202,10 +191,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
202
191
|
subjectId: otherUserId,
|
|
203
192
|
},
|
|
204
193
|
});
|
|
205
|
-
|
|
206
|
-
})
|
|
207
|
-
it('should reject the request if subjectless keys are not allowed', () =>
|
|
208
|
-
const result = (
|
|
194
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
195
|
+
});
|
|
196
|
+
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
197
|
+
const result = (await manager.recordItem({
|
|
209
198
|
recordKeyOrRecordName: subjectlessKey,
|
|
210
199
|
userId: otherUserId,
|
|
211
200
|
item: createTestItem({
|
|
@@ -228,23 +217,23 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
228
217
|
subjectId: otherUserId,
|
|
229
218
|
},
|
|
230
219
|
});
|
|
231
|
-
|
|
232
|
-
})
|
|
220
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toBeFalsy();
|
|
221
|
+
});
|
|
233
222
|
}
|
|
234
223
|
});
|
|
235
224
|
describe('update', () => {
|
|
236
|
-
beforeEach(() =>
|
|
237
|
-
|
|
225
|
+
beforeEach(async () => {
|
|
226
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
238
227
|
address: 'address',
|
|
239
228
|
markers: [PUBLIC_READ_MARKER],
|
|
240
229
|
}));
|
|
241
|
-
})
|
|
242
|
-
it('should update the markers in the store', () =>
|
|
230
|
+
});
|
|
231
|
+
it('should update the markers in the store', async () => {
|
|
243
232
|
const item = createTestItem({
|
|
244
233
|
address: 'address',
|
|
245
234
|
markers: [PRIVATE_MARKER],
|
|
246
235
|
});
|
|
247
|
-
const result = (
|
|
236
|
+
const result = (await manager.recordItem({
|
|
248
237
|
recordKeyOrRecordName: recordName,
|
|
249
238
|
userId,
|
|
250
239
|
item,
|
|
@@ -255,14 +244,14 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
255
244
|
recordName: recordName,
|
|
256
245
|
address: 'address',
|
|
257
246
|
});
|
|
258
|
-
|
|
259
|
-
})
|
|
260
|
-
it('should reject the request if given an invalid key', () =>
|
|
247
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
248
|
+
});
|
|
249
|
+
it('should reject the request if given an invalid key', async () => {
|
|
261
250
|
const item = createTestItem({
|
|
262
251
|
address: 'address',
|
|
263
252
|
markers: [PUBLIC_READ_MARKER],
|
|
264
253
|
});
|
|
265
|
-
const result = (
|
|
254
|
+
const result = (await manager.recordItem({
|
|
266
255
|
recordKeyOrRecordName: 'not_a_key',
|
|
267
256
|
userId,
|
|
268
257
|
item,
|
|
@@ -273,15 +262,15 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
273
262
|
errorCode: 'record_not_found',
|
|
274
263
|
errorMessage: expect.any(String),
|
|
275
264
|
});
|
|
276
|
-
|
|
277
|
-
})
|
|
265
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
266
|
+
});
|
|
278
267
|
if (allowRecordKeys) {
|
|
279
|
-
it('should support using a record key', () =>
|
|
268
|
+
it('should support using a record key', async () => {
|
|
280
269
|
const item = createTestItem({
|
|
281
270
|
address: 'address',
|
|
282
271
|
markers: [PRIVATE_MARKER],
|
|
283
272
|
});
|
|
284
|
-
const result = (
|
|
273
|
+
const result = (await manager.recordItem({
|
|
285
274
|
recordKeyOrRecordName: key,
|
|
286
275
|
userId,
|
|
287
276
|
item,
|
|
@@ -292,14 +281,14 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
292
281
|
recordName: recordName,
|
|
293
282
|
address: 'address',
|
|
294
283
|
});
|
|
295
|
-
|
|
296
|
-
})
|
|
297
|
-
it('should be able to use subjectless keys', () =>
|
|
284
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
285
|
+
});
|
|
286
|
+
it('should be able to use subjectless keys', async () => {
|
|
298
287
|
const item = createTestItem({
|
|
299
288
|
address: 'address',
|
|
300
289
|
markers: [PRIVATE_MARKER],
|
|
301
290
|
});
|
|
302
|
-
const result = (
|
|
291
|
+
const result = (await manager.recordItem({
|
|
303
292
|
recordKeyOrRecordName: subjectlessKey,
|
|
304
293
|
userId,
|
|
305
294
|
item,
|
|
@@ -310,16 +299,16 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
310
299
|
recordName: recordName,
|
|
311
300
|
address: 'address',
|
|
312
301
|
});
|
|
313
|
-
|
|
314
|
-
})
|
|
302
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(item);
|
|
303
|
+
});
|
|
315
304
|
}
|
|
316
305
|
else {
|
|
317
|
-
it('should reject the request if record keys are not allowed', () =>
|
|
306
|
+
it('should reject the request if record keys are not allowed', async () => {
|
|
318
307
|
const item = createTestItem({
|
|
319
308
|
address: 'address',
|
|
320
309
|
markers: [PRIVATE_MARKER],
|
|
321
310
|
});
|
|
322
|
-
const result = (
|
|
311
|
+
const result = (await manager.recordItem({
|
|
323
312
|
recordKeyOrRecordName: key,
|
|
324
313
|
userId: otherUserId,
|
|
325
314
|
item,
|
|
@@ -339,17 +328,17 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
339
328
|
subjectId: otherUserId,
|
|
340
329
|
},
|
|
341
330
|
});
|
|
342
|
-
|
|
331
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createTestItem({
|
|
343
332
|
address: 'address',
|
|
344
333
|
markers: [PUBLIC_READ_MARKER],
|
|
345
334
|
}));
|
|
346
|
-
})
|
|
347
|
-
it('should reject the request if subjectless keys are not allowed', () =>
|
|
335
|
+
});
|
|
336
|
+
it('should reject the request if subjectless keys are not allowed', async () => {
|
|
348
337
|
const item = createTestItem({
|
|
349
338
|
address: 'address',
|
|
350
339
|
markers: [PRIVATE_MARKER],
|
|
351
340
|
});
|
|
352
|
-
const result = (
|
|
341
|
+
const result = (await manager.recordItem({
|
|
353
342
|
recordKeyOrRecordName: subjectlessKey,
|
|
354
343
|
userId: otherUserId,
|
|
355
344
|
item,
|
|
@@ -369,31 +358,31 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
369
358
|
subjectId: otherUserId,
|
|
370
359
|
},
|
|
371
360
|
});
|
|
372
|
-
|
|
361
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address')).resolves.toMatchObject(createTestItem({
|
|
373
362
|
address: 'address',
|
|
374
363
|
markers: [PUBLIC_READ_MARKER],
|
|
375
364
|
}));
|
|
376
|
-
})
|
|
365
|
+
});
|
|
377
366
|
}
|
|
378
367
|
});
|
|
379
368
|
});
|
|
380
369
|
describe('getItem()', () => {
|
|
381
|
-
beforeEach(() =>
|
|
382
|
-
|
|
370
|
+
beforeEach(async () => {
|
|
371
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
383
372
|
address: 'address',
|
|
384
373
|
markers: [PUBLIC_READ_MARKER],
|
|
385
374
|
}));
|
|
386
|
-
|
|
375
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
387
376
|
address: 'address2',
|
|
388
377
|
markers: [PRIVATE_MARKER],
|
|
389
378
|
}));
|
|
390
|
-
|
|
379
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
391
380
|
address: 'address3',
|
|
392
381
|
markers: [PUBLIC_READ_MARKER],
|
|
393
382
|
}));
|
|
394
|
-
})
|
|
395
|
-
it('should return the item if the user has access', () =>
|
|
396
|
-
const result =
|
|
383
|
+
});
|
|
384
|
+
it('should return the item if the user has access', async () => {
|
|
385
|
+
const result = await manager.getItem({
|
|
397
386
|
recordName: recordName,
|
|
398
387
|
userId,
|
|
399
388
|
address: 'address2',
|
|
@@ -406,9 +395,9 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
406
395
|
markers: [PRIVATE_MARKER],
|
|
407
396
|
}),
|
|
408
397
|
});
|
|
409
|
-
})
|
|
410
|
-
it('should return data_not_found if the item was not found', () =>
|
|
411
|
-
const result =
|
|
398
|
+
});
|
|
399
|
+
it('should return data_not_found if the item was not found', async () => {
|
|
400
|
+
const result = await manager.getItem({
|
|
412
401
|
recordName: recordName,
|
|
413
402
|
userId,
|
|
414
403
|
address: 'missing',
|
|
@@ -419,9 +408,9 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
419
408
|
errorCode: 'data_not_found',
|
|
420
409
|
errorMessage: expect.any(String),
|
|
421
410
|
});
|
|
422
|
-
})
|
|
423
|
-
it('should return record_not_found if the record doesnt exist', () =>
|
|
424
|
-
const result =
|
|
411
|
+
});
|
|
412
|
+
it('should return record_not_found if the record doesnt exist', async () => {
|
|
413
|
+
const result = await manager.getItem({
|
|
425
414
|
recordName: 'missing',
|
|
426
415
|
userId,
|
|
427
416
|
address: 'address',
|
|
@@ -432,10 +421,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
432
421
|
errorCode: 'record_not_found',
|
|
433
422
|
errorMessage: expect.any(String),
|
|
434
423
|
});
|
|
435
|
-
})
|
|
424
|
+
});
|
|
436
425
|
if (allowRecordKeys) {
|
|
437
|
-
it('should be able to use a record key to access the item', () =>
|
|
438
|
-
const result =
|
|
426
|
+
it('should be able to use a record key to access the item', async () => {
|
|
427
|
+
const result = await manager.getItem({
|
|
439
428
|
recordName: key,
|
|
440
429
|
userId,
|
|
441
430
|
address: 'address2',
|
|
@@ -448,11 +437,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
448
437
|
markers: [PRIVATE_MARKER],
|
|
449
438
|
}),
|
|
450
439
|
});
|
|
451
|
-
})
|
|
440
|
+
});
|
|
452
441
|
}
|
|
453
442
|
else {
|
|
454
|
-
it('should return not_authorized if record keys are not allowed', () =>
|
|
455
|
-
const result =
|
|
443
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
444
|
+
const result = await manager.getItem({
|
|
456
445
|
recordName: key,
|
|
457
446
|
userId: otherUserId,
|
|
458
447
|
address: 'address2',
|
|
@@ -472,26 +461,26 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
472
461
|
subjectId: otherUserId,
|
|
473
462
|
},
|
|
474
463
|
});
|
|
475
|
-
})
|
|
464
|
+
});
|
|
476
465
|
}
|
|
477
466
|
});
|
|
478
467
|
describe('eraseItem()', () => {
|
|
479
|
-
beforeEach(() =>
|
|
480
|
-
|
|
468
|
+
beforeEach(async () => {
|
|
469
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
481
470
|
address: 'address',
|
|
482
471
|
markers: [PUBLIC_READ_MARKER],
|
|
483
472
|
}));
|
|
484
|
-
|
|
473
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
485
474
|
address: 'address2',
|
|
486
475
|
markers: [PRIVATE_MARKER],
|
|
487
476
|
}));
|
|
488
|
-
|
|
477
|
+
await itemsStore.createItem(recordName, createTestItem({
|
|
489
478
|
address: 'address3',
|
|
490
479
|
markers: [PUBLIC_READ_MARKER],
|
|
491
480
|
}));
|
|
492
|
-
})
|
|
493
|
-
it('should erase the item if the user has access', () =>
|
|
494
|
-
const result =
|
|
481
|
+
});
|
|
482
|
+
it('should erase the item if the user has access', async () => {
|
|
483
|
+
const result = await manager.eraseItem({
|
|
495
484
|
recordName: recordName,
|
|
496
485
|
userId,
|
|
497
486
|
address: 'address2',
|
|
@@ -500,10 +489,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
500
489
|
expect(result).toEqual({
|
|
501
490
|
success: true,
|
|
502
491
|
});
|
|
503
|
-
|
|
504
|
-
})
|
|
505
|
-
it('should return data_not_found if the item doesnt exist', () =>
|
|
506
|
-
const result =
|
|
492
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeFalsy();
|
|
493
|
+
});
|
|
494
|
+
it('should return data_not_found if the item doesnt exist', async () => {
|
|
495
|
+
const result = await manager.eraseItem({
|
|
507
496
|
recordName: recordName,
|
|
508
497
|
userId,
|
|
509
498
|
address: 'missing',
|
|
@@ -514,10 +503,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
514
503
|
errorCode: 'data_not_found',
|
|
515
504
|
errorMessage: 'The item was not found.',
|
|
516
505
|
});
|
|
517
|
-
})
|
|
506
|
+
});
|
|
518
507
|
if (allowRecordKeys) {
|
|
519
|
-
it('should erase the item if the record key has access', () =>
|
|
520
|
-
const result =
|
|
508
|
+
it('should erase the item if the record key has access', async () => {
|
|
509
|
+
const result = await manager.eraseItem({
|
|
521
510
|
recordName: key,
|
|
522
511
|
userId: otherUserId,
|
|
523
512
|
address: 'address2',
|
|
@@ -526,12 +515,12 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
526
515
|
expect(result).toEqual({
|
|
527
516
|
success: true,
|
|
528
517
|
});
|
|
529
|
-
|
|
530
|
-
})
|
|
518
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeFalsy();
|
|
519
|
+
});
|
|
531
520
|
}
|
|
532
521
|
else {
|
|
533
|
-
it('should return not_authorized if the controller doesnt allow record keys', () =>
|
|
534
|
-
const result =
|
|
522
|
+
it('should return not_authorized if the controller doesnt allow record keys', async () => {
|
|
523
|
+
const result = await manager.eraseItem({
|
|
535
524
|
recordName: key,
|
|
536
525
|
userId: otherUserId,
|
|
537
526
|
address: 'address2',
|
|
@@ -551,11 +540,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
551
540
|
subjectId: otherUserId,
|
|
552
541
|
},
|
|
553
542
|
});
|
|
554
|
-
|
|
555
|
-
})
|
|
543
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeTruthy();
|
|
544
|
+
});
|
|
556
545
|
}
|
|
557
|
-
it('should return record_not_found if the record doesnt exist', () =>
|
|
558
|
-
const result =
|
|
546
|
+
it('should return record_not_found if the record doesnt exist', async () => {
|
|
547
|
+
const result = await manager.eraseItem({
|
|
559
548
|
recordName: 'missing',
|
|
560
549
|
userId,
|
|
561
550
|
address: 'address2',
|
|
@@ -566,24 +555,24 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
566
555
|
errorCode: 'record_not_found',
|
|
567
556
|
errorMessage: expect.any(String),
|
|
568
557
|
});
|
|
569
|
-
|
|
570
|
-
})
|
|
558
|
+
await expect(itemsStore.getItemByAddress(recordName, 'address2')).resolves.toBeTruthy();
|
|
559
|
+
});
|
|
571
560
|
});
|
|
572
561
|
describe('listItems()', () => {
|
|
573
562
|
let items;
|
|
574
|
-
beforeEach(() =>
|
|
563
|
+
beforeEach(async () => {
|
|
575
564
|
items = [];
|
|
576
565
|
for (let i = 0; i < 20; i++) {
|
|
577
566
|
const item = createTestItem({
|
|
578
567
|
address: 'address' + i,
|
|
579
568
|
markers: [PRIVATE_MARKER],
|
|
580
569
|
});
|
|
581
|
-
|
|
570
|
+
await itemsStore.createItem(recordName, item);
|
|
582
571
|
items.push(item);
|
|
583
572
|
}
|
|
584
|
-
})
|
|
585
|
-
it('should return a list of items', () =>
|
|
586
|
-
const result =
|
|
573
|
+
});
|
|
574
|
+
it('should return a list of items', async () => {
|
|
575
|
+
const result = await manager.listItems({
|
|
587
576
|
recordName: recordName,
|
|
588
577
|
userId,
|
|
589
578
|
startingAddress: null,
|
|
@@ -595,10 +584,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
595
584
|
items: items.slice(0, 10),
|
|
596
585
|
totalCount: 20,
|
|
597
586
|
});
|
|
598
|
-
})
|
|
587
|
+
});
|
|
599
588
|
if (allowRecordKeys) {
|
|
600
|
-
it('should be able to use a record key', () =>
|
|
601
|
-
const result =
|
|
589
|
+
it('should be able to use a record key', async () => {
|
|
590
|
+
const result = await manager.listItems({
|
|
602
591
|
recordName: key,
|
|
603
592
|
userId: otherUserId,
|
|
604
593
|
startingAddress: null,
|
|
@@ -610,11 +599,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
610
599
|
items: items.slice(0, 10),
|
|
611
600
|
totalCount: 20,
|
|
612
601
|
});
|
|
613
|
-
})
|
|
602
|
+
});
|
|
614
603
|
}
|
|
615
604
|
else {
|
|
616
|
-
it('should return not_authorized if record keys are not allowed', () =>
|
|
617
|
-
const result =
|
|
605
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
606
|
+
const result = await manager.listItems({
|
|
618
607
|
recordName: key,
|
|
619
608
|
userId: otherUserId,
|
|
620
609
|
startingAddress: null,
|
|
@@ -633,10 +622,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
633
622
|
subjectId: otherUserId,
|
|
634
623
|
},
|
|
635
624
|
});
|
|
636
|
-
})
|
|
625
|
+
});
|
|
637
626
|
}
|
|
638
|
-
it('should return items after the given starting address', () =>
|
|
639
|
-
const result =
|
|
627
|
+
it('should return items after the given starting address', async () => {
|
|
628
|
+
const result = await manager.listItems({
|
|
640
629
|
recordName: recordName,
|
|
641
630
|
userId,
|
|
642
631
|
startingAddress: 'address3',
|
|
@@ -648,9 +637,9 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
648
637
|
items: items.slice(4, 10),
|
|
649
638
|
totalCount: 20,
|
|
650
639
|
});
|
|
651
|
-
})
|
|
652
|
-
it('should return not_authorized if the user does not have access to the account marker', () =>
|
|
653
|
-
const result =
|
|
640
|
+
});
|
|
641
|
+
it('should return not_authorized if the user does not have access to the account marker', async () => {
|
|
642
|
+
const result = await manager.listItems({
|
|
654
643
|
recordName: recordName,
|
|
655
644
|
userId: otherUserId,
|
|
656
645
|
startingAddress: 'address3',
|
|
@@ -670,11 +659,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
670
659
|
type: 'missing_permission',
|
|
671
660
|
},
|
|
672
661
|
});
|
|
673
|
-
})
|
|
662
|
+
});
|
|
674
663
|
});
|
|
675
664
|
describe('listItemsByMarker()', () => {
|
|
676
665
|
let items;
|
|
677
|
-
beforeEach(() =>
|
|
666
|
+
beforeEach(async () => {
|
|
678
667
|
items = [];
|
|
679
668
|
for (let i = 0; i < 40; i++) {
|
|
680
669
|
const item = createTestItem({
|
|
@@ -683,12 +672,12 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
683
672
|
i % 2 === 0 ? PRIVATE_MARKER : PUBLIC_READ_MARKER,
|
|
684
673
|
],
|
|
685
674
|
});
|
|
686
|
-
|
|
675
|
+
await itemsStore.createItem(recordName, item);
|
|
687
676
|
items.push(item);
|
|
688
677
|
}
|
|
689
|
-
})
|
|
690
|
-
it('should return a list of items that have the given marker', () =>
|
|
691
|
-
const result =
|
|
678
|
+
});
|
|
679
|
+
it('should return a list of items that have the given marker', async () => {
|
|
680
|
+
const result = await manager.listItemsByMarker({
|
|
692
681
|
recordName: recordName,
|
|
693
682
|
userId,
|
|
694
683
|
marker: PRIVATE_MARKER,
|
|
@@ -703,9 +692,9 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
703
692
|
.slice(0, 10),
|
|
704
693
|
totalCount: 20,
|
|
705
694
|
});
|
|
706
|
-
})
|
|
707
|
-
it('should return a list of items that are after the starting address', () =>
|
|
708
|
-
const result =
|
|
695
|
+
});
|
|
696
|
+
it('should return a list of items that are after the starting address', async () => {
|
|
697
|
+
const result = await manager.listItemsByMarker({
|
|
709
698
|
recordName: recordName,
|
|
710
699
|
userId,
|
|
711
700
|
marker: PRIVATE_MARKER,
|
|
@@ -720,10 +709,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
720
709
|
.slice(1, 11),
|
|
721
710
|
totalCount: 20,
|
|
722
711
|
});
|
|
723
|
-
})
|
|
712
|
+
});
|
|
724
713
|
if (allowRecordKeys) {
|
|
725
|
-
it('should be able to use a record key', () =>
|
|
726
|
-
const result =
|
|
714
|
+
it('should be able to use a record key', async () => {
|
|
715
|
+
const result = await manager.listItemsByMarker({
|
|
727
716
|
recordName: key,
|
|
728
717
|
userId: otherUserId,
|
|
729
718
|
marker: PRIVATE_MARKER,
|
|
@@ -738,11 +727,11 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
738
727
|
.slice(0, 10),
|
|
739
728
|
totalCount: 20,
|
|
740
729
|
});
|
|
741
|
-
})
|
|
730
|
+
});
|
|
742
731
|
}
|
|
743
732
|
else {
|
|
744
|
-
it('should return not_authorized if record keys are not allowed', () =>
|
|
745
|
-
const result =
|
|
733
|
+
it('should return not_authorized if record keys are not allowed', async () => {
|
|
734
|
+
const result = await manager.listItemsByMarker({
|
|
746
735
|
recordName: key,
|
|
747
736
|
userId: otherUserId,
|
|
748
737
|
marker: PRIVATE_MARKER,
|
|
@@ -762,10 +751,10 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
762
751
|
subjectId: otherUserId,
|
|
763
752
|
},
|
|
764
753
|
});
|
|
765
|
-
})
|
|
754
|
+
});
|
|
766
755
|
}
|
|
767
|
-
it('should return not_authorized if the user does not have access to the marker', () =>
|
|
768
|
-
const result =
|
|
756
|
+
it('should return not_authorized if the user does not have access to the marker', async () => {
|
|
757
|
+
const result = await manager.listItemsByMarker({
|
|
769
758
|
recordName: recordName,
|
|
770
759
|
userId: otherUserId,
|
|
771
760
|
marker: PRIVATE_MARKER,
|
|
@@ -786,7 +775,7 @@ export function testCrudRecordsController(allowRecordKeys, resourceKind, storeFa
|
|
|
786
775
|
type: 'missing_permission',
|
|
787
776
|
},
|
|
788
777
|
});
|
|
789
|
-
})
|
|
778
|
+
});
|
|
790
779
|
});
|
|
791
780
|
}
|
|
792
781
|
//# sourceMappingURL=CrudRecordsControllerTests.js.map
|