diff --git a/.github/ISSUE_TEMPLATE/01-feature-request.yml b/.github/ISSUE_TEMPLATE/01-feature-request.yml new file mode 100644 index 0000000..bab5d3b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/01-feature-request.yml @@ -0,0 +1,28 @@ +name: Feature Request +description: Create a feature request +labels: ['feature'] +body: + - type: markdown + attributes: + value: Thanks for taking the time to file a feature request! Please fill out this form as completely as possible. + - type: markdown + attributes: + value: 'Feature requests will be converted to the GitHub Discussions "Ideas" section.' + - type: textarea + attributes: + label: Describe the feature you'd like to request + description: A clear and concise description of what you want and what your use case is. + validations: + required: true + - type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/02-bug-report.yml b/.github/ISSUE_TEMPLATE/02-bug-report.yml new file mode 100644 index 0000000..767f8d8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/02-bug-report.yml @@ -0,0 +1,52 @@ +name: Bug Report +description: Create a bug report +labels: ['bug'] +body: + - type: markdown + attributes: + value: Thanks for taking the time to file a bug report! Please fill out this form as completely as possible. + - type: input + attributes: + label: What version of Stackpress are you using? + description: 'For example: 0.1.1' + validations: + required: true + - type: input + attributes: + label: What OS are you experiencing this issue? + description: 'For example: Windows 10 Pro, MacOS Monterey, Ubuntu 23.10' + validations: + required: true + - type: textarea + attributes: + label: Describe the Bug + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + attributes: + label: Expected Behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + - type: textarea + attributes: + label: To Reproduce + description: Steps to reproduce the behavior, please provide a clear code snippets that always reproduces the issue or a GitHub repository. Screenshots can be provided in the issue body below. + validations: + required: true + - type: input + attributes: + label: Include git repo/fork so we can easily reproduce the issue + description: 'For example: https://github.com/username/repo.git' + validations: + required: false + - type: markdown + attributes: + value: Before posting the issue go through the steps you've written down to make sure the steps provided are detailed and clear. + - type: markdown + attributes: + value: Contributors should be able to follow the steps provided in order to reproduce the bug. + - type: markdown + attributes: + value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance! \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..4ae92ad --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,32 @@ + + +## What is this PR for? + + - [ ] Just updating content and/or documentation + - [ ] This fixes issue #_____ + - [ ] Spot fix *(no issue #)* + - [ ] Merging WIP feature #_____ + - [ ] Merging done feature #_____ + - [ ] This is a merge from a version branch + - [ ] Adding/Updating tests + - [ ] This is a conflict resolution + - [ ] This is a branch cleanup + - [ ] Other: ________________ + +## I verify that... + + - [ ] I have logged my time in the commits + - [ ] I have logged my time in this PR + - [ ] I have tagged all the relevant issues + - [ ] I am using VS Code for type checks and linting, or + - [ ] I have ran `npm run test` with no errors + - [ ] I have manually checked that this bug or feature is working diff --git a/packages/stackpress-src/src/plugins/admin/pages/detail.ts b/packages/stackpress-src/src/plugins/admin/pages/detail.ts index e9d9f1f..5fa19f1 100644 --- a/packages/stackpress-src/src/plugins/admin/pages/detail.ts +++ b/packages/stackpress-src/src/plugins/admin/pages/detail.ts @@ -22,6 +22,8 @@ export default function AdminDetailPageFactory(model: Model) { logo: admin.logo || '/images/logo-square.png', menu: admin.menu || [] }); + req.data.set('columns', model.query); + //if there is a response body or there is an error code if (res.body || (res.code && res.code !== 200)) { //let the response pass through diff --git a/packages/stackpress-src/src/plugins/admin/pages/search.ts b/packages/stackpress-src/src/plugins/admin/pages/search.ts index b1529da..368e32d 100644 --- a/packages/stackpress-src/src/plugins/admin/pages/search.ts +++ b/packages/stackpress-src/src/plugins/admin/pages/search.ts @@ -16,25 +16,35 @@ export default function AdminSearchPageFactory(model: Model) { //get the admin config const admin = server.config('admin') || {}; //set data for template layer - res.data.set('admin', { + res.data.set('admin', { root: admin.root || '/admin', - name: admin.name || 'Admin', + name: admin.name || 'Admin', logo: admin.logo || '/images/logo-square.png', - menu: admin.menu || [] + menu: admin.menu || [], }); + req.data.set('columns', model.query); //if there is a response body or there is an error code if (res.body || (res.code && res.code !== 200)) { //let the response pass through return; } //extract filters from url query - let { q, filter, span, sort, skip, take } = req.data<{ - q?: string, - filter?: Record, - span?: Record, - sort?: Record, - skip?: number, - take?: number + let { + q, + filter, + span, + sort, + skip, + take, + columns = [ '*' ], + } = req.data<{ + q?: string; + filter?: Record; + span?: Record; + sort?: Record; + skip?: number; + take?: number; + columns?: string[]; }>(); if (skip && !isNaN(Number(skip))) { @@ -47,7 +57,7 @@ export default function AdminSearchPageFactory(model: Model) { //search using the filters const response = await server.call( `${model.dash}-search`, - { q, filter, span, sort, skip, take }, + { q, filter, span, sort, skip, take, columns }, res ); //if error @@ -64,14 +74,15 @@ export default function AdminSearchPageFactory(model: Model) { //decrypt the data for (const key in row) { const column = model.column(key); + if (column && column.encrypted) { const string = String(row[key]); if (string.length > 0) { try { row[key] = decrypt(String(row[key]), seed); } catch(e) { - //this can fail if the data was not encrypted - //using the same seed or not encrypted at all + //this can fail if the data was not encrypted + //using the same seed or not encrypted at all } } } @@ -80,4 +91,4 @@ export default function AdminSearchPageFactory(model: Model) { }); res.setRows(rows, total || rows.length); }; -}; \ No newline at end of file +} diff --git a/packages/stackpress-src/src/schema/spec/Attributes.ts b/packages/stackpress-src/src/schema/spec/Attributes.ts index ff6c5ea..3f602e3 100644 --- a/packages/stackpress-src/src/schema/spec/Attributes.ts +++ b/packages/stackpress-src/src/schema/spec/Attributes.ts @@ -299,6 +299,19 @@ export default class Attributes extends Map { return 0; } + /** + * Returns the table @query + * example: @query([ "*" ]) + * example: @query([ "id", "name" ]) + */ + public get query() { + const query = this.get('query'); + if (Array.isArray(query)) { + return query[0] as string[]; + } + return [ '*' ]; + } + /** * Returns relation information */ diff --git a/packages/stackpress-src/src/schema/spec/Model.ts b/packages/stackpress-src/src/schema/spec/Model.ts index d895bbe..91b2f03 100644 --- a/packages/stackpress-src/src/schema/spec/Model.ts +++ b/packages/stackpress-src/src/schema/spec/Model.ts @@ -48,6 +48,15 @@ export default class Model extends Fieldset { ); } + /** + * Returns the table @query + * example: @query([ "*" ]) + * example: @query([ "id", "name" ]) + */ + public get query() { + return this.attributes.query; + } + /** * Returns all the models with columns related to this model */ diff --git a/packages/stackpress-src/stackpress.idea b/packages/stackpress-src/stackpress.idea index e19472b..33d0e39 100644 --- a/packages/stackpress-src/stackpress.idea +++ b/packages/stackpress-src/stackpress.idea @@ -72,13 +72,14 @@ model Profile model Auth @label("Auth" "Auth") @template("{{token}}") - @icon("lock") + @icon("lock") + @query([ "*" "profile.*" ]) { id String @label("ID") @id @default("cuid()") @list.overflow({ length 10 hellip true }) - profileId String @label("Profile") + profileId String @label("Profile") @field.relation({ href "/admin/profile/search" key "profile" @@ -92,7 +93,7 @@ model Auth foreign "id" template "{{name}}" }) - @list.template({ key "profile" template "{{name}}" }) + @list.template({ key "profile" template "{{name}}" }) @view.template({ key "profile" template "{{name}}" }) type String @label("Type") @@ -207,6 +208,7 @@ model Session @label("Session" "Sessions") @template("{{profile.name}}") @icon("coffee") + @query([ "*" "profile.*" "application.*"]) { id String @label("ID") @id @default("cuid()")