Skip to content

refactor(cms): pnk-token-page-types #28

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

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 12 additions & 7 deletions cms-backend/src/api/exchange/content-types/exchange/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@
"info": {
"singularName": "exchange",
"pluralName": "exchanges",
"displayName": "Exchange"
"displayName": "Exchange",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"url": {
"type": "string"
},
"icon": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
]
},
"name": {
"type": "string"
},
"url": {
"type": "string"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"header": {
"type": "string"
},
"buyCards": {
"type": "component",
"repeatable": true,
"component": "pnk-token-page.buy-card"
},
"exchanges": {
"type": "relation",
"relation": "oneToMany",
"target": "api::exchange.exchange"
},
"featuredExchanges": {
"type": "relation",
"relation": "oneToMany",
"target": "api::exchange.exchange"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@
"repeatable": false,
"component": "content.button-link"
},
"socials": {
"type": "relation",
"relation": "oneToMany",
"target": "api::social.social"
},
"background": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
],
"type": "media",
"multiple": false
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"info": {
"singularName": "pnk-token-page-need-section",
"pluralName": "pnk-token-page-need-sections",
"displayName": "PNKTokenPageNeedSection"
"displayName": "PNKTokenPageNeedSection",
"description": ""
},
"options": {
"draftAndPublish": true
Expand All @@ -24,7 +25,7 @@
},
"arrowLink": {
"type": "component",
"repeatable": true,
"repeatable": false,
"component": "content.button-link"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"kind": "collectionType",
"collectionName": "token_explorers",
"info": {
"singularName": "token-explorer",
"pluralName": "token-explorers",
"displayName": "TokenExplorer",
"description": ""
},
"options": {
"draftAndPublish": true
},
"pluginOptions": {},
"attributes": {
"icon": {
"type": "media",
"multiple": false,
"required": false,
"allowedTypes": [
"images",
"files",
"videos",
"audios"
]
},
"name": {
"type": "string"
},
"url": {
"type": "string"
}
Comment on lines +26 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation and constraints to name and url fields

The name and url fields lack validation constraints which could lead to data integrity issues:

  1. The name field should have length constraints and uniqueness validation
  2. The url field should have URL format validation
 "name": {
-  "type": "string"
+  "type": "string",
+  "required": true,
+  "unique": true,
+  "minLength": 1,
+  "maxLength": 50
 },
 "url": {
-  "type": "string"
+  "type": "string",
+  "required": true,
+  "regex": "^https?:\\/\\/.+",
+  "unique": true
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"name": {
"type": "string"
},
"url": {
"type": "string"
}
"name": {
"type": "string",
"required": true,
"unique": true,
"minLength": 1,
"maxLength": 50
},
"url": {
"type": "string",
"required": true,
"regex": "^https?:\\/\\/.+",
"unique": true
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-explorer controller
*/

import { factories } from '@strapi/strapi'

export default factories.createCoreController('api::token-explorer.token-explorer');
7 changes: 7 additions & 0 deletions cms-backend/src/api/token-explorer/routes/token-explorer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-explorer router
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('api::token-explorer.token-explorer');
7 changes: 7 additions & 0 deletions cms-backend/src/api/token-explorer/services/token-explorer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* token-explorer service
*/

import { factories } from '@strapi/strapi';

export default factories.createCoreService('api::token-explorer.token-explorer');
28 changes: 0 additions & 28 deletions cms-backend/src/components/pnk-token-page/buy-card.json

This file was deleted.

17 changes: 0 additions & 17 deletions cms-backend/types/generated/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,6 @@ export interface PnkTokenPageTokenStatDisplay extends Struct.ComponentSchema {
};
}

export interface PnkTokenPageBuyCard extends Struct.ComponentSchema {
collectionName: 'components_pnk_token_page_buy_cards';
info: {
displayName: 'buy-card';
description: '';
};
attributes: {
title: Schema.Attribute.String;
icon: Schema.Attribute.Media<
'images' | 'files' | 'videos' | 'audios',
true
>;
link: Schema.Attribute.Relation<'oneToOne', 'api::link.link'>;
};
}

export interface ForBuildersPageSolutionSection extends Struct.ComponentSchema {
collectionName: 'solution_sections';
info: {
Expand Down Expand Up @@ -165,7 +149,6 @@ declare module '@strapi/strapi' {
export module Public {
export interface ComponentSchemas {
'pnk-token-page.token-stat-display': PnkTokenPageTokenStatDisplay;
'pnk-token-page.buy-card': PnkTokenPageBuyCard;
'for-builders-page.solution-section': ForBuildersPageSolutionSection;
'for-builders-page.key-challenge': ForBuildersPageKeyChallenge;
'for-builders-page.get-in-touch-section': ForBuildersPageGetInTouchSection;
Expand Down
45 changes: 41 additions & 4 deletions cms-backend/types/generated/contentTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,15 @@ export interface ApiExchangeExchange extends Struct.CollectionTypeSchema {
singularName: 'exchange';
pluralName: 'exchanges';
displayName: 'Exchange';
description: '';
};
options: {
draftAndPublish: true;
};
attributes: {
url: Schema.Attribute.String;
icon: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'>;
name: Schema.Attribute.String;
url: Schema.Attribute.String;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
Expand Down Expand Up @@ -1098,8 +1100,11 @@ export interface ApiPnkTokenPageBuySectionPnkTokenPageBuySection
};
attributes: {
header: Schema.Attribute.String;
buyCards: Schema.Attribute.Component<'pnk-token-page.buy-card', true>;
exchanges: Schema.Attribute.Relation<'oneToMany', 'api::exchange.exchange'>;
featuredExchanges: Schema.Attribute.Relation<
'oneToMany',
'api::exchange.exchange'
>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
Expand Down Expand Up @@ -1131,7 +1136,6 @@ export interface ApiPnkTokenPageHeroPnkTokenPageHero
header: Schema.Attribute.String;
subtitle: Schema.Attribute.String;
buyButton: Schema.Attribute.Component<'content.button-link', false>;
socials: Schema.Attribute.Relation<'oneToMany', 'api::social.social'>;
background: Schema.Attribute.Media<
'images' | 'files' | 'videos' | 'audios'
>;
Expand All @@ -1157,6 +1161,7 @@ export interface ApiPnkTokenPageNeedSectionPnkTokenPageNeedSection
singularName: 'pnk-token-page-need-section';
pluralName: 'pnk-token-page-need-sections';
displayName: 'PNKTokenPageNeedSection';
description: '';
};
options: {
draftAndPublish: true;
Expand All @@ -1165,7 +1170,7 @@ export interface ApiPnkTokenPageNeedSectionPnkTokenPageNeedSection
header: Schema.Attribute.String;
subtitle: Schema.Attribute.String;
card: Schema.Attribute.Component<'content.cta-card', true>;
arrowLink: Schema.Attribute.Component<'content.button-link', true>;
arrowLink: Schema.Attribute.Component<'content.button-link', false>;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
Expand Down Expand Up @@ -1279,6 +1284,37 @@ export interface ApiSolutionSolution extends Struct.CollectionTypeSchema {
};
}

export interface ApiTokenExplorerTokenExplorer
extends Struct.CollectionTypeSchema {
collectionName: 'token_explorers';
info: {
singularName: 'token-explorer';
pluralName: 'token-explorers';
displayName: 'TokenExplorer';
description: '';
};
options: {
draftAndPublish: true;
};
attributes: {
icon: Schema.Attribute.Media<'images' | 'files' | 'videos' | 'audios'>;
name: Schema.Attribute.String;
url: Schema.Attribute.String;
createdAt: Schema.Attribute.DateTime;
updatedAt: Schema.Attribute.DateTime;
publishedAt: Schema.Attribute.DateTime;
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private;
locale: Schema.Attribute.String;
localizations: Schema.Attribute.Relation<
'oneToMany',
'api::token-explorer.token-explorer'
>;
};
}

export interface ApiTokenStatTokenStat extends Struct.CollectionTypeSchema {
collectionName: 'token_stats';
info: {
Expand Down Expand Up @@ -1735,6 +1771,7 @@ declare module '@strapi/strapi' {
'api::pnk-token-page-tokenomics-section.pnk-token-page-tokenomics-section': ApiPnkTokenPageTokenomicsSectionPnkTokenPageTokenomicsSection;
'api::social.social': ApiSocialSocial;
'api::solution.solution': ApiSolutionSolution;
'api::token-explorer.token-explorer': ApiTokenExplorerTokenExplorer;
'api::token-stat.token-stat': ApiTokenStatTokenStat;
'api::use-case.use-case': ApiUseCaseUseCase;
'admin::permission': AdminPermission;
Expand Down