Skip to content

Develop #290

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

Draft
wants to merge 75 commits into
base: v1
Choose a base branch
from
Draft

Develop #290

wants to merge 75 commits into from

Conversation

Jipperism
Copy link
Contributor

No description provided.

Refactors the base supabase service to apply strategies from
`QueryStrategies.ts` when queried. This simplifies the architecture of
the base service to have cleaner code and improve the testability and
typing of the codebase.

This is a setup for introducing more robust tests and removes the
abundance of any-typed fields
…rgument generation

Introduces a new `argGenerator.ts` to centralize and streamline GraphQL
argument generation across different entity types.

- Created a dynamic argument generation utility that reduces boilerplate
- Removed multiple (or all) input type files in favor of a more generic
approach
- Standardized argument generation for where, sort, and pagination
- Improved type safety and reduced code duplication
- Updated resolvers and type definitions to use the new argument
generation method
- basic tests for argGenerator method
The big one. This commit refactors all away the supabase services in
favor of services per entity.

Query strategies are generated for every tables query. When query args
are detected to referenced tables, the query building is applied
accordingly.

Creating a service for an entity defines the default getSingle and
getMany methods including the argumentation.

Field resolvers are implemented by using injected services and pass the
query args.

The created services also provide specific CRUD like methods, for
example getting collection admins by calling the collection_admins table
via the collections entity service.

The resolver classes are updated to use injected services for the base
type and fields resolvers where need.

As the services were also applied in the API flow, those are updates
following a similar approach.

This commit is the big refactor, subsequent commits add documentation
and test cases.
basic guide on how to add entities to the API
The createSortArgs, applySort and queryModifiers handled the sort fields
input differently.

This commit implements:
- sort fields can only be primitive type (i.e. not reference fields)
- sortBy is an optional fields
- undefined values in sort options
Refactored metadata-related files to use 'hypercerts' instead of 'claims' in query strategies and type definitions. Updated resolvers and type definitions to reflect the new relationship between metadata and hypercerts.
The item_ids consist of token ids of a fraction. Changed the sales query strategy to use 'item_ids' array containment instead of 'token_id'.
Refined the type filtering for addresses by using a type predicate to ensure only non-null string values are included in the address list.
Refined the type definition for query arguments to explicitly include sort order types instead of just object
Adjusted blueprint ID handling to use number type instead of string in multiple files:
- Updated BlueprintController to remove toString() conversion
- Modified WhereFieldDefinitions to change blueprint ID type
- Updated CollectionEntityService to preserve blueprint ID type
Updated UserWhereInput to use WhereFieldDefinitions for User entity. Replaced user input with with type shorthand in upsertUsers.
…ategy

removing the optional metadata join condition, which was unnecessary. Metadata can be fetched via hypercert
Fixed type arguments in CollectionsQueryStrategy to use GetCollectionsArgs instead of GetContractsArgs
Added support for filtering signature requests by status, including:
- Updated signatureRequestArgs to include status field
- Extended SearchOptionType and SearchOptionMap to handle enum search options
…verage and documentation

Improved the createEntitySortArgs utility with:
- Detailed JSDoc documentation explaining function purpose and usage
- Expanded test suite covering edge cases like empty definitions, special characters, and complex field types
…entation and test coverage

Improved the createEntityWhereArgs utility with:
- Detailed JSDoc documentation explaining function purpose, usage, and type handling
- Expanded test suite covering primitive fields, nested reference fields, and error scenarios
- Added comprehensive test cases for field initialization and complex nested structures
…ion and test coverage

Improved the createEntityArgs utility with:
- Detailed JSDoc documentation explaining function purpose, usage, and type handling
- Expanded test suite and added more structure
…and test coverage

Improved the TypeRegistry utility with:
- Detailed JSDoc documentation explaining class purpose, methods, and type handling
- Added clear() method to reset registry state
- Enhanced type safety with generic type parameters
- Expanded test suite covering edge cases, type creation, and registry operations
- Updated import and usage of EntityTypeDefs for consistent type references
…proved testing

Converted TypeRegistry to a tsyringe singleton:
- Added @singleton decorator to TypeRegistry
- Updated import and usage of container from tsyringe
- Refactored test suite to use container.resolve() for registry instances
- Removed manual singleton export in favor of container resolution
- Enhanced singleton behavior tests to verify instance consistency
Updated BaseQueryArgs utility with:
- Detailed JSDoc documentation explaining function purpose, usage, and type handling
- Remaning of test suite to match lib filename
…d table relations

Improved the buildWhereCondition utility with:
- Updated definitions for complex filtering
- Refactored support for custom nested relations to new tableRelations module to manage custom table join conditions
- Extensive test coverage for various filtering scenarios
- Enhanced SQL generation for different filter operators leveraging query parameters instead of inline injection of sql string (sql injection anyone?)
…and usage example

Improved the DataResponse utility with:
- Detailed JSDoc documentation explaining function purpose, usage, and type handling
- Added comprehensive example demonstrating how to create and use the generic response type
- Enhanced inline comments to clarify the purpose of each field and method
Enhanced the WhereFieldDefinitions utility with:
- Detailed JSDoc documentation explaining the purpose and structure of field definitions
- Added type documentation for WhereFieldDefinition to ensure type safety
- Clarified the use case for defining filterable fields across different entities
…d improved testing

Improved the applyPagination utility with:
- Detailed JSDoc documentation explaining function purpose, type parameters, and usage
- Enhanced type definitions for pagination arguments
- Comprehensive test suite covering various pagination scenarios, edge cases, and query builder integration
- Updated testing using pg-mem for in-memory database simulation
…ust testing

Improved the applyWhere utility with:
- Detailed JSDoc documentation explaining function purpose, type parameters, and usage
- Comprehensive test suite covering various filtering scenarios, comparison operators, and query builder integration
- Enhanced testing using pg-mem for in-memory database simulation
…st testing

Improved the applySort utility with:
- Detailed JSDoc documentation explaining function purpose, type parameters, and usage
- Comprehensive test suite covering various sorting scenarios, query builder integration, and data validation
- Enhanced testing using pg-mem for in-memory database simulation
- Removed error handling try-catch block to simplify implementation
… robust testing

Improved the queryModifiers utility with:
- Detailed JSDoc documentation for QueryModifier type, composeQueryModifiers, and createStandardQueryModifier
- Enhanced type safety and flexibility for query modification functions
- Comprehensive test suite using pg-mem for in-memory database simulation
- Added graceful handling of undefined modifier returns
- Verified modifier composition order and individual modifier behaviors
Migrated the following db related method the to appropriate lib
Copy link

github-actions bot commented Apr 17, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 58.2% (🎯 58%) 110 / 189
🟢 Statements 58.2% (🎯 58%) 110 / 189
🟢 Functions 25.53% (🎯 25%) 12 / 47
🟢 Branches 38.98% (🎯 38%) 23 / 59
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/index.ts 0% 0% 0% 0% 1-2
src/client/evmClient.ts 100% 100% 100% 100%
src/client/graphql.ts 0% 0% 0% 0% 1-28
src/client/kysely.ts 100% 100% 100% 100%
src/commands/CommandFactory.ts 0% 0% 0% 0% 1
src/commands/MarketplaceCreateOrderCommand.ts 0% 0% 0% 0% 1
src/commands/SafeApiCommand.ts 0% 0% 0% 0% 1
src/commands/UserUpsertCommand.ts 0% 0% 0% 0% 1
src/controllers/AllowListController.ts 100% 100% 100% 100%
src/controllers/BlueprintController.ts 0% 0% 0% 0% 1
src/controllers/HyperboardController.ts 0% 0% 0% 0% 1
src/controllers/MarketplaceController.ts 0% 0% 0% 0% 1
src/controllers/MetadataController.ts 100% 100% 100% 100%
src/controllers/MonitoringController.ts 100% 100% 100% 100%
src/controllers/SignatureRequestController.ts 0% 0% 0% 0% 1
src/controllers/UploadController.ts 100% 100% 100% 100%
src/controllers/UserController.ts 0% 0% 0% 0% 1
src/lib/db/queryModifiers/applyPagination.ts 100% 100% 100% 100%
src/lib/db/queryModifiers/applySort.ts 100% 100% 100% 100%
src/lib/db/queryModifiers/applyWhere.ts 100% 100% 100% 100%
src/lib/db/queryModifiers/buildWhereCondition.ts 73.68% 88.88% 100% 73.68% 11-15
src/lib/db/queryModifiers/queryModifiers.ts 100% 100% 100% 100%
src/lib/db/queryModifiers/tableRelations.ts 100% 100% 100% 100%
src/lib/graphql/BaseQueryArgs.ts 100% 100% 100% 100%
src/lib/graphql/DataResponse.ts 100% 100% 100% 100%
src/lib/graphql/TypeRegistry.ts 100% 100% 100% 100%
src/lib/graphql/createEntityArgs.ts 100% 100% 100% 100%
src/lib/graphql/createEntitySortArgs.ts 100% 100% 100% 100%
src/lib/graphql/createEntityWhereArgs.ts 100% 100% 100% 100%
src/lib/graphql/whereFieldDefinitions.ts 100% 100% 100% 100%
src/lib/marketplace/EOACreateOrderStrategy.ts 0% 0% 0% 0% 1
src/lib/marketplace/MarketplaceStrategy.ts 0% 0% 0% 0% 1
src/lib/marketplace/MarketplaceStrategyFactory.ts 0% 0% 0% 0% 1
src/lib/marketplace/MultisigCreateOrderStrategy.ts 0% 0% 0% 0% 1
src/lib/strategies/isWhereEmpty.ts 100% 100% 100% 100%
src/lib/tsoa/iocContainer.ts 0% 0% 0% 0% 1
src/lib/users/EOAUpsertStrategy.ts 0% 0% 0% 0% 1
src/lib/users/MultisigUpsertStrategy.ts 0% 0% 0% 0% 1
src/lib/users/UserUpsertStrategy.ts 0% 0% 0% 0% 1
src/services/SignatureRequestProcessor.ts 0% 0% 0% 0% 1
src/services/database/entities/AllowListRecordEntityService.ts 100% 100% 100% 100%
src/services/database/entities/AttestationEntityService.ts 100% 100% 100% 100%
src/services/database/entities/AttestationSchemaEntityService.ts 100% 100% 100% 100%
src/services/database/entities/BlueprintsEntityService.ts 100% 100% 100% 100%
src/services/database/entities/CollectionEntityService.ts 100% 100% 100% 100%
src/services/database/entities/ContractEntityService.ts 100% 100% 100% 100%
src/services/database/entities/EntityServiceFactory.ts 100% 100% 100% 100%
src/services/database/entities/FractionEntityService.ts 100% 100% 100% 100%
src/services/database/entities/HyperboardEntityService.ts 100% 100% 100% 100%
src/services/database/entities/HypercertsEntityService.ts 100% 100% 100% 100%
src/services/database/entities/MarketplaceOrdersEntityService.ts 100% 100% 100% 100%
src/services/database/entities/MetadataEntityService.ts 100% 100% 100% 100%
src/services/database/entities/SalesEntityService.ts 100% 100% 100% 100%
src/services/database/entities/SignatureRequestsEntityService.ts 100% 100% 100% 100%
src/services/database/entities/UsersEntityService.ts 100% 100% 100% 100%
src/services/database/strategies/AllowlistQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/AttestationQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/BlueprintsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/ClaimsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/CollectionsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/ContractsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/FractionsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/HyperboardsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/MarketplaceOrdersQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/MetadataQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/QueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/QueryStrategyFactory.ts 100% 100% 100% 100%
src/services/database/strategies/SalesQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/SignatureRequestsQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/SupportedSchemasQueryStrategy.ts 100% 100% 100% 100%
src/services/database/strategies/UsersQueryStrategy.ts 100% 100% 100% 100%
src/services/graphql/resolvers/allowlistRecordResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/attestationResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/attestationSchemaResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/blueprintResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/collectionResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/contractResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/fractionResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/hyperboardResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/hypercertResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/metadataResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/orderResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/salesResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/signatureRequestResolver.ts 100% 100% 100% 100%
src/services/graphql/resolvers/userResolver.ts 100% 100% 100% 100%
src/utils/addPriceInUSDToOrder.ts 100% 100% 100% 100%
src/utils/constants.ts 100% 100% 100% 100%
src/utils/getCheapestOrder.ts 100% 100% 100% 100%
src/utils/getFractionsById.ts 0% 0% 0% 0% 1-12
src/utils/processCollectionToSection.ts 100% 100% 100% 100%
src/utils/processSectionsToHyperboardOwnership.ts 100% 100% 100% 100%
src/utils/validateMetadataAndClaimdata.ts 100% 100% 100% 100%
src/utils/waitForTxThenMintBlueprint.ts 0% 0% 0% 0% 1
Generated in workflow #109 for commit 1cbf4ac by the Vitest Coverage Report Action

- Removed Infura API key references from .env.template, constants, and related files.
- Updated CI workflow to exclude Infura API key.
- Adjusted EvmClient to only use Alchemy and DRPC providers.
- Updated tests to reflect the removal of Infura.
Jipperism added 15 commits June 6, 2025 19:56
- Introduced a new 'hypercert' field in the Metadata entity arguments.
- The 'hypercert' field is defined as an ID type and references the Hypercert entity and its fields.
… reference

- Introduced a new HypercertWithMetadata class to include metadata in hypercerts.
- Updated the Order type to reference HypercertWithMetadata instead of HypercertBaseType.
- it results in scientific notation which makes it unparseable as BigInt
…e object

- prevents erronous sql exists() checks as whereinput is initialized with all keys but values undefined
- for some reason, kysely database reads return a string when it's supposed to be a uint8 or number. parsing them manually fixes the problem, but to ensure no other bugs exist we should figure out how to make it parse them as numbers.
- to prevent circular imports in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants