Skip to content

docs(api): add creator query normalization docs with before/after examples#238

Merged
Chucks1093 merged 2 commits intoaccesslayerorg:mainfrom
Spagero763:docs/creator-query-normalization-211
Apr 28, 2026
Merged

docs(api): add creator query normalization docs with before/after examples#238
Chucks1093 merged 2 commits intoaccesslayerorg:mainfrom
Spagero763:docs/creator-query-normalization-211

Conversation

@Spagero763
Copy link
Copy Markdown
Contributor

@Spagero763 Spagero763 commented Apr 27, 2026

Summary

  • Adds docs/api/creator-query-normalization.md — a dedicated reference page for how creatorId, creatorAddress, and username query params are normalized before use in creator lookup endpoints
  • Covers field-by-field rules (trimming, case-folding, format validation) with before/after tables for each field
  • Adds a Validation integration section showing how parsePublicQuery + Zod enforce these rules at the route layer
  • Adds a cross-reference link in the parsePublicQuery JSDoc comment in src/utils/public-query-parse.utils.ts so readers navigating the code can find the doc

Before / after preview

Field Raw Normalized
username Alice alice
username Alice alice
creatorId 3F6A1B2C-… 3f6a1b2c-…
creatorAddress GABC…XYZ GABC…XYZ

Test plan

  • Doc renders correctly in GitHub markdown (tables, code block, cross-links)
  • pnpm lint passes (only a .ts comment change, linted by lint-staged)
  • pnpm build passes (no code logic changed)

Closes #211

…mples (accesslayerorg#211)

Adds docs/api/creator-query-normalization.md covering normalization rules
for creatorId, creatorAddress, and username query params, with
before/after tables and a link to the Zod validation layer.
Links the doc from public-query-parse.utils.ts JSDoc comment.

Closes accesslayerorg#211
Copilot AI review requested due to automatic review settings April 27, 2026 20:50
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 27, 2026

@Spagero763 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds dedicated documentation describing how creator-identifying query parameters should be normalized/validated, and links that doc from the shared query-parse helper.

Changes:

  • Add docs/api/creator-query-normalization.md describing expected normalization rules with examples.
  • Add a cross-reference link to the new doc in parsePublicQuery JSDoc.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/utils/public-query-parse.utils.ts Adds a JSDoc pointer to the new creator query normalization reference doc.
docs/api/creator-query-normalization.md New reference page for creator query normalization + validation integration examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +36 to +41
| Raw query string | Normalized value used in query |
| :------------------------ | :----------------------------------- |
| `creatorId=ABC-123` | rejected — not a valid UUID |
| `creatorId= 3f6a1b2c-… ` | `3f6a1b2c-…` (whitespace stripped) |
| `creatorId=3F6A1B2C-…` | `3f6a1b2c-…` (lowercased) |
| `creatorId=3f6a1b2c-…` | `3f6a1b2c-…` (unchanged, valid UUID) |
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Same table formatting issue as above: these before/after examples use || at the start of each row, which adds an unintended empty column in rendered Markdown. Use a single leading | for each row.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +63
| Raw query string | Normalized value used in query |
| :-------------------------- | :---------------------------------------------- |
| `creatorAddress= GABC…XYZ ` | `GABC…XYZ` (whitespace stripped) |
| `creatorAddress=gabc…xyz` | rejected — lowercase Stellar address is invalid |
| `creatorAddress=GABC…XYZ` | `GABC…XYZ` (unchanged, valid address) |
| `creatorAddress=SHORTKEY` | rejected — not 56 characters |

Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Same table formatting issue as above: this table uses || at the start of rows/headers, which renders an extra blank first column. Switch to a single leading | for proper GitHub Markdown tables.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +85
| Raw query string | Normalized value used in query |
| :--------------------- | :----------------------------- |
| `username=Alice` | `alice` |
| `username= Alice ` | `alice` (trimmed + lowercased) |
| `username=MUSIC_MAKER` | `music_maker` |
| `username=` | _(parameter ignored)_ |

Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Same table formatting issue as above: this table’s rows start with ||, which creates an extra empty column when rendered. Use a single leading | for each row to match standard GitHub Markdown table syntax.

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +13
This document describes how raw query parameters for creator lookup endpoints are
normalized before use. See [`src/utils/public-query-parse.utils.ts`](../../src/utils/public-query-parse.utils.ts)
for the generic Zod-based validation layer that wraps these parameters.

## Overview

Creator lookup endpoints accept three optional identifier fields. Each field is
read directly from `req.query` by
[`parseCreatorPublicQuery`](../../src/utils/creator-public-query.util.ts) and
forwarded to the service layer as-is. No coercion, trimming, or case-folding is
applied at the utility level — normalization is the caller's responsibility.
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

This states the creator lookup endpoints read req.query via parseCreatorPublicQuery, but parseCreatorPublicQuery is not referenced anywhere in src/ (it’s currently only defined in src/utils/creator-public-query.util.ts). Either update the docs to describe the actual current call path/schemas that normalize these params, or clarify that this utility (and these query keys) are not wired into any endpoint yet.

Suggested change
This document describes how raw query parameters for creator lookup endpoints are
normalized before use. See [`src/utils/public-query-parse.utils.ts`](../../src/utils/public-query-parse.utils.ts)
for the generic Zod-based validation layer that wraps these parameters.
## Overview
Creator lookup endpoints accept three optional identifier fields. Each field is
read directly from `req.query` by
[`parseCreatorPublicQuery`](../../src/utils/creator-public-query.util.ts) and
forwarded to the service layer as-is. No coercion, trimming, or case-folding is
applied at the utility level — normalization is the caller's responsibility.
This document describes the creator-related public query keys currently defined
in the codebase and how they are intended to be normalized before use. See
[`src/utils/public-query-parse.utils.ts`](../../src/utils/public-query-parse.utils.ts)
for the generic Zod-based validation layer that wraps public query parameters.
## Overview
The creator-specific helper
[`parseCreatorPublicQuery`](../../src/utils/creator-public-query.util.ts)
defines three optional identifier fields for creator lookups. However, this
utility is not currently referenced by endpoint code in `src/`, so the fields
below should be read as documented query definitions rather than a guaranteed
live endpoint call path. Where these fields are used by callers, no coercion,
trimming, or case-folding is applied at the utility level — normalization
remains the caller's responsibility.

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +100
creatorId: z.string().uuid().optional(),
creatorAddress: z.string().length(56).startsWith('G').optional(),
username: z.string().trim().toLowerCase().optional(),
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The example schema doesn’t match the normalization rules described above: creatorId isn’t trimmed/lowercased before UUID validation, creatorAddress isn’t trimmed, and username will return '' (not undefined) for username= after .trim(). Consider updating the example to show the same trim/case-folding/empty-string-to-absent behavior the doc specifies.

Suggested change
creatorId: z.string().uuid().optional(),
creatorAddress: z.string().length(56).startsWith('G').optional(),
username: z.string().trim().toLowerCase().optional(),
creatorId: z.string()
.trim()
.toLowerCase()
.pipe(z.string().uuid())
.optional(),
creatorAddress: z.string()
.trim()
.pipe(z.string().length(56).startsWith('G'))
.optional(),
username: z.string()
.trim()
.toLowerCase()
.transform((value) => (value === '' ? undefined : value))
.optional(),

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +19
| Query key | Constant | Typical format |
| :--------------- | :------------------------------------------ | :---------------------- |
| `creatorId` | `CREATOR_PUBLIC_QUERY_KEYS.CREATOR_ID` | UUID v4 string |
| `creatorAddress` | `CREATOR_PUBLIC_QUERY_KEYS.CREATOR_ADDRESS` | Stellar public key (G…) |
| `username` | `CREATOR_PUBLIC_QUERY_KEYS.USERNAME` | Lowercase handle |
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Markdown tables here start with || instead of |, which renders an extra empty first column in GitHub Markdown. Update the table rows/header separators to use a single leading | so the table columns align as intended.

Copilot uses AI. Check for mistakes.
@Chucks1093 Chucks1093 merged commit 068561e into accesslayerorg:main Apr 28, 2026
1 check passed
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.

Add creator query normalization docs with examples

3 participants