polubis / 4markdown

16 stars 3 forks source link

[Feature] Change document name and paths creation logic #441

Open polubis opened 1 month ago

polubis commented 1 month ago

DOD

Validation Rules Change

  1. Document Name

    • Input: User provides a document name as a free-form string.
    • Validation:
      • The name must be between 1 and 160 characters.
      • After processing, the name will be converted into a URL-friendly slug (all lowercase, spaces replaced by hyphens).
      • The final slug will generate a path, formatted as /<slug>/.
      • The slug should be split into segments by hyphens, with between 1 and 15 segments for structure.
      • If the document is permanent, or we want to change status to permanent, the segments must be between 3-15
  2. Document Description

    • Input: User enters a document description.
    • Validation:
      • Must be between 110 and 160 characters.
  3. Document Tags

    • Input: User provides tags associated with the document.
    • Validation:
      • Each tag must be between 1 and 40 characters.
      • Tags are converted to lowercase, and any special formatting is removed.
      • Tags are checked against a whitelist (e.g., "c++," "c#," "f#") and remain unchanged if they match.
      • Non-whitelisted tags are converted into a URL-friendly slug format.
      • Must have between 1 and 10 tags with no duplicates.
    1. All validation from client side - realtime, is removed, now only backend validates.

UI Changes

  1. When creating document, now we've following Modal displayed instead of Popup

image

  1. The hints and placeholders for making document permanent should be changed to following:

image

Technical Changes

  1. Database schema changes - all documents have now path.
  2. All permanent documents haves now tags - at least one, if no specified it's [programming].
  3. The path property is used to verify duplicates.

Behavioral Changes

  1. There is new endpoint for updating status - updateDocumentVisibility, and old updateDoc is removed.
  2. There is a migration endpoint for running migrations - migrateDatabase only for admin.
  3. There is an admin list stored and retrieved from Google Cloud secrets.
polubis commented 4 weeks ago

Plan:

  1. Write a script to migrate current Database schema, and add missing path property for every type of documents.
  2. Change validation logic.
  3. Apply changes on FE
polubis commented 3 weeks ago

BE: https://github.com/polubis/greenonsoftware-api/pull/48

polubis commented 3 weeks ago

FE: https://github.com/polubis/4markdown/pull/476

polubis commented 3 weeks ago

Tested