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.
Readers return Conditions.missing_value for no value, and the session
names a package entry as {type:, key:}.
The new featurevisor-schemas gem, beside the core gem, validates data
against those schemas with the rules, messages, mutations and issues
of @featurevisor/schemas, and describes fields for forms through
handles, with synchronous checks in code. The gem check builds and
loads it apart from the core gem.
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.
…ript does Without the m flag, ^ and $ now match only at the start and end of a value, where Onigmo's match at every line. \s and \S follow JavaScript's whitespace, with NBSP and the BOM, and without the s flag a dot refuses only JavaScript's line terminators. Numbers compare as doubles, so integers above 2^53 that JavaScript cannot tell apart are equal. sdk-conditions.json pins each, and sdk-package-conditions.json now runs match_conditions 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, and \u{...} escapes compile. format holds issue entries back, and
additionalProperties other than true or a schema takes no extra key. The
conformance spec checks diagnostics, and the built datafile spec reads the
shared schemas-datafile.json instead of its own copies.
The module API's evaluate runs every module's before_evaluation for a package's own entry, with the entry's type and key, and answers the conditions its block 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. Feature leaves never carry the package's key. 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. The CLI loads the featurevisor-schemas gem when it is there, so the featurevisor gem does not depend on it, and without it each schema case fails saying so. A Node.js CLI from before schema specs rejects the option, so the runner asks again without it.
Featurevisor#on took only a callable, so the README's block form raised ArgumentError. It now takes either, as a child instance does.
…once The modules manager records which phases its modules take part in, so evaluations skip before and after evaluation, bucket key and bucket value when no module has them, and a module that only reads the datafile, such as the schemas package's, no longer makes flags slower. Package conditions given as JSON text are parsed once per datafile and frozen, with conditions_parse_error reported for text that does not parse.
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, hashes key by key and arrays item by item, with a hash or array given again as the same object counted as changed, and every key when the stored context itself comes back. A string and a symbol stay apart. 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.
set_datafile 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 keeps 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 spec that inspects the index subscribes a listener, since only then is there one.
…and drop [] The JavaScript package exports none of them. The engine's modules are private constants, child, field_keys, checks? and validate_rules are private, and get is the one way to a handle, as fields with each field's name is to an object's fields.
JavaScript keeps both for its React hooks, and Ruby has none.
Featurevisor::Schemas.flatten was a second way to flatten issues, so its logic is a private constant.
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 store by node, in two generations rotated on datafile_set and bounded at 4096 entries each, so an unchanged schema keeps its validator across a datafile change. Views validate about 45% faster. An application or form message that is neither text, a symbol nor callable is passed over, and child gives a key such as 2fa the handle at gives, each with a test. 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 before_evaluation and after_evaluation run for flags, variations and both kinds of variable, while a schema validation also runs every module's before_evaluation, with type and key naming the schema instead of a feature key, and never runs after_evaluation. 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. Numbers are written as text by their digits, as PHP does. The pattern cache is new, a dash in a character class is escaped, and a view's memo follows the context and sticky values. The publish workflow pushes the schemas gem too, 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.
…as, not kind kind 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 method is render_as. The README's Schemas section, the tests, the comments and the datafile fixture, whose member is renderAs, follow.
4.1.0 ships the extension seam and the featurevisor-schemas gem at one version. Both lockfiles follow. The README installs schemas with ~> 4.1, since no 4.0 schemas gem exists, and names the three gems the build produces.
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