Repository navigation
refactor(interface-data-api): build on interface-core 0.4's typed decorator targets - #84
Merged
Merged
Conversation
…orator targets The field decorators get a DecoratorTarget and read the decorated class through the isClass guard before they look up its DataAPIMeta. RegisterDataController hands the parameter and route decorators the class prototype read through prototypeOf, and builds the route location from the controller class, since ControllerMeta.location may now be undefined. Pins interface-core 6a8b526 (0.4.0), interface-api 2d1cc37, interface-database-decorators ca0851d and core 68d5ce0 (1.20.0), and drops the api-scoped interface-core 0.2.7 override so the tree holds one interface-core.
…ertyDecorator Filter returned a decorator whose target was the filter function's row type, while the factory it wraps takes a DecoratorTarget. It now returns that PropertyDecorator, so a data type that applies a filter to the target it was handed needs no stand-in row type.
# Conflicts: # guardrails.ratchet.json
…tor/decorator-targets # Conflicts: # .campaign/tgz/SHA256SUMS # README.md # package.json # pnpm-lock.yaml # pnpm-workspace.yaml
… prove the field refusal
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.
Why
Antony's goal: delete every AntelopeJS
guardrails.ratchet.jsonthrough verified PRs on campaign/integration, each contract change proven by tarball against every consumer, with no fallback or back-compat. This PR belongs to W7, the last contract wave: interface-core 0.4 types decorator targets asDecoratorTarget, defaultsClass<T>toobjectand types log arguments asunknown[](interface-core PR, tarball 6a8b526). The field decorators handed interface-core'sanytarget toonField: 12no-unsafe-argumentrows inmetadata.ts.What changed
onField(target: DecoratorTarget, …)reads the decorated class through the existingisClassguard beforeGetMetadata(owner, DataAPIMeta)(throwsA field decorator applies to a class.otherwise; a member decorator's target always has its class asconstructor, so no real caller reaches it).RegisterDataControllerpasses the class prototype read through the existingprototypeOfguard to the parameter and route decorators, and builds the route location from the controller class (target.location), sinceControllerMeta.locationmay now beundefined. It still readsControllerMeta.computed_propsas before.Filterreturns interface-core'sPropertyDecorator(the type of the factory it wraps) instead of(target: T, propertyKey: string | symbol) => void, so a data type that applies a filter to the target it was handed (dmsdecorateColumn) needs no stand-in row type.@antelopejs/api>@antelopejs/interface-core: 0.2.7override, so the tree holds one interface-core.Rows (ratchet:update)
typescript/no-unsafe-argument: 12 -> 0typescript/no-unsafe-assignment: 6 -> 0typescript/no-unsafe-return: 4 -> 2Measured rows 15 -> 3. The assignment and return ceilings were above their counts on integration; the 12 argument rows are this wave's.
Proofs
pnpm run checks(CI state, network namespace):Checks: 9 passed, 0 failed.;ajs module test .: 190 passing.Filter's return type changes; runtime export keys identical (4 entries). api-diff suppressions: 0 to 0,@ts-expect-error5 to 5,SAFETY:4 to 4.antelopejs-interface-data-api-7a8719d.tgz,TGZ_VERSION=0.6.0 KEEP=1at 7a8719d, sha25605044cb0607b154f1efc4780fa783548e6101c134da56ca0e27ce86b8a55b247.Attention
Filter(fn)no longer checks at the decoration site that the decorated class matchesfn's row typeT;Tstill typesfn.src/metadata.tsis 19994 bytes, 6 under the size cap.Round 2 pins (supersede the pin and tarball lines above)
Head 1c2d010. interface-api#67 raised its interface-core peer floor to
>=0.4.0 <1.0.0, so interface-api was repacked and interface-core#62 and antelopejs#356 landed; integration is merged in.8e017528574748687b246df07affa6cbcfbe931cc6086fcb5dd2c7a28c1f0d8e, interface-core peer>=0.4.0 <1.0.0), interface-core f7df541 (0.4.0,30391718e65481815db5b5bb10e7eabb1feac13165005ee46e54b592f3676c69), core 184eb90 (1.20.0,0a51c9c2da58c2586bfa5095b1da92a7b74130acf1e64820bfd5f98eaa4200f9)antelopejs-interface-data-api-1c2d010.tgz(TGZ_VERSION=0.6.0), sha256583046f873e66224df3ca03174642c2ac3646b48950f16f056cb64da03003d90. Its dist equals 7a8719d; only README and devDependency pin text differ.pnpm run checksand tgz-proof PASS,Checks: 9 passed, 0 failed.; CI green.Verifier correction (w7-b, 28ffb6e)
typescript/no-unsafe-argument12 -> 0 only. Theno-unsafe-assignment 6 -> 0andno-unsafe-return 4 -> 2lines compare with the older merge-base 169448e; integration had already lowered those ceilings to 0 and 2.onField'sisClasscheck could not fail fortarget.constructor(typedFunction):isClasswastypeof value === "function". With the check replaced byif (false)in the built output,ajs module test .still passed 190 of 190.Round 3 (bca1ca6)
isClassnow requires a function with an objectprototype(arrow functions, methods and bound functions fail it). A generator function has aprototypetoo, a language limit shared with everyprototypetest.prototypes.tsis its other caller and passes a prototype object'sconstructor, a class.src/tests/index/field_decorator_target.test.ts: a target whoseconstructoris an arrow function must throwA field decorator applies to a class., and a class target declares its field. Noas, no directive.ajs module test .: baseline 193 passing.if (!isClass(owner))replaced byif (false): 191 passing, 2 failing.isClassreduced toisFunction(value)(the old check): 191 passing, 2 failing.pnpm run checks(no dist,GITHUB_BASE_REF=campaign/integration): 9 passed, 0 failed. Integration was 0 commits ahead.Verifier correction (w7-r3, bca1ca6)
onField's check set toif (false)andisClassreduced toisFunction, gives 191 passing, 1 failing (not 2): the 193/2 run included a "constructor is a method" test that is not in this head.RegisterDataControllernow reads the prototype throughprototypeOf, whose refusal (on integration since 1c5030c) no test reaches: with it set toif (false), 192 of 192 still pass. A bound-class test can cover it.isClasslets generator and async generator functions through (they have an objectprototypebut are not constructible) and refuses bound classes (constructible, noprototype).