-
Notifications
You must be signed in to change notification settings - Fork 0
feat: validate lexicons #5
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
Open
caidanw
wants to merge
19
commits into
main
Choose a base branch
from
caidanw/atm-202-validate-lexicons
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+879
−76
Open
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
27960dd
feat: add @atproto/lexicon-resolver package
caidanw 475008f
feat: add @atproto/syntax package
caidanw be7409b
feat: add @atproto/lexicon package
caidanw 37dc82b
feat(util): add LexiconSchemaRecord type and type guard for lexicon N…
caidanw a377825
feat(api): validate lexicon schema record and enforce DID authority i…
caidanw 6ff2ae8
feat: add zod package
caidanw 7a07c86
refactor(util): redefine LexiconSchemaRecord to require 'id' field fo…
caidanw 8982863
feat(api): parse and validate lexicon records using parseLexiconDoc a…
caidanw dc5c7dd
refactor(db): separate valid and invalid lexicons into distinct tables
caidanw ee77d08
feat(api): store valid and invalid lexicons in separate tables
caidanw 28a66b0
refactor(db): squash migrations into single init migration
caidanw de572dd
chore(dev): add compose.override.yaml for local development with cust…
caidanw 45910bd
fix(api): prevent duplicate valid lexicon inserts with onConflictDoNo…
caidanw b6b6509
fix(api): improve ZodError detection to catch validation errors properly
caidanw 74e9a2a
refactor(api): extract isZodError helper for clearer validation error…
caidanw ecc3500
refactor(api): inline lexiconDoc declaration in ingest route for clea…
caidanw f3bef21
docs(api): fix typo in DNS validation comment in ingest route
caidanw 69980d5
refactor(api): simplify DNS validation check in ingest route
caidanw 84a4023
refactor(api): remove unused LexiconDoc import from ingest route
caidanw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # Development overrides for docker-compose | ||
| # This file is automatically loaded by docker-compose and overrides compose.yaml | ||
| # For production, use: docker-compose -f compose.yaml up | ||
| # | ||
| # In development, run lexhub locally with: npm run dev | ||
| # Only nexus and postgres run in Docker for development | ||
|
|
||
| services: | ||
| lexhub: | ||
| # Disable lexhub service in development | ||
| # Run it locally instead with: npm run dev | ||
| scale: 0 | ||
|
|
||
| nexus: | ||
| restart: no | ||
| network_mode: host | ||
| ports: [] | ||
| volumes: [] | ||
| environment: | ||
| # Reduced parallelism for lighter resource usage | ||
| - NEXUS_FIREHOSE_PARALLELISM=5 | ||
| - NEXUS_RESYNC_PARALLELISM=2 | ||
| - NEXUS_OUTBOX_PARALLELISM=2 | ||
| # Debug logging for development | ||
| - NEXUS_LOG_LEVEL=debug | ||
| - NEXUS_WEBHOOK_URL=http://host.docker.internal:10000/api/ingest | ||
|
|
||
| postgres: | ||
| restart: no | ||
| command: | ||
| - "postgres" | ||
| - "-c" | ||
| - "shared_preload_libraries=pg_stat_statements" | ||
| - "-c" | ||
| - "pg_stat_statements.track=all" | ||
| # Reduced resources for development | ||
| - "-c" | ||
| - "max_connections=100" | ||
| - "-c" | ||
| - "shared_buffers=128MB" | ||
| - "-c" | ||
| - "effective_cache_size=512MB" | ||
| - "-c" | ||
| - "work_mem=8MB" | ||
| - "-c" | ||
| - "maintenance_work_mem=64MB" | ||
| # SQL query logging for debugging | ||
| - "-c" | ||
| - "log_statement=all" | ||
| - "-c" | ||
| - "log_duration=on" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,31 @@ | ||
| CREATE TABLE "lexicons" ( | ||
| "id" varchar(317) NOT NULL, | ||
| -- Create valid_lexicons table | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably don't need this comment 😄
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same with a couple others |
||
| CREATE TABLE "valid_lexicons" ( | ||
| "nsid" varchar(317) NOT NULL, | ||
| "cid" varchar(100) NOT NULL, | ||
| "repo_did" varchar(256) NOT NULL, | ||
| "repo_rev" varchar(256) NOT NULL, | ||
| "data" jsonb NOT NULL, | ||
| "created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
| "updated_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
| CONSTRAINT "lexicons_id_cid_pk" PRIMARY KEY("id","cid") | ||
| "ingested_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
| CONSTRAINT "valid_lexicons_nsid_cid_repo_did_pk" PRIMARY KEY("nsid","cid","repo_did") | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE INDEX "lexicons_id_idx" ON "lexicons" USING btree ("id");--> statement-breakpoint | ||
| CREATE INDEX "lexicons_created_at_idx" ON "lexicons" USING btree ("created_at");--> statement-breakpoint | ||
| CREATE INDEX "lexicons_data_gin_idx" ON "lexicons" USING gin ("data");--> statement-breakpoint | ||
|
|
||
|
|
||
| CREATE OR REPLACE FUNCTION update_updated_at_column() | ||
| RETURNS TRIGGER AS $$ | ||
| BEGIN | ||
| NEW.updated_at = NOW(); | ||
| RETURN NEW; | ||
| END; | ||
| $$ language 'plpgsql'; | ||
|
|
||
| CREATE TRIGGER update_lexicons_updated_at | ||
| BEFORE UPDATE ON "lexicons" | ||
| FOR EACH ROW | ||
| EXECUTE FUNCTION update_updated_at_column(); | ||
| -- Create invalid_lexicons table | ||
| CREATE TABLE "invalid_lexicons" ( | ||
| "nsid" varchar(317) NOT NULL, | ||
| "cid" varchar(100) NOT NULL, | ||
| "repo_did" varchar(256) NOT NULL, | ||
| "repo_rev" varchar(256) NOT NULL, | ||
| "raw_data" jsonb NOT NULL, | ||
| "validation_errors" jsonb NOT NULL, | ||
| "ingested_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
| CONSTRAINT "invalid_lexicons_nsid_cid_repo_did_pk" PRIMARY KEY("nsid","cid","repo_did") | ||
| ); | ||
| --> statement-breakpoint | ||
| -- Create indexes for valid_lexicons | ||
| CREATE INDEX "valid_lexicons_nsid_idx" ON "valid_lexicons" USING btree ("nsid");--> statement-breakpoint | ||
| CREATE INDEX "valid_lexicons_repo_did_idx" ON "valid_lexicons" USING btree ("repo_did");--> statement-breakpoint | ||
| CREATE INDEX "valid_lexicons_data_gin_idx" ON "valid_lexicons" USING gin ("data");--> statement-breakpoint | ||
| -- Create indexes for invalid_lexicons | ||
| CREATE INDEX "invalid_lexicons_nsid_idx" ON "invalid_lexicons" USING btree ("nsid");--> statement-breakpoint | ||
| CREATE INDEX "invalid_lexicons_repo_did_idx" ON "invalid_lexicons" USING btree ("repo_did");--> statement-breakpoint | ||
| CREATE INDEX "invalid_lexicons_raw_data_gin_idx" ON "invalid_lexicons" USING gin ("raw_data"); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be in .gitignore?