-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: develop
Are you sure you want to change the base?
Conversation
…ng of UUID strings to non-UUID strings
…feature/integrate-xp-api
…feature/integrate-xp-api
…feature/integrate-xp-api
…feature/integrate-xp-api
This commit adds (separates and abstracts from existing impl) the interface, which represents a memory lock store used to store and enforce locks in memory. It includes a method to acquire a lock for a given ID with a specified timeout.
The word aquire has been corrected to acquire
This commit adds the XpStore interface and related interfaces for managing XP accounts, users, contracts, invoices, and account entries. It also includes the implementation of these interfaces in the MemoryStore class. The XpStore allows saving and retrieving XP accounts and users, as well as performing transactions and accessing meta data associated with users in the Xp system.
This is a WIP commit, no errors but lacking viability/relevance in relation to codebase
This commit adds the implementation of the createXpAccount and createXpUser methods in the XpController class. The createXpAccount method creates a new XP account with a unique ID and initializes it with default values. The createXpUser method creates a new XP user with a unique ID and associates it with an email address. Both methods are asynchronous and will be updated but are not yet fully able to perform the necessary operations to save the created accounts and users in the XpStore.
…feature/integrate-xp-api
…feature/integrate-xp-api
This commit adds utility types and functions for object manipulation. These changes contribute to the codebase by providing reusable utility types and functions for object manipulation.
…feature/integrate-xp-api
…feature/integrate-xp-api
… user retrieval and creation
…nd integrate getUserMeta into RecordsServer
…db.UUID type for xpUserId; create migration scripts for new XpSystemEvent and XpSystemEventAdjustment tables
…feature/integrate-xp-api
…feature/integrate-xp-api
getXpUserMeta: procedure() | ||
.origins('api') | ||
.http('GET', '/api/v2/xp/user') | ||
.inputs(GetXpUserById) | ||
.handler(async (input, context) => { | ||
const authUser = await this._validateSessionKey( | ||
context.sessionKey | ||
); | ||
if (!authUser.success) { | ||
return authUser; | ||
} | ||
if (!input.userId && !input.xpId && !authUser.userId) { | ||
return { | ||
success: false, | ||
errorCode: 'unacceptable_request', | ||
errorMessage: | ||
'One of properties userId or xpId must be provided.', | ||
}; | ||
} | ||
if (input.userId && input.xpId) { | ||
return { | ||
success: false, | ||
errorCode: 'unacceptable_request', | ||
errorMessage: | ||
'You cannot provide both userId and xpId.\nProperties are mutually exclusive.', | ||
}; | ||
} | ||
//* An empty string for any of the query types will be treated as the current logged in user | ||
const user = await this._xpController.getXpUser( | ||
input.xpId | ||
? { xpId: input.xpId } | ||
: input.userId | ||
? { userId: input.userId } | ||
: { userId: authUser.userId } | ||
); | ||
return user; | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LandonSiler If xpController is null or undefined, then this procedure should check that and return a not_supported
result just like the getNotificationsApplicationServerKey
procedure.
}) | ||
) | ||
.handler(async ({ contract }, context) => { | ||
const authUser = await this._validateSessionKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LandonSiler This procedure should check to see if the xpController is supported as well.
{ contractId, newStatus, newDescription }, | ||
context | ||
) => { | ||
const authUser = await this._validateSessionKey( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LandonSiler This procedure should check to see if the xpController is supported as well.
beforeAll(async () => { | ||
initServices(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LandonSiler Technically this isn't needed because the services are being initialized before each test.
(await this._xpStore[ | ||
`getXpUserBy${id.userId ? 'Auth' : ''}Id` | ||
](id.userId ?? id.xpId)) ?? null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LandonSiler Please prefer regular dot-syntax for choosing which store function to call. IMO it will be easier to read and also won't require constructing a new string just to call a function:
let user = id.userId ?
await this._xpStore.getXpUserByAuthId(id.userId) :
await this._xpStore.getXpUserById(id.xpId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely 👍, I believe my initial plan with the dynamic accessing was to support multiple forms of Id querying which weren't implemented in any capacity outside of auth and xp Ids', this is/was a YAGNI moment :)
This pull request includes several changes across multiple files to enhance the functionality and configuration of the xp api within the project. The most important changes focus on updates to the
MemoryStore
class, integration of XP features, and the addition of the XpController.Enhancements to
MemoryStore
:XpUser
,XpAccount
,XpContract
, andXpInvoice
insrc/aux-records/MemoryStore.ts
[1] [2].saveXpAccount
,createXpUserWithAccount
,saveXpUser
,saveXpContract
, and various getters for XP entities insrc/aux-records/MemoryStore.ts
[1] [2].Integration of XP features:
XpController
and integrated it into theRecordsServer
class to handle XP-related requests insrc/aux-records/RecordsServer.ts
[1] [2].getXpUserMeta
,createXpContract
, andupdateXpContract
insrc/aux-records/RecordsServer.ts
.Development environment settings:
.vscode/settings.json
to include preferences for JavaScript module specifiers and spell-checking custom words.docker/docker-compose.dev.yml
to use a configuration file for Redis and updated the Redis configuration indocker/conf/redis.conf
[1] [2].Additional updates:
jakefile.js
to update the path for thetsconfig.json
file in thegenerate-stub-projects
task.src/aux-records/TestUtils.ts
,src/aux-records/Utils.spec.ts
) [1] [2] [3] [4].These changes collectively improve the project's functionality, particularly around XP management, and enhance the development environment configuration.
Closes #506