Skip to content

Commit

Permalink
Remove support for single point model
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulLeCam committed Apr 15, 2024
1 parent 94efded commit 4f7821b
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 504 deletions.
2 changes: 1 addition & 1 deletion composites/points/composite.json

Large diffs are not rendered by default.

40 changes: 13 additions & 27 deletions composites/points/schemas/1-init.graphql
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
#
# Generic interface used by all point allocations
# Generic interface used by all point allocations and aggregations
#

interface GenericPointAllocation
@createModel(description: "Interface for a generic point allocation to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
}

#
# Interface specific to a single point allocation
#

interface SinglePointAllocation implements GenericPointAllocation
@createModel(description: "Interface for the allocation of a single point to an account") {
interface PointsInterface
@createModel(description: "Interface for a generic points association to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
points: Int!
}

#
# Interfaces for multiple points allocation and aggregations
# Interfaces for points allocations and aggregations
#

interface MultiplePointsAllocation implements GenericPointAllocation
@createModel(description: "Interface for the allocation of multiple points to an account") {
interface PointsAllocationInterface implements PointsInterface
@createModel(description: "Interface for a single allocation of points to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
points: Int!
}

interface PointsAggregation @createModel(description: "Interface for points aggregation") {
interface PointsAggregationInterface implements PointsInterface
@createModel(description: "Interface for an aggregation of points to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
points: Int!
Expand All @@ -40,22 +32,16 @@ interface PointsAggregation @createModel(description: "Interface for points aggr
# Default models implementing the interfaces
#

type SinglePoint implements SinglePointAllocation
@createModel(description: "Allocation of a single point to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
}

type MultiplePoints implements MultiplePointsAllocation
@createModel(description: "Allocation of multiple points to an account") {
type SimplePointsAllocation implements PointsAllocationInterface
@createModel(description: "Simple points allocation to an account") {
issuer: DID! @documentAccount
recipient: DID! @accountReference
points: Int!
}

type TotalPoints implements PointsAggregation
type SimplePointsAggregation implements PointsAggregationInterface
@createModel(
description: "Points aggregation at a specific date"
description: "Simple points aggregation to an account at a specific date"
accountRelation: SET
accountRelationFields: ["recipient"]
) {
Expand Down
119 changes: 50 additions & 69 deletions composites/points/src/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,128 +2,109 @@
import type { RuntimeCompositeDefinition } from '@composedb/types'
export const definition: RuntimeCompositeDefinition = {
models: {
GenericPointAllocation: {
PointsAggregationInterface: {
interface: true,
implements: [],
id: 'kjzl6hvfrbw6c6m3n64vb2h4n8nxq9jjfb7sf7a9y893spm1pjd0enrsdlyphg4',
implements: ['kjzl6hvfrbw6c6lxvcf8bc07wjyn29ocoxqn877uia1y86qph79axtdrcuijpeo'],
id: 'kjzl6hvfrbw6c5m5bxe6jl7cocyxpg9b8em5w9mo3l8ws4zl5c0tu5vgapitpvk',
accountRelation: { type: 'none' },
},
MultiplePoints: {
interface: false,
implements: [
'kjzl6hvfrbw6ca7buvthejhv7vqr85vmpsepzj0mc6665y2zarvjbuvtm3v4kah',
'kjzl6hvfrbw6c6m3n64vb2h4n8nxq9jjfb7sf7a9y893spm1pjd0enrsdlyphg4',
],
id: 'kjzl6hvfrbw6c9fmjjdsbuxnewf0yhvco3dn5mihiogeso6i1csdbw2fq8oeijy',
accountRelation: { type: 'list' },
},
MultiplePointsAllocation: {
PointsAllocationInterface: {
interface: true,
implements: ['kjzl6hvfrbw6c6m3n64vb2h4n8nxq9jjfb7sf7a9y893spm1pjd0enrsdlyphg4'],
id: 'kjzl6hvfrbw6ca7buvthejhv7vqr85vmpsepzj0mc6665y2zarvjbuvtm3v4kah',
implements: ['kjzl6hvfrbw6c6lxvcf8bc07wjyn29ocoxqn877uia1y86qph79axtdrcuijpeo'],
id: 'kjzl6hvfrbw6cakj74rf7d3qjnm3xoydcgx7orzw4bwdmc6kljd04uojuhpef2j',
accountRelation: { type: 'none' },
},
PointsAggregation: {
PointsInterface: {
interface: true,
implements: [],
id: 'kjzl6hvfrbw6cb6393dpd8blke5w8r7pvbl4449mxetuibcav3oab8fnxmys6d6',
id: 'kjzl6hvfrbw6c6lxvcf8bc07wjyn29ocoxqn877uia1y86qph79axtdrcuijpeo',
accountRelation: { type: 'none' },
},
SinglePoint: {
SimplePointsAggregation: {
interface: false,
implements: [
'kjzl6hvfrbw6c7ilzfpjw96drd04jadb0aybiklk70ys2imxp5mjbjmgkecgddf',
'kjzl6hvfrbw6c6m3n64vb2h4n8nxq9jjfb7sf7a9y893spm1pjd0enrsdlyphg4',
'kjzl6hvfrbw6c5m5bxe6jl7cocyxpg9b8em5w9mo3l8ws4zl5c0tu5vgapitpvk',
'kjzl6hvfrbw6c6lxvcf8bc07wjyn29ocoxqn877uia1y86qph79axtdrcuijpeo',
],
id: 'kjzl6hvfrbw6c9332q9di7qfshxczet94w2tzeubvkbkk9vtuwmya6s9f1bvx9p',
accountRelation: { type: 'list' },
},
SinglePointAllocation: {
interface: true,
implements: ['kjzl6hvfrbw6c6m3n64vb2h4n8nxq9jjfb7sf7a9y893spm1pjd0enrsdlyphg4'],
id: 'kjzl6hvfrbw6c7ilzfpjw96drd04jadb0aybiklk70ys2imxp5mjbjmgkecgddf',
accountRelation: { type: 'none' },
id: 'kjzl6hvfrbw6capj3or1esf65c1jbluhky3t2wupxefeuocqt5lz5u4gum07o24',
accountRelation: { type: 'set', fields: ['recipient'] },
},
TotalPoints: {
SimplePointsAllocation: {
interface: false,
implements: ['kjzl6hvfrbw6cb6393dpd8blke5w8r7pvbl4449mxetuibcav3oab8fnxmys6d6'],
id: 'kjzl6hvfrbw6c5be4exsm7nkkksnqatki8bceyvbgtmcu2bu5vign23b7x4emlb',
accountRelation: { type: 'set', fields: ['recipient'] },
implements: [
'kjzl6hvfrbw6cakj74rf7d3qjnm3xoydcgx7orzw4bwdmc6kljd04uojuhpef2j',
'kjzl6hvfrbw6c6lxvcf8bc07wjyn29ocoxqn877uia1y86qph79axtdrcuijpeo',
],
id: 'kjzl6hvfrbw6c9rahz7aal75i0ncxkf5wmircmtpz2s34xls8ux1p08ic655oek',
accountRelation: { type: 'list' },
},
},
objects: {
GenericPointAllocation: {
PointsAggregationInterface: {
date: { type: 'datetime', required: true, immutable: false },
points: { type: 'integer', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
MultiplePoints: {
PointsAllocationInterface: {
points: { type: 'integer', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
MultiplePointsAllocation: {
PointsInterface: {
points: { type: 'integer', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
PointsAggregation: {
SimplePointsAggregation: {
date: { type: 'datetime', required: true, immutable: false },
points: { type: 'integer', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
SinglePoint: {
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
SinglePointAllocation: {
recipient: { type: 'did', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: true },
issuer: { type: 'view', viewType: 'documentAccount' },
},
TotalPoints: {
date: { type: 'datetime', required: true, immutable: false },
SimplePointsAllocation: {
points: { type: 'integer', required: true, immutable: false },
recipient: { type: 'did', required: true, immutable: true },
recipient: { type: 'did', required: true, immutable: false },
issuer: { type: 'view', viewType: 'documentAccount' },
},
},
enums: {},
accountData: {
genericPointAllocationList: { type: 'connection', name: 'GenericPointAllocation' },
multiplePointsAllocationList: { type: 'connection', name: 'MultiplePointsAllocation' },
multiplePointsList: { type: 'connection', name: 'MultiplePoints' },
pointsAggregationList: { type: 'connection', name: 'PointsAggregation' },
recipientOfGenericPointAllocationList: {
pointsAggregationInterfaceList: { type: 'connection', name: 'PointsAggregationInterface' },
pointsAllocationInterfaceList: { type: 'connection', name: 'PointsAllocationInterface' },
pointsInterfaceList: { type: 'connection', name: 'PointsInterface' },
recipientOfPointsAggregationInterfaceList: {
type: 'account',
name: 'GenericPointAllocation',
name: 'PointsAggregationInterface',
property: 'recipient',
},
recipientOfMultiplePointsAllocationList: {
recipientOfPointsAllocationInterfaceList: {
type: 'account',
name: 'MultiplePointsAllocation',
name: 'PointsAllocationInterface',
property: 'recipient',
},
recipientOfMultiplePointsList: {
recipientOfPointsInterfaceList: {
type: 'account',
name: 'MultiplePoints',
name: 'PointsInterface',
property: 'recipient',
},
recipientOfSimplePointsAggregation: {
type: 'account-set',
name: 'SimplePointsAggregation',
property: 'recipient',
},
recipientOfPointsAggregationList: {
recipientOfSimplePointsAggregationList: {
type: 'account',
name: 'PointsAggregation',
name: 'SimplePointsAggregation',
property: 'recipient',
},
recipientOfSinglePointAllocationList: {
recipientOfSimplePointsAllocationList: {
type: 'account',
name: 'SinglePointAllocation',
name: 'SimplePointsAllocation',
property: 'recipient',
},
recipientOfSinglePointList: { type: 'account', name: 'SinglePoint', property: 'recipient' },
recipientOfTotalPoints: { type: 'account-set', name: 'TotalPoints', property: 'recipient' },
recipientOfTotalPointsList: { type: 'account', name: 'TotalPoints', property: 'recipient' },
singlePointAllocationList: { type: 'connection', name: 'SinglePointAllocation' },
singlePointList: { type: 'connection', name: 'SinglePoint' },
totalPoints: { type: 'set', name: 'TotalPoints' },
totalPointsList: { type: 'connection', name: 'TotalPoints' },
simplePointsAggregation: { type: 'set', name: 'SimplePointsAggregation' },
simplePointsAggregationList: { type: 'connection', name: 'SimplePointsAggregation' },
simplePointsAllocationList: { type: 'connection', name: 'SimplePointsAllocation' },
},
}
6 changes: 5 additions & 1 deletion composites/points/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
* @module points-composite
*/

export { definition } from './definition.js'
import { definition } from './definition.js'

export { definition }
export const SimplePointsAggregationID = definition.models.SimplePointsAggregation.id
export const SimplePointsAllocationID = definition.models.SimplePointsAllocation.id
70 changes: 0 additions & 70 deletions demo/server/src/controllers/singleController.ts

This file was deleted.

2 changes: 0 additions & 2 deletions demo/server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import express, { json, Request, Response, NextFunction } from 'express'
import cors from 'cors'
import singleRouter from './routes/single.js'
import multiRouter from './routes/multi.js'

const app = express()
Expand All @@ -24,7 +23,6 @@ const allowCrossDomain = (_req: Request, res: Response, next: NextFunction) => {

app.use(allowCrossDomain)

app.use('/single', singleRouter)
app.use('/multi', multiRouter)

app.listen(port, () => {
Expand Down
38 changes: 0 additions & 38 deletions demo/server/src/routes/single.ts

This file was deleted.

Loading

0 comments on commit 4f7821b

Please sign in to comment.