Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/integrate xp api: GetXpUserMeta #572

Open
wants to merge 59 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
f8f01f8
chore(xp-api): init relevant config
LandonSiler Jul 8, 2024
eb811ac
feat: Add data model for xpAPI
KallynGowdy Jul 10, 2024
d5440eb
fix(prisma): Update XP API model relations to correct mismatched typi…
LandonSiler Jul 24, 2024
f3a89b5
chore: Add index.ts to XP API and include src/xp-api in pnpm lock
LandonSiler Jul 24, 2024
c5cf62c
docs(xp-api): Add developers.md
LandonSiler Jul 25, 2024
ecd9f39
feat(xp-api): Add generic type utilities and functions
LandonSiler Jul 25, 2024
e70aa1a
test(xp-api): Add structure for tests
LandonSiler Jul 25, 2024
052c635
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Jul 25, 2024
9f9bc44
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Jul 31, 2024
010e6c3
docs(xp-api): Expand terminology definitions and clean up markdown
LandonSiler Jul 31, 2024
e62bfcf
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Aug 24, 2024
1f35662
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Aug 29, 2024
4825af0
docs(xp-api): xp prisma comments better define property niche
LandonSiler Aug 29, 2024
3b401f5
chore: Update cSpell dictionary with KASP
LandonSiler Aug 30, 2024
c9d39ca
feat: Add ISO4217 currency code map and ArrayOfKASP utility type
LandonSiler Aug 30, 2024
31f0a33
chore: Remove unused test utility typings
LandonSiler Aug 30, 2024
b0b20de
feat: Add utility functions for error handling and type manipulation
LandonSiler Aug 30, 2024
50db0e5
chore: Update schema to implement optional flags on certain xp api types
LandonSiler Sep 3, 2024
a5b7800
feat: Add MemoryLockStore interface
LandonSiler Sep 4, 2024
b4f3050
refactor: Correct typo in code and documentation
LandonSiler Sep 4, 2024
c610102
docs: Add acronyms KASP and DMC to developers.md
LandonSiler Sep 4, 2024
3c23308
feat: Add XpStore and implementation in MemoryStore
LandonSiler Sep 4, 2024
e5a2fc9
refactor: Update import path for TypeUtils in Utils.ts
LandonSiler Sep 4, 2024
bc38689
fix: Testing is more relevant
LandonSiler Sep 4, 2024
a42e1a3
feat: Add XpController and framework methods
LandonSiler Sep 4, 2024
a2b3483
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Sep 4, 2024
25522db
feat: Add models that allow tracking events and adjustments to the sy…
KallynGowdy Sep 18, 2024
5cf23a9
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Sep 23, 2024
66cd1c5
chore: Remove unnecessary path from tsconfig.test.json
LandonSiler Oct 17, 2024
d479431
feat: Add utility types and functions for object manipulation
LandonSiler Oct 17, 2024
8ccb058
feat: Implement XpStore in MemoryStore
LandonSiler Oct 17, 2024
2f7d6c1
feat: Add XpStore to aux-records
LandonSiler Oct 17, 2024
bd4fc93
fix: saveXpUser parameter requests correct user id
LandonSiler Oct 17, 2024
495c286
fix: getXpUser method allows getting a user by xp and auth id
LandonSiler Oct 17, 2024
0e20f09
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Oct 21, 2024
21bc91e
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Oct 23, 2024
7df1c3b
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Oct 23, 2024
19c341f
chore: remove unused xp-api files and update implementing parties
LandonSiler Oct 31, 2024
5df0717
chore: add dev Redis configuration file and update docker-compose for…
LandonSiler Oct 31, 2024
d4d0f1c
feat: add XpController to aux-records exports
LandonSiler Oct 31, 2024
71117f7
refactor: update MemoryStore methods to use SuccessResult and improve…
LandonSiler Oct 31, 2024
f8c5a30
feat: add utility functions for type checking and error handling
LandonSiler Oct 31, 2024
352473d
feat: implement top level xp api and getUserMeta method
LandonSiler Oct 31, 2024
c2e106d
feat: enhance XpStore with new user creation and retrieval methods, a…
LandonSiler Oct 31, 2024
e0ec90b
fix: correct import path for handleAxiosErrors in SloydInterface
LandonSiler Oct 31, 2024
6a328b8
feat: update XpUser model to make accountId non-nullable and enforce …
LandonSiler Oct 31, 2024
167125b
feat: integrate XpStore and XpController into ServerBuilder
LandonSiler Oct 31, 2024
d272f24
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Oct 31, 2024
3cc8ac3
feat: add XpController testing utilities
LandonSiler Oct 31, 2024
899c893
refactor: Make relative import references consistent
LandonSiler Nov 12, 2024
3674d68
feat: enhance getXpUserMeta functionality and standards
LandonSiler Nov 18, 2024
6bb640f
feat: implement saveXpContract
LandonSiler Nov 19, 2024
2c61a79
fix: implemented missing syntax
LandonSiler Nov 19, 2024
bb1431c
feat: Improve contract and invoice models
LandonSiler Nov 19, 2024
dedd343
Merge branch 'develop' of github.com:casual-simulation/casualos into …
LandonSiler Nov 19, 2024
3274924
test: Add snapshots for xp integrations
LandonSiler Nov 19, 2024
f0cd938
feat: Add schema for querying users consistently in api
LandonSiler Nov 19, 2024
f793293
feat: Add snapshot expectations createXpContract, updateXpContract
LandonSiler Nov 19, 2024
644cecd
fix: PR review consistency improvements
LandonSiler Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.detectIndentation": false,
"javascript.preferences.importModuleSpecifier": "relative",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"workbench.colorCustomizations": {},
"deno.enable": false,
"jest.autoEnable": false,
"typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.tsserver.maxTsServerMemory": 8192,
"jest.autoRun": "off"
"jest.autoRun": "off",
"cSpell.words": ["KASP"]
}
2 changes: 2 additions & 0 deletions docker/conf/redis.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bind 0.0.0.0 ::
protected-mode no
4 changes: 3 additions & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ services:
- '6379:6379'
networks:
- enable_ipv6
command: ['redis-server', '--bind', '0.0.0.0', '::']
volumes:
- ./conf/redis.conf:/etc/redis.conf
command: ['redis-server', '/etc/redis.conf']
livekit:
image: livekit/livekit-server:v1.8.0
restart: always
Expand Down
2 changes: 1 addition & 1 deletion jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ task('generate-stub-projects', [], async function () {
const { existsSync, writeFileSync, mkdirSync } = await import('fs');

const projects = [
path.resolve(__dirname, 'xpexchange', 'xp-api', 'tsconfig.json'),
path.resolve(__dirname, 'xpexchange', 'tsconfig.json'),
path.resolve(
__dirname,
'extensions',
Expand Down
84 changes: 82 additions & 2 deletions src/aux-records/MemoryStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { cloneDeep, orderBy, sortBy } from 'lodash';
import { RegexRule } from './Utils';
import { cloneDeepNull, RegexRule } from './Utils';
import {
AddressType,
AuthInvoice,
Expand Down Expand Up @@ -149,6 +149,15 @@ import {
} from './SystemNotificationMessenger';
import { ModerationConfiguration } from './ModerationConfiguration';
import { uniq } from 'lodash';
import {
XpAccount,
XpAccountEntry,
XpContract,
XpInvoice,
XpStore,
XpUser,
} from './XpStore';
import { SuccessResult } from './TypeUtils';

export interface MemoryConfiguration {
subscriptions: SubscriptionConfiguration;
Expand All @@ -168,7 +177,8 @@ export class MemoryStore
ConfigurationStore,
InstRecordsStore,
ModerationStore,
SystemNotificationMessenger
SystemNotificationMessenger,
XpStore
{
private _users: AuthUser[] = [];
private _userAuthenticators: AuthUserAuthenticator[] = [];
Expand Down Expand Up @@ -213,6 +223,13 @@ export class MemoryStore
private _studioLoomConfigs: Map<string, LoomConfig> = new Map();
private _studioHumeConfigs: Map<string, HumeConfig> = new Map();

private _xpUsers: Map<XpUser['id'], XpUser> = new Map();
private _xpAccounts: Map<XpAccount['id'], XpAccount> = new Map();
private _xpContracts: Map<XpContract['id'], XpContract> = new Map();
private _xpInvoices: Map<XpInvoice['id'], XpInvoice> = new Map();
private _xpAccountEntries: Map<XpAccountEntry['id'], XpAccountEntry> =
new Map();

// TODO: Support global permissions
// private _globalPermissionAssignments: GlobalPermissionAssignment[] = [];

Expand Down Expand Up @@ -351,6 +368,69 @@ export class MemoryStore
this.roleAssignments = {};
}

async saveXpAccount(
associationId: XpUser['id'] | XpContract['id'],
account: XpAccount
): Promise<SuccessResult> {
this._xpAccounts.set(associationId, account);
return {
success: true,
};
}

async saveXpUserWithAccount(user: XpUser, account: XpAccount) {
this._xpUsers.set(user.id, user);
this._xpAccounts.set(account.id, account);
}

async saveXpUser(id: XpUser['id'], user: XpUser): Promise<SuccessResult> {
this._xpUsers.set(id, user);
return {
success: true,
};
}

async saveXpContract(
contract: XpContract,
account: XpAccount | null
): Promise<void> {
this._xpContracts.set(contract.id, contract);
if (account !== null) {
this._xpAccounts.set(account.id, account);
}
}

async getXpUserByAuthId(id: AuthUser['id']): Promise<XpUser> {
const user = Array.from(this._xpUsers.values()).find(
(u: XpUser) => u.userId === id
);
return cloneDeepNull(user ?? undefined);
}

async getXpUserById(id: XpUser['id']): Promise<XpUser> {
return cloneDeep(this._xpUsers.get(id) ?? undefined);
}

async getXpAccount(
associationId: XpUser['id'] | XpContract['id']
): Promise<XpAccount> {
return cloneDeepNull(this._xpAccounts.get(associationId) ?? undefined);
}

async getXpAccountEntry(
entryId: XpAccountEntry['id']
): Promise<XpAccountEntry> {
return cloneDeepNull(this._xpAccountEntries.get(entryId) ?? undefined);
}

async getXpContract(contractId: XpContract['id']): Promise<XpContract> {
return cloneDeepNull(this._xpContracts.get(contractId) ?? undefined);
}

async getXpInvoice(invoiceId: XpInvoice['id']): Promise<XpInvoice> {
return cloneDeepNull(this._xpInvoices.get(invoiceId) ?? undefined);
}

init?(): Promise<void>;

/**
Expand Down
Loading