@casual-simulation/aux-records 3.7.0 → 3.7.1-alpha.17585632798

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/MemoryStore.d.ts +2 -1
  2. package/MemoryStore.js +30 -0
  3. package/MemoryStore.js.map +1 -1
  4. package/PolicyController.d.ts +27 -0
  5. package/PolicyController.js +2 -1
  6. package/PolicyController.js.map +1 -1
  7. package/PolicyStore.d.ts +13 -0
  8. package/PolicyStore.js +16 -0
  9. package/PolicyStore.js.map +1 -1
  10. package/RecordsController.d.ts +0 -5
  11. package/RecordsServer.d.ts +61 -5
  12. package/RecordsServer.js +61 -3
  13. package/RecordsServer.js.map +1 -1
  14. package/ServerConfig.d.ts +413 -0
  15. package/ServerConfig.js +32 -0
  16. package/ServerConfig.js.map +1 -1
  17. package/SubscriptionConfigBuilder.d.ts +4 -1
  18. package/SubscriptionConfigBuilder.js +14 -0
  19. package/SubscriptionConfigBuilder.js.map +1 -1
  20. package/SubscriptionConfiguration.d.ts +287 -0
  21. package/SubscriptionConfiguration.js +41 -0
  22. package/SubscriptionConfiguration.js.map +1 -1
  23. package/crud/CrudRecordsController.d.ts +19 -2
  24. package/crud/CrudRecordsController.js +13 -6
  25. package/crud/CrudRecordsController.js.map +1 -1
  26. package/crud/CrudRecordsControllerTests.d.ts +3 -3
  27. package/crud/CrudRecordsControllerTests.js +15 -4
  28. package/crud/CrudRecordsControllerTests.js.map +1 -1
  29. package/database/DatabaseInterface.d.ts +103 -0
  30. package/database/DatabaseInterface.js +19 -0
  31. package/database/DatabaseInterface.js.map +1 -0
  32. package/database/DatabaseRecordsController.d.ts +92 -0
  33. package/database/DatabaseRecordsController.js +167 -0
  34. package/database/DatabaseRecordsController.js.map +1 -0
  35. package/database/DatabaseRecordsStore.d.ts +40 -0
  36. package/database/DatabaseRecordsStore.js +2 -0
  37. package/database/DatabaseRecordsStore.js.map +1 -0
  38. package/database/DatabaseUtils.d.ts +12 -0
  39. package/database/DatabaseUtils.js +33 -0
  40. package/database/DatabaseUtils.js.map +1 -0
  41. package/database/MemoryDatabaseInterface.d.ts +14 -0
  42. package/database/MemoryDatabaseInterface.js +119 -0
  43. package/database/MemoryDatabaseInterface.js.map +1 -0
  44. package/database/MemoryDatabaseRecordsStore.d.ts +10 -0
  45. package/database/MemoryDatabaseRecordsStore.js +38 -0
  46. package/database/MemoryDatabaseRecordsStore.js.map +1 -0
  47. package/database/SqliteDatabaseInterface.d.ts +16 -0
  48. package/database/SqliteDatabaseInterface.js +135 -0
  49. package/database/SqliteDatabaseInterface.js.map +1 -0
  50. package/database/TursoDatabaseInterface.d.ts +31 -0
  51. package/database/TursoDatabaseInterface.js +221 -0
  52. package/database/TursoDatabaseInterface.js.map +1 -0
  53. package/database/index.d.ts +7 -0
  54. package/database/index.js +24 -0
  55. package/database/index.js.map +1 -0
  56. package/package.json +6 -4
  57. package/packages/PackageRecordsController.d.ts +3 -2
  58. package/packages/PackageRecordsController.js +30 -1
  59. package/packages/PackageRecordsController.js.map +1 -1
  60. package/search/SearchRecordsController.d.ts +6 -6
  61. package/search/SearchRecordsController.js.map +1 -1
  62. package/webhooks/WebhookRecordsController.d.ts +3 -1
  63. package/webhooks/WebhookRecordsController.js +21 -19
  64. package/webhooks/WebhookRecordsController.js.map +1 -1
  65. package/websockets/InstRecordsStore.d.ts +7 -0
  66. package/websockets/SplitInstRecordsStore.d.ts +1 -0
  67. package/websockets/SplitInstRecordsStore.js +3 -0
  68. package/websockets/SplitInstRecordsStore.js.map +1 -1
  69. package/websockets/WebsocketController.d.ts +1 -1
  70. package/websockets/WebsocketController.js +45 -29
  71. package/websockets/WebsocketController.js.map +1 -1
@@ -0,0 +1,92 @@
1
+ import type { ActionKinds, Result, SimpleError } from '@casual-simulation/aux-common';
2
+ import type { AuthorizationContext, AuthorizeUserAndInstancesSuccess, AuthorizeUserAndInstancesForResourcesSuccess } from '../PolicyController';
3
+ import type { CrudRecordsConfiguration, CheckSubscriptionMetricsFailure, CheckSubscriptionMetricsSuccess } from '../crud';
4
+ import { CrudRecordsController } from '../crud';
5
+ import type { DatabasesFeaturesConfiguration, SubscriptionConfiguration } from '../SubscriptionConfiguration';
6
+ import type { DatabaseRecord, DatabaseRecordsStore, DatabaseSubscriptionMetrics } from './DatabaseRecordsStore';
7
+ import type { DatabaseInterface, DatabaseStatement, QueryResult, SQliteDatabase, TursoDatabase } from './DatabaseInterface';
8
+ export type DatabaseType = SQliteDatabase | TursoDatabase;
9
+ /**
10
+ * Defines the configuration for a webhook records controller.
11
+ */
12
+ export interface DatabaseRecordsConfiguration extends Omit<CrudRecordsConfiguration<DatabaseRecord, DatabaseRecordsStore>, 'resourceKind' | 'allowRecordKeys' | 'name'> {
13
+ /**
14
+ * The name of the provider that the interface uses.
15
+ */
16
+ databaseInterfaceProviderName: 'sqlite' | 'turso';
17
+ /**
18
+ * The interface to the search engine that should be used.
19
+ */
20
+ databaseInterface: DatabaseInterface<DatabaseType>;
21
+ }
22
+ /**
23
+ * Defines a controller that can be used to interact with DatabaseRecords.
24
+ */
25
+ export declare class DatabaseRecordsController extends CrudRecordsController<DatabaseRecordInput, DatabaseRecord, DatabaseRecordsStore, DatabaseRecordOutput> {
26
+ private _databaseInterface;
27
+ private _providerName;
28
+ constructor(config: DatabaseRecordsConfiguration);
29
+ query(request: DatabaseQuery): Promise<Result<QueryResult[], SimpleError>>;
30
+ protected _eraseItemCore(recordName: string, address: string, item: DatabaseRecord, authorization: AuthorizeUserAndInstancesSuccess | AuthorizeUserAndInstancesForResourcesSuccess): Promise<Result<void, SimpleError>>;
31
+ protected _convertItemToResult(item: DatabaseRecord, context: AuthorizationContext, action: ActionKinds): Promise<DatabaseRecordOutput>;
32
+ protected _convertItemsToResults(items: DatabaseRecord[], context: AuthorizationContext, action: ActionKinds): Promise<DatabaseRecordOutput[]>;
33
+ protected _transformInputItem(item: DatabaseRecordInput, existingItem: DatabaseRecord, action: ActionKinds, context: AuthorizationContext, authorization: AuthorizeUserAndInstancesSuccess | AuthorizeUserAndInstancesForResourcesSuccess, metrics: DatabaseRecordsSubscriptionMetricsSuccess): Promise<Result<DatabaseRecord, SimpleError>>;
34
+ protected _checkSubscriptionMetrics(action: ActionKinds, context: AuthorizationContext, authorization: AuthorizeUserAndInstancesSuccess | AuthorizeUserAndInstancesForResourcesSuccess, item?: DatabaseRecordInput): Promise<DatabaseRecordsSubscriptionMetricsResult>;
35
+ }
36
+ export type DatabaseRecordsSubscriptionMetricsResult = DatabaseRecordsSubscriptionMetricsSuccess | CheckSubscriptionMetricsFailure;
37
+ export interface DatabaseRecordsSubscriptionMetricsSuccess extends CheckSubscriptionMetricsSuccess {
38
+ config: SubscriptionConfiguration;
39
+ metrics: DatabaseSubscriptionMetrics;
40
+ features: DatabasesFeaturesConfiguration;
41
+ }
42
+ export interface DatabaseRecordInput extends Omit<DatabaseRecord, 'databaseInfo' | 'databaseProvider' | 'databaseName'> {
43
+ }
44
+ /**
45
+ * Defines a record that represents a database that can be queried using SQL.
46
+ *
47
+ * @dochash types/records/database
48
+ * @docname DatabaseRecord
49
+ */
50
+ export interface DatabaseRecordOutput extends Omit<DatabaseRecord, 'databaseInfo' | 'databaseProvider' | 'databaseName'> {
51
+ }
52
+ /**
53
+ * Defines a request to query a database.
54
+ *
55
+ * @dochash types/records/database
56
+ * @docname DatabaseQuery
57
+ */
58
+ export interface DatabaseQuery {
59
+ /**
60
+ * The name of the record that the search should be performed on.
61
+ */
62
+ recordName: string;
63
+ /**
64
+ * The address of the search record that the search should be performed on.
65
+ */
66
+ address: string;
67
+ /**
68
+ * The SQL statements to execute.
69
+ */
70
+ statements: DatabaseStatement[];
71
+ /**
72
+ * Whether the query should be executed in read-only mode.
73
+ *
74
+ * This is a safety switch that helps prevent accidental modifications to the database.
75
+ */
76
+ readonly: boolean;
77
+ /**
78
+ * Whether to automatically wrap the statements in a transaction if there are multiple statements.
79
+ *
80
+ * Defaults to true.
81
+ */
82
+ automaticTransaction?: boolean;
83
+ /**
84
+ * The ID of the user that is currently logged in.
85
+ */
86
+ userId: string | null;
87
+ /**
88
+ * The instance(s) that are making the request.
89
+ */
90
+ instances: string[];
91
+ }
92
+ //# sourceMappingURL=DatabaseRecordsController.d.ts.map
@@ -0,0 +1,167 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { failure, isFailure, success } from '@casual-simulation/aux-common';
8
+ import { CrudRecordsController } from '../crud';
9
+ import { getDatabaseFeatures } from '../SubscriptionConfiguration';
10
+ import { v4 as uuid } from 'uuid';
11
+ import { traced } from '../tracing/TracingDecorators';
12
+ const TRACE_NAME = 'DatabaseRecordsController';
13
+ /**
14
+ * Defines a controller that can be used to interact with DatabaseRecords.
15
+ */
16
+ export class DatabaseRecordsController extends CrudRecordsController {
17
+ constructor(config) {
18
+ super({
19
+ ...config,
20
+ name: 'DatabaseRecordsController',
21
+ resourceKind: 'database',
22
+ });
23
+ this._providerName = config.databaseInterfaceProviderName;
24
+ this._databaseInterface = config.databaseInterface;
25
+ }
26
+ async query(request) {
27
+ var _a;
28
+ const baseRequest = {
29
+ recordKeyOrRecordName: request.recordName,
30
+ userId: request.userId,
31
+ instances: request.instances,
32
+ };
33
+ const context = await this.policies.constructAuthorizationContext(baseRequest);
34
+ if (context.success === false) {
35
+ return failure(context);
36
+ }
37
+ const item = await this.store.getItemByAddress(context.context.recordName, request.address);
38
+ if (!item) {
39
+ return failure({
40
+ success: false,
41
+ errorCode: 'data_not_found',
42
+ errorMessage: 'The item was not found.',
43
+ });
44
+ }
45
+ const markers = item.markers;
46
+ const resources = [
47
+ {
48
+ resourceKind: this.resourceKind,
49
+ resourceId: request.address,
50
+ markers: markers,
51
+ action: 'read',
52
+ },
53
+ ];
54
+ if (!request.readonly) {
55
+ resources.push({
56
+ resourceKind: this.resourceKind,
57
+ resourceId: request.address,
58
+ markers: markers,
59
+ action: 'update',
60
+ });
61
+ }
62
+ const authorization = await this.policies.authorizeUserAndInstancesForResources(context.context, {
63
+ userId: request.userId,
64
+ instances: request.instances,
65
+ resources: resources,
66
+ });
67
+ if (authorization.success === false) {
68
+ return failure(authorization);
69
+ }
70
+ const result = await this._databaseInterface.query(item.databaseInfo, request.statements, request.readonly, (_a = request.automaticTransaction) !== null && _a !== void 0 ? _a : true);
71
+ return result;
72
+ }
73
+ async _eraseItemCore(recordName, address, item, authorization) {
74
+ const result = await super._eraseItemCore(recordName, address, item, authorization);
75
+ if (isFailure(result)) {
76
+ return result;
77
+ }
78
+ await this._databaseInterface.deleteDatabase(item.databaseName);
79
+ return success();
80
+ }
81
+ async _convertItemToResult(item, context, action) {
82
+ return {
83
+ address: item.address,
84
+ markers: item.markers,
85
+ };
86
+ }
87
+ async _convertItemsToResults(items, context, action) {
88
+ return items.map((i) => ({
89
+ address: i.address,
90
+ markers: i.markers,
91
+ }));
92
+ }
93
+ async _transformInputItem(item, existingItem, action, context, authorization, metrics) {
94
+ if (action !== 'create' && action !== 'update') {
95
+ return failure({
96
+ errorCode: 'action_not_supported',
97
+ errorMessage: `The action '${action}' is not supported for database records.`,
98
+ });
99
+ }
100
+ if (action === 'create') {
101
+ const databaseName = uuid();
102
+ const database = await this._databaseInterface.createDatabase(databaseName, {
103
+ maxSizeBytes: metrics.features.maxBytesPerDatabase,
104
+ });
105
+ if (isFailure(database)) {
106
+ return database;
107
+ }
108
+ return success({
109
+ address: item.address,
110
+ markers: item.markers,
111
+ databaseProvider: this._providerName,
112
+ databaseInfo: database.value,
113
+ databaseName: databaseName,
114
+ });
115
+ }
116
+ else if (action === 'update') {
117
+ // For updates, we need to update the existing collection's schema
118
+ if (!existingItem) {
119
+ return failure({
120
+ errorCode: 'record_not_found',
121
+ errorMessage: 'Cannot update a database record that does not exist.',
122
+ });
123
+ }
124
+ return success({
125
+ address: item.address,
126
+ markers: item.markers,
127
+ databaseProvider: existingItem.databaseProvider,
128
+ databaseInfo: existingItem.databaseInfo,
129
+ databaseName: existingItem.databaseName,
130
+ });
131
+ }
132
+ }
133
+ async _checkSubscriptionMetrics(action, context, authorization, item) {
134
+ const config = await this.config.getSubscriptionConfiguration();
135
+ const metrics = await this.store.getSubscriptionMetrics({
136
+ ownerId: context.recordOwnerId,
137
+ studioId: context.recordStudioId,
138
+ });
139
+ const features = getDatabaseFeatures(config, metrics.subscriptionStatus, metrics.subscriptionId, metrics.subscriptionType, metrics.currentPeriodStartMs, metrics.currentPeriodEndMs);
140
+ if (!features.allowed) {
141
+ return {
142
+ success: false,
143
+ errorCode: 'not_authorized',
144
+ errorMessage: 'Database records are not allowed for this subscription.',
145
+ };
146
+ }
147
+ if (action === 'create' && typeof features.maxItems === 'number') {
148
+ if (metrics.totalItems >= features.maxItems) {
149
+ return {
150
+ success: false,
151
+ errorCode: 'subscription_limit_reached',
152
+ errorMessage: 'The maximum number of database record items has been reached for your subscription.',
153
+ };
154
+ }
155
+ }
156
+ return {
157
+ success: true,
158
+ config,
159
+ metrics,
160
+ features,
161
+ };
162
+ }
163
+ }
164
+ __decorate([
165
+ traced(TRACE_NAME)
166
+ ], DatabaseRecordsController.prototype, "query", null);
167
+ //# sourceMappingURL=DatabaseRecordsController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseRecordsController.js","sourceRoot":"","sources":["DatabaseRecordsController.ts"],"names":[],"mappings":";;;;;;AAsBA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAY5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAKhD,OAAO,EAAE,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B;gBAC3B,YAAY,EACR,yDAAyD;aAChE,CAAC;QACN,CAAC;QAED,IAAI,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC/D,IAAI,OAAO,CAAC,UAAU,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBAC1C,OAAO;oBACH,OAAO,EAAE,KAAK;oBACd,SAAS,EAAE,4BAA4B;oBACvC,YAAY,EACR,qFAAqF;iBAC5F,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO;YACH,OAAO,EAAE,IAAI;YACb,MAAM;YACN,OAAO;YACP,QAAQ;SACX,CAAC;IACN,CAAC;CACJ;AAlOS;IADL,MAAM,CAAC,UAAU,CAAC;sDAyElB"}
@@ -0,0 +1,40 @@
1
+ import type { CrudRecord, CrudRecordsStore, CrudSubscriptionMetrics } from '../crud';
2
+ import type { SubscriptionFilter } from '../MetricsStore';
3
+ import type { SQliteDatabase, TursoDatabase } from './DatabaseInterface';
4
+ /**
5
+ * Defines a store that contains search records.
6
+ */
7
+ export interface DatabaseRecordsStore extends CrudRecordsStore<DatabaseRecord> {
8
+ /**
9
+ * Gets the item metrics for the subscription of the given user or studio.
10
+ * @param filter The filter to use.
11
+ */
12
+ getSubscriptionMetrics(filter: SubscriptionFilter): Promise<DatabaseSubscriptionMetrics>;
13
+ }
14
+ /**
15
+ * Defines a record that represents a database that can be queried using SQL.
16
+ */
17
+ export interface DatabaseRecord extends CrudRecord {
18
+ /**
19
+ * The provider for the database.
20
+ *
21
+ * - "turso" the database is stored in turso.
22
+ * - "sqlite" The database is stored as a local sqlite database file.
23
+ */
24
+ databaseProvider: 'turso' | 'sqlite';
25
+ /**
26
+ * The info for the database.
27
+ */
28
+ databaseInfo: TursoDatabase | SQliteDatabase;
29
+ /**
30
+ * The name of the database.
31
+ */
32
+ databaseName: string;
33
+ }
34
+ export interface DatabaseSubscriptionMetrics extends CrudSubscriptionMetrics {
35
+ /**
36
+ * The total number of database records that are stored in the subscription.
37
+ */
38
+ totalItems: number;
39
+ }
40
+ //# sourceMappingURL=DatabaseRecordsStore.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=DatabaseRecordsStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseRecordsStore.js","sourceRoot":"","sources":["DatabaseRecordsStore.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { DatabaseStatement } from './DatabaseInterface';
2
+ /**
3
+ * Constructs a database statement from the given query text and parameters.
4
+ *
5
+ * Can be used as a tagged template string.
6
+ *
7
+ * @param templates The template strings.
8
+ * @param params The parameters for the query.
9
+ * @returns
10
+ */
11
+ export declare function query(templates: TemplateStringsArray, ...params: unknown[]): DatabaseStatement;
12
+ //# sourceMappingURL=DatabaseUtils.d.ts.map
@@ -0,0 +1,33 @@
1
+ /* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences.
2
+ *
3
+ * Copyright (c) 2019-2025 Casual Simulation, Inc.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as
7
+ * published by the Free Software Foundation, either version 3 of the
8
+ * License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ /**
19
+ * Constructs a database statement from the given query text and parameters.
20
+ *
21
+ * Can be used as a tagged template string.
22
+ *
23
+ * @param templates The template strings.
24
+ * @param params The parameters for the query.
25
+ * @returns
26
+ */
27
+ export function query(templates, ...params) {
28
+ return {
29
+ query: templates.join('?'),
30
+ params,
31
+ };
32
+ }
33
+ //# sourceMappingURL=DatabaseUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatabaseUtils.js","sourceRoot":"","sources":["DatabaseUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CACjB,SAA+B,EAC/B,GAAG,MAAiB;IAEpB,OAAO;QACH,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1B,MAAM;KACT,CAAC;AACN,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type Result, type SimpleError } from '@casual-simulation/aux-common';
2
+ import type { CreateDatabaseOptions, DatabaseInterface, DatabaseStatement, QueryResult, SQliteDatabase } from './DatabaseInterface';
3
+ /**
4
+ * Defines a database interface that uses in-memory SQLite databases.
5
+ */
6
+ export declare class MemoryDatabaseInterface implements DatabaseInterface<SQliteDatabase> {
7
+ private _databases;
8
+ get databases(): string[];
9
+ createDatabase(databaseName: string, options: CreateDatabaseOptions): Promise<Result<SQliteDatabase, SimpleError>>;
10
+ deleteDatabase(databaseName: string): Promise<Result<void, SimpleError>>;
11
+ query(database: SQliteDatabase, statements: DatabaseStatement[], readonly: boolean, automaticTransaction: boolean): Promise<Result<QueryResult[], SimpleError>>;
12
+ dispose(): void;
13
+ }
14
+ //# sourceMappingURL=MemoryDatabaseInterface.d.ts.map
@@ -0,0 +1,119 @@
1
+ /* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences.
2
+ *
3
+ * Copyright (c) 2019-2025 Casual Simulation, Inc.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as
7
+ * published by the Free Software Foundation, either version 3 of the
8
+ * License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { failure, success, } from '@casual-simulation/aux-common';
19
+ import BetterSQLite3 from 'libsql';
20
+ /**
21
+ * Defines a database interface that uses in-memory SQLite databases.
22
+ */
23
+ export class MemoryDatabaseInterface {
24
+ constructor() {
25
+ this._databases = new Map();
26
+ }
27
+ get databases() {
28
+ return Array.from(this._databases.keys());
29
+ }
30
+ async createDatabase(databaseName, options) {
31
+ const db = new BetterSQLite3(':memory:');
32
+ this._databases.set(databaseName, db);
33
+ return success({
34
+ filePath: databaseName,
35
+ });
36
+ }
37
+ async deleteDatabase(databaseName) {
38
+ const db = this._databases.get(databaseName);
39
+ if (!db) {
40
+ return failure({
41
+ errorCode: 'not_found',
42
+ errorMessage: 'The database was not found.',
43
+ });
44
+ }
45
+ db.close();
46
+ this._databases.delete(databaseName);
47
+ return success();
48
+ }
49
+ async query(database, statements, readonly, automaticTransaction) {
50
+ try {
51
+ const db = this._databases.get(database.filePath);
52
+ if (!db) {
53
+ return failure({
54
+ errorCode: 'not_found',
55
+ errorMessage: 'The database was not found.',
56
+ });
57
+ }
58
+ const results = [];
59
+ let hasTransaction = false;
60
+ if (automaticTransaction) {
61
+ db.exec('BEGIN;');
62
+ hasTransaction = true;
63
+ }
64
+ for (let s of statements) {
65
+ const q = db.prepare(s.query);
66
+ if (q.reader) {
67
+ q.raw(true);
68
+ const columns = q.columns();
69
+ const rows = q.all(s.params);
70
+ results.push({
71
+ columns: columns.map((c) => c.name),
72
+ rows,
73
+ affectedRowCount: 0,
74
+ });
75
+ }
76
+ else {
77
+ if (readonly && !q.readonly) {
78
+ if (hasTransaction) {
79
+ db.exec('ROLLBACK;');
80
+ }
81
+ return failure({
82
+ errorCode: 'invalid_request',
83
+ errorMessage: 'Queries that modify data are not allowed in read-only mode.',
84
+ });
85
+ }
86
+ const result = q.run(s.params);
87
+ results.push({
88
+ columns: [],
89
+ rows: [],
90
+ affectedRowCount: result.changes,
91
+ lastInsertId: result.lastInsertRowid || undefined,
92
+ });
93
+ }
94
+ }
95
+ if (hasTransaction) {
96
+ db.exec('COMMIT;');
97
+ }
98
+ return success(results);
99
+ }
100
+ catch (err) {
101
+ if (err instanceof BetterSQLite3.SqliteError) {
102
+ return failure({
103
+ errorCode: 'invalid_request',
104
+ errorMessage: err.message,
105
+ });
106
+ }
107
+ else {
108
+ throw err;
109
+ }
110
+ }
111
+ }
112
+ dispose() {
113
+ for (let db of this._databases.values()) {
114
+ db.close();
115
+ }
116
+ this._databases.clear();
117
+ }
118
+ }
119
+ //# sourceMappingURL=MemoryDatabaseInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDatabaseInterface.js","sourceRoot":"","sources":["MemoryDatabaseInterface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACH,OAAO,EACP,OAAO,GAGV,MAAM,+BAA+B,CAAC;AAQvC,OAAO,aAAa,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAApC;QAGY,eAAU,GAAwC,IAAI,GAAG,EAAE,CAAC;IAqHxE,CAAC;IAnHG,IAAI,SAAS;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,YAAoB,EACpB,OAA8B;QAE9B,MAAM,EAAE,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;YACX,QAAQ,EAAE,YAAY;SACzB,CAAC,CAAC;IACP,CAAC;IAED,KAAK,CAAC,cAAc,CAChB,YAAoB;QAEpB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,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CAAC,KAAK,EAAE,CAAC;QACf,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ import { MemoryCrudRecordsStore } from '../crud/MemoryCrudRecordsStore';
2
+ import type { SubscriptionFilter } from '../MetricsStore';
3
+ import type { DatabaseRecord, DatabaseRecordsStore, DatabaseSubscriptionMetrics } from './DatabaseRecordsStore';
4
+ /**
5
+ * A Memory-based implementation of the DatabaseRecordsStore.
6
+ */
7
+ export declare class MemoryDatabaseRecordsStore extends MemoryCrudRecordsStore<DatabaseRecord> implements DatabaseRecordsStore {
8
+ getSubscriptionMetrics(filter: SubscriptionFilter): Promise<DatabaseSubscriptionMetrics>;
9
+ }
10
+ //# sourceMappingURL=MemoryDatabaseRecordsStore.d.ts.map
@@ -0,0 +1,38 @@
1
+ /* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences.
2
+ *
3
+ * Copyright (c) 2019-2025 Casual Simulation, Inc.
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as
7
+ * published by the Free Software Foundation, either version 3 of the
8
+ * License, or (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ * GNU Affero General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Affero General Public License
16
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { MemoryCrudRecordsStore } from '../crud/MemoryCrudRecordsStore';
19
+ /**
20
+ * A Memory-based implementation of the DatabaseRecordsStore.
21
+ */
22
+ export class MemoryDatabaseRecordsStore extends MemoryCrudRecordsStore {
23
+ async getSubscriptionMetrics(filter) {
24
+ const info = await super.getSubscriptionMetrics(filter);
25
+ let totalItems = 0;
26
+ const records = filter.ownerId
27
+ ? await this.store.listRecordsByOwnerId(filter.ownerId)
28
+ : await this.store.listRecordsByStudioId(filter.studioId);
29
+ for (let record of records) {
30
+ totalItems += this.getItemRecord(record.name).size;
31
+ }
32
+ return {
33
+ ...info,
34
+ totalItems,
35
+ };
36
+ }
37
+ }
38
+ //# sourceMappingURL=MemoryDatabaseRecordsStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryDatabaseRecordsStore.js","sourceRoot":"","sources":["MemoryDatabaseRecordsStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAQxE;;GAEG;AACH,MAAM,OAAO,0BACT,SAAQ,sBAAsC;IAG9C,KAAK,CAAC,sBAAsB,CACxB,MAA0B;QAE1B,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAExD,IAAI,UAAU,GAAG,CAAC,CAAC;QAEnB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;YAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC;YACvD,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,QAAS,CAAC,CAAC;QAC/D,KAAK,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;YACzB,UAAU,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QACvD,CAAC;QAED,OAAO;YACH,GAAG,IAAI;YACP,UAAU;SACb,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,16 @@
1
+ import { type Result, type SimpleError } from '@casual-simulation/aux-common';
2
+ import type { CreateDatabaseOptions, DatabaseInterface, DatabaseStatement, QueryResult, SQliteDatabase } from './DatabaseInterface';
3
+ /**
4
+ * Defines a database interface that uses in-memory SQLite databases.
5
+ */
6
+ export declare class SqliteDatabaseInterface implements DatabaseInterface<SQliteDatabase> {
7
+ #private;
8
+ private _folderPath;
9
+ constructor(folder: string, encryptionKey?: string | null);
10
+ createDatabase(databaseName: string, options: CreateDatabaseOptions): Promise<Result<SQliteDatabase, SimpleError>>;
11
+ private _getDatabasePath;
12
+ deleteDatabase(databaseName: string): Promise<Result<void, SimpleError>>;
13
+ query(database: SQliteDatabase, statements: DatabaseStatement[], readonly: boolean, automaticTransaction: boolean): Promise<Result<QueryResult[], SimpleError>>;
14
+ dispose(): void;
15
+ }
16
+ //# sourceMappingURL=SqliteDatabaseInterface.d.ts.map