feat: add detailed schemas for V2Log data payloads#1234
Conversation
…a structures - Added descriptions for V2Log properties to clarify their purpose. - Introduced new schemas for log data types: V2LogDataNewTransaction, V2LogDataSetMetadata, V2LogDataRevertedTransaction, V2LogDataDeleteMetadata, and V2LogDataInsertedSchema. - Improved overall documentation for better understanding of log entry structures and their payloads.
…nal log data structures - Removed unnecessary x-speakeasy-errors from the insertSchema endpoint. - Enhanced descriptions for V2Log properties to improve clarity. - Added new schemas for log data types: V2LogTransaction, V2LogDataNewTransaction, V2LogDataSetMetadata, V2LogDataRevertedTransaction, V2LogDataDeleteMetadata, and V2LogDataInsertedSchema. - Improved documentation for log entry structures and their payloads.
…escriptions - Expanded the V2Log schema to include comprehensive descriptions for properties. - Added new log data structures: V2LogTransaction, V2LogDataNewTransaction, V2LogDataSetMetadata, V2LogDataRevertedTransaction, V2LogDataDeleteMetadata, and V2LogDataInsertedSchema. - Improved documentation for log entry payloads and their respective structures to facilitate better understanding.
…entation - Introduced new log data structures: V2LogDataDeleteMetadata, V2LogDataDeleteMetadataTargetID, V2LogDataDeleteMetadataTargetType, V2LogDataInsertedSchema, V2LogDataNewTransaction, V2LogDataRevertedTransaction, and V2LogDataSetMetadata. - Updated V2LogData to support various log entry types, enhancing the payload structure for better clarity. - Improved documentation for log entry payloads and their respective structures to facilitate better understanding and usage.
- Refactored tests to utilize the updated V2LogDataNewTransaction structure for better clarity and consistency. - Changed assertions to match the new data types and structures, ensuring accurate validation of log entries. - Improved readability by replacing map assertions with structured field access for transaction data.
WalkthroughThis PR replaces V2Log's generic Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/e2e/api_logs_list_test.go (1)
222-228: Test assertion will fail: comparingV2LogDatastruct tomap[string]any.The
Datafield is now typed asV2LogData(a struct), but this assertion still compares it to amap[string]any. This type mismatch will cause the test to fail at runtime.Update to use the typed
V2LogDataSetMetadataaccessor, consistent with the NEW_TRANSACTION assertions below.🐛 Proposed fix
- Expect(response.V2LogsCursorResponse.Cursor.Data[0].Data).To(Equal(map[string]any{ - "targetType": "ACCOUNT", - "metadata": map[string]any{ - "clientType": "gold", - }, - "targetId": "foo:baz", - })) + Expect(response.V2LogsCursorResponse.Cursor.Data[0].Data.V2LogDataSetMetadata).NotTo(BeNil()) + setMetadata := response.V2LogsCursorResponse.Cursor.Data[0].Data.V2LogDataSetMetadata + Expect(setMetadata.TargetType).To(Equal(components.TargetTypeAccount)) + Expect(setMetadata.TargetID.Str).To(Equal(pointer.For("foo:baz"))) + Expect(setMetadata.Metadata).To(Equal(map[string]string{ + "clientType": "gold", + }))
🤖 Fix all issues with AI agents
In `@pkg/client/docs/models/components/targetid.md`:
- Around line 6-16: The TargetID docs contain empty "###" headings and invalid
Go snippets; update the headings to meaningful text (e.g., "CreateTargetID from
string" and "CreateTargetID from bigint") and replace the broken examples for
CreateTargetIDStr and CreateTargetIDBigint with valid Go code: show a simple
string literal for CreateTargetIDStr and a proper big.Int construction (import
"math/big", use big.NewInt or new(big.Int).SetString) for CreateTargetIDBigint
so the examples compile and demonstrate correct usage of CreateTargetIDStr and
CreateTargetIDBigint.
In `@pkg/client/docs/models/components/v2logdatadeletemetadata.md`:
- Around line 8-12: Update the documentation row for TargetID
(components.V2LogDataDeleteMetadataTargetID) to replace "N/A" with a concise
description stating that TargetID identifies the target entity being
modified/removed, and may be represented as a string or bigint (e.g., UUID,
numeric ID) so consumers know how to construct the identifier; keep the
description short and concrete so readers understand its purpose and accepted
formats.
In `@pkg/client/docs/models/components/v2logtransaction.md`:
- Line 14: The table entries for the fields Reference and Template are
incorrectly formatted as "`**string*`"; update those type cells to the correct
pointer notation "`*string`" (i.e., replace `**string*` with `*string`) in the
v2logtransaction component markdown so both the Reference and Template rows
display the optional string pointer type correctly.
- Line 12: The docs table for the V2LogTransaction component shows a
typographical error in the Metadata type; replace the incorrect
`map[string]*string*` with the correct `map[string]string` to match the
V2LogTransaction struct's Metadata field and remove the stray asterisks so the
generated docs accurately reflect the type.
🧹 Nitpick comments (3)
pkg/client/docs/models/components/v2logdatasetmetadata.md (1)
8-12: Consider describing TargetID/Metadata semantics instead of “N/A.”A short description will make the table more actionable for readers.
✏️ Suggested doc tweak
-| `TargetID` | [components.TargetID](../../models/components/targetid.md) | :heavy_check_mark: | N/A | | -| `Metadata` | map[string]*string* | :heavy_check_mark: | N/A | {<br/>"admin": "true"<br/>} | +| `TargetID` | [components.TargetID](../../models/components/targetid.md) | :heavy_check_mark: | Account address (ACCOUNT) or transaction ID (TRANSACTION) | `users:001` | +| `Metadata` | map[string]*string* | :heavy_check_mark: | Metadata key/value set on the target | {<br/>"admin": "true"<br/>} |pkg/client/docs/models/components/v2logdatadeletemetadatatargetid.md (1)
6-16: Add headings for the supported variants.The two subsections have empty titles, which hurts scanability in generated docs. Consider naming them (e.g., “String” and “BigInt”).
📝 Suggested doc tweak
-### +### String ... -### +### BigInttest/e2e/api_logs_list_test.go (1)
275-283:compareLogsassumesV2LogDataNewTransactionwithout type verification.The helper directly accesses
log.Data.V2LogDataNewTransactionwithout checking if the log type isNEW_TRANSACTION. If this helper is ever used with a different log type, it will panic on nil pointer dereference.Consider adding a guard or documenting the precondition.
♻️ Suggested improvement
var ( compareLogs = func(log components.V2Log, expected expectedLog) { Expect(log.ID).To(Equal(expected.id)) Expect(log.Type).To(Equal(expected.typ)) + Expect(log.Type).To(Equal(components.V2LogTypeNewTransaction), "compareLogs only supports NEW_TRANSACTION logs") Expect(log.Data.V2LogDataNewTransaction).NotTo(BeNil())
Use typed V2LogDataSetMetadata structure instead of map[string]any
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1234 +/- ##
=======================================
Coverage 74.63% 74.63%
=======================================
Files 198 198
Lines 10410 10410
=======================================
Hits 7769 7769
- Misses 1512 1514 +2
+ Partials 1129 1127 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
This PR adds strongly-typed schemas for all V2Log data payloads in the OpenAPI specification, addressing feedback from issue #1232.
Changes
New schemas added to
openapi/v2.yaml:V2LogTransaction- Transaction structure specific to log payloadsV2LogDataNewTransaction- Payload forNEW_TRANSACTIONlogsV2LogDataSetMetadata- Payload forSET_METADATAlogsV2LogDataRevertedTransaction- Payload forREVERTED_TRANSACTIONlogsV2LogDataDeleteMetadata- Payload forDELETE_METADATAlogsV2LogDataInsertedSchema- Payload forINSERTED_SCHEMAlogsModified
V2Logschema to useoneOfwith discriminated types instead ofadditionalProperties: trueRegenerated SDK with new strongly-typed models
Updated e2e tests to use the new typed structures
Benefits
Related
Closes #1232
Test plan
go build ./...passesjust lintpasses (0 issues)go build -tags it ./test/e2e/...passes