Repository navigation
feat: schemas - #9
Merged
Merged
Conversation
Datafiles can carry sections beside the SDK's own keys, such as schemas. The SDK now keeps them through every replace and merge, merging a section by entry as segments merge, and datafile_set details list the changed entries of each section. The module API gains getEntry, getEntryKeys and matchConditions. The last answers a package's conditions, as JSON text or trees, with the instance's engine, in one dependency session whose root is the package's entry, and reads leaves only the package knows, such as input, through readers that tell an absent value from null. VariableMutations.applyVariableOperations, Conditions.getPortableTimestamp and CompareVersions.isValidVersion are public for such packages. The new featurevisor-schemas Maven module, com.featurevisor.schemas, validates data against those schemas with the rules, messages, mutations and issues of @featurevisor/schemas, and describes fields for forms through handles, with checks in code and option sources. The artifact check verifies its JAR and POM. It passes the 85 cases of conformance/schemas-validation.json twice and matches the JavaScript package on a datafile the CLI built, issues, messages and handle members included. A schema that references itself follows the value, and one that loops fails closed after 128 nested references with schema_reference_depth.
Without the m flag, $ now matches only at the end of a value, never before a final line break. \s and \S follow JavaScript's whitespace, with U+00A0 and U+FEFF and without U+0085, and without the s flag a dot refuses only JavaScript's line terminators. sdk-conditions.json pins each, and sdk-package-conditions.json now runs matchConditions with readers.
…cript does Patterns now mean what JavaScript means with the u flag, so what u rejects, such as an escape without a meaning or a lone brace, fails every value. A mutation that cannot be applied fails the value with refineError and one schema_mutation_error diagnostic instead of throwing, and views keep such a node as it is. format holds issue entries back, and additionalProperties other than true or a schema takes no extra key. The conformance runner checks diagnostics, and the differential test reads the shared schemas-datafile.json.
Segments listed by the Node.js CLI carry authoring fields such as metadata, which the SDK's segments do not hold. Reading them failed every test run on a project whose segments have metadata, Example 1 among them.
The module API's evaluate runs every module's beforeEvaluation for a package's own entry, with the entry's type and key, and answers the conditions its callback matches with the context the modules leave, in one dependency session. Schemas validate and describe views inside it, so context a module adds reaches mutations and issue entries as it reaches flags. Nested feature and variable reads never carry the package's key or readers. The shared fixtures gain package condition cases with a module that adds context, and drop the case that counted references at one value to exactly 128.
The test runner asks for schema specs and validates each assertion's value as the JavaScript CLI does, against the datafile of its environment and Target, under its context. featurevisor-schemas provides the validator as a service, so the SDK does not depend on it. Run the CLI from the featurevisor-schemas module to have it, while from featurevisor-sdk alone each schema case fails saying so. A Node.js CLI from before schema specs rejects the option, so the runner asks again without it.
The README now has the JavaScript SDK page's sections in its order: install, create an instance with an options table, context, flags, variations and variables with typed methods and composition, default values, evaluating everything at once, sticky values, datafile updates with merging and an interval refresh, child instances, events, diagnostics, evaluation details with the reasons table, modules, and schemas from creating an instance to patterns. Examples use the docs' running example, checkout, pricing, buyButton and supportEmail for user-4 in the Netherlands, and the signUp schema, so each page reads like the others in its own language. The README test reads the example under its new heading.
context_set details now carry keys, the top level keys whose values changed, compared by value: numbers by numeric value, so an Integer and a Double holding 30 are the same though a Boolean is never a number, maps key by key and lists and arrays item by item, with a map or list given again as the same object counted as changed. A merge compares only the keys it carries, a replace every key of either context, and a child its own context. The keys are worked out only when a listener or a debug diagnostic receiver reads them. datafile_set details now carry segments, the segments whose definitions were added, changed or, on replace, removed, which the SDK already worked out to find the features and variables they affect. conformance/sdk-events.json pins both, as in JavaScript, and the README documents them as the JavaScript page does. Its contents list links datafile_set by GitHub's anchor.
setDatafile worked out the changed features, variables, segments and sections, and their dependency closure, on every call, even when no listener and no diagnostic at info received them. It now does only when a datafile_set listener, a child's among them, or an info diagnostic receiver exists, and otherwise skips the details, the diagnostic and the event, and the new provider builds no dependency index, which the next update that is read builds again from the datafile it has. What the SDK answers is unchanged, and so are the details whenever someone receives them.
The README now calls the section Create an instance, so the README check CI runs could not find the example it compiles and runs.
…les package private The JavaScript package exports none of them. getFields gives the fields' handles, each with its getName, and validate is the one way to validate.
…lled JavaScript keeps both for its React hooks, and Java has none.
The shared fixture's sign up form gives accountType and a newsletter box a default, which the business mutation turns off, and the built datafile test reads both.
The README says what default is and that a handle from with input has the one a mutation sets, as the JavaScript page does.
…and unlisted fields come in name order An issues entry waited for any issue of shape in its object. It now waits only while one sits at or inside its path, or anywhere in the object without a path, or in a field its conditions read, as JavaScript's does. Fields an order leaves out come in name order by Unicode code point, and the built datafile test compares field order exactly. The README says Schemas are experimental, as JavaScript's does, and that unlisted fields come in name order.
The JavaScript package was simplified for review with no change in behaviour, and this port follows it where it has the same structure: one position for report, an issue entry's path split once, inputsOf keeping only strings, a oneOf branch chosen from a map of kinds, attribution worked out once per issue, and one classifier for path steps. Compiled validators and mutated rules are kept per instance by node identity, in two generations, so an unchanged schema keeps its validator across a datafile change while memory holds two datafiles at most, and an array without items shares one string node. child gives a key such as 2fa the handle at gives, with a test. Messages are typed, so no other bug applied. The shared schemas-validation.json gains two cases for a field a mutation adds by schema reference, which pass. The README follows the JavaScript page: the data is value beside the handle, Follow the values typed so far comes after Read annotations, Check in code names its optional fields, and the constraints and options rows say which member is keyed by field path.
The Modules section said beforeEvaluation and afterEvaluation run for flags, variations and both kinds of variable, while a schema validation also runs every module's beforeEvaluation, with getType() and getKey() naming the schema instead of a feature key, and never runs afterEvaluation. It now says so, and to check the type before reading the keys, as the JavaScript SDK's page does.
A schema used twice, such as an address for billing and for shipping, lost its constraints and choices the second time, since walks stopped at any schema already seen. The port now follows the JavaScript package's release fixes. Walks guard only the current path, and kind stops on a list of itself. A missing field reports no missing schema, the message translator runs last, and required applies without properties. A value nested more than 128 references deep fails closed at the 129th, and a check that throws fails closed with schema_check_error. Every diagnostic's dedupe resets with a new datafile, no handle is kept for a key the datafile lacks, patterns compile once into a cache capped at 4096 that holds failures, and an unknown type fails every value. Both conformance fixtures are copied again from the monorepo, with 150 validation cases and an address schema used twice. The README says how a field's handle treats a missing value and when schema_check_error is reported, and gives no minimum CLI version. HandleOptions keeps the handles made from it for as long as it lives, and a view's memo follows the context and sticky values. The release scripts check every artifact's version, and the README's stale second Schemas section is gone.
Test specs already use at for a bucket position, and schema specs may need it too once their conditions read rollouts, so at(path) on a handle read as one more meaning of the same word. The port follows the JavaScript package: field(path) pairs with fields and is what the docs call the result, a field's handle. Nothing is released yet, so the rename needs no deprecation. The README's Schemas section, the tests and the comments say field now.
…erAs(), not getKind() getKind() named what a field's rules say it renders as, such as select or list, but the word told a reader nothing without the docs and already names condition kinds. The port follows the JavaScript package, which calls it renderAs. The values are unchanged, and nothing is released yet, so the rename needs no deprecation. The handle's getRenderAs() returns the RenderAs enum, where getKind() returned FieldKind. The README's Schemas section, the tests, the comments and the datafile fixture, whose member is renderAs, follow.
5.1.0 ships the extension seam and featurevisor-schemas, a minor as decided. The Maven revision, the CLI version and every README installation example say 5.1.0, which verify-release.sh and test-release.sh check.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refs featurevisor/featurevisor#449