feat(sdk): add shorthand enum constants for policy types#357
feat(sdk): add shorthand enum constants for policy types#357marythought merged 1 commit intomainfrom
Conversation
Add PolicyEnums utility class with readable constant aliases for verbose protobuf enum names so developers can write PolicyEnums.OPERATOR_IN instead of SubjectMappingOperatorEnum.SUBJECT_MAPPING_OPERATOR_ENUM_IN. Constants added for SubjectMappingOperatorEnum, ConditionBooleanTypeEnum, AttributeRuleTypeEnum, and ActiveStateEnum. Examples updated to use the new shorthand via static imports. Companion to opentdf/platform#3408 (Go SDK equivalent). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility class, PolicyEnums, which provides shorthand constants for commonly used policy enum values to improve code readability. The existing example classes have been updated to utilize these constants via static imports, and a corresponding test suite has been added to verify the enum mappings. I have no feedback to provide as the changes are clean and well-structured.
|
X-Test Results✅ java-main |
… badges - Update JS imports to use barrel exports from @opentdf/sdk instead of deep proto paths - Update policy.mdx Java example to use PolicyEnums shorthand constants - Update policy.mdx JS example to use enum values instead of strings - Add SdkVersion badges with NEXT placeholders to code samples (replace with actual versions once SDK releases ship) Note: Java code_samples/java/ files are pulled from the java-sdk repo at build time via remote-content plugin. They will update automatically once javaSdkVersion is bumped in docusaurus.config.ts after the java-sdk release containing opentdf/java-sdk#357. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
… badges - Update JS imports to use barrel exports from @opentdf/sdk instead of deep proto paths - Update policy.mdx Java example to use PolicyEnums shorthand constants - Update policy.mdx JS example to use enum values instead of strings - Add SdkVersion badges with NEXT placeholders to code samples (replace with actual versions once SDK releases ship) Note: Java code_samples/java/ files are pulled from the java-sdk repo at build time via remote-content plugin. They will update automatically once javaSdkVersion is bumped in docusaurus.config.ts after the java-sdk release containing opentdf/java-sdk#357. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
…928) Re-export SubjectMappingOperatorEnum, ConditionBooleanTypeEnum, AttributeRuleTypeEnum, and ActiveStateEnum from the main @opentdf/sdk entry point so users can import them directly instead of reaching into generated proto paths. Companion to opentdf/platform#3408 (Go SDK) and opentdf/java-sdk#357 (Java SDK). Signed-off-by: Mary Dickson <mary.dickson@virtru.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dmihalcik-virtru
left a comment
There was a problem hiding this comment.
We need to wire up a formatter with import sorting for examples, it seems
🤖 I have created a release *beep* *boop* --- <details><summary>0.15.0</summary> ## [0.15.0](v0.14.0...v0.15.0) (2026-04-29) ### Features * **sdk:** add shorthand enum constants for policy types ([#357](#357)) ([a1d4651](a1d4651)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
… badges - Update JS imports to use barrel exports from @opentdf/sdk instead of deep proto paths - Update policy.mdx Java example to use PolicyEnums shorthand constants - Update policy.mdx JS example to use enum values instead of strings - Add SdkVersion badges with NEXT placeholders to code samples (replace with actual versions once SDK releases ship) Note: Java code_samples/java/ files are pulled from the java-sdk repo at build time via remote-content plugin. They will update automatically once javaSdkVersion is bumped in docusaurus.config.ts after the java-sdk release containing opentdf/java-sdk#357. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
## Summary - Update Go SDK code samples to use the new shorthand enum constants (`policy.OperatorIn`, `policy.BooleanAnd`, `policy.RuleAnyOf`) instead of verbose proto enum names - Update JS SDK imports to use barrel exports from `@opentdf/sdk` instead of deep proto paths (`@opentdf/sdk/platform/policy/objects_pb.js`) - Update JS SDK examples to use enum values (`ConditionBooleanTypeEnum.AND`) instead of string literals (`'CONDITION_BOOLEAN_TYPE_ENUM_AND'`) - Update Java SDK inline examples in policy.mdx to use `PolicyEnums` shorthand constants - Add `SdkVersion` badges with `NEXT` placeholders — replace with actual versions once SDK releases ship ### Companion PRs | SDK | PR | Status | |---|---|---| | Go | opentdf/platform#3408 | Open | | Java | opentdf/java-sdk#357 | Open | | JavaScript | opentdf/web-sdk#928 | Open | ### Note on Java code samples The `code_samples/java/` files are pulled from the java-sdk repo at build time via `docusaurus-plugin-remote-content`. They will update automatically once `javaSdkVersion` is bumped in `docusaurus.config.ts` after the java-sdk release containing opentdf/java-sdk#357. ## Test plan - [x] `npm run build` passes - [ ] Surge preview renders correctly - [ ] Replace `NEXT` version placeholders after SDK releases 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated policy and quickstart code examples for Go, Java, and JavaScript to use simplified SDK enum constants for clearer, more idiomatic samples. * Switched JavaScript examples to use package entry-point imports instead of generated-module paths. * Added SDK version markers to code samples to show explicit language/version context and improve consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Mary Dickson <mary.dickson@virtru.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>



Summary
PolicyEnumsutility class with readable constant aliases for verbose protobuf enum names so developers can writePolicyEnums.OPERATOR_INinstead ofSubjectMappingOperatorEnum.SUBJECT_MAPPING_OPERATOR_ENUM_INConstants added
OPERATOR_INSUBJECT_MAPPING_OPERATOR_ENUM_INOPERATOR_NOT_INSUBJECT_MAPPING_OPERATOR_ENUM_NOT_INOPERATOR_IN_CONTAINSSUBJECT_MAPPING_OPERATOR_ENUM_IN_CONTAINSBOOLEAN_ANDCONDITION_BOOLEAN_TYPE_ENUM_ANDBOOLEAN_ORCONDITION_BOOLEAN_TYPE_ENUM_ORRULE_ALL_OFATTRIBUTE_RULE_TYPE_ENUM_ALL_OFRULE_ANY_OFATTRIBUTE_RULE_TYPE_ENUM_ANY_OFRULE_HIERARCHYATTRIBUTE_RULE_TYPE_ENUM_HIERARCHYSTATE_ACTIVEACTIVE_STATE_ENUM_ACTIVESTATE_INACTIVEACTIVE_STATE_ENUM_INACTIVESTATE_ANYACTIVE_STATE_ENUM_ANYBefore / After
Test plan
mvn compilepasses (full project including examples)mvn test -Dtest=PolicyEnumsTest— 4 tests, all pass🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Tests