Skip to content
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

templates and agreement partial fetch and pagination #15

Open
niallroche opened this issue Dec 4, 2024 · 2 comments · May be fixed by #31 or #32
Open

templates and agreement partial fetch and pagination #15

niallroche opened this issue Dec 4, 2024 · 2 comments · May be fixed by #31 or #32

Comments

@niallroche
Copy link

The fetch of a list of templates returns a list of all templates, this could lead to a very large response. Is there an alternative pattern we could use where the list of template names is fetched and then individual fetch template requests can be made? I am worried about the size of the response for large templates and unnecessary response overhead. Another possibility would be a param supplied to the request to indicate if a full list of templates would be returned or just a list of ids. If a full list is returned maybe there could be a max size/number of responses returned or it maybe it could be paginated. Perhaps a list of just the template metadata is a good compromise too.

@niallroche
Copy link
Author

As a starting point for a suggested way to improve the partial fetching options and searching we could consider the following options.

Partial selection of template and agreement nested resources

If there nested resources (e.g., metadata, clauses, agreement data), represent them in a hierarchy beneath the primary resource ID

  • /templates/{templateId}/metadata
  • /templates/{templateId}/clauses/{clauseId}
  • /templates/{templateId}/model
  • /agreements/{agreementId}/metadata
  • /agreements/{agreementId}/data

The paths above should consider versioning of the templates and agreement too so potentially adding:

  • /version/{versionId} (where versionId is a valid version)

A possible extension could be retrieval could be:

  • GET /agreements/{agreementId}?fields=id&keywords=foo,bar

Pagination

Common query parameters for pagination are:

  1. Offset/Limit:
  • GET /templates?offset=0&limit=10
  • offset and limit provide straightforward pagination.
  1. Page/Size:
  • GET /templates?page=1&pageSize=10
  • More user-friendly at the expense of slightly less control.

Include pagination metadata in responses:

  • Return pagination details in response headers or as part of a top-level response object. This might include:
  • X-Total-Count: Total number of resources available.
  • X-Total-Pages: Number of pages (if using page-based pagination).
    Alternatively, include a pagination object in the JSON response:
{
  "data": [...],
  "meta": {
    "total": 100,
    "offset": 0,
    "limit": 10
  }
}

Pagination links

Consider returning next, prev, first, and last links in the response body. This makes it easier for clients to navigate collections:

{
  "data": [...],
  "links": {
    "self": "/templates?offset=0&limit=10",
    "next": "/templates?offset=10&limit=10",
    "prev": null,
    "first": "/templates?offset=0&limit=10",
    "last": "/templates?offset=90&limit=10"
  },
  "meta": {
    "total": 100,
    "offset": 0,
    "limit": 10
  }
}

Marvinrose added a commit to Marvinrose/apap that referenced this issue Mar 2, 2025
@Marvinrose
Copy link

Hi @niallroche

I sent a pr that successfully resolves this issue.

prince04-coder added a commit to prince04-coder/apap that referenced this issue Mar 4, 2025
Fixes accordproject#15

Implement pagination and partial fetching for the `listTemplates` operation.

* **client/typescript/apap.ts**
  - Add `offset`, `limit`, and `fields` query parameters to `listTemplates` operation.
  - Update `listTemplates` response to include pagination metadata.
  - Update `listTemplates` response to include pagination links.

* **server/index.ts**
  - Add support for `offset`, `limit`, and `fields` query parameters in `listTemplates` operation.
  - Update `listTemplates` response to include pagination metadata.
  - Update `listTemplates` response to include pagination links.

* **README.md**
  - Update documentation to include information about pagination and partial fetching options in `listTemplates` operation.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/accordproject/apap/issues/15?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants