@casual-simulation/aux-records 3.8.1 → 3.10.2
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/AIChatInterface.d.ts +7 -43
- package/AIChatInterface.js +8 -6
- package/AIChatInterface.js.map +1 -1
- package/AIController.js +44 -49
- package/AIController.js.map +1 -1
- package/AIOpenAIRealtimeInterface.d.ts +1 -1
- package/AnthropicAIChatInterface.js +4 -4
- package/AnthropicAIChatInterface.js.map +1 -1
- package/AuthController.d.ts +78 -10
- package/AuthController.js +230 -166
- package/AuthController.js.map +1 -1
- package/AuthStore.d.ts +317 -4
- package/BigIntPatch.d.ts +1 -0
- package/BigIntPatch.js +24 -0
- package/BigIntPatch.js.map +1 -0
- package/BlockadeLabsGenerateSkyboxInterface.js +4 -4
- package/BlockadeLabsGenerateSkyboxInterface.js.map +1 -1
- package/CachingConfigStore.d.ts +8 -1
- package/CachingConfigStore.js +50 -0
- package/CachingConfigStore.js.map +1 -1
- package/ComIdConfig.d.ts +132 -86
- package/ComIdConfig.js +5 -5
- package/ComIdConfig.js.map +1 -1
- package/ConfigurationStore.d.ts +1393 -3
- package/ConfigurationStore.js +49 -0
- package/ConfigurationStore.js.map +1 -1
- package/DataRecordsController.js +28 -28
- package/DataRecordsController.js.map +1 -1
- package/EventRecordsController.js +9 -9
- package/EventRecordsController.js.map +1 -1
- package/FileRecordsController.js +18 -17
- package/FileRecordsController.js.map +1 -1
- package/GoogleAIChatInterface.js +4 -4
- package/GoogleAIChatInterface.js.map +1 -1
- package/HttpTestUtils.d.ts +48 -0
- package/HttpTestUtils.js +256 -0
- package/HttpTestUtils.js.map +1 -0
- package/LivekitController.js +2 -2
- package/LivekitController.js.map +1 -1
- package/LoomController.js +3 -4
- package/LoomController.js.map +1 -1
- package/MemoryStore.d.ts +60 -7
- package/MemoryStore.js +427 -59
- package/MemoryStore.js.map +1 -1
- package/MetricsStore.d.ts +11 -0
- package/ModerationConfiguration.d.ts +11 -85
- package/ModerationConfiguration.js +17 -17
- package/ModerationConfiguration.js.map +1 -1
- package/ModerationController.js +9 -11
- package/ModerationController.js.map +1 -1
- package/OpenAIChatInterface.js +8 -13
- package/OpenAIChatInterface.js.map +1 -1
- package/OpenAIImageInterface.js +4 -5
- package/OpenAIImageInterface.js.map +1 -1
- package/PolicyController.js +66 -73
- package/PolicyController.js.map +1 -1
- package/PolicyStore.d.ts +59 -33
- package/PolicyStore.js +35 -1
- package/PolicyStore.js.map +1 -1
- package/PrivoClient.d.ts +3 -1
- package/PrivoClient.js +2 -4
- package/PrivoClient.js.map +1 -1
- package/PrivoConfiguration.d.ts +6 -72
- package/PrivoConfiguration.js +30 -31
- package/PrivoConfiguration.js.map +1 -1
- package/README.md +276 -2
- package/RateLimitController.js +2 -2
- package/RateLimitController.js.map +1 -1
- package/RecordsClient.d.ts +3 -1
- package/RecordsClient.js +6 -6
- package/RecordsClient.js.map +1 -1
- package/RecordsController.d.ts +145 -3
- package/RecordsController.js +399 -61
- package/RecordsController.js.map +1 -1
- package/RecordsServer.d.ts +1932 -1109
- package/RecordsStore.d.ts +99 -14
- package/RecordsStore.js +8 -10
- package/RecordsStore.js.map +1 -1
- package/ServerConfig.d.ts +698 -9867
- package/ServerConfig.js +457 -377
- package/ServerConfig.js.map +1 -1
- package/SloydInterface.js +1 -1
- package/SloydInterface.js.map +1 -1
- package/StabilityAIImageInterface.js +6 -9
- package/StabilityAIImageInterface.js.map +1 -1
- package/StripeInterface.d.ts +431 -287
- package/StripeInterface.js +21 -1
- package/StripeInterface.js.map +1 -1
- package/SubscriptionConfigBuilder.d.ts +10 -1
- package/SubscriptionConfigBuilder.js +72 -41
- package/SubscriptionConfigBuilder.js.map +1 -1
- package/SubscriptionConfiguration.d.ts +606 -6334
- package/SubscriptionConfiguration.js +460 -277
- package/SubscriptionConfiguration.js.map +1 -1
- package/SubscriptionController.d.ts +677 -4
- package/SubscriptionController.js +2986 -186
- package/SubscriptionController.js.map +1 -1
- package/SystemNotificationMessenger.d.ts +14 -70
- package/SystemNotificationMessenger.js +17 -20
- package/SystemNotificationMessenger.js.map +1 -1
- package/TestUtils.d.ts +18 -3
- package/TestUtils.js +84 -8
- package/TestUtils.js.map +1 -1
- package/TypeUtils.d.ts +991 -0
- package/TypeUtils.js +2 -0
- package/TypeUtils.js.map +1 -0
- package/Utils.d.ts +59 -0
- package/Utils.js +507 -3
- package/Utils.js.map +1 -1
- package/Validations.d.ts +24 -108
- package/Validations.js +62 -45
- package/Validations.js.map +1 -1
- package/ViewTemplateRenderer.d.ts +39 -0
- package/ViewTemplateRenderer.js +19 -0
- package/ViewTemplateRenderer.js.map +1 -0
- package/contracts/ContractRecordsController.d.ts +58 -0
- package/contracts/ContractRecordsController.js +144 -0
- package/contracts/ContractRecordsController.js.map +1 -0
- package/contracts/ContractRecordsStore.d.ts +285 -0
- package/contracts/ContractRecordsStore.js +19 -0
- package/contracts/ContractRecordsStore.js.map +1 -0
- package/contracts/MemoryContractRecordsStore.d.ts +27 -0
- package/contracts/MemoryContractRecordsStore.js +124 -0
- package/contracts/MemoryContractRecordsStore.js.map +1 -0
- package/contracts/index.d.ts +4 -0
- package/contracts/index.js +21 -0
- package/contracts/index.js.map +1 -0
- package/crud/CrudHelpers.d.ts +25 -26
- package/crud/CrudHelpers.js +1 -1
- package/crud/CrudHelpers.js.map +1 -1
- package/crud/CrudRecordsController.js +13 -16
- package/crud/CrudRecordsController.js.map +1 -1
- package/crud/CrudRecordsControllerTests.d.ts +2 -2
- package/crud/CrudRecordsControllerTests.js +605 -580
- package/crud/CrudRecordsControllerTests.js.map +1 -1
- package/crud/MemoryCrudRecordsStore.js +1 -2
- package/crud/MemoryCrudRecordsStore.js.map +1 -1
- package/crud/sub/MemorySubCrudRecordsStore.js +4 -6
- package/crud/sub/MemorySubCrudRecordsStore.js.map +1 -1
- package/crud/sub/SubCrudRecordsController.js +8 -8
- package/crud/sub/SubCrudRecordsController.js.map +1 -1
- package/database/DatabaseRecordsController.js +1 -2
- package/database/DatabaseRecordsController.js.map +1 -1
- package/database/SqliteDatabaseInterface.js +1 -2
- package/database/SqliteDatabaseInterface.js.map +1 -1
- package/dns/DNSDomainNameValidator.d.ts +11 -0
- package/dns/DNSDomainNameValidator.js +59 -0
- package/dns/DNSDomainNameValidator.js.map +1 -0
- package/dns/DomainNameValidator.d.ts +36 -0
- package/dns/DomainNameValidator.js +19 -0
- package/dns/DomainNameValidator.js.map +1 -0
- package/dns/index.d.ts +3 -0
- package/dns/index.js +20 -0
- package/dns/index.js.map +1 -0
- package/financial/FinancialController.d.ts +272 -0
- package/financial/FinancialController.js +762 -0
- package/financial/FinancialController.js.map +1 -0
- package/financial/FinancialInterface.d.ts +352 -0
- package/financial/FinancialInterface.js +642 -0
- package/financial/FinancialInterface.js.map +1 -0
- package/financial/FinancialStore.d.ts +186 -0
- package/financial/FinancialStore.js +19 -0
- package/financial/FinancialStore.js.map +1 -0
- package/financial/MemoryFinancialInterface.d.ts +23 -0
- package/financial/MemoryFinancialInterface.js +592 -0
- package/financial/MemoryFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleFinancialInterface.d.ts +46 -0
- package/financial/TigerBeetleFinancialInterface.js +109 -0
- package/financial/TigerBeetleFinancialInterface.js.map +1 -0
- package/financial/TigerBeetleTestUtils.d.ts +40 -0
- package/financial/TigerBeetleTestUtils.js +185 -0
- package/financial/TigerBeetleTestUtils.js.map +1 -0
- package/financial/Types.d.ts +1 -0
- package/financial/Types.js +801 -0
- package/financial/Types.js.map +1 -0
- package/financial/index.d.ts +6 -0
- package/financial/index.js +24 -0
- package/financial/index.js.map +1 -0
- package/index.d.ts +4 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/notifications/NotificationRecordsController.js +14 -14
- package/notifications/NotificationRecordsController.js.map +1 -1
- package/notifications/WebPushInterface.d.ts +24 -155
- package/notifications/WebPushInterface.js +2 -2
- package/notifications/WebPushInterface.js.map +1 -1
- package/package.json +72 -70
- package/packages/version/MemoryPackageVersionRecordsStore.js +12 -15
- package/packages/version/MemoryPackageVersionRecordsStore.js.map +1 -1
- package/packages/version/PackageVersionRecordsController.d.ts +19 -0
- package/packages/version/PackageVersionRecordsController.js +102 -22
- package/packages/version/PackageVersionRecordsController.js.map +1 -1
- package/packages/version/PackageVersionRecordsStore.js +6 -8
- package/packages/version/PackageVersionRecordsStore.js.map +1 -1
- package/purchasable-items/MemoryPurchasableItemRecordsStore.d.ts +7 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js +33 -0
- package/purchasable-items/MemoryPurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsController.d.ts +16 -0
- package/purchasable-items/PurchasableItemRecordsController.js +72 -0
- package/purchasable-items/PurchasableItemRecordsController.js.map +1 -0
- package/purchasable-items/PurchasableItemRecordsStore.d.ts +66 -0
- package/purchasable-items/PurchasableItemRecordsStore.js +2 -0
- package/purchasable-items/PurchasableItemRecordsStore.js.map +1 -0
- package/purchasable-items/index.d.ts +4 -0
- package/purchasable-items/index.js +21 -0
- package/purchasable-items/index.js.map +1 -0
- package/queue/MemoryQueue.js +1 -1
- package/queue/MemoryQueue.js.map +1 -1
- package/search/MemorySearchInterface.js +1 -2
- package/search/MemorySearchInterface.js.map +1 -1
- package/search/SearchRecordsController.d.ts +66 -244
- package/search/SearchRecordsController.js +35 -36
- package/search/SearchRecordsController.js.map +1 -1
- package/search/SearchSyncProcessor.d.ts +7 -83
- package/search/TypesenseSearchInterface.js +8 -11
- package/search/TypesenseSearchInterface.js.map +1 -1
- package/tracing/TracingDecorators.js +5 -8
- package/tracing/TracingDecorators.js.map +1 -1
- package/webhooks/WebhookEnvironment.d.ts +36 -560
- package/webhooks/WebhookEnvironment.js +1 -1
- package/webhooks/WebhookEnvironment.js.map +1 -1
- package/webhooks/WebhookRecordsController.js +14 -16
- package/webhooks/WebhookRecordsController.js.map +1 -1
- package/websockets/MemoryLockStore.d.ts +18 -0
- package/websockets/MemoryLockStore.js +2 -0
- package/websockets/MemoryLockStore.js.map +1 -0
- package/websockets/MemoryTempInstRecordsStore.js +15 -27
- package/websockets/MemoryTempInstRecordsStore.js.map +1 -1
- package/websockets/MemoryWebsocketConnectionStore.js +6 -8
- package/websockets/MemoryWebsocketConnectionStore.js.map +1 -1
- package/websockets/MemoryWebsocketMessenger.js +1 -2
- package/websockets/MemoryWebsocketMessenger.js.map +1 -1
- package/websockets/SplitInstRecordsStore.js +2 -2
- package/websockets/SplitInstRecordsStore.js.map +1 -1
- package/websockets/WebsocketController.d.ts +5 -0
- package/websockets/WebsocketController.js +122 -83
- package/websockets/WebsocketController.js.map +1 -1
- package/RecordsServer.js +0 -6435
- package/RecordsServer.js.map +0 -1
package/MemoryStore.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { cloneDeep, orderBy, sortBy } from 'es-toolkit/compat';
|
|
19
19
|
import { v4 as uuid } from 'uuid';
|
|
20
20
|
import { getExpireTime, getSubjectUserId } from './PolicyStore';
|
|
21
|
+
import { CONFIGURATION_SCHEMAS_MAP, } from './ConfigurationStore';
|
|
21
22
|
import { DateTime } from 'luxon';
|
|
22
23
|
export class MemoryStore {
|
|
23
24
|
get aiOpenAIRealtimeMetrics() {
|
|
@@ -80,6 +81,24 @@ export class MemoryStore {
|
|
|
80
81
|
set moderationConfiguration(value) {
|
|
81
82
|
this._moderationConfiguration = value;
|
|
82
83
|
}
|
|
84
|
+
get webConfig() {
|
|
85
|
+
return this._webConfig;
|
|
86
|
+
}
|
|
87
|
+
set webConfig(value) {
|
|
88
|
+
this._webConfig = value;
|
|
89
|
+
}
|
|
90
|
+
get playerWebManifest() {
|
|
91
|
+
return this._playerWebManifest;
|
|
92
|
+
}
|
|
93
|
+
set playerWebManifest(value) {
|
|
94
|
+
this._playerWebManifest = value;
|
|
95
|
+
}
|
|
96
|
+
get ab1Bootstrap() {
|
|
97
|
+
return this._ab1Bootstrap;
|
|
98
|
+
}
|
|
99
|
+
set ab1Bootstrap(value) {
|
|
100
|
+
this._ab1Bootstrap = value;
|
|
101
|
+
}
|
|
83
102
|
get userInstReports() {
|
|
84
103
|
return this._userInstReports;
|
|
85
104
|
}
|
|
@@ -98,8 +117,25 @@ export class MemoryStore {
|
|
|
98
117
|
get grantedPackageEntitlements() {
|
|
99
118
|
return this._grantedPackageEntitlements;
|
|
100
119
|
}
|
|
120
|
+
get checkoutSessions() {
|
|
121
|
+
return this._checkoutSessions;
|
|
122
|
+
}
|
|
123
|
+
get purchasedItems() {
|
|
124
|
+
return this._purchasedItems;
|
|
125
|
+
}
|
|
126
|
+
get activationKeys() {
|
|
127
|
+
return this._activationKeys;
|
|
128
|
+
}
|
|
129
|
+
get financialAccounts() {
|
|
130
|
+
return this._financialAccounts;
|
|
131
|
+
}
|
|
132
|
+
get externalPayouts() {
|
|
133
|
+
return this._externalPayouts;
|
|
134
|
+
}
|
|
135
|
+
get customDomains() {
|
|
136
|
+
return this._customDomains;
|
|
137
|
+
}
|
|
101
138
|
constructor(config) {
|
|
102
|
-
var _a, _b;
|
|
103
139
|
this._users = [];
|
|
104
140
|
this._userAuthenticators = [];
|
|
105
141
|
this._loginRequests = [];
|
|
@@ -109,6 +145,7 @@ export class MemoryStore {
|
|
|
109
145
|
this._subscriptions = [];
|
|
110
146
|
this._periods = [];
|
|
111
147
|
this._invoices = [];
|
|
148
|
+
this._checkoutSessions = [];
|
|
112
149
|
this._records = [];
|
|
113
150
|
this._recordKeys = [];
|
|
114
151
|
this._studios = [];
|
|
@@ -128,6 +165,9 @@ export class MemoryStore {
|
|
|
128
165
|
this._instRecords = new Map();
|
|
129
166
|
this._privoConfiguration = null;
|
|
130
167
|
this._moderationConfiguration = null;
|
|
168
|
+
this._webConfig = null;
|
|
169
|
+
this._playerWebManifest = null;
|
|
170
|
+
this._ab1Bootstrap = null;
|
|
131
171
|
this._recordNotifications = [];
|
|
132
172
|
this._comIdRequests = [];
|
|
133
173
|
this._resourcePermissionAssignments = [];
|
|
@@ -136,18 +176,225 @@ export class MemoryStore {
|
|
|
136
176
|
this._studioLoomConfigs = new Map();
|
|
137
177
|
this._studioHumeConfigs = new Map();
|
|
138
178
|
this._loadedPackages = new Map();
|
|
179
|
+
this._financialAccounts = [];
|
|
180
|
+
this._customDomains = [];
|
|
181
|
+
this._purchasedItems = [];
|
|
182
|
+
this._activationKeys = [];
|
|
183
|
+
this._externalPayouts = [];
|
|
139
184
|
// TODO: Support global permissions
|
|
140
185
|
// private _globalPermissionAssignments: GlobalPermissionAssignment[] = [];
|
|
141
186
|
this.maxAllowedInstSize = Infinity;
|
|
142
187
|
this._moderationJobs = [];
|
|
143
188
|
this._moderationFileResults = [];
|
|
144
189
|
this._subscriptionConfiguration = config.subscriptions;
|
|
145
|
-
this._privoConfiguration =
|
|
146
|
-
this._moderationConfiguration =
|
|
190
|
+
this._privoConfiguration = config.privo ?? null;
|
|
191
|
+
this._moderationConfiguration = config.moderation ?? null;
|
|
147
192
|
this.policies = {};
|
|
148
193
|
this.roles = {};
|
|
149
194
|
this.roleAssignments = {};
|
|
150
195
|
}
|
|
196
|
+
async setConfiguration(key, value) {
|
|
197
|
+
const finalValue = value
|
|
198
|
+
? CONFIGURATION_SCHEMAS_MAP[key].parse(value)
|
|
199
|
+
: null;
|
|
200
|
+
if (key === 'moderation') {
|
|
201
|
+
this._moderationConfiguration =
|
|
202
|
+
finalValue;
|
|
203
|
+
}
|
|
204
|
+
else if (key === 'privo') {
|
|
205
|
+
this._privoConfiguration = finalValue;
|
|
206
|
+
}
|
|
207
|
+
else if (key === 'subscriptions') {
|
|
208
|
+
this._subscriptionConfiguration =
|
|
209
|
+
finalValue;
|
|
210
|
+
}
|
|
211
|
+
else if (key === 'web') {
|
|
212
|
+
this._webConfig = finalValue;
|
|
213
|
+
}
|
|
214
|
+
else if (key === 'playerWebManifest') {
|
|
215
|
+
this._playerWebManifest = finalValue;
|
|
216
|
+
}
|
|
217
|
+
else if (key === 'ab1Bootstrap') {
|
|
218
|
+
this._ab1Bootstrap = finalValue;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
throw new Error('Unsupported configuration key: ' + key);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async getConfiguration(key, defaultValue) {
|
|
225
|
+
if (key === 'moderation') {
|
|
226
|
+
return (this._moderationConfiguration ??
|
|
227
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
228
|
+
.nullable()
|
|
229
|
+
.parse(defaultValue ?? null));
|
|
230
|
+
}
|
|
231
|
+
else if (key === 'privo') {
|
|
232
|
+
return (this._privoConfiguration ??
|
|
233
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
234
|
+
.nullable()
|
|
235
|
+
.parse(defaultValue ?? null));
|
|
236
|
+
}
|
|
237
|
+
else if (key === 'subscriptions') {
|
|
238
|
+
return (this._subscriptionConfiguration ??
|
|
239
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
240
|
+
.nullable()
|
|
241
|
+
.parse(defaultValue ?? null));
|
|
242
|
+
}
|
|
243
|
+
else if (key === 'web') {
|
|
244
|
+
return (this._webConfig ??
|
|
245
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
246
|
+
.nullable()
|
|
247
|
+
.parse(defaultValue ?? null));
|
|
248
|
+
}
|
|
249
|
+
else if (key === 'playerWebManifest') {
|
|
250
|
+
return (this._playerWebManifest ??
|
|
251
|
+
CONFIGURATION_SCHEMAS_MAP[key]
|
|
252
|
+
.nullable()
|
|
253
|
+
.parse(defaultValue ?? null));
|
|
254
|
+
}
|
|
255
|
+
else if (key === 'ab1Bootstrap') {
|
|
256
|
+
return (this._ab1Bootstrap ?? null);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
throw new Error('Unsupported configuration key: ' + key);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
async saveCustomDomain(domain) {
|
|
263
|
+
const existingIndex = this._customDomains.findIndex((d) => d.id === domain.id);
|
|
264
|
+
if (existingIndex >= 0) {
|
|
265
|
+
this._customDomains[existingIndex] = domain;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
this._customDomains.push(domain);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async deleteCustomDomain(domainId) {
|
|
272
|
+
this._customDomains = this._customDomains.filter((d) => d.id !== domainId);
|
|
273
|
+
}
|
|
274
|
+
async listCustomDomainsByStudioId(studioId) {
|
|
275
|
+
return this._customDomains.filter((d) => d.studioId === studioId);
|
|
276
|
+
}
|
|
277
|
+
async getVerifiedCustomDomainByName(domainName) {
|
|
278
|
+
const domain = this._customDomains.find((d) => d.domainName === domainName && d.verified === true);
|
|
279
|
+
if (!domain) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const studio = await this.getStudioById(domain.studioId);
|
|
283
|
+
if (!studio) {
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
id: domain.id,
|
|
288
|
+
domainName: domain.domainName,
|
|
289
|
+
studioId: domain.studioId,
|
|
290
|
+
verificationKey: domain.verificationKey,
|
|
291
|
+
verified: domain.verified,
|
|
292
|
+
studio,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
async getCustomDomainById(domainId) {
|
|
296
|
+
const domain = this._customDomains.find((d) => d.id === domainId);
|
|
297
|
+
if (!domain) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const studio = await this.getStudioById(domain.studioId);
|
|
301
|
+
if (!studio) {
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
id: domain.id,
|
|
306
|
+
domainName: domain.domainName,
|
|
307
|
+
studioId: domain.studioId,
|
|
308
|
+
verificationKey: domain.verificationKey,
|
|
309
|
+
verified: domain.verified,
|
|
310
|
+
studio,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async markCustomDomainAsVerified(domainId) {
|
|
314
|
+
const index = this._customDomains.findIndex((d) => d.id === domainId);
|
|
315
|
+
if (index >= 0) {
|
|
316
|
+
this._customDomains[index] = {
|
|
317
|
+
...this._customDomains[index],
|
|
318
|
+
verified: true,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
async createExternalPayout(payout) {
|
|
323
|
+
const index = this._externalPayouts.findIndex((p) => p.id === payout.id);
|
|
324
|
+
if (index === -1) {
|
|
325
|
+
this._externalPayouts.push(payout);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
this._externalPayouts[index] = payout;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async markPayoutAsPosted(payoutId, postedTransferId, postedAtMs) {
|
|
332
|
+
const index = this._externalPayouts.findIndex((p) => p.id === payoutId);
|
|
333
|
+
if (index >= 0) {
|
|
334
|
+
this._externalPayouts[index] = {
|
|
335
|
+
...this._externalPayouts[index],
|
|
336
|
+
postedTransferId,
|
|
337
|
+
postedAtMs,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async markPayoutAsVoided(payoutId, voidedTransferId, voidedAtMs) {
|
|
342
|
+
const index = this._externalPayouts.findIndex((p) => p.id === payoutId);
|
|
343
|
+
if (index >= 0) {
|
|
344
|
+
this._externalPayouts[index] = {
|
|
345
|
+
...this._externalPayouts[index],
|
|
346
|
+
voidedTransferId,
|
|
347
|
+
voidedAtMs,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
async updateExternalPayout(payout) {
|
|
352
|
+
const index = this._externalPayouts.findIndex((p) => p.id === payout.id);
|
|
353
|
+
if (index >= 0) {
|
|
354
|
+
this._externalPayouts[index] = {
|
|
355
|
+
...this._externalPayouts[index],
|
|
356
|
+
...payout,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
async getAccountById(id) {
|
|
361
|
+
return this._financialAccounts.find((a) => a.id === id) ?? null;
|
|
362
|
+
}
|
|
363
|
+
async getAccountByFilter(filter) {
|
|
364
|
+
if (filter.userId) {
|
|
365
|
+
return this._financialAccounts.find((a) => a.userId === filter.userId && a.ledger === filter.ledger);
|
|
366
|
+
}
|
|
367
|
+
else if (filter.studioId) {
|
|
368
|
+
return this._financialAccounts.find((a) => a.studioId === filter.studioId && a.ledger === filter.ledger);
|
|
369
|
+
}
|
|
370
|
+
else if (filter.contractId) {
|
|
371
|
+
return this._financialAccounts.find((a) => a.contractId === filter.contractId &&
|
|
372
|
+
a.ledger === filter.ledger);
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
async listAccounts(filter) {
|
|
377
|
+
return this._financialAccounts.filter((a) => {
|
|
378
|
+
if (filter.userId && a.userId !== filter.userId) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
if (filter.studioId && a.studioId !== filter.studioId) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
if (filter.contractId && a.contractId !== filter.contractId) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (filter.ledger && a.ledger !== filter.ledger) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
async createAccount(account) {
|
|
394
|
+
this._financialAccounts.push({
|
|
395
|
+
...account,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
151
398
|
/**
|
|
152
399
|
* Constructs a deep clone of this memory store.
|
|
153
400
|
* Effectively copies all the data in the store into a new one.
|
|
@@ -157,6 +404,7 @@ export class MemoryStore {
|
|
|
157
404
|
subscriptions: cloneDeep(this._subscriptionConfiguration),
|
|
158
405
|
privo: cloneDeep(this._privoConfiguration),
|
|
159
406
|
moderation: cloneDeep(this._moderationConfiguration),
|
|
407
|
+
webConfig: cloneDeep(this._webConfig),
|
|
160
408
|
});
|
|
161
409
|
newStore._users = cloneDeep(this._users);
|
|
162
410
|
newStore._loginRequests = cloneDeep(this._loginRequests);
|
|
@@ -187,6 +435,7 @@ export class MemoryStore {
|
|
|
187
435
|
newStore._comIdRequests = cloneDeep(this._comIdRequests);
|
|
188
436
|
newStore._resourcePermissionAssignments = cloneDeep(this._resourcePermissionAssignments);
|
|
189
437
|
newStore._markerPermissionAssignments = cloneDeep(this._markerPermissionAssignments);
|
|
438
|
+
newStore._customDomains = cloneDeep(this._customDomains);
|
|
190
439
|
newStore.maxAllowedInstSize = this.maxAllowedInstSize;
|
|
191
440
|
newStore.roles = cloneDeep(this.roles);
|
|
192
441
|
newStore.roleAssignments = cloneDeep(this.roleAssignments);
|
|
@@ -270,6 +519,12 @@ export class MemoryStore {
|
|
|
270
519
|
async getModerationConfig() {
|
|
271
520
|
return this._moderationConfiguration;
|
|
272
521
|
}
|
|
522
|
+
async getWebConfig() {
|
|
523
|
+
return this._webConfig;
|
|
524
|
+
}
|
|
525
|
+
async getPlayerWebManifest() {
|
|
526
|
+
return this._playerWebManifest;
|
|
527
|
+
}
|
|
273
528
|
async getRecordByName(name) {
|
|
274
529
|
const record = this._records.find((r) => r.name === name);
|
|
275
530
|
return record;
|
|
@@ -362,6 +617,9 @@ export class MemoryStore {
|
|
|
362
617
|
async getStudioByStripeCustomerId(customerId) {
|
|
363
618
|
return this._studios.find((s) => s.stripeCustomerId === customerId);
|
|
364
619
|
}
|
|
620
|
+
async getStudioByStripeAccountId(accountId) {
|
|
621
|
+
return this._studios.find((s) => s.stripeAccountId === accountId);
|
|
622
|
+
}
|
|
365
623
|
async listStudiosForUser(userId) {
|
|
366
624
|
const assignments = await this.listUserAssignments(userId);
|
|
367
625
|
const studios = await Promise.all(assignments.map(async (a) => {
|
|
@@ -408,10 +666,10 @@ export class MemoryStore {
|
|
|
408
666
|
}
|
|
409
667
|
async listStudioAssignments(studioId, filters) {
|
|
410
668
|
const assignments = this._studioAssignments.filter((s) => {
|
|
411
|
-
const matchesRole = !
|
|
412
|
-
const matchesPrimaryContact = !
|
|
669
|
+
const matchesRole = !filters?.role || s.role === filters.role;
|
|
670
|
+
const matchesPrimaryContact = !filters?.isPrimaryContact ||
|
|
413
671
|
s.isPrimaryContact === filters.isPrimaryContact;
|
|
414
|
-
const matchesUserId = !
|
|
672
|
+
const matchesUserId = !filters?.userId || s.userId === filters.userId;
|
|
415
673
|
return (s.studioId === studioId &&
|
|
416
674
|
matchesRole &&
|
|
417
675
|
matchesPrimaryContact &&
|
|
@@ -453,15 +711,13 @@ export class MemoryStore {
|
|
|
453
711
|
});
|
|
454
712
|
}
|
|
455
713
|
async getStudioLoomConfig(studioId) {
|
|
456
|
-
|
|
457
|
-
return (_a = this._studioLoomConfigs.get(studioId)) !== null && _a !== void 0 ? _a : null;
|
|
714
|
+
return this._studioLoomConfigs.get(studioId) ?? null;
|
|
458
715
|
}
|
|
459
716
|
async updateStudioLoomConfig(studioId, config) {
|
|
460
717
|
this._studioLoomConfigs.set(studioId, config);
|
|
461
718
|
}
|
|
462
719
|
async getStudioHumeConfig(studioId) {
|
|
463
|
-
|
|
464
|
-
return (_a = this._studioHumeConfigs.get(studioId)) !== null && _a !== void 0 ? _a : null;
|
|
720
|
+
return this._studioHumeConfigs.get(studioId) ?? null;
|
|
465
721
|
}
|
|
466
722
|
async updateStudioHumeConfig(studioId, config) {
|
|
467
723
|
this._studioHumeConfigs.set(studioId, config);
|
|
@@ -621,12 +877,10 @@ export class MemoryStore {
|
|
|
621
877
|
};
|
|
622
878
|
}
|
|
623
879
|
async getMarkerPermissionAssignmentById(id) {
|
|
624
|
-
|
|
625
|
-
return ((_a = this._markerPermissionAssignments.find((a) => a.id === id)) !== null && _a !== void 0 ? _a : null);
|
|
880
|
+
return (this._markerPermissionAssignments.find((a) => a.id === id) ?? null);
|
|
626
881
|
}
|
|
627
882
|
async getResourcePermissionAssignmentById(id) {
|
|
628
|
-
|
|
629
|
-
return ((_a = this._resourcePermissionAssignments.find((a) => a.id === id)) !== null && _a !== void 0 ? _a : null);
|
|
883
|
+
return (this._resourcePermissionAssignments.find((a) => a.id === id) ?? null);
|
|
630
884
|
}
|
|
631
885
|
async deleteResourcePermissionAssignment(assigment) {
|
|
632
886
|
this._resourcePermissionAssignments =
|
|
@@ -708,13 +962,12 @@ export class MemoryStore {
|
|
|
708
962
|
packageIds.includes(e.packageId));
|
|
709
963
|
}
|
|
710
964
|
async findGrantedPackageEntitlementByUserIdPackageIdFeatureAndScope(userId, packageId, feature, scope, recordName) {
|
|
711
|
-
|
|
712
|
-
return ((_a = this._grantedPackageEntitlements.find((e) => e.userId === userId &&
|
|
965
|
+
return (this._grantedPackageEntitlements.find((e) => e.userId === userId &&
|
|
713
966
|
e.packageId === packageId &&
|
|
714
967
|
e.feature === feature &&
|
|
715
968
|
e.scope === scope &&
|
|
716
969
|
e.revokeTimeMs === null &&
|
|
717
|
-
e.recordName === recordName)
|
|
970
|
+
e.recordName === recordName) ?? null);
|
|
718
971
|
}
|
|
719
972
|
async findGrantedPackageEntitlementById(id) {
|
|
720
973
|
return this._grantedPackageEntitlements.find((e) => e.id === id);
|
|
@@ -755,8 +1008,10 @@ export class MemoryStore {
|
|
|
755
1008
|
}
|
|
756
1009
|
}
|
|
757
1010
|
async saveNewUser(user) {
|
|
758
|
-
let index = this._users.findIndex((u) => (!!user.email && u.email === user.email) ||
|
|
759
|
-
(!!user.phoneNumber &&
|
|
1011
|
+
let index = this._users.findIndex((u) => ((!!user.email && u.email === user.email) ||
|
|
1012
|
+
(!!user.phoneNumber &&
|
|
1013
|
+
u.phoneNumber === user.phoneNumber)) &&
|
|
1014
|
+
(u.loginStudioId ?? null) === (user.loginStudioId ?? null));
|
|
760
1015
|
if (index >= 0) {
|
|
761
1016
|
return {
|
|
762
1017
|
success: false,
|
|
@@ -784,16 +1039,21 @@ export class MemoryStore {
|
|
|
784
1039
|
});
|
|
785
1040
|
}
|
|
786
1041
|
}
|
|
787
|
-
async findUserByAddress(address, addressType) {
|
|
788
|
-
const user = this._users.find((u) => addressType === 'email'
|
|
1042
|
+
async findUserByAddress(address, addressType, loginStudioId = null) {
|
|
1043
|
+
const user = this._users.find((u) => (addressType === 'email'
|
|
789
1044
|
? u.email === address
|
|
790
|
-
: u.phoneNumber === address)
|
|
1045
|
+
: u.phoneNumber === address) &&
|
|
1046
|
+
(u.loginStudioId ?? null) === (loginStudioId ?? null));
|
|
791
1047
|
return user;
|
|
792
1048
|
}
|
|
793
1049
|
async findUserByStripeCustomerId(customerId) {
|
|
794
1050
|
const user = this._users.find((u) => u.stripeCustomerId === customerId);
|
|
795
1051
|
return user;
|
|
796
1052
|
}
|
|
1053
|
+
async findUserByStripeAccountId(accountId) {
|
|
1054
|
+
const user = this._users.find((u) => u.stripeAccountId === accountId);
|
|
1055
|
+
return user || null;
|
|
1056
|
+
}
|
|
797
1057
|
async findUserByPrivoServiceId(serviceId) {
|
|
798
1058
|
const user = this._users.find((u) => u.privoServiceId === serviceId);
|
|
799
1059
|
return user;
|
|
@@ -1022,8 +1282,10 @@ export class MemoryStore {
|
|
|
1022
1282
|
async getInvoiceById(id) {
|
|
1023
1283
|
return this._invoices.find((i) => i.id === id);
|
|
1024
1284
|
}
|
|
1285
|
+
async getInvoiceByStripeId(id) {
|
|
1286
|
+
return this._invoices.find((i) => i.stripeInvoiceId === id);
|
|
1287
|
+
}
|
|
1025
1288
|
async updateSubscriptionInfo(request) {
|
|
1026
|
-
var _a, _b, _c, _d;
|
|
1027
1289
|
if (request.userId) {
|
|
1028
1290
|
const user = await this.findUser(request.userId);
|
|
1029
1291
|
let subscription = request.stripeSubscriptionId
|
|
@@ -1058,10 +1320,10 @@ export class MemoryStore {
|
|
|
1058
1320
|
...user,
|
|
1059
1321
|
subscriptionId: request.subscriptionId,
|
|
1060
1322
|
subscriptionStatus: request.subscriptionStatus,
|
|
1061
|
-
stripeCustomerId:
|
|
1323
|
+
stripeCustomerId: request.stripeCustomerId ?? user.stripeCustomerId,
|
|
1062
1324
|
subscriptionPeriodStartMs: request.currentPeriodStartMs,
|
|
1063
1325
|
subscriptionPeriodEndMs: request.currentPeriodEndMs,
|
|
1064
|
-
subscriptionInfoId:
|
|
1326
|
+
subscriptionInfoId: subscription?.id ?? null,
|
|
1065
1327
|
});
|
|
1066
1328
|
}
|
|
1067
1329
|
else if (request.studioId) {
|
|
@@ -1098,10 +1360,10 @@ export class MemoryStore {
|
|
|
1098
1360
|
...studio,
|
|
1099
1361
|
subscriptionId: request.subscriptionId,
|
|
1100
1362
|
subscriptionStatus: request.subscriptionStatus,
|
|
1101
|
-
stripeCustomerId:
|
|
1363
|
+
stripeCustomerId: request.stripeCustomerId ?? studio.stripeCustomerId,
|
|
1102
1364
|
subscriptionPeriodStartMs: request.currentPeriodStartMs,
|
|
1103
1365
|
subscriptionPeriodEndMs: request.currentPeriodEndMs,
|
|
1104
|
-
subscriptionInfoId:
|
|
1366
|
+
subscriptionInfoId: subscription?.id ?? null,
|
|
1105
1367
|
});
|
|
1106
1368
|
}
|
|
1107
1369
|
}
|
|
@@ -1138,6 +1400,7 @@ export class MemoryStore {
|
|
|
1138
1400
|
id: invoiceId,
|
|
1139
1401
|
periodId: periodId,
|
|
1140
1402
|
subscriptionId: subscription.id,
|
|
1403
|
+
checkoutSessionId: null,
|
|
1141
1404
|
...request.invoice,
|
|
1142
1405
|
});
|
|
1143
1406
|
await this.saveSubscriptionPeriod({
|
|
@@ -1180,6 +1443,7 @@ export class MemoryStore {
|
|
|
1180
1443
|
id: invoiceId,
|
|
1181
1444
|
periodId: periodId,
|
|
1182
1445
|
subscriptionId: subscription.id,
|
|
1446
|
+
checkoutSessionId: null,
|
|
1183
1447
|
...request.invoice,
|
|
1184
1448
|
});
|
|
1185
1449
|
await this.saveSubscriptionPeriod({
|
|
@@ -1191,6 +1455,86 @@ export class MemoryStore {
|
|
|
1191
1455
|
});
|
|
1192
1456
|
}
|
|
1193
1457
|
}
|
|
1458
|
+
async updateCheckoutSessionInfo(request) {
|
|
1459
|
+
let sessionIndex = this._checkoutSessions.findIndex((s) => s.id === request.id);
|
|
1460
|
+
let invoiceId = null;
|
|
1461
|
+
if (request.invoice) {
|
|
1462
|
+
let invoice = this._invoices.find((i) => i.stripeInvoiceId === request.invoice.stripeInvoiceId);
|
|
1463
|
+
if (!invoice) {
|
|
1464
|
+
invoice = {
|
|
1465
|
+
id: uuid(),
|
|
1466
|
+
...request.invoice,
|
|
1467
|
+
checkoutSessionId: request.id,
|
|
1468
|
+
subscriptionId: null,
|
|
1469
|
+
periodId: null,
|
|
1470
|
+
};
|
|
1471
|
+
await this.saveInvoice(invoice);
|
|
1472
|
+
invoiceId = invoice.id;
|
|
1473
|
+
}
|
|
1474
|
+
else {
|
|
1475
|
+
invoice = {
|
|
1476
|
+
...invoice,
|
|
1477
|
+
...request.invoice,
|
|
1478
|
+
checkoutSessionId: request.id,
|
|
1479
|
+
};
|
|
1480
|
+
await this.saveInvoice(invoice);
|
|
1481
|
+
invoiceId = invoice.id;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
if (sessionIndex < 0) {
|
|
1485
|
+
const session = {
|
|
1486
|
+
id: request.id,
|
|
1487
|
+
paid: request.paid,
|
|
1488
|
+
stripePaymentStatus: request.paymentStatus,
|
|
1489
|
+
stripeStatus: request.status,
|
|
1490
|
+
stripeCheckoutSessionId: request.stripeCheckoutSessionId,
|
|
1491
|
+
fulfilledAtMs: request.fulfilledAtMs,
|
|
1492
|
+
userId: request.userId,
|
|
1493
|
+
invoiceId,
|
|
1494
|
+
items: request.items,
|
|
1495
|
+
transferIds: request.transferIds,
|
|
1496
|
+
transfersPending: request.transfersPending,
|
|
1497
|
+
transactionId: request.transactionId,
|
|
1498
|
+
shouldBeAutomaticallyFulfilled: request.shouldBeAutomaticallyFulfilled,
|
|
1499
|
+
};
|
|
1500
|
+
this._checkoutSessions.push(session);
|
|
1501
|
+
}
|
|
1502
|
+
else {
|
|
1503
|
+
let session = this._checkoutSessions[sessionIndex];
|
|
1504
|
+
session = {
|
|
1505
|
+
...session,
|
|
1506
|
+
paid: request.paid,
|
|
1507
|
+
stripePaymentStatus: request.paymentStatus,
|
|
1508
|
+
stripeStatus: request.status,
|
|
1509
|
+
stripeCheckoutSessionId: request.stripeCheckoutSessionId,
|
|
1510
|
+
fulfilledAtMs: request.fulfilledAtMs,
|
|
1511
|
+
userId: request.userId,
|
|
1512
|
+
items: request.items,
|
|
1513
|
+
transferIds: request.transferIds,
|
|
1514
|
+
transfersPending: request.transfersPending,
|
|
1515
|
+
transactionId: request.transactionId,
|
|
1516
|
+
shouldBeAutomaticallyFulfilled: request.shouldBeAutomaticallyFulfilled,
|
|
1517
|
+
};
|
|
1518
|
+
if (request.invoice) {
|
|
1519
|
+
session.invoiceId = invoiceId;
|
|
1520
|
+
}
|
|
1521
|
+
this._checkoutSessions[sessionIndex] = session;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
async markCheckoutSessionFulfilled(sessionId, fulfilledAtMs) {
|
|
1525
|
+
const index = this._checkoutSessions.findIndex((s) => s.id === sessionId);
|
|
1526
|
+
if (index >= 0) {
|
|
1527
|
+
const session = this._checkoutSessions[index];
|
|
1528
|
+
this._checkoutSessions[index] = {
|
|
1529
|
+
...session,
|
|
1530
|
+
fulfilledAtMs,
|
|
1531
|
+
transfersPending: false,
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
async getCheckoutSessionById(id) {
|
|
1536
|
+
return this._checkoutSessions.find((s) => s.id === id);
|
|
1537
|
+
}
|
|
1194
1538
|
_findUserIndex(id) {
|
|
1195
1539
|
return this._users.findIndex((u) => u.id === id);
|
|
1196
1540
|
}
|
|
@@ -1263,12 +1607,11 @@ export class MemoryStore {
|
|
|
1263
1607
|
};
|
|
1264
1608
|
}
|
|
1265
1609
|
async listDataByMarker(request) {
|
|
1266
|
-
var _a;
|
|
1267
1610
|
const marker = request.marker;
|
|
1268
1611
|
let record = this._getDataRecord(request.recordName);
|
|
1269
1612
|
let items = [];
|
|
1270
1613
|
const address = request.startingAddress;
|
|
1271
|
-
const sortAscending = (
|
|
1614
|
+
const sortAscending = (request.sort ?? 'ascending') === 'ascending';
|
|
1272
1615
|
let count = 0;
|
|
1273
1616
|
for (let [key, item] of record.entries()) {
|
|
1274
1617
|
if (item.markers.includes(marker)) {
|
|
@@ -1545,10 +1888,10 @@ export class MemoryStore {
|
|
|
1545
1888
|
}
|
|
1546
1889
|
async _getUserPrivacyFeatures(userId) {
|
|
1547
1890
|
const user = await this.findUser(userId);
|
|
1548
|
-
if (user
|
|
1891
|
+
if (user?.privacyFeatures) {
|
|
1549
1892
|
return {
|
|
1550
1893
|
...user.privacyFeatures,
|
|
1551
|
-
userRole: user
|
|
1894
|
+
userRole: user?.role,
|
|
1552
1895
|
};
|
|
1553
1896
|
}
|
|
1554
1897
|
return {
|
|
@@ -1556,7 +1899,7 @@ export class MemoryStore {
|
|
|
1556
1899
|
allowPublicData: true,
|
|
1557
1900
|
allowAI: true,
|
|
1558
1901
|
allowPublicInsts: true,
|
|
1559
|
-
userRole: user
|
|
1902
|
+
userRole: user?.role,
|
|
1560
1903
|
};
|
|
1561
1904
|
}
|
|
1562
1905
|
async listRolesForUser(recordName, userId) {
|
|
@@ -1627,7 +1970,7 @@ export class MemoryStore {
|
|
|
1627
1970
|
totalCount += 1;
|
|
1628
1971
|
}
|
|
1629
1972
|
}
|
|
1630
|
-
assignments = sortBy(assignments, (a) => a.role.role, (a) =>
|
|
1973
|
+
assignments = sortBy(assignments, (a) => a.role.role, (a) => a.userId ?? a.inst);
|
|
1631
1974
|
if (startingRole) {
|
|
1632
1975
|
assignments = assignments.filter((a) => a.role.role > startingRole);
|
|
1633
1976
|
}
|
|
@@ -1637,11 +1980,10 @@ export class MemoryStore {
|
|
|
1637
1980
|
};
|
|
1638
1981
|
}
|
|
1639
1982
|
async assignSubjectRole(recordName, subjectId, type, role) {
|
|
1640
|
-
var _a;
|
|
1641
1983
|
if (!this.roleAssignments[recordName]) {
|
|
1642
1984
|
this.roleAssignments[recordName] = {};
|
|
1643
1985
|
}
|
|
1644
|
-
const roles =
|
|
1986
|
+
const roles = this.roleAssignments[recordName][subjectId] ?? [];
|
|
1645
1987
|
const filtered = roles.filter((r) => r.role !== role.role ||
|
|
1646
1988
|
getExpireTime(r.expireTimeMs) <= role.expireTimeMs);
|
|
1647
1989
|
this.roleAssignments[recordName][subjectId] = [
|
|
@@ -1656,11 +1998,10 @@ export class MemoryStore {
|
|
|
1656
1998
|
};
|
|
1657
1999
|
}
|
|
1658
2000
|
async revokeSubjectRole(recordName, subjectId, type, role) {
|
|
1659
|
-
var _a;
|
|
1660
2001
|
if (!this.roleAssignments[recordName]) {
|
|
1661
2002
|
this.roleAssignments[recordName] = {};
|
|
1662
2003
|
}
|
|
1663
|
-
const roles =
|
|
2004
|
+
const roles = this.roleAssignments[recordName][subjectId] ?? [];
|
|
1664
2005
|
const filtered = roles.filter((r) => r.role !== role);
|
|
1665
2006
|
this.roleAssignments[recordName][subjectId] = filtered;
|
|
1666
2007
|
return {
|
|
@@ -1668,9 +2009,8 @@ export class MemoryStore {
|
|
|
1668
2009
|
};
|
|
1669
2010
|
}
|
|
1670
2011
|
_getRolesForEntity(recordName, id) {
|
|
1671
|
-
|
|
1672
|
-
const
|
|
1673
|
-
const assignments = (_d = (_c = this.roleAssignments[recordName]) === null || _c === void 0 ? void 0 : _c[id]) !== null && _d !== void 0 ? _d : [];
|
|
2012
|
+
const roles = this.roles[recordName]?.[id] ?? new Set();
|
|
2013
|
+
const assignments = this.roleAssignments[recordName]?.[id] ?? [];
|
|
1674
2014
|
return [
|
|
1675
2015
|
...[...roles].map((r) => ({
|
|
1676
2016
|
role: r,
|
|
@@ -1747,11 +2087,11 @@ export class MemoryStore {
|
|
|
1747
2087
|
? this._aiChatMetrics.filter((m) => m.userId === filter.ownerId &&
|
|
1748
2088
|
(!info.currentPeriodStartMs ||
|
|
1749
2089
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1750
|
-
m.createdAtMs
|
|
2090
|
+
m.createdAtMs <= info.currentPeriodEndMs)))
|
|
1751
2091
|
: this._aiChatMetrics.filter((m) => m.studioId === filter.studioId &&
|
|
1752
2092
|
(!info.currentPeriodStartMs ||
|
|
1753
2093
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1754
|
-
m.createdAtMs
|
|
2094
|
+
m.createdAtMs <= info.currentPeriodEndMs)));
|
|
1755
2095
|
let totalTokens = 0;
|
|
1756
2096
|
for (let m of metrics) {
|
|
1757
2097
|
totalTokens += m.tokens;
|
|
@@ -1800,20 +2140,17 @@ export class MemoryStore {
|
|
|
1800
2140
|
async getSubscriptionInfoForRecord(recordName) {
|
|
1801
2141
|
return await this._getSubscriptionInfo(recordName);
|
|
1802
2142
|
}
|
|
1803
|
-
async listRecordsForSubscriptionByRecordName(recordName) {
|
|
1804
|
-
return await this._listRecordsForSubscription(recordName);
|
|
1805
|
-
}
|
|
1806
2143
|
async getSubscriptionAiSloydMetrics(filter) {
|
|
1807
2144
|
const info = await this._getSubscriptionMetrics(filter);
|
|
1808
2145
|
const metrics = filter.ownerId
|
|
1809
2146
|
? this._aiSloydMetrics.filter((m) => m.userId === filter.ownerId &&
|
|
1810
2147
|
(!info.currentPeriodStartMs ||
|
|
1811
2148
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1812
|
-
m.createdAtMs
|
|
2149
|
+
m.createdAtMs <= info.currentPeriodEndMs)))
|
|
1813
2150
|
: this._aiSloydMetrics.filter((m) => m.studioId === filter.studioId &&
|
|
1814
2151
|
(!info.currentPeriodStartMs ||
|
|
1815
2152
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1816
|
-
m.createdAtMs
|
|
2153
|
+
m.createdAtMs <= info.currentPeriodEndMs)));
|
|
1817
2154
|
let totalModels = 0;
|
|
1818
2155
|
for (let m of metrics) {
|
|
1819
2156
|
totalModels += m.modelsCreated;
|
|
@@ -1846,11 +2183,11 @@ export class MemoryStore {
|
|
|
1846
2183
|
? this._aiRealtimeMetrics.filter((m) => m.userId === filter.ownerId &&
|
|
1847
2184
|
(!info.currentPeriodStartMs ||
|
|
1848
2185
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1849
|
-
m.createdAtMs
|
|
2186
|
+
m.createdAtMs <= info.currentPeriodEndMs)))
|
|
1850
2187
|
: this._aiRealtimeMetrics.filter((m) => m.studioId === filter.studioId &&
|
|
1851
2188
|
(!info.currentPeriodStartMs ||
|
|
1852
2189
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1853
|
-
m.createdAtMs
|
|
2190
|
+
m.createdAtMs <= info.currentPeriodEndMs)));
|
|
1854
2191
|
let totalModels = metrics.length;
|
|
1855
2192
|
return {
|
|
1856
2193
|
...info,
|
|
@@ -1869,11 +2206,11 @@ export class MemoryStore {
|
|
|
1869
2206
|
? this._aiImageMetrics.filter((m) => m.userId === filter.ownerId &&
|
|
1870
2207
|
(!info.currentPeriodStartMs ||
|
|
1871
2208
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1872
|
-
m.createdAtMs
|
|
2209
|
+
m.createdAtMs <= info.currentPeriodEndMs)))
|
|
1873
2210
|
: this._aiImageMetrics.filter((m) => m.studioId === filter.studioId &&
|
|
1874
2211
|
(!info.currentPeriodStartMs ||
|
|
1875
2212
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1876
|
-
m.createdAtMs
|
|
2213
|
+
m.createdAtMs <= info.currentPeriodEndMs)));
|
|
1877
2214
|
let totalPixels = 0;
|
|
1878
2215
|
for (let m of metrics) {
|
|
1879
2216
|
totalPixels += m.squarePixels;
|
|
@@ -1892,11 +2229,11 @@ export class MemoryStore {
|
|
|
1892
2229
|
? this._aiSkyboxMetrics.filter((m) => m.userId === filter.ownerId &&
|
|
1893
2230
|
(!info.currentPeriodStartMs ||
|
|
1894
2231
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1895
|
-
m.createdAtMs
|
|
2232
|
+
m.createdAtMs <= info.currentPeriodEndMs)))
|
|
1896
2233
|
: this._aiSkyboxMetrics.filter((m) => m.studioId === filter.studioId &&
|
|
1897
2234
|
(!info.currentPeriodStartMs ||
|
|
1898
2235
|
(m.createdAtMs >= info.currentPeriodStartMs &&
|
|
1899
|
-
m.createdAtMs
|
|
2236
|
+
m.createdAtMs <= info.currentPeriodEndMs)));
|
|
1900
2237
|
let totalSkyboxes = 0;
|
|
1901
2238
|
for (let m of metrics) {
|
|
1902
2239
|
totalSkyboxes += m.skyboxes;
|
|
@@ -1918,11 +2255,10 @@ export class MemoryStore {
|
|
|
1918
2255
|
};
|
|
1919
2256
|
}
|
|
1920
2257
|
async _getSubscriptionMetrics(filter) {
|
|
1921
|
-
var _a;
|
|
1922
2258
|
const config = await this.getSubscriptionConfiguration();
|
|
1923
2259
|
let currentPeriodStart = null;
|
|
1924
2260
|
let currentPeriodEnd = null;
|
|
1925
|
-
if (
|
|
2261
|
+
if (config?.defaultFeatures?.defaultPeriodLength) {
|
|
1926
2262
|
const now = DateTime.utc();
|
|
1927
2263
|
const periodStart = now.minus(config.defaultFeatures.defaultPeriodLength);
|
|
1928
2264
|
currentPeriodStart = periodStart.toMillis();
|
|
@@ -1936,6 +2272,8 @@ export class MemoryStore {
|
|
|
1936
2272
|
currentPeriodStartMs: currentPeriodStart,
|
|
1937
2273
|
currentPeriodEndMs: currentPeriodEnd,
|
|
1938
2274
|
subscriptionType: filter.ownerId ? 'user' : 'studio',
|
|
2275
|
+
stripeAccountId: null,
|
|
2276
|
+
stripeAccountStatus: null,
|
|
1939
2277
|
};
|
|
1940
2278
|
if (filter.ownerId) {
|
|
1941
2279
|
const user = await this.findUser(filter.ownerId);
|
|
@@ -1944,6 +2282,8 @@ export class MemoryStore {
|
|
|
1944
2282
|
metrics.subscriptionId = user.subscriptionId;
|
|
1945
2283
|
metrics.currentPeriodEndMs = user.subscriptionPeriodEndMs;
|
|
1946
2284
|
metrics.currentPeriodStartMs = user.subscriptionPeriodStartMs;
|
|
2285
|
+
metrics.stripeAccountId = user.stripeAccountId;
|
|
2286
|
+
metrics.stripeAccountStatus = user.stripeAccountStatus;
|
|
1947
2287
|
}
|
|
1948
2288
|
}
|
|
1949
2289
|
else if (filter.studioId) {
|
|
@@ -1953,10 +2293,15 @@ export class MemoryStore {
|
|
|
1953
2293
|
metrics.subscriptionStatus = studio.subscriptionStatus;
|
|
1954
2294
|
metrics.currentPeriodEndMs = studio.subscriptionPeriodEndMs;
|
|
1955
2295
|
metrics.currentPeriodStartMs = studio.subscriptionPeriodStartMs;
|
|
2296
|
+
metrics.stripeAccountId = studio.stripeAccountId;
|
|
2297
|
+
metrics.stripeAccountStatus = studio.stripeAccountStatus;
|
|
1956
2298
|
}
|
|
1957
2299
|
}
|
|
1958
2300
|
return metrics;
|
|
1959
2301
|
}
|
|
2302
|
+
async listRecordsForSubscriptionByRecordName(recordName) {
|
|
2303
|
+
return await this._listRecordsForSubscription(recordName);
|
|
2304
|
+
}
|
|
1960
2305
|
async _listRecordsForSubscription(recordName) {
|
|
1961
2306
|
const record = await this.getRecordByName(recordName);
|
|
1962
2307
|
if (record.ownerId) {
|
|
@@ -2100,9 +2445,8 @@ export class MemoryStore {
|
|
|
2100
2445
|
return loadedPackages;
|
|
2101
2446
|
}
|
|
2102
2447
|
async isPackageLoaded(recordName, inst, packageId) {
|
|
2103
|
-
var _a;
|
|
2104
2448
|
const loaded = await this.listLoadedPackages(recordName, inst);
|
|
2105
|
-
return
|
|
2449
|
+
return loaded.find((p) => p.packageId === packageId) ?? null;
|
|
2106
2450
|
}
|
|
2107
2451
|
async saveInst(inst) {
|
|
2108
2452
|
const r = await this._getInstRecord(inst.recordName);
|
|
@@ -2117,7 +2461,7 @@ export class MemoryStore {
|
|
|
2117
2461
|
const { branches, ...rest } = inst;
|
|
2118
2462
|
let update = {
|
|
2119
2463
|
branches: null,
|
|
2120
|
-
...(i
|
|
2464
|
+
...(i ?? {
|
|
2121
2465
|
instSizeInBytes: 0,
|
|
2122
2466
|
}),
|
|
2123
2467
|
...rest,
|
|
@@ -2354,7 +2698,7 @@ export class MemoryStore {
|
|
|
2354
2698
|
// }
|
|
2355
2699
|
async _getInst(recordName, inst) {
|
|
2356
2700
|
let record = await this._getInstRecord(recordName);
|
|
2357
|
-
return record
|
|
2701
|
+
return record?.get(inst);
|
|
2358
2702
|
}
|
|
2359
2703
|
async _getInstRecord(recordName) {
|
|
2360
2704
|
let record = this._instRecords.get(recordName);
|
|
@@ -2367,5 +2711,29 @@ export class MemoryStore {
|
|
|
2367
2711
|
}
|
|
2368
2712
|
return record;
|
|
2369
2713
|
}
|
|
2714
|
+
async savePurchasedItem(item) {
|
|
2715
|
+
const index = this._purchasedItems.findIndex((i) => i.id === item.id);
|
|
2716
|
+
if (index >= 0) {
|
|
2717
|
+
this._purchasedItems[index] = {
|
|
2718
|
+
...item,
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
else {
|
|
2722
|
+
this._purchasedItems.push({
|
|
2723
|
+
...item,
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
async createActivationKey(key) {
|
|
2728
|
+
this._activationKeys.push({
|
|
2729
|
+
...key,
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
async getActivationKeyById(id) {
|
|
2733
|
+
return this._activationKeys.find((k) => k.id === id);
|
|
2734
|
+
}
|
|
2735
|
+
async listPurchasedItemsByActivationKeyId(keyId) {
|
|
2736
|
+
return this._purchasedItems.filter((i) => i.activationKeyId === keyId);
|
|
2737
|
+
}
|
|
2370
2738
|
}
|
|
2371
2739
|
//# sourceMappingURL=MemoryStore.js.map
|