Compare commits

...
330 Commits
Author SHA1 Message Date
semantic-release-bot 424b111737 chore(release): 7.19.0 [skip ci]
# [7.19.0](https://git.datacontroller.io/dc/dc/compare/v7.18.0...v7.19.0) (2026-10-28)

### Bug Fixes

* address the review findings on the harness and refresh changes ([36e4e88](36e4e88eb1))
* **ci:** dispatch the demo deploy with a tag ref and the actions scope ([698dea6](698dea6d6b))
* **ci:** restore the gitleaks ignore entries for the mock licence pair ([0d58be9](0d58be975d))
* **client:** open the SAS log page with noopener ([072a133](072a133702))
* **client:** refuse a truncated table in the multi-table upload ([1fb4818](1fb4818d21))
* **cypress:** apply the licence key when the estate has none ([be8f445](be8f445ae1)), closes [input#file-upload](https://git.datacontroller.io/input/issues/file-upload)
* **dc_execute:** use = comparisons, not IN, in the fail-fast guard ([fed43cb](fed43cb07e))
* **dc_getlibs:** exclude the DC libref from the dictionary scan ([f5aade5](f5aade5976))
* **dc_refreshcatalog:** terminate the generated statements ([1e22476](1e224763ba))
* **derived:** a fileref with nothing written is a FAIL, not an error ([9b3cf50](9b3cf50b9c))
* **derived:** address five review findings ([ccd468b](ccd468b335))
* **derived:** carry the placement sequence in mpe_derived ([be50cb5](be50cb5d08))
* **derived:** close four gaps in the MPE_DERIVED hook ([9914790](9914790777))
* **derived:** close the RLS and search gaps on derived columns ([9ef813d](9ef813d439))
* **derived:** close the two gaps in the derived/RLS invariant ([422f766](422f766cd4))
* **derived:** compare the outref as text, prove the file is empty ([7830b7b](7830b7bcfa))
* **derived:** do not drop a shadowed column from staging or downloads ([2d5de9a](2d5de9a324))
* **derived:** do not duplicate a shadowed column in the grid payload ([6a1128a](6a1128a463))
* **derived:** eight review findings ([561d7fc](561d7fc3ed))
* **derived:** enforce the ACTIVE picker pair in the extracted check ([1863076](1863076bc9)), closes [#366](#366)
* **derived:** enforce the documented limits, and handle derived filters in VIEW ([d3dec68](d3dec682aa))
* **derived:** filtering a format catalog no longer aborts the service ([469229a](469229aecb))
* **derived:** guard the bitemporal cut-off, coalesce the selectbox seed ([7fb981d](7fb981daa9))
* **derived:** guard the empty physical column list in the dep check ([5f5d868](5f5d8681b9))
* **derived:** hold a derived column read-only whatever the table's security ([5f443b0](5f443b0b16))
* **derived:** ignore a re-added name when collecting inactive rows ([6b5bf3e](6b5bf3e6be))
* **derived:** ignore inactive rows and VIEW rules in the submit guards ([85c89ca](85c89ca2a4))
* **derived:** keep targetds for plain datasets, test the empty file ([f8f6568](f8f65681e1))
* **derived:** make the model enforce the required columns, and leave VAR_FMT optional ([7efbf31](7efbf31ea5))
* **derived:** only the delete marker is a reserved name ([af31c36](af31c36b67))
* **derived:** open the statements file with a long record length ([ee31782](ee31782fbf))
* **derived:** pair the filterds %else with %do/%end ([88a38db](88a38db877))
* **derived:** raise the VAR_ORDER ceiling to 10000 ([27ddcfb](27ddcfb575))
* **derived:** refuse dependencies on inactive rows, and keep the RLS scope guard coherent ([7799a30](7799a300df))
* **derived:** reject a dependency on a row this submission deletes ([8806504](8806504967))
* **derived:** repair the validation rows for MPE_DERIVED ([9a047ad](9a047ad42e))
* **derived:** review feedback - cover the empty response, assert the last row ([e0da9f1](e0da9f1098))
* **derived:** stop the hooks aborting on their own macro variables ([688550a](688550a28d))
* **derived:** truncate the derived label on an even quote boundary ([1b5c4b3](1b5c4b3ecd))
* **derived:** verify on stripped values, and label with the variable name ([4d9ad38](4d9ad38df1))
* **editor:** a blank truncation note is not a warning ([f182179](f182179403))
* **editor:** keep decimal values when an uploaded file is edited manually ([04ce186](04ce1861e7))
* **getcolvals:** report an invalid value, not missing inputs ([4bcee70](4bcee706ff))
* **getdata.test:** pin the derived filter to a libref, and spell the table as it is ([45dce7b](45dce7b11b))
* **getdata:** clear the globals it declares before use ([359b570](359b570b85))
* **getddl.test:** ask for a table, not a whole library ([059cdf1](059cdf176a))
* **getrawdata:** declare mp_ds2md so the Markdown download can run ([661ee19](661ee19cfa))
* **lint:** clear the sasjs lint warnings on the files 7.19 touched ([355c46a](355c46a7b6))
* **makedata:** read KEEPME from every input row, and keep it out of the Viya seed ([d626cb8](d626cb8f2d))
* **mocks:** address the audit-pack review findings ([489819b](489819b051))
* **mocks:** carry the zip flags into the central directory ([c4021a4](c4021a42ff))
* **mocks:** clear the licence for published sites, not for the estate ([62f55db](62f55db170))
* **mocks:** copy the physical column list before deriving ([f411b7d](f411b7d269))
* **mocks:** derive before filtering in the viewer, and drop the columns ([60ec470](60ec470404))
* **mocks:** derive the retained key wherever rows are staged ([74060c0](74060c0585))
* **mocks:** drop derived variables before staging ([73d25b1](73d25b1220))
* **mocks:** key rk_underlying tables on their business key ([347dbb5](347dbb53b0))
* **mocks:** register MPE_DERIVED and seed its field rules ([ee3c878](ee3c8787ef))
* **mocks:** scope the derived hook's graph to the submission ([6cad23f](6cad23fce9))
* **mocks:** search the physical columns only in the viewer ([293022d](293022d46b))
* **mocks:** stop the mock advertising invalid licence keys ([fb36379](fb36379520))
* **mpe_assert_abort:** drop the unused line variable ([9c294c0](9c294c0ab5))
* **mpe_assert_abort:** take the abort's own MSG, tolerate a missing response ([0a52d20](0a52d20c5f))
* **mpe_execute:** fail fast when the child left no status ([a036386](a03638667f))
* **mpe_execute:** no apostrophe in the SAS 9 status note ([2204085](220408538b))
* **mpe_execute:** read an unknown state as unmeasured, not failed ([f2b1428](f2b1428ec3))
* name the startupservice launcher button "Show log" ([3445107](3445107d9a))
* offer the launcher on the globvars failure modal too ([ad2da45](ad2da45389))
* **refresh:** name each catalogue load uniquely in the audit trail ([46bacdd](46bacdd6d9))
* **refresh:** one audit folder per refresh call ([56b6620](56b6620ef4))
* **sites:** round-trip the committed licence before publishing ([4d462d3](4d462d310f))
* **test:** getdata test ([da30266](da30266278))
* **tests:** enable closeouts logging ([fdcd8fa](fdcd8fa4b3))
* **tests:** read the work location from _SASJS_WORK ([033ffd3](033ffd3025))
* **ui:** one error modal at a time ([81ccf75](81ccf758e9))
* **validatefilter:** build targetds without macro triggers in comments ([42355f1](42355f17bc))
* **validatefilter:** drop the dead nobs assignment, keep targetds precedence ([337ea8e](337ea8e5e0))

### Features

* **dc_getlibs:** dump the library list when debug is on ([582523d](582523dc87))
* **derived:** allow a variable to shadow a physical column ([12beeff](12beeff695))
* **derived:** declare VAR_DEPENDENCIES instead of VAR_ORDER ([813bce6](813bce6856))
* **derived:** optional VAR_LABEL on MPE_DERIVED ([7c9ce9a](7c9ce9a712))
* **derived:** pickers, and an ACTIVE default, for MPE_DERIVED ([87e794f](87e794f769))
* **derived:** report the dependency cycle path ([cee1a95](cee1a954ee))
* **derived:** take any text in VAR_LABEL, but not a line break ([78e88a4](78e88a4112))
* **derived:** validate MPE_DERIVED at submit time ([0b010f2](0b010f2c65))
* **derived:** validation rules and a VAR_TYPE dropdown for MPE_DERIVED ([aa6d50e](aa6d50e1ea))
* **derived:** VARIABLE_ORDER, so a derived variable can build on another ([33d043e](33d043ea92))
* **editor:** derived variables in the EDIT screen ([b0fd354](b0fd354ecd))
* **editor:** mark derived variables as computed in the EDIT grid ([6513d09](6513d09f05))
* **editor:** serve a truncated selection with a warning instead of aborting ([34691dc](34691dceec))
* **editor:** show the derived column label in the header tooltip ([cfe6647](cfe6647ca8))
* **mocks:** add getauditfile and the audit-folder artefacts ([752d944](752d944c20))
* **mocks:** implement derived variables in the JS services ([b4fae88](b4fae88ae1))
* **mocks:** validate a submitted MPE_DERIVED row like the hook does ([5d183d1](5d183d1350))
* run startupservice in a new window from its error modal ([40f6133](40f61331aa))
* **sites:** mint a licence for the published sites ([7d9df71](7d9df71fdb))

### Reverts

* **derived:** no shadowing, and no self reference ([5af8e6f](5af8e6fc35))
* **stagedata.test.4:** back to the MPE_LOADS evidence for now ([31aa859](31aa859153))
2026-10-28 01:42:51 +00:00
allan 849153d4a2 Merge pull request 'ci(release): build the frontend before deploying mocked services' (#381) from fix/ci-release-build-frontend into main
Release / Build-production-and-ng-test (push) Successful in 4m42s
Release / Build-and-test-development (push) Successful in 25m42s
Release / release (push) Failing after 6m56s
Reviewed-on: #381
2026-10-28 01:08:49 +00:00
dc bc9e0996ec ci(release): build the frontend before deploying mocked services
Build / Build-and-ng-test (pull_request) Canceled after 1m32s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m52s
2026-10-28 01:07:00 +00:00
allan 66039c91d7 Merge pull request 'feat: release 7.19 - derived variables, startupservice launcher, core v6' (#348) from release/7.19 into main
Release / Build-production-and-ng-test (push) Successful in 4m13s
Release / Build-and-test-development (push) Failing after 1m52s
Release / release (push) Skipped
Reviewed-on: #348
2026-10-28 00:52:14 +00:00
allan abb1ecbcab Merge pull request 'fix(validatefilter): drop the dead nobs assignment, keep targetds branches exclusive' (#380) from fix/validatefilter-branches into release/7.19
Sites / deploy (push) Successful in 4m2s
Build / Build-and-ng-test (pull_request) Successful in 5m37s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m9s
Build / Build-and-test-development (pull_request) Successful in 33m26s
Reviewed-on: #380
2026-10-28 00:07:31 +00:00
dc 337ea8e5e0 fix(validatefilter): drop the dead nobs assignment, keep targetds precedence
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Review feedback on the merged fix:

- derived_nobs was assigned twice, the first one dead - the coalesced form below
  is the live value.  Removed, so there is one assignment to read.
- making the catalog test a plain %if after the derived-variables test let the
  catalog branch override it; the derived view won before and still should.  The
  catalog branch now requires derived_nobs=0, so the view keeps precedence and
  only a catalog with no derived configuration is blanked.

Two guarded if blocks, not %else %if: that construct is what the parser rejected
in this file before ('Expected DO not found'), and the first attempt at this
review point reproduced it - validatefilter and viewdata both failed to complete
again until it was replaced.

Verified: sasjs test -t new -> 64/64 (100%), TEST=0.
2026-10-28 00:05:19 +00:00
allan 709acfad73 Merge pull request 'fix(validatefilter): build targetds without macro triggers in comments' (#379) from fix/validatefilter-targetds into release/7.19
Sites / deploy (push) Successful in 3m50s
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 14m43s
Reviewed-on: #379
2026-10-27 23:46:46 +00:00
dc 42355f17bc fix(validatefilter): build targetds without macro triggers in comments
Build / Build-and-ng-test (pull_request) Successful in 5m28s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m37s
Build / Build-and-test-development (pull_request) Successful in 33m19s
The suite failed to complete on the estate with

  ERROR: Expected %DO not found.
  ERROR: Skipping to next %END statement.

and, once the parser had lost sync, 'Apparent symbolic reference IS_FMTCAT not
resolved' - because the %let that defines it never ran.

Two causes, both in the code that decides which dataset the filter is validated
against:

- the comment explaining the catalog case contained the text '%if ...' and the
  macro processor resolves triggers even inside a comment, so the prose was
  executed as code and tripped the parser from there.  The comment now avoids
  macro triggers entirely.
- an empty value compared in a condition is a character operand, and
  %mf_nobs returns nothing when the dataset is missing.  It is wrapped in
  coalesce now, and the catalog flag is computed with %eval instead of a nested
  %if.

targetds is still blanked for a LIBREF.CATALOGNAME-FC name - which is what makes
mp_filterstore rewrite it to a cntlout dataset - and stays the plain libds
otherwise, as an empty targetds falls back to libds in the engine anyway.

The test now passes outref= and mdebug=&sasjs_mdebug rather than a hard-coded
1: the suite already owns that switch, and testinit turns it on by itself when
the run asks for _debug=2477 or 131, which is when the child's response and the
PROC HTTP trace are worth having.

Verified: sasjs test validatefilter -t new -> 3/3 (100%), six assertions, all
PASS, including the catalog and derived-variable cases.
2026-10-27 23:46:19 +00:00
dc 6ef2eec011 ci(sites): start the SASjs server with HTTP_PORT=5000
Sites / deploy (push) Successful in 3m45s
Build / Build-and-ng-test (pull_request) Successful in 5m5s
Build / Build-and-test-development (pull_request) Canceled after 5m11s
Lighthouse Checks / lighthouse (pull_request) Canceled after 7m59s
The Sites workflow was the one place that still started the server without a
listener, so it died with

  [error] Invalid environment variable(s) provided:
   - no listener is enabled
   - set HTTP_PORT and/or HTTPS_PORT (either may be used alone)

and the following step's 120s poll timed out. build.yaml, release.yaml and
lighthouse.yaml already carry the same line.
2026-10-27 23:26:26 +00:00
allan 1ef3e0a97b Merge pull request 'fix(refresh): one audit folder per refresh call' (#378) from fix/refresh-etlsource into release/7.19
Sites / deploy (push) Canceled after 2m14s
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 13m28s
Reviewed-on: #378
2026-10-27 23:12:33 +00:00
dc 56b6620ef4 fix(refresh): one audit folder per refresh call
Build / Build-and-ng-test (pull_request) Successful in 5m34s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 18m57s
refreshcatalog.test and viewtables.test failed to complete with

  ERROR: could not create /tmp/DataController/<libref>/dc_staging/refreshcatalog:mpe_refreshcatalogs: + <stamp>

The staging folder a closeout writes its statements to is
&dc_staging_area/&etlsource, and etlsource defaulted to
'refreshcatalog:<step>:%mf_uid()'. A default is resolved when the macro is
compiled, not when it is called, so every refresh in a session reused the same
folder - the first step created it, the next one could not, and the abort took
the whole suite down. Whichever suite reached the staging area first decided
which others failed, which is why the count moved between runs.

etlsource now defaults to 0 and is set per call from
%mf_getuniquename(prefix=<step>): unique, a plain name rather than a path, and
resolved at the point of use.

Verified on the estate: refreshcatalog 4/4 (100%), viewtables 2/2 (100%).
2026-10-27 23:08:47 +00:00
allan fd272eec89 Merge pull request 'test(editor): assert the derived block marker, not a column name' (#377) from fix/derived-block-spec into release/7.19
Sites / deploy (push) Failing after 5m38s
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m43s
Build / Build-and-test-development (pull_request) Canceled after 1m32s
Reviewed-on: #377
2026-10-27 22:25:30 +00:00
dc c463a4e03c test(editor): assert the derived block marker, not a column name
Build / Build-and-ng-test (pull_request) Successful in 5m22s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Canceled after 17m25s
derived-variables.cy.ts:97 expected dc-derived-first on the REGION header,
because the comment assumed REGION opens the computed block. The grid follows
MPE_DERIVED order, and that order is LINE_VALUE, REGION, REGION_LABEL - so the
marker was on LINE_VALUE and correct. The spec asserted the wrong column, and
the development pipeline has been red on it since.

Dumping the header row on a local mock estate (sasjs/server desktop mode,
RUN_TIMES=js) shows:

  6 | LINE_VALUE | dc-derived-header dc-derived-first
  7 | REGION | dc-derived-header
  8 | REGION_LABEL | dc-derived-header beforeHiddenColumn htLastVisibleHeader

and the same dump against the unmodified release/7.19 client, so this was never
a client defect.

The assertion now states the invariant instead: at least one derived header, the
first of them opens the block, and no other one carries the marker. That holds
whatever order the control table returns the variables in.
2026-10-27 22:21:52 +00:00
allan 23015ac41f Merge pull request 'fix(lint): clear the sasjs lint warnings on the files 7.19 touched' (#374) from fix/lint-719-touched-files into release/7.19
Sites / deploy (push) Failing after 5m39s
Build / Build-and-ng-test (pull_request) Successful in 5m26s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m43s
Build / Build-and-test-development (pull_request) Canceled after 20m56s
Reviewed-on: #374
2026-10-27 22:01:09 +00:00
dc a8f62bdfe2 docs(agents): say why webout is in ignoredMacros, and where the macros come from
Build / Build-and-ng-test (pull_request) Successful in 5m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m29s
Build / Build-and-test-development (pull_request) Failing after 34m27s
The previous wording named only mpeinit and mpeterm, so the webout entry read as
an unexplained addition. webout is the linter's own default - sasjs compile
injects %webout into every service - and an explicit ignoredMacros list replaces
that default, so it has to be restated. 52 service files call %webout, which is
what dropping the entry would start reporting.
2026-10-27 21:47:19 +00:00
dc 355c46a7b6 fix(lint): clear the sasjs lint warnings on the files 7.19 touched
Build / Build-and-ng-test (pull_request) Successful in 5m30s
Lighthouse Checks / lighthouse (pull_request) Canceled after 14m27s
Build / Build-and-test-development (pull_request) Failing after 34m21s
sasjs lint (@sasjs/cli 6.2.5) reported 24 warnings across the 11 .sas files
this release touches. None of them are in those files now:

- mpeinit and mpeterm are added to ignoredMacros in sas/.sasjslint. Every
  service is compiled with a serviceInit program (sasjs/utils/
  serviceinitsas9|viya|server.sas), and all three declare both macros in
  their own header, which is how a service body's %mpeinit()/%mpeterm()
  resolves without a declaration of its own. An explicit ignoredMacros list
  replaces the default, so webout stays listed.
- Header entries nothing in the file calls are dropped: mp_binarycopy in
  getrawdata (it arrives through mp_streamfile, which calls it - the
  compiled program is unchanged), mp_jsonout in viewdata,
  mp_assertcolvals in validatefilter.test, and mx_execute in testsetup
  (every file that calls it declares it).
- Prose carrying "error"/"warning" is reworded. Where the text is log
  output, %put WARNING: is written %put %str(WARN)ING: so the line the
  log receives is unchanged.
- The server makedata service keeps its doxygen @warning tag - the tag is
  the content - so that file carries @sasjslint {"noBannedStrings": false}.
- Two comment lines in getdata are re-indented to the file's multiple of 2.

AGENTS.md records the ignoredMacros rule and the %str(WARN)ING convention so
the next warning is not silenced by reflex. Compile passes; the 93 warnings
that remain are all in files this release does not touch.
2026-10-27 21:27:54 +00:00
dc 661ee19cfa fix(getrawdata): declare mp_ds2md so the Markdown download can run
The MARKDOWN branch of the service calls %mp_ds2md(), which ships with
@sasjs/core, but the header never listed it. The compiled service therefore
carries no definition of the macro - verified by compiling the release header
and grepping the output - so a Markdown download fails at run time. The viewer
offers "Markdown (.md)" in the download list, so the path is reachable.

Found by sasjs lint (noUndeclaredMacros) while clearing the warnings on the
files this release touches.
2026-10-27 21:27:09 +00:00
allan 619fe9f9b9 Merge pull request 'fix(derived): format catalog filtering, cut-off guard, selectbox seed' (#373) from fix/format-catalog-filter into release/7.19
Sites / deploy (push) Canceled after 0s
Build / Build-and-ng-test (pull_request) Successful in 5m34s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m48s
Build / Build-and-test-development (pull_request) Canceled after 28m13s
Reviewed-on: #373
2026-10-27 21:13:46 +00:00
dc 7830b7bcfa fix(derived): compare the outref as text, prove the file is empty
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 3m52s
Review: '%if &outref ne 0' handed %EVAL the text 'derref5 ne 0', which needs a
numeric operand - so the catalog branch failed in exactly the case it was added
for, on every caller that passes a fileref.  Quoted, the default 0 still skips
the file and a fileref creates it.

The test now proves both halves: fopen tells us the file was created, and a
read loop counted zero records tells us it is empty.  A single INPUT is no
good - on an empty file it stops the step before the symputx, which is why the
first version recorded a FAIL.

The outvars placeholder keeps 'keep=name'; the comment records why that is the
whole column set: the engine builds the dataset in exactly two places and both
project NAME, and the only projection in the SAS tree is getdata.sas.
2026-10-27 21:08:22 +00:00
dc f8f65681e1 fix(derived): keep targetds for plain datasets, test the empty file
Build / Build-and-ng-test (pull_request) Successful in 5m49s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m22s
Build / Build-and-test-development (pull_request) Failing after 34m17s
Review feedback: the first version left targetds out for every filter without
derived variables, which silently changed the plain-dataset path to whatever
mp_filterstore defaults to.  It is now passed exactly as before unless the libds
is a format catalog - the one case mp_filterstore has to rewrite itself.

The catalog test no longer writes to the statement file: it reads one record
from it instead, so -1 means the file could not be opened and 0 means
mpe_derived left it empty, which is the claim the branch makes.
2026-10-27 20:41:33 +00:00
dc 7fb981daa9 fix(derived): guard the bitemporal cut-off, coalesce the selectbox seed
mpe_derived used &dc_dttmtfmt in its where= but the guard only checked libds and
dclib, so an unset value turned the filter into 'lt tx_to' and the control-table
step failed with a syntax error a long way from the cause.  It is now part of
the guard, named in the message.

The 7.19 migration took max(selectbox_rk) into a macro variable, which is
missing on an install whose MPE_SELECTBOX is still empty - %eval(&maxrk+1) then
fails.  coalesce(max(selectbox_rk),0) makes the first row start at 1.
2026-10-27 20:41:21 +00:00
dc 469229aecb fix(derived): filtering a format catalog no longer aborts the service
Build / Build-and-ng-test (pull_request) Successful in 5m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m20s
Build / Build-and-test-development (pull_request) Failing after 34m47s
A format catalog is addressed as LIBREF.CATALOGNAME-FC.  Two places assumed a
dataset:

- mpe_derived passed the name straight to mp_derivedvars, whose existence check
  aborted with 'Target table not found: DCTEST.DCFMTS-FC' - so validatefilter,
  getrawdata, viewdata, getcolvals and stagedata all failed on a catalog.  A
  catalog has no observations, so it can have no derived variables: return an
  empty variable list and an empty statement file, and leave the view alone.
- validatefilter then passed that same -FC name as targetds to mp_filterstore.
  The engine handles a -FC libds itself (it rewrites it to a cntlout dataset),
  but a targetds it is handed is used as given, so mp_filtercheck built a step
  against a name it could not open.  targetds is now only passed when the
  derived view is actually in use.

mpe_derived.test gains a case for the catalog path: no derived variables, no
generated statements, and no abort.
2026-10-27 20:21:30 +00:00
allan 6c7c8ebf74 Merge pull request 'fix(derived): harness follow-ups from the estate test run' (#367) from fix/harness-test-followups into release/7.19
Sites / deploy (push) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Reviewed-on: #367
2026-10-27 19:46:59 +00:00
allan 468bdf5ab3 Merge pull request 'feat(editor): derived column tooltip carries the label' (#371) from fix/derived-label-tooltip into release/7.19
Sites / deploy (push) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Reviewed-on: #371
2026-10-27 19:43:17 +00:00
dc e0da9f1098 fix(derived): review feedback - cover the empty response, assert the last row
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
- mpe_assert_abort.test: the unassigned-outref case is back, so the branch
  that checks fileexist() on an outref the child never wrote to is covered by
  a test rather than by a note.  It runs: the four cases pass on the estate.
  The header now states the four cases it proves, and names the three that
  were removed and why, so nothing untested is claimed.
- mpe_execute.test: read the LAST row of outstatus with point=nobs and assert
  on its contents, which is what the macro itself reads.  The row-count
  assertion stays >0 with the reason: one HTTP attempt writes a row, and an
  aborted call leaves two on SASjs Server, so =1 cannot hold.
- Descriptions and comments reworded so no log line ends in error or warning:
  log scans look for the trailing word.
2026-10-27 19:39:37 +00:00
dc cfe6647ca8 feat(editor): show the derived column label in the header tooltip
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
The hover text on a derived column said only that the column cannot be edited,
which tells the user nothing about what it holds.  It now carries the column
label - the configured VAR_LABEL, or the generated name=expression that
mp_derivedvars writes when the administrator left the label blank - and falls
back to the plain rule when the label merely repeats the column name.

The cypress case that marks derived columns apart now also checks the tooltip
for both shapes: REGION_LABEL carries a configured label, REGION falls back to
the generated one.
2026-10-27 19:36:51 +00:00
allan cdfb3d01aa Merge pull request 'fix(ui): one error modal at a time' (#370) from fix/modal-stacking into release/7.19
Sites / deploy (push) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Reviewed-on: #370
2026-10-27 19:33:16 +00:00
allan e80ca2af4d Merge pull request 'fix(derived): NOT NULL in the model, VAR_FMT optional' (#369) from fix/derived-model-notnull into release/7.19
Sites / deploy (push) Canceled after 0s
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Reviewed-on: #369
2026-10-27 19:32:38 +00:00
dc 81ccf758e9 fix(ui): one error modal at a time
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
Submitting a rejected MPE_DERIVED row showed the SAS abort message, and then a
second modal on top of it reading

    Submit error
    SAS Service: editors/stagedata
    Submit request failed
    undefined

Two separate faults.  sasService.request already shows the abort message when
the service returns a sasjsAbort, and the adapter error when the call fails -
then it rejects, and the editor's catch showed its own modal for the same
failure.  That second modal read 'undefined' because it looked for
'adapterRespnse' (typo), a property that does not exist, so the text it built
was JSON.stringify(undefined).

- sas.service.ts marks a rejection 'errorShown' when it has already told the
  user, on both paths that display a modal.
- the editor's catch now only reports a failure when nothing was shown, and
  reads err.adapterResponse.error when it does.
- app.component.ts replaces the open abort modal instead of pushing another
  onto the array: a second emit stacked a modal over the first, so one failure
  needed two dismissals, and the lower one was usually the duplicate.
2026-10-27 19:27:00 +00:00
dc 7efbf31ea5 fix(derived): make the model enforce the required columns, and leave VAR_FMT optional
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
LIBREF, DSN, VAR_NM, VAR_TYPE, VAR_LEN, VAR_LOGIC and ACTIVE are NOT NULL in the
table definition, so the requirement is stated once, in the model, instead of
being repeated as NOTNULL rules in MPE_VALIDATIONS for each column.

VAR_FMT stays nullable: it is optional on a derived variable, and its HARDREGEX
already accepts an empty value.

The seven NOTNULL rule inserts are removed from the 7.19 migration, and the
comment on ACTIVE no longer describes a rule that is not there.
2026-10-27 19:25:27 +00:00
dc 9b3cf50b9c fix(derived): a fileref with nothing written is a FAIL, not an error
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
The guard covered an unassigned fileref, but not the case that actually
happens: mx_execute hands back a fileref that exists and was never
written, because the child aborted before producing a response. Reading
it raises 'Physical file does not exist', so the macro errored instead of
recording the FAIL the caller is asserting. Check fileexist on the
fileref's pathname as well.

mpe_execute.test asserted one status row per call. On SASjs Server the
call goes through ms_runstp and writes a row per HTTP attempt, so a
retried or aborted call leaves two. The contract is that the outcome is
recorded - assert that, keeping the state and uri assertions that read
the last row.

mpe_assert_abort.test keeps the three cases that run: expected MSG,
different MSG, no abort object. The four further cases it carried stop
the program writing results at all, and could not be isolated without a
SAS session to iterate in; the header records which went and why.
2026-10-27 19:14:03 +00:00
allan e929ca047f Merge pull request 'feat(derived): pickers for MPE_DERIVED key columns, and the blank truncation tooltip' (#366) from fix/empty-truncation-tooltip into release/7.19
Sites / deploy (push) Failing after 5m16s
Build / Build-and-ng-test (pull_request) Successful in 8m25s
Lighthouse Checks / lighthouse (pull_request) Failing after 22m35s
Build / Build-and-test-development (pull_request) Canceled after 0s
Reviewed-on: #366
2026-10-27 18:53:37 +00:00
dc d95ffdfb97 chore(derived): ACTIVE needs no HARDSELECT, and no cross-reference note
Lighthouse Checks / lighthouse (pull_request) Canceled after 0s
Build / Build-and-ng-test (pull_request) Canceled after 0s
Build / Build-and-test-development (pull_request) Canceled after 0s
The picker comes from the MPE_SELECTBOX rows - the client builds the dropdown
from that data and the SELECT rule types only set whether a value outside the
list can be typed.  NOTNULL is what makes ACTIVE mandatory, and the post edit
hook is what refuses anything other than 0 and 1, so the HARDSELECT row was
saying the same thing a third time.

Drop it in both writers, and drop the comment pointing at the migration: the
two files are read side by side anyway.
2026-10-27 18:44:41 +00:00
dc 87e794f769 feat(derived): pickers, and an ACTIVE default, for MPE_DERIVED
Lighthouse Checks / lighthouse (pull_request) Canceled after 1m16s
Build / Build-and-ng-test (pull_request) Canceled after 4m52s
Build / Build-and-test-development (pull_request) Canceled after 0s
MPE_DERIVED is maintained through the EDIT screen, but LIBREF and DSN were free
text - a typo in either silently produced a rule that never fired.

LIBREF now offers the editable libraries and DSN the tables in the LIBREF on the
same row, through the same SOFTSELECT_HOOK services the other configuration
tables use (libraries_editable, tables_editable).  VAR_NM stays typed: a derived
variable names a column the table does not have yet, so a list of existing
columns would be the wrong control.  ACTIVE becomes the fixed pair 1 and 0 from
MPE_SELECTBOX, with HARDSELECT so it cannot be typed freehand, and its NOTNULL
rule carries '1' - the value the EDIT screen pre-fills on Add Row
(getColumnDefault), because a derived variable only takes effect when active.

The rows are written by mpe_makedata.sas for a fresh install and by the v7.19
migration for an upgrade, and each names the other so the pair cannot drift
unnoticed; the ACTIVE guard itself lives once, in mpe_derived_check.sas.

The mock hook carries the ACTIVE rule, as it carries every rule
mpe_derived_check.sas enforces.
2026-10-27 18:39:15 +00:00
dc f182179403 fix(editor): a blank truncation note is not a warning
getdata returns TRUNC_MSG as a single blank when the selection was not
truncated: SAS has no zero-length character value, so mp_jsonout's trim of a
blank $200 leaves one blank and it serialises as a single space.  The editor
assigned it straight to truncationNote, and a space is truthy in JavaScript, so
the EDIT screen showed the orange truncation warning against the table name and
its tooltip contained one space - a dark bubble with nothing in it.

Trim the note before it is tested.
2026-10-27 18:36:46 +00:00
allan 803bb1ad76 Merge pull request 'fix(admin): make service-test calls observable, and fix the catalogue, getdata and makedata defects it exposed' (#363) from fix/dc-test-harness into release/7.19
Sites / deploy (push) Canceled after 0s
Build / Build-and-ng-test (pull_request) Successful in 5m10s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m14s
Build / Build-and-test-development (pull_request) Canceled after 0s
Reviewed-on: #363
2026-10-27 18:33:37 +00:00
dc 1863076bc9 fix(derived): enforce the ACTIVE picker pair in the extracted check
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m49s
Build / Build-and-test-development (pull_request) Canceled after 0s
Same rule as the 7.19 hook (PR #366): ACTIVE is NOTNULL + HARDSELECT in the
EDIT screen, so the field checks must refuse a missing value or anything other
than 0 and 1 - otherwise a direct stagedata submission stages a row the picker
would never have allowed.

The fixture gains the active column (1 by default, 2 for BADACTIVE) and the
count of reported rows goes from five to six.
2026-10-27 18:24:34 +00:00
dc 36e4e88eb1 fix: address the review findings on the harness and refresh changes
Lighthouse Checks / lighthouse (pull_request) Successful in 22m41s
Build / Build-and-ng-test (pull_request) Successful in 5m52s
Build / Build-and-test-development (pull_request) Failing after 34m22s
getcolvals - mf_nobs returns -1 when the dataset does not exist, so the guard
tested ==0 and a request that supplied no iwant at all fell through to the SQL.
It now tests <=0, which covers both an empty and an absent input.

mpe_refreshcatalogs - etlsource defaulted to a bare uid while its two siblings
use refreshcatalog:<step>:<uid>, so a load through this path could not be traced
to the step that wrote it. The default now has the same shape, and the explicit
etlsource=0 path follows it too.

mpe_execute - the status table was read without being cleared, so a child that
died before core wrote a row left the previous call's row in place and failfast
read it as completed. The table is deleted before the call.

makedata - KEEPME is compared through cats(), so a numeric column no longer
raises in upcase().
2026-10-27 18:22:18 +00:00
dc 1e224763ba fix(dc_refreshcatalog): terminate the generated statements
Build / Build-and-ng-test (pull_request) Successful in 5m40s
Build / Build-and-test-development (pull_request) Failing after 34m52s
Lighthouse Checks / lighthouse (pull_request) Failing after 22m3s
The statements written into the catalog ended without a semicolon, so the
%INCLUDE that ran them ran on into the caller: the parser finished the statement
with the text after the include and tried to include it, producing
'Cannot open %INCLUDE file PROC' immediately before the next proc sql, and
refreshlibinfo aborted with syscc non-zero.

The three refresh macros are only reached through those generated statements, so
the false 'declared but not used' warnings are switched off with a @sasjslint
block rather than by dropping the declarations.
2026-10-27 18:12:10 +00:00
dc 059cdf176a fix(getddl.test): ask for a table, not a whole library
Build / Build-and-ng-test (pull_request) Successful in 5m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m40s
Build / Build-and-test-development (pull_request) Failing after 35m8s
getddl requires a dataset - it aborts when the member cannot be found, and only
treats a format catalog specially - so a request with ds= always aborted and the
assertion read a stale webout.  Test 1 now names MPE_TABLES and checks that the
TSQL header names it, which keeps TSQL coverage on a request the service accepts.
2026-10-27 17:59:32 +00:00
dc 45dce7b11b fix(getdata.test): pin the derived filter to a libref, and spell the table as it is
Build / Build-and-ng-test (pull_request) Successful in 5m48s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m12s
Build / Build-and-test-development (pull_request) Failing after 35m8s
Test4 filtered only on the derived column, so it returned the same DSN once per
libref, including transient session librefs.  The filter now pins LIBREF as well,
built in a data step because datalines leave &dc_libref unresolved, and the
expected derived value uses MPE_LOCKANYTABLE - the name makedata registers.
2026-10-27 17:48:19 +00:00
dc ddb1671e37 test(getdata): dump the Test4 payloads under debug, and count the derived row
mp_assertcols tests variable names, so it can never find a DERIVED_NOTE row in
the cols payload - the assertion now counts rows instead.  With debug on, both
Test4 payloads are printed so a wrong payload can be read rather than guessed.
2026-10-27 17:18:40 +00:00
_ da30266278 fix(test): getdata test
Build / Build-and-ng-test (pull_request) Successful in 9m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m26s
Build / Build-and-test-development (pull_request) Failing after 34m35s
2026-10-27 17:17:53 +00:00
_ fdcd8fa4b3 fix(tests): enable closeouts logging
Build / Build-and-ng-test (pull_request) Successful in 10m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m15s
Build / Build-and-test-development (pull_request) Failing after 35m42s
2026-10-27 17:14:01 +00:00
dc 220408538b fix(mpe_execute): no apostrophe in the SAS 9 status note
Build / Build-and-ng-test (pull_request) Successful in 5m38s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m32s
Build / Build-and-test-development (pull_request) Failing after 34m45s
An apostrophe in a %put breaks macro compilation on this platform: the statement
ends early and the next macro is left unterminated, which showed up as 'Macro
keyword LET appears as text' several hundred lines further down.
2026-10-27 16:45:12 +00:00
dc 4bcee706ff fix(getcolvals): report an invalid value, not missing inputs
Build / Build-and-ng-test (pull_request) Successful in 5m37s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Failing after 34m57s
libds and col2 are only populated once validation passes, so the
"Missing inputs from iwant" abort - which tested those macro variables - fired for
any invalid payload and hid the specific reason.  It now tests whether the
request carried rows at all, leaving Invalid libds / Invalid col to report the
value.  The service still refuses the same requests; only the message changes.

The matching tests carried two faults of their own: getcolvals.test.4 sent its
libds through single quotes so the libref itself was invalid, and getdiffs /
getrawdata expected "Invalid table" for cases their own field names.
2026-10-27 16:23:31 +00:00
dc ded8bd13b3 ci: drop the HTTP_PORT explainer from the workflows
Build / Build-and-ng-test (pull_request) Successful in 5m35s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m49s
Build / Build-and-test-development (pull_request) Failing after 34m53s
The line that sets it is the change; the four lines above it only restate it.
2026-10-27 16:12:50 +00:00
dc@4gl.io f2b1428ec3 fix(mpe_execute): read an unknown state as unmeasured, not failed
Build / Build-and-ng-test (pull_request) Successful in 5m16s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m47s
Build / Build-and-test-development (pull_request) Failing after 34m58s
SAS 9 has no job state: core's SASMETA branch writes state='unknown' with
'proc stp returns no job status' on a call that succeeded.  The fail-fast
change would have turned every converted test on that platform into a failure,
so unknown is noted rather than aborted on.  A missing status table, a blank
state, canceled and failed still stop the caller.

The macro test asserted on uri, which the SAS 9 status row leaves empty; it now
asserts the platform column, which every branch populates.
2026-10-27 14:58:00 +00:00
dc@4gl.io ea300f73e7 test(macros): cover mpe_execute and mpe_assert_abort
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m24s
Build / Build-and-test-development (pull_request) Failing after 35m16s
mpe_assert_abort decides PASS/FAIL by scanning response text, and a mistake in
that scan either fails a genuine abort or passes on any sasjsAbort string in the
response; nothing reported it.  Its test builds the responses as files: the
expected MSG, a different MSG, no abort object, several MSGs where the first
belongs to the abort, an object split across lines, an abort past 32767
characters, and an unassigned fileref.

mpe_execute is covered against a child that aborts for a known reason: one
status row per call, the state named and not completed, the uri recorded, and
the child log kept only when mdebug asks for it.
2026-10-27 14:49:59 +00:00
dc@4gl.io 359b570b85 fix(getdata): clear the globals it declares before use
loadtype, var_txfrom, var_txto, var_processed, filter_text, pk, coltype, sortpk,
var_busfrom, var_busto, rk_underlying, buskey and pre_edit_hook are declared
%global but were never initialised, so in a reused session a code path that
skipped an assignment applied the previous request's value - a stale
pre_edit_hook or buskey against the wrong table.
2026-10-27 14:49:59 +00:00
dc@4gl.io d626cb8f2d fix(makedata): read KEEPME from every input row, and keep it out of the Viya seed
The KEEPME probe did 'set work.fromjs' inside the varnum guard and then stopped,
so only the first observation was inspected: a submission that set KEEPME on a
later row still self-destructed.  It now reads to end of file.

makeDataNextViya.json ships KEEPME=Y and is the config that seeds a real Viya
environment, so the default posture there was 'the seeding program stays on the
server'.  KEEPME stays in makeDataSas719.json, which exists for the test
harness, and is removed from the environment seed.
2026-10-27 14:49:59 +00:00
dc@4gl.io 0a52d20c5f fix(mpe_assert_abort): take the abort's own MSG, tolerate a missing response
Three defects in the scan:

- 's/.*"MSG" *: *"([^"]*)".*/$1/' is greedy, so a response carrying more
  than one MSG compared the last one rather than the abort's.  The pattern is
  now matched with prxmatch and the capture read with prxposn, which returns
  the first match at or after the sasjsAbort marker.
- the whole response was concatenated into $32767, so a longer response
  truncated silently and an abort near the tail was missed.  The file is now
  scanned a line at a time and the scan stops at the first MSG.
- 'infile &outref' had no fileref check, so a child that died before writing a
  response raised an unassigned-fileref error instead of recording a FAIL.
2026-10-27 14:49:55 +00:00
dc@4gl.io a03638667f fix(mpe_execute): fail fast when the child left no status
failfast fired only on state=canceled or state=failed, and read &outstatus
unguarded.  A child that never reached the runner leaves no status table, and
a status row with a blank state left both macro variables blank - either way the
test carried on against whatever the previous call left in outlib, which is the
inference this wrapper exists to remove.

The status table is now read only if it exists, a missing table is named as
such, and failfast aborts unless the state is completed.  A status row that is
absent and one that is blank both fail.
2026-10-27 14:49:55 +00:00
dc@4gl.io 638c34a070 Merge release/7.19 into the test harness
The release branch gained 36e1689, which fixed the same four security tests
(getcols, getcolvals, getrawdata, validatefilter) by introducing
dc_assert_abort.  This branch had already fixed them with mpe_assert_abort and
mpe_execute, and mpe_assert_abort is the wider of the two: it also checks the
expected MSG, and the calls pass outstatus/failfast so the child cannot be
inferred from a stale outlib.  Kept the harness versions and dropped
dc_assert_abort.sas, which nothing references after the merge.
2026-10-27 14:46:04 +00:00
allan 9aef2f4f03 Merge pull request 'feat(editor): mark derived variables as computed in the EDIT grid' (#365) from feat/derived-var-styling into fix/dc-test-harness
Build / Build-and-ng-test (pull_request) Successful in 5m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m21s
Build / Build-and-test-development (pull_request) Failing after 35m38s
Reviewed-on: #365
2026-10-27 14:42:49 +00:00
dc@4gl.io 9aea59dfef ci: start the SASjs Server with HTTP_PORT=5000
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m4s
Build / Build-and-test-development (pull_request) Failing after 34m12s
SASjs Server 3.x deprecated PORT and PROTOCOL and refuses to start when an
.env names neither HTTP_PORT nor HTTPS_PORT, exiting with

    - no listener is enabled
     - set HTTP_PORT and/or HTTPS_PORT (either may be used alone)

The three workflows downloaded releases/latest and wrote an .env without a
listener, so api-linux never bound :5000 and the 'Setup and start SASjs
server' step failed after its 120s wait (build runs for #363 and #365, both
failed there). Add HTTP_PORT=5000 to build.yaml, release.yaml and
lighthouse.yaml, and document it in the local-dev .env in CONTRIBUTING.md,
where the default-port claim is no longer true.
2026-10-27 14:34:13 +00:00
dc 6513d09f05 feat(editor): mark derived variables as computed in the EDIT grid
Derived variables are read-only, but they were rendered exactly like any other
read-only column: dimmed via readonlyCell, with no indication that the column is
computed at read time rather than locked by a rule or by column level security.
The grid could not tell the difference either - getdata holds a derived column
read-only with a READONLY DQ rule, which is also a rule type a table can be
configured with.

getdata now names the derived columns in sasparams.DERIVEDVARS (space separated,
upper case, from MPE_DERIVED's outvars). The EDIT screen holds that list, and
marks those columns with their own classes instead of the read-only dimming:
a tinted header with an 'fx' marker and a tooltip, tinted italic cells, and a
left edge on the first derived column so the computed block reads as a group.
Blue is the info family, leaving the primary key green and the warning ochre to
their existing meanings. Light and dark values are both set.

The SASjs mock getdata.js returns the same field, so the Cypress suite exercises
the styling; the existing derived-variables spec asserted readonlyCell on the
derived header, which is now the fallback for a plain read-only column, so that
assertion moves to dc-derived-header and a physical column stays the control.

Lint: prettier --check clean on the touched client files; sasjs lint reports no
new warnings for getdata.sas.
2026-10-27 14:34:13 +00:00
dc@4gl.io 356308e13f chore(deps): sync the sas lockfile to @sasjs/core 6.1.0
Lighthouse Checks / lighthouse (pull_request) Failing after 3m0s
Build / Build-and-ng-test (pull_request) Successful in 5m47s
Build / Build-and-test-development (pull_request) Failing after 6m32s
The harness pins @sasjs/core exactly (6.1.0) so the tests can read the
outstatus table, but the lockfile still resolved 6.0.0. 'npm ci' refuses to
install when an exact pin and the lockfile disagree, which failed the mocked
deploy in both build and lighthouse ("lock file's @sasjs/core@6.0.0 does not
satisfy @sasjs/core@6.1.0"). Regenerated with 'npm install
--package-lock-only': the only change is the core entry.
2026-10-27 14:32:20 +00:00
dc 46bacdd6d9 fix(refresh): name each catalogue load uniquely in the audit trail
Lighthouse Checks / lighthouse (pull_request) Failing after 2m58s
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Build / Build-and-test-development (pull_request) Failing after 6m4s
MPE_DATALOADS is keyed on (processed_dttm, libref, dsn, etlsource), and etlsource
was the calling macro name, so a second catalogue load of the same table in the
same second was refused as a duplicate.  The three refresh macros now take an
etlsource parameter, defaulting to refreshcatalog:<step>:%mf_uid(), which records
which step loaded what and keeps the audit row unique.

dc_refreshcatalog also echoes the generated statements when debug is on, since a
failure inside one of them otherwise names no libref.
2026-10-27 14:22:20 +00:00
dc 582523dc87 feat(dc_getlibs): dump the library list when debug is on
A refresh that catalogues the wrong libraries is hard to read from the log: the
list is built here, then filtered and reworked by its callers.  With
sasjs_mdebug set, print the result so the library list can be checked at source.
2026-10-27 14:22:20 +00:00
dc 105052b948 test: prove staged rejections from the response, and check the field rules at macro level
The MPE_DERIVED post edit hook aborts with mp_abort, so the webout carries a
sasjsAbort object: stagedata.test.3 and .4 now read that through
mpe_assert_abort instead of inferring the outcome from MPE_LOADS.

The field level rules move into mpe_derived_check so they can be tested
directly.  A service cannot exercise them all - VAR_LABEL is varchar(256) and a
staging dataset declares the same length, so a longer label is truncated before
any check sees it - and the macro test runs in seconds rather than minutes.
2026-10-27 14:22:16 +00:00
dc d0bc5ae297 refactor: rename dc_execute to mpe_execute
Lighthouse Checks / lighthouse (pull_request) Failing after 2m53s
Build / Build-and-ng-test (pull_request) Successful in 4m44s
Build / Build-and-test-development (pull_request) Failing after 5m42s
The wrapper is DC specific and sits alongside mpe_assert_abort, so the mpe_
prefix marks which layer it belongs to.  File, macro name, %mend and all seven
callers updated; no dc_execute reference remains in the tree.
2026-10-27 11:18:26 +00:00
dc 31aa859153 revert(stagedata.test.4): back to the MPE_LOADS evidence for now
Lighthouse Checks / lighthouse (pull_request) Failing after 3m5s
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Build / Build-and-test-development (pull_request) Failing after 5m45s
Reading the sasjsAbort object instead did not work for this test: the derived post
edit hook aborts with `abort cancel FILE` via %mp_include, and with the
response-based version the test stopped before reporting any assertion, where the
MPE_LOADS version reports ten and fails five.

Which evidence is right depends on where that abort is raised - the test's own
session or the child's - and the log does not distinguish the two here.  Reverting
until that is settled, so the branch is not carrying a change that reduces
coverage.
2026-10-27 11:00:55 +00:00
dc a141e38da4 refactor(stagedata.test.4): call the service through dc_execute
Lighthouse Checks / lighthouse (pull_request) Failing after 2m54s
Build / Build-and-ng-test (pull_request) Successful in 4m50s
Build / Build-and-test-development (pull_request) Failing after 6m5s
Same inputs and outputs, with a status row and no fail-fast, so the echoed child
log carries the CHILD: prefix - which is what distinguishes an abort raised in
the child from one raised in the test's own session.
2026-10-27 10:55:16 +00:00
dc e3ec1da55c refactor(stagedata.test.4): prove the rejections from the response, not MPE_LOADS
Lighthouse Checks / lighthouse (pull_request) Failing after 2m54s
Build / Build-and-ng-test (pull_request) Successful in 4m50s
Build / Build-and-test-development (pull_request) Failing after 5m45s
The five rejected-submission cases queried MPE_LOADS for a row that did not reach
SUCCESS.  The post edit hook aborts with mp_abort, so the webout carries a
sasjsAbort object: mpe_assert_abort reads that directly, which is the actual
evidence that the submission was refused.
2026-10-27 10:39:24 +00:00
dc 9c294c0ab5 fix(mpe_assert_abort): drop the unused line variable
Lighthouse Checks / lighthouse (pull_request) Failing after 3m1s
Build / Build-and-ng-test (pull_request) Successful in 5m11s
Build / Build-and-test-development (pull_request) Failing after 5m49s
It was declared but never assigned, and this session treats an uninitialized
variable as an error that stops the step before the assertion runs - so the
macro reported FAIL for a response that did carry the abort object.
2026-10-27 09:38:36 +00:00
dc fed43cb07e fix(dc_execute): use = comparisons, not IN, in the fail-fast guard
Lighthouse Checks / lighthouse (pull_request) Failing after 2m59s
Build / Build-and-ng-test (pull_request) Successful in 5m11s
Build / Build-and-test-development (pull_request) Failing after 6m13s
%if &failfast=1 and "&state" in ("canceled" "failed") fails to evaluate: %EVAL
reports it needs a numeric operand and stops the macro, which aborted every test
that reached the guard even though the child had completed or aborted cleanly.
Two plain comparisons do the same job and evaluate reliably.
2026-10-27 09:32:54 +00:00
dc a20a5a627c refactor(tests): mpe_assert_abort reads the sasjsAbort object from the response
Lighthouse Checks / lighthouse (pull_request) Failing after 3m1s
Build / Build-and-ng-test (pull_request) Successful in 4m53s
Build / Build-and-test-development (pull_request) Failing after 6m4s
dc_assert_abort inferred the outcome from the status row.  The assertion should
prove the service rejected its input, so it now reads the child's response and
requires a sasjsAbort object, and compares that object's MSG value with the
message the service is expected to return:

  %mpe_assert_abort(desc=An invalid libds aborts the service,
    outref=web1, msg=Invalid libds)

Renamed with the mpe_ prefix to match the other macro-level helpers.  getdata
Test 4 asserted completion with the abort macro, which was the wrong tool; it
now checks the status row for state=completed directly.
2026-10-27 09:26:34 +00:00
dc f5aade5976 fix(dc_getlibs): exclude the DC libref from the dictionary scan
Lighthouse Checks / lighthouse (pull_request) Failing after 2m57s
Build / Build-and-ng-test (pull_request) Successful in 4m49s
Build / Build-and-test-development (pull_request) Failing after 5m44s
dictionary.libnames lists the DC libref as well, so it was seeded into the
result by the SELECT and then added a second time by the explicit INSERT.  The
duplicate row then collides with pk_mpe_datacatalog_libs when the refresh closes
the bitemporal record:

  ERROR: Duplicate values not allowed on index pk_mpe_datacatalog_libs

The DC libref is now excluded from the scan, so it arrives once, from the INSERT
that carries its library name and engine.
2026-10-27 09:04:16 +00:00
dc 867faf8dd8 refactor(tests): read the outcome from core's outstatus, drop the local mx_execute
Lighthouse Checks / lighthouse (pull_request) Failing after 3m0s
Build / Build-and-ng-test (pull_request) Successful in 4m58s
Build / Build-and-test-development (pull_request) Failing after 5m46s
@sasjs/core 6.1.0 ships outlogds and outstatus, so the temporary copy of
mx_execute is gone and the abort assertions no longer need a platform branch:

- dc_assert_abort reads the status dataset instead of work.results on Viya and
  the response text elsewhere - one table, one code path;
- the abort cases call dc_execute with outstatus and failfast=0, so a cancelled
  child is reported rather than aborting the test;
- getdata Test 4 loses its %mf_getplatform() gate for the same reason, and reads
  the outlib only when the status says the child completed;
- dc_execute passes viyaresult through, which the abort cases ask for.
2026-10-27 01:19:45 +00:00
dc 609f2a743c test(hooks): seed the baseline from an npm script, not from testsetup
Lighthouse Checks / lighthouse (pull_request) Failing after 2m57s
Build / Build-and-ng-test (pull_request) Successful in 4m51s
Build / Build-and-test-development (pull_request) Failing after 5m42s
A full makedata on every sasjs test run is expensive, and it made the suite
depend on state the tests themselves should not be creating.  Move it to where
DC already does this: the npm scripts that send deploy/makeData*.json to
services/admin/makedata.

  npm run sas719setup   deploy, then seed once
  npm run sas719test    run the suite as often as wanted

KEEPME in the payload keeps makedata on the server, so a reseed does not need a
redeploy first.  Viya's makedata gains the same switch, so nextviyamakedata
behaves the same way.

Tests must now leave the estate as they found it - that is the follow-up, and it
is what makes re-running a single test possible.
2026-10-26 23:51:59 +00:00
dc 16e9b31e65 test(harness): a measurable wrapper around mx_execute for service tests
Build / Build-and-ng-test (pull_request) Successful in 4m50s
Build / Build-and-test-development (pull_request) Failing after 5m48s
Lighthouse Checks / lighthouse (pull_request) Failing after 2m53s
Tests inferred whether a service call worked by reading an outlib that a failed
call never touched, so assertions ran against the previous call's tables.  This
adds dc_execute, which wraps mx_execute and makes each call observable:

 - failfast: abort as soon as the child did not complete, with its message, so
   the first failure is the real one
 - a status row per call (outstatus) so a test can assert the outcome
 - the child's log behind the harness debug flag, quiet otherwise

testsetup reseeds the data baseline before the test library is built, makedata
honours a keepme switch and getdata initialises the variables it later tests
with %length, plus desc= values reworded where a comma or apostrophe unbalanced
the parameter.

sasjs/macros/mx_execute.sas is a TEMPORARY copy from sasjs/core#476, which adds
outlogds/outstatus and stops leaving work.results in the caller WORK.  Delete it
and bump the dependency once that PR is released.
2026-10-26 23:29:46 +00:00
dc 8096772119 test(security): assert aborts from the webout where there is no job state
The four security test programs proved that a bad input aborted the service by
reading work.results, the job table %mv_jobflow writes in the Viya branch of
%mx_execute. The SASjs Server and SAS 9 branches call %ms_testservice instead,
so the table never exists, the data step fails with "File WORK.RESULTS.DATA
does not exist." and the assertion reported (0=1) - a failure that says
nothing about whether the service validated its input.

The platform difference is now in one macro, dc_assert_abort: on Viya it reads
the job state as before, elsewhere it looks for the sasjsAbort block that
mp_abort leaves in the webout %mx_execute returns through outref. The call to
the service stays outside the platform check, so the payloads are submitted on
every platform and the assertion is real rather than a skip.

Verified on SASjs Server (sas.4gl.io, target sas719, appLoc /Public/app/dc719):
the seven abort assertions PASS, i.e. the services do abort on the macro, SQL
injection and path traversal payloads. Negative control: the same program with
a valid libds reports FAIL (0=1), so the assertion can still fail.

sasjs lint: exit 0, no warnings in the five files.
2026-10-26 23:29:33 +00:00
dc 36e168971c test(security): assert aborts from the webout where there is no job state
Sites / deploy (push) Successful in 3m43s
Build / Build-and-ng-test (pull_request) Successful in 5m2s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m48s
Build / Build-and-test-development (pull_request) Successful in 33m28s
The four security test programs proved that a bad input aborted the service by
reading work.results, the job table %mv_jobflow writes in the Viya branch of
%mx_execute. The SASjs Server and SAS 9 branches call %ms_testservice instead,
so the table never exists, the data step fails with "File WORK.RESULTS.DATA
does not exist." and the assertion reported (0=1) - a failure that says
nothing about whether the service validated its input.

The platform difference is now in one macro, dc_assert_abort: on Viya it reads
the job state as before, elsewhere it looks for the sasjsAbort block that
mp_abort leaves in the webout %mx_execute returns through outref. The call to
the service stays outside the platform check, so the payloads are submitted on
every platform and the assertion is real rather than a skip.

Verified on SASjs Server (sas.4gl.io, target sas719, appLoc /Public/app/dc719):
the seven abort assertions PASS, i.e. the services do abort on the macro, SQL
injection and path traversal payloads. Negative control: the same program with
a valid libds reports FAIL (0=1), so the assertion can still fail.

sasjs lint: exit 0, no warnings in the five files.
2026-10-26 20:17:50 +00:00
dc 0d58be975d fix(ci): restore the gitleaks ignore entries for the mock licence pair
Sites / deploy (push) Successful in 3m48s
Build / Build-and-ng-test (pull_request) Successful in 5m23s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m31s
Build / Build-and-test-development (pull_request) Successful in 32m19s
116c37b removed them on the grounds that a three-segment fingerprint matches
nothing. That is wrong for the mode this repo scans in: with `--no-git`, gitleaks
reports a finding as `file:rule:***` - the line number is not part of the
fingerprint - so the entries were matching, and the pipeline failed on the next
push with two findings in sas/mocks/mock-licence.json.

Measured on a clean checkout of this head, with the pinned tool
(@nogoo9/gitleaks 8.30.1-post.2) and the command the workflow runs:

  with .gitleaksignore     6.10 MB scanned, no leaks found
  without it               6.10 MB scanned, leaks found: 2

The 6.10 MB scan is the same figure the CI log reports, which is what makes this
comparable; my earlier check was run in a tree that still had node_modules in it,
scanned 1.05 GB, and its verdict meant nothing.

The entries stay, with the comment explaining that the pair is RSA key material
for the browser mock rather than a credential.
2026-10-26 10:34:36 +00:00
dc fe2388718a chore(deps): handsontable 18.1.2, so a wrapped entitlement key cannot lock the grid
Build / Build-and-ng-test (pull_request) Failing after 23s
Build / Build-and-test-development (pull_request) Skipped
Sites / deploy (push) Successful in 3m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m38s
18.1.2 carries one fix (2026-10-07): an entitlement licence key whose bracketed
block is broken across lines - by an email client, typically - read as invalid and
locked the grid.

That is this app's key path. The DC licence payload carries `hot_license_key`, and
licence.service puts it on `hotTable.licenseKey` for every grid - editor, viewer,
viewboxes, stage, multi-dataset, xlmap - so a key pasted with line breaks would
lock the editor rather than open it, on 18.1.1.

Both packages move together. The licence-checker exclusions pick up the new
version too: handsontable and @handsontable/angular-wrapper declare `SEE LICENSE
IN LICENSE.txt`, which the checker reports as a custom licence, so every pinned
version is listed in excludePackages - 18.1.1 was already there, 18.1.2 is added
beside it.

Checked: client 603/603, production build green, npm audit --omit=dev clean,
licence checker "All packages are licensed properly".
2026-10-26 10:22:59 +00:00
dc 05b91cb43e refactor(getdata): scope the payload row cap to the SET, and assert the column list
Build / Build-and-ng-test (pull_request) Failing after 21s
Build / Build-and-test-development (pull_request) Skipped
Sites / deploy (push) Successful in 3m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m53s
The review read the cap as a session option that is never restored, so every later
data step - including the derived-column merge into work.cols1 - would be cut to
&maxrows observations, and a table wide enough to hit the cell limit would lose
columns rather than rows.

On this head the reset is there, two lines after the data step (`options obs=max;`
at what was line 360), so the leak described is not live. It is worth removing the
dependency on that line though: the cap is now a data set option on the SET that
builds the payload, so there is no session option to leak and no later step can be
cut by it, whether or not a reset is remembered.

The existing cell-limit test asserted the row count only - 199 rows for a
1004-column table - which would have passed with 805 columns missing. It now also
compares the COLS payload against dictionary.columns, so the metadata being whole
is tested rather than assumed.

The other obs pair in this program (`options obs=10000` around the filtered
selection, restored at line 290) is deliberately left alone: it bounds the input
rows that the WHERE clause reads, which a data set option on the SET cannot do.
2026-10-26 10:09:25 +00:00
dc 072a133702 fix(client): open the SAS log page with noopener
window.open(url, '_blank') hands the opened page a window.opener reference. The
URL is built from config.serverUrl, which on Viya is a different origin from the
app, so the SAS log page could navigate this tab - a log page is exactly the sort
of thing that gets rendered from backend content.

'noopener' in the window features drops the reference in every browser that
supports it. The two existing specs asserted the call's two arguments, so they
now assert the third; the client suite is 603/603 with handsontable 18.1.1 from
the lockfile.
2026-10-26 10:09:21 +00:00
dc 116c37b379 chore: drop the gitleaks ignore entries that matched nothing
Build / Build-and-ng-test (pull_request) Failing after 16s
Build / Build-and-test-development (pull_request) Skipped
Sites / deploy (push) Successful in 3m37s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m32s
The three-segment entries in .gitleaksignore were meant to cover the mock licence
pair, but a fingerprint is commit:file:rule:line, so file:rule:*** never matched
anything - and the file does not need covering anyway:

  gitleaks detect --no-git --source . --redact   (the CI command, on this tree)
    no leaks found

  gitleaks protect --staged --redact             (after touching mock-licence.json)
    no leaks found

A full-history detect over 1088 commits reports 58 findings, none of them in
mock-licence.json - they are an old viewdata.js commit, .npmrc and
mock-storage/licence.json, all outside the tree CI scans. Removing the file is
more honest than keeping an exception that guards nothing; if a future edit to
the pair does fire, the commit fails and the real fingerprint can be added then.
2026-10-26 09:53:47 +00:00
dc 1fb4818d21 fix(client): refuse a truncated table in the multi-table upload
getdata now serves a selection over DC_MAXOBS_WEBEDIT / DC_MAXCELLS_WEBEDIT
truncated rather than aborting, which the EDIT screen reports above the grid. The
multi-table upload is the other caller: it fetches each table to compare the whole
of it against the uploaded workbook, so a partial read would compute the changes
against the wrong starting state and submit differences nobody asked for.

It now refuses such a table with a message naming the limit, rather than carrying
on with the rows it received. The EDIT screen already reads the same
sasparams.TRUNCATED flag; sas.service only transports the response.
2026-10-26 09:53:47 +00:00
dc 78e88a4112 feat(derived): take any text in VAR_LABEL, but not a line break
VAR_LABEL was the one free-text column with no rule at all, in the hook or in the
MPE_VALIDATIONS seed. The suggestion in review was an allowlist, but a label has
no reason to exclude any character - quotes are doubled by %mp_derivedvars before
the attrib statement is built, and the value never reaches a macro context - so
the rule is a denylist of what cannot be a single-line column label:

  * a control character, which covers the line breaks and tabs that would carry
    through into the generated DATA step and render as nothing in a header
  * a label over 256 characters, which the engine truncates silently on a quote
    boundary, so the configured value and the applied one differ with nothing
    saying so

Everything else passes: any script, and the semicolon, ampersand, percent and
comment markers that VAR_FMT and VAR_LOGIC refuse. Implemented in the hook
(anycntrl, klength), as a HARDREGEX in all three seed writers (migration,
mpe_makedata.sas, the mock's makedata.js) so the grid refuses it before submit,
and in the mock hook for the deployed mock.

SAS: new stagedata.test.4 cases 8-10 - a label with an embedded LF is rejected, a
label of free text is accepted, and 257 characters is rejected.

Verified against the deployed mock: the tab and 257-character cases abort with the
right message, free text and UTF-8 pass, and a 256-character label passes. The
newline case cannot be driven through `sasjs request` - the mock server splits a
jsdata row at an embedded newline, so the row arrives short - hence the SAS test.
2026-10-26 09:53:37 +00:00
allan bca1b9363f Merge pull request 'fix(derived): hold derived columns read-only regardless of CLS, and register MPE_DERIVED in the mock' (#360) from fix/derived-readonly-and-mock-config into release/7.19
Sites / deploy (push) Successful in 3m56s
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m49s
Build / Build-and-test-development (pull_request) Successful in 33m35s
Reviewed-on: #360
2026-10-26 08:37:45 +00:00
dc 1b13120839 Merge release/7.19 into fix/derived-readonly-and-mock-config
Build / Build-and-ng-test (pull_request) Successful in 5m40s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m7s
Build / Build-and-test-development (pull_request) Successful in 33m25s
#359 has landed, so the CLI bump this branch was waiting on is now in the base
and the merge brings it in. One conflict, in
client/cypress/support/commands.ts: both sides reworked loginAndUpdateValidKey.

The base version decides from the body captured before login, which is where
the original bug was - on an estate that shows a login form that capture has no
nav tree, so the command early-returned and never applied a key, and the upload
specs then found no file input. This branch re-reads the loaded page and treats
the licence banner as the signal. Kept this side; prettier re-indented the
result. Every other file merged automatically, and the hookErrmsg veto in
stagedata.js and loadfile.js survives the merge.
2026-10-26 08:34:32 +00:00
dc 6cad23fce9 fix(mocks): scope the derived hook's graph to the submission
Build / Build-and-ng-test (pull_request) Successful in 4m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m50s
Build / Build-and-test-development (pull_request) Successful in 31m26s
Two divergences from the server hook, both of which reject a valid submission:

- VAR_DEP_UNION joins on libref, dsn and name, so a derived variable called
  STATE on one table does not make STATE a derived name on another. The mock
  kept a flat set of names, so a physical column named STATE was reported as
  an undeclared reference whenever any other table derived a variable of that
  name.

- The control-table arm filters staging_ds for the tables being submitted, so
  another table's configuration cannot block this one. The mock read the whole
  MPE_DERIVED table, so a cycle declared on an unrelated table blocked every
  submission.

Reproduced both against the previous head - a physical STATE reference and an
unrelated CYC_A/CYC_B cycle were each rejected - and both pass after, while the
cycle, undeclared-reference and stale-dependency cases on the submitted table
still fire.
2026-10-25 23:44:17 +00:00
dc 5fc0ff1ee3 docs(derived): record why the read-only rules are safe to append and the union unguarded
Build / Build-and-ng-test (pull_request) Successful in 4m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m48s
Build / Build-and-test-development (pull_request) Successful in 31m9s
Both come up in review every time these lines are read: dqrules is the
request-local array the filter/map builds, and work.derived_vars is written by
%mpe_derived before it can return, empty when the table has no derived
variables. Said where the code is, rather than in a review reply.
2026-10-25 23:04:20 +00:00
dc 5b70c000d7 test(derived): assert the read-only marker instead of inferring it
The case rested on an editor not appearing after a fixed wait, which passes for
any reason the editor did not open. The editor marks a read-only column with
readonlyCell on the header and on its cells, and STATE in the same grid is the
control, so the state is asserted directly and the sleep goes.

Mutating the mock to drop the READONLY rule fails the case on exactly that
assertion (expected '<th.darkTH>' to have class 'readonlyCell'); restoring it
passes 5/5 in about 50s.
2026-10-25 23:04:19 +00:00
dc d7cadc0b7b refactor(derived): name the invalid-character test, and prefix the cycle message
Build / Build-and-ng-test (pull_request) Successful in 4m56s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m56s
Build / Build-and-test-development (pull_request) Successful in 31m19s
has() returned true for a character outside the allowed set, which every call
site read as the opposite; it is hasInvalidChar now.

The cycle rejection was the one message without the MPE_DERIVED: prefix. The
SAS hook produced the same text, so both are prefixed rather than letting the
mock drift away from the message a real deployment shows.
2026-10-25 22:19:06 +00:00
dc 9914790777 fix(derived): close four gaps in the MPE_DERIVED hook
Build / Build-and-ng-test (pull_request) Successful in 5m35s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m54s
Build / Build-and-test-development (pull_request) Successful in 31m45s
loadfile names the submitted rows 'rows' and never defined jsDataRows, so
eval'd there the hook threw a ReferenceError - which the caller logged and
ignored. The rows are bound under the name the hook reads, and a hook that
throws now rejects the submission instead of being swallowed: a hook whose job
is to reject cannot fail open.

The hook's current-row test also required a TX_TO in the future, while the
read-time engine (mpeDerived) treats a missing or zero TX_TO as current, so a
dependency on an open-ended row validated here and broke at read time. Both the
graph and the inactive set, and the RLS guard, now use the engine's predicate.

The VAR_FMT message named '//*' where the check is for /* and */; it now names
the markers it rejects, in the hook and in its SAS counterpart.
2026-10-25 21:39:19 +00:00
dc e0ee99c178 test(derived): wait for the editor before asserting its absence
should('not.exist') passes the moment the element is missing, so a timeout on
it does not widen the window: an editor that opens after the assertion has
already passed goes unnoticed. The wait gives it that window, which is what the
case needs to rule the cell's editability out.
2026-10-25 21:39:19 +00:00
dc 5d183d1350 feat(mocks): validate a submitted MPE_DERIVED row like the hook does
Build / Build-and-ng-test (pull_request) Successful in 5m33s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m53s
Build / Build-and-test-development (pull_request) Successful in 33m15s
The MPE_TABLES row registered services/hooks/mpe_derived_postedit, but no
mock counterpart existed, so a submission to the now-visible control table skipped
the checks the server hook runs and only failed later, when the EDIT screen
tried to build the view.

The hook mirrors mpe_derived_postedit.sas in its order: normalise the incoming
rows, reject a duplicate name and a bad field, then check the dependency graph
the resulting configuration would have - an inactive dependency, a self
reference, a reference the row does not declare, a declared input the
expression never uses, a name an active RLS rule uses, and a cycle, whose path
is reported.  The collision with a physical column stays with the read-time
engine, as on the server.

A hook rejects a submission by setting hookErrmsg, which stagedata/loadfile
turn into a sasjsAbort before anything is staged; that is the mock's equivalent
of the hook's %mp_abort.
2026-10-25 20:59:15 +00:00
dc fa7a468fd3 test(derived): state the negative assertion's wait explicitly
Build / Build-and-ng-test (pull_request) Successful in 5m34s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m14s
Build / Build-and-test-development (pull_request) Successful in 33m49s
The window a 'not to exist' assertion covers is its timeout, so it is set
here rather than inherited from the config default.
2026-10-25 20:50:38 +00:00
dc d14395a0f8 test(derived): enter edit mode, and add the positive control
Build / Build-and-ng-test (pull_request) Successful in 4m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m48s
Build / Build-and-test-development (pull_request) Failing after 33m17s
The screen opens read-only until the edit button is pressed, so the case
asserted nothing about the column: no cell opened an editor. It now enters edit
mode first, asserts the editor's absence directly rather than typing at
whatever happens to be focused, and a sibling case proves a physical column in
the same grid does open one - so the silence is about the column, not the
screen.

Mutating the mock to drop the READONLY rule fails the derived case and passes
the physical one; restoring it passes both (5/5, ~48s).
2026-10-25 20:30:09 +00:00
dc f411b7d269 fix(mocks): copy the physical column list before deriving
physicalColumns held the same array the derive helper reads, so every later
use in the file - cols, the search, the row loop, the empty-row fallback and
vars - depended on that helper returning a new list rather than extending the
one it was given. Taking a copy makes the invariant local to this file.
2026-10-25 20:30:09 +00:00
dc be8f445ae1 fix(cypress): apply the licence key when the estate has none
Build / Build-and-ng-test (pull_request) Successful in 5m31s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m36s
Build / Build-and-test-development (pull_request) Successful in 32m51s
loginAndUpdateValidKey decided whether a key was already working by looking
for the nav tree, and looked for it in the body captured before login.  A free
tier estate renders the tree as well, so on an unlicensed estate the command
took the 'already licensed' branch every time and never applied a key.  Every
upload spec then lost its feature set: onShowUploadModal shows the locked
feature dialog instead of the panel, so input#file-upload never renders.

The loaded page is read again after login, the licence banner decides whether
a key is needed, and an estate with no key is left untouched unless the caller
asked for one - the free tier specs are written against that state.

Measured on an unlicensed mock estate: excel.cy.ts 24 failing in 14m 1s before,
24 passing in 5m 44s after; csv.cy.ts 1 failing before, 1 passing after.
2026-10-25 19:31:14 +00:00
dc 293022d46b fix(mocks): search the physical columns only in the viewer
Build / Build-and-ng-test (pull_request) Successful in 5m55s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m56s
Build / Build-and-test-development (pull_request) Failing after 36m0s
viewdata.sas drops the derived columns in the vwsearch data step that
mp_searchdata then reads, so a search matches on the columns the grid shows.
The mock handed the full column list, so a search could match a row on a
derived column that is never displayed.
2026-10-25 15:32:57 +00:00
dc 60ec470404 fix(mocks): derive before filtering in the viewer, and drop the columns
Build / Build-and-ng-test (pull_request) Successful in 5m11s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m0s
Build / Build-and-test-development (pull_request) Failing after 36m4s
viewdata.sas builds the derived view and filters against it, so a filter stored
on a derived column resolves in the VIEW screen; the mock served the physical
table only, so the same filter matched nothing and the viewer showed its
no-data row.  The mock now derives ahead of the filter and reports the physical
columns only, as viewdata.sas drops them from the output.
2026-10-25 15:20:15 +00:00
dc ee3c8787ef fix(mocks): register MPE_DERIVED and seed its field rules
Build / Build-and-ng-test (pull_request) Successful in 5m4s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m25s
Build / Build-and-test-development (pull_request) Failing after 36m2s
The mock seeded MPE_DERIVED's rows and schema but no MPE_TABLES registration,
and the table tree lists registered tables only, so the hosted mock showed no
MPE_DERIVED at all - the derived variables could be seen on a table but not
configured.  The field rules and the VAR_TYPE dropdown were missing for the
same reason.

Mirrors mpe_makedata.sas and the v7.19 migration: the MPE_TABLES row
(TXTEMPORAL, buskey LIBREF DSN VAR_NM, mpe_derived_postedit hook), the 19
MPE_VALIDATIONS rows and the two VAR_TYPE selectbox values.
2026-10-25 15:17:43 +00:00
dc 5f443b0b16 fix(derived): hold a derived column read-only whatever the table's security
COLS.CLS_RULE is the only thing that marks a column read-only in the grid,
and the client applies it only when CLS_FLAG is set - which column level
security drives.  A table with no CLS rules therefore rendered its derived
columns as ordinary editable cells, although the values are computed at read
time and dropped from the submission.

getdata now unions a READONLY dq rule per derived variable, which the client
honours unconditionally, and the mock emits the same rule.  The SAS test
asserts the rule; the cypress spec double-clicks a derived cell and asserts the
value is unchanged.
2026-10-25 15:17:40 +00:00
allan 3e8f200a1a Merge pull request 'chore(deps): @sasjs/cli 6.2.0, so the browser mock serves file downloads' (#359) from chore/cli-6.2-mock-downloads into release/7.19
Sites / deploy (push) Successful in 4m4s
Build / Build-and-ng-test (pull_request) Successful in 5m38s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m3s
Build / Build-and-test-development (pull_request) Successful in 37m27s
Reviewed-on: #359
2026-10-25 14:26:18 +00:00
dc 03b67c44c7 chore(deps): @sasjs/cli 6.2.0, so the browser mock serves file downloads
Build / Build-and-ng-test (pull_request) Successful in 5m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m18s
Build / Build-and-test-development (pull_request) Failing after 35m40s
The browser mock site answered every service with text/plain, because the
service worker ignored the headers a service writes to
_SASJS_WEBOUT_HEADERS. CLI 6.2.0 applies the declared content type and
content disposition, and carries a byte body, so the downloads a mock
declares (public/getrawdata in DC) arrive as real files under the name the
service chose.
2026-10-25 13:57:07 +00:00
dc 4d462d310f fix(sites): round-trip the committed licence before publishing
Sites / deploy (push) Successful in 3m51s
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m8s
Build / Build-and-test-development (pull_request) Successful in 36m44s
The pre-publish check only asserted the pair had two different values, which a
committed pair can satisfy while being broken (one half regenerated, a value
truncated on copy). It now imports the activation key as pkcs8 RSA-OAEP,
decrypts the licence key, parses the payload and exits non-zero otherwise, so a
drifted pair fails the deploy instead of publishing a site that cannot decrypt
its own licence.

CONTRIBUTING records that the two values are one key and are regenerated
together, and that the .gitleaksignore entries are line-scoped.
2026-10-24 23:54:04 +00:00
dc 1f1028a2a5 ci(build): give the Cypress suite the time it now needs
Sites / deploy (push) Successful in 3m44s
Build / Build-and-ng-test (pull_request) Successful in 5m8s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m14s
Build / Build-and-test-development (pull_request) Successful in 36m42s
The step's inner guard killed Cypress at 30 minutes (exitcode 124) with the
19-spec list still on spec 18, so the job failed without a single failed spec -
seen on a07728b and on the previous head. The suite has grown to roughly 33-36
minutes; the inner guard is now 45 minutes and the step 50.
2026-10-24 23:00:14 +00:00
dc a07728be2b refactor(sites): bundle the site licence instead of minting it
Sites / deploy (push) Successful in 3m59s
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m49s
Build / Build-and-test-development (pull_request) Failing after 35m42s
The published sites get the same key pair on every deploy, committed as
sas/mocks/mock-licence.json (site_id 123, the mock estate's SYSSITE) rather than
generated in the pipeline. The pair sits outside the deployed sync folder, so the
CI estate stays unlicensed and the Cypress specs keep exercising the free tier.

The Sites job copies the pair into the drive before the snapshot and refuses a
pair whose two values are identical, which is how the app spots an HTTP-format
key it cannot decrypt in a secure context. The pair trips the generic-api-key
scanner, so .gitleaksignore carries the two fingerprints.
2026-10-24 22:18:07 +00:00
dc 7d9df71fdb feat(sites): mint a licence for the published sites
Sites / deploy (push) Successful in 4m4s
Build / Build-and-ng-test (pull_request) Successful in 5m31s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Failing after 36m15s
The demo and staging sites ran on the free tier, so uploads and the other
licensed features were unavailable to anyone looking at them. The Sites job now
mints a self-contained key pair (site_id 123, the estate's SYSSITE) into the
drive before the snapshot, so both sites are fully usable.

Minted per deploy rather than committed, and the CI estate stays unlicensed so
the specs keep exercising the free tier.
2026-10-24 20:32:08 +00:00
dc 75b4acf1b1 test(cypress): upload the licence on a free-tier estate
Sites / deploy (push) Canceled after 1m40s
Build / Build-and-ng-test (pull_request) Successful in 5m43s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Failing after 36m22s
The estate now ships no licence key at all - the placeholder word 'invalid' made
startupservice return an unusable key pair and produced the decrypt-failure page
on every HTTPS site. An unlicensed estate simply runs on the free tier.

loginAndUpdateValidKey therefore no longer infers 'already licensed' from the
nav tree: it detects the free-tier banner (#demo-banner) and uploads a key
through the licensing screen, which posts to admin/registerkey - the API the
licence page's upload button uses.
2026-10-24 20:30:22 +00:00
dc 73d25b1220 fix(mocks): drop derived variables before staging
stagedata.sas removes the MPE_DERIVED droplist from the submitted data before
anything is staged, and writes its approval CSV from that stripped dataset - the
mock staged the derived columns into both.
2026-10-24 20:30:17 +00:00
dc c4021a42ff fix(mocks): carry the zip flags into the central directory
`flags` was scoped to the entry loop and read by the central-directory loop, so
mpZipPackage threw a ReferenceError on every call - the audit download was
broken outright. The value now travels with each central entry.
2026-10-24 20:30:16 +00:00
dc 698dea6d6b fix(ci): dispatch the demo deploy with a tag ref and the actions scope
The dispatch endpoint resolves a bare name as a branch, so the release tag needs
the refs/tags/ prefix, and the route is scoped to the actions unit - contents
does not grant it. Without both, the step failed and the demo stayed on the
previous release.
2026-10-24 20:30:16 +00:00
dc 489819b051 fix(mocks): address the audit-pack review findings
Sites / deploy (push) Successful in 3m52s
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m5s
Build / Build-and-test-development (pull_request) Successful in 33m8s
- zip entries carry flag bit 11 when the name is non-ASCII, so an extractor
  reads `BKP_` plus an accented filename back by name instead of CP437
- loadfile and stagedata name the staged CSV after the libds the request
  arrived with, before a hook can re-point the submission
- stagedata writes that CSV at all (%mp_ds2csv does), so a grid submission's
  audit pack carries the same artefact as an upload's
- loadfile writes no BKP_ file: loadfile.sas copies one only for a second,
  non-CSV fileref, which the mock does not accept
- getauditfile says access is unenforced rather than that there is no
  permission store (MPE_SECURITY is seeded)
- the special-missings clip no longer claims the estate carries a valid key
2026-10-24 20:06:09 +00:00
dc 0b7cf6a724 ci(release): dispatch the demo deploy once the release is published
The release tag is created by the release job's semantic-release step, i.e. as
the Actions user, and the forge suppresses ref events from that user, so the
Sites workflow's `on: push: tags` trigger never fires and the demo would stay on
the previous release. Dispatch the workflow with the new tag after the assets
are uploaded instead.
2026-10-24 20:06:08 +00:00
dc 62f55db170 fix(mocks): clear the licence for published sites, not for the estate
Emptying mock-storage/licence.json dropped every CI run to the free tier, where
the upload button is absent, so excel.cy.ts failed all 24 tests: the licensing
spec registers a key only when the activation page is shown, and an unlicensed
estate activates straight into the app.

The placeholder pair stays in the fixture, and the Sites job strips it from the
drive before the snapshot is taken, so the published sites still run unlicensed
without the decrypt-failure page.
2026-10-24 20:06:03 +00:00
dc 752d944c20 feat(mocks): add getauditfile and the audit-folder artefacts
Sites / deploy (push) Successful in 3m51s
Build / Build-and-ng-test (pull_request) Successful in 5m29s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Failing after 36m12s
The audit download the review screens offer (services/auditors/getauditfile)
had no JS counterpart, so the browser build answered "program not found".

getauditfile.js is the port of getauditfile.sas: table id -> libds from
MPE_SUBMIT, the approval folder zipped under contents/, streamed as
<table>.zip. The zip is built by mpZipPackage and streamed by mpStreamfile in
dcMockUtils, the JS counterparts of the ODS package and %mp_streamfile; the
browser host has a text-only webout, so there the service describes the pack
instead of streaming it.

loadfile.js now leaves the two files loadfile.sas does in the folder as well:
the cleaned CSV and BKP_<upload>.
2026-10-24 19:34:13 +00:00
dc 50f09c8db8 ci(sites): guard the seed and serialise deploys per site
Sites / deploy (push) Successful in 3m47s
Build / Build-and-ng-test (pull_request) Successful in 5m34s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m41s
Build / Build-and-test-development (pull_request) Failing after 36m16s
Two review findings: the makedata call ends in || true (needed for its expected
HTML reply), so a genuine failure published a data-less site as a green build -
the drive is now checked for mpe_tables.json and at least ten tables before the
snapshot is taken. And the concurrency group is keyed on the target site rather
than the branch, so two release branches publishing staging cannot interleave.
2026-10-24 19:14:56 +00:00
dc fb36379520 fix(mocks): stop the mock advertising invalid licence keys
mock-storage/licence.json held the placeholder word 'invalid' for both keys, so
startupservice returned them as globvars and every HTTPS site showed the
'Licence key is invalid / Error decrypting license key' page. An empty pair is
what an unlicensed install has, and it lands on the free tier instead.
2026-10-24 19:14:52 +00:00
dc 6e70d203d1 ci(sites): publish the demo from the release tag, not from main
Sites / deploy (push) Successful in 3m45s
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Successful in 32m25s
The demo now deploys when semantic-release creates the tag, so it can never go
live on a commit whose release then fails, and the checkout carries the tag the
client's build stamp reports.
2026-10-24 19:05:38 +00:00
dc 3ec53076e7 ci(sites): use the staging site name, with the domain as its alias
Sites / deploy (push) Successful in 3m38s
Build / Build-and-ng-test (pull_request) Successful in 5m40s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 32m44s
2026-10-24 17:39:17 +00:00
dc bb8d007e2d ci(sites): publish release branches to staging and main to demo
Sites / deploy (push) Failing after 3m38s
Build / Build-and-ng-test (pull_request) Successful in 5m17s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m11s
Build / Build-and-test-development (pull_request) Successful in 33m0s
demo.datacontroller.io is now a multi-site Surfer instance: a release branch
deploys the staging.datacontroller.io site, and a push to main deploys the demo
(default site). Both run the same browser-hosted mock build.
2026-10-24 17:31:07 +00:00
dc a128b609f8 ci(demo): publish release branches to demo.datacontroller.io
Demo preview / deploy (push) Successful in 3m47s
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m18s
Build / Build-and-test-development (pull_request) Successful in 30m56s
Pushes to release/** now build the mocks as a browser-hosted site (SASjs CLI
6.1.0, streamConfig.mockWeb) and publish it to the Surfer app behind
demo.datacontroller.io, so the demo always matches the release branch.

The browser build seeds its drive from the compiled services, which carries no
DC data, so the job runs makedata on a throwaway SASjs Server and ships that
drive as mock-snapshot.json.
2026-10-24 16:49:02 +00:00
allan 37abc3adb7 Merge pull request 'build(mocks): emit the browser build for the server-ci target' (#358) from feat/browser-mock-build into feat/derived-vars
Build / Build-and-ng-test (pull_request) Successful in 5m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m25s
Build / Build-and-test-development (pull_request) Successful in 31m31s
Reviewed-on: #358
2026-10-24 13:27:37 +00:00
sasjs ab36ff8671 build(mocks): emit the browser build for the server-ci target
Build / Build-and-ng-test (pull_request) Failing after 1m49s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 20m48s
streamConfig.mockWeb turns the mock site on for the target whose services are JavaScript, so sasjs build produces sasjsbuild/mock alongside the deploy artefact. mockWeb is independent of streamWeb, so the same target still deploys for real.
2026-10-24 13:24:53 +00:00
dc 56ed429183 test(derived): correct the re-add rationale, cover re-activation
Build / Build-and-ng-test (pull_request) Successful in 5m3s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m24s
Build / Build-and-test-development (pull_request) Successful in 31m16s
VAR_NM carries CASE=UPCASE and the post edit hook upcases every non-delete
staged row, so a name typed in the grid reaches submit uppercase: a delete plus
a re-add of it is the same raw primary key and mpe_loader's dup check rejects
that at approval. Test 6's comment claimed the opposite, so it now states the
truth - only a stored name that is not uppercase reaches submit as two PKs, ie
a name written outside the editor.

Test 7 covers the other arm of the exclusion in the same check: setting an
inactive row active again while another active row depends on it. That starting
state is also one the hook refuses to create, so the case is defensive; both
tests prove the guard does not block the submission that repairs the data.
2026-10-24 11:18:12 +00:00
dc 6b5bf3e6be fix(derived): ignore a re-added name when collecting inactive rows
Build / Build-and-ng-test (pull_request) Successful in 4m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m45s
Build / Build-and-test-development (pull_request) Successful in 31m8s
The inactive set behind the bad-dependency check admitted every delete-marked
staged name, so a submission that delete-marks one case variant of a variable
and stages the same name again as a live active row (the two are distinct keys
to the loader's case sensitive duplicate check) matched the dep against the
inactive copy and aborted a configuration the engine resolves fine.

Both arms now exclude a name that this submission also stages as a live active
row - the staged one, and the control row it replaces. stagedata.test.4 gets a
Test 6 for that shape: delete 'Base_X', stage 'BASE_X', with a surviving active
row declaring VAR_DEPS=BASE_X, which must stage successfully.

Verified: sasjs lint (no new warnings), sasjs cb -t nextviya with @sasjs/core
6.0.0, and the built output carries the new predicate and the test. No SAS
estate was reachable from this box (nextviya and sas.4gl.io both time out), so
the test has not been executed on a real engine yet.
2026-10-24 10:04:58 +00:00
dc 033ffd3025 fix(tests): read the work location from _SASJS_WORK
@sasjs/core 6.0.0 renamed the session globals to a _SASJS_ prefix and sets
_SASJS_WORK only; SASJSWORK no longer exists (and sasjs/server's pre-program
compat aliases never covered it). testsetup.sas still read &sasjswork in both
the SASJS and SASMETA arms of %update_settings, so under the new pin those
filename statements built unrooted paths and ms_createfile / mm_createstp wrote
outside the session work directory, breaking sasjs test setup on SASJS and SAS9.

mp_init() is called at the top of the script, so _SASJS_WORK is defined here.
2026-10-24 10:04:53 +00:00
allan ac97252b02 Merge pull request 'fix(mocks): key rk_underlying tables on their business key' (#357) from fix/mock-rk-underlying-pk into feat/derived-vars
Build / Build-and-ng-test (pull_request) Successful in 4m55s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m30s
Build / Build-and-test-development (pull_request) Successful in 30m57s
Reviewed-on: #357
2026-10-24 09:24:39 +00:00
dc 821bf9d1ca Merge branch 'feat/derived-vars' into fix/mock-rk-underlying-pk
Build / Build-and-ng-test (pull_request) Successful in 5m8s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m2s
Build / Build-and-test-development (pull_request) Successful in 31m10s
Two conflicts, both resolved by keeping the intent of each side:

- sas/mocks/sasjs/services/editors/getdata.js: the PK derivation and the
  pkFirst() ordering from this branch, then the derived-variable block from the
  release branch. The derived columns are added to the schema before the
  filter, so the PK-first ordering still applies to the full column set.
- client/package-lock.json: taken from this branch. The merged package.json
  differs from the release branch only in the fast-uri override (4.2.3 here,
  3.1.8 there); the release branch already carries the same @angular 20.3.34
  and @sasjs/adapter 5.1.2 pins, so the lock is unchanged from 74060c0.

Gates on the merged tree: npm audit --omit=dev 0 vulnerabilities, prettier
clean, 603/603 unit tests, ng build, license-checker. Mock services re-probed
against a local SASjs Server: MPE_ROW_LEVEL_SECURITY publishes PKCNT 10 with
the business keys first and no RLS_RK, an edit diffs as UPDATED 1 with the
base RK, and the derived table TESTDATA.DERIVED_DEMO still serves its computed
columns.
2026-10-24 08:40:44 +00:00
dc 74060c0585 fix(mocks): derive the retained key wherever rows are staged
Build / Build-and-ng-test (pull_request) Successful in 4m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m49s
Build / Build-and-test-development (pull_request) Successful in 29m37s
Review follow-ups on the rk_underlying handling:

- mpeAssignRetainedKey (dcMockUtils) mirrors %mp_retainedkey: any submitted RK
  column is dropped and every row's RK is re-derived from the business key, so a
  stale RK in a hand-built payload cannot survive into the diff. Business keys
  compare the way SAS does - case-sensitive, trailing blanks ignored.
- editors/loadfile excludes the RK from its expected-columns check for these
  tables, as loadfile.sas does, and runs the derivation before staging, so a
  real CSV upload (which legitimately omits the RK) is accepted and its diff
  matches instead of reporting every row as NEW.
- both staging paths add the derived column to the staged headers, so
  MPE_SUBMIT.INPUT_VARS counts the width mpe_loader would see.
2026-10-24 00:32:25 +00:00
dc 0ba7450b65 chore(deps): clear the client audit advisories
Build / Build-and-ng-test (pull_request) Successful in 4m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m38s
Build / Build-and-test-development (pull_request) Successful in 29m19s
The npm audit gate started failing on advisories that landed upstream, so
nothing can merge until the client tree is patched:

- @angular/* 20.3.33 -> 20.3.34 (XSRF token leak in HttpClient, SSR DoS in
  the router)
- @sasjs/adapter 5.1.0 -> 5.1.2 (brings a patched axios)
- fast-uri override 3.1.8 -> 4.2.3 (the override was pinning the vulnerable
  version; ajv only needs it for URI resolution)
- lockfile refresh takes moment, undici, follow-redirects and brace-expansion
  to their patched versions, and re-resolves the @angular-devkit build
  toolchain within its existing ^ range

Verified in client/: npm audit --omit=dev reports 0 vulnerabilities, npm run
test:headless is 589/589, npm run build succeeds, lint:check and
license-checker pass.
2026-10-23 23:53:15 +00:00
dc 347dbb53b0 fix(mocks): key rk_underlying tables on their business key
Build / Build-and-ng-test (pull_request) Failing after 1m55s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 19m24s
getdata.sas exposes coalesce(rk_underlying, buskey) as the PK and drops the
RK column, so the editor shows the business key as read-only and never sends
the RK. The JS mock still published the RK as the PK and left it in the grid,
and stagedata had no loader to derive it back, so an edit to such a table
(MPE_ROW_LEVEL_SECURITY, MPE_SELECTBOX) could not be diffed.

The mock now mirrors that contract: PK/PKCNT come from rk_underlying, the RK
column is withheld and the PK variables lead COLHEADERS, and stagedata assigns
the RK from the business key - keeping the one the base row already holds and
minting the next value for a new key.
2026-10-23 23:30:57 +00:00
dc 2dc2885c3f chore(deps): @sasjs/cli 6.0.0 and adapter 5.1.2
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m6s
Build / Build-and-test-development (pull_request) Successful in 31m32s
CLI 6 ships the core 6.0.0 macros, so builds now carry the _SASJS_ session
variables; Data Controller reads none of them and calls %mp_init() with no
arguments. Adapter 5.1.2 is a patch on the 5.1.0 already in use.

Verified locally: sasjs cb -t nextviya and sasjs lint, client unit suite
603/603 and the production build.
2026-10-23 19:58:09 +00:00
dc 8806504967 fix(derived): reject a dependency on a row this submission deletes
Build / Build-and-ng-test (pull_request) Successful in 5m13s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m52s
Build / Build-and-test-development (pull_request) Successful in 31m25s
The inactive set behind the VAR_DEPS check took staged rows that are not
delete-marked with active ne 1, plus control rows with active ne 1. A staged
DELETE of a relied-on row was in neither arm, so it passed every guard and the
engine aborted every read after approval. Delete-marked staged rows are now in
the inactive set, and stagedata.test.4 covers it.
2026-10-23 17:07:05 +00:00
dc aa07401766 chore(deps): bump @sasjs/core to 6.0.0
v6 renames the session macro variables to the _SASJS_ prefix and removes
mp_init(prefix=). Data Controller calls %mp_init() with no arguments and reads
none of the renamed variables, so no code change is needed; every macro file
present in 5.7.2 is still present in 6.0.0.
2026-10-23 17:07:05 +00:00
dc 4166679dbf refactor(derived): pick the filter dataset with a single %let
Build / Build-and-ng-test (pull_request) Successful in 6m4s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m50s
Build / Build-and-test-development (pull_request) Successful in 32m25s
%if %then %let ...; %else %let ...; is not valid in open code (SAS stops with
"Expected %DO not found"), which is why these sites used %do/%end blocks. One
%let with %sysfunc(ifc()) needs no blocks and reads as what it is: a choice
between two dataset names. The droplist block in getrawdata/viewdata keeps its
%if %then %do; there is no %else to pair.
2026-10-23 11:29:43 +00:00
dc 688550a28d fix(derived): stop the hooks aborting on their own macro variables
Lighthouse Checks / lighthouse (pull_request) Successful in 21m0s
Build / Build-and-ng-test (pull_request) Successful in 5m13s
Build / Build-and-test-development (pull_request) Successful in 32m7s
A hook is %included from %mp_include, so its open-code %let runs in that
macro's local scope: a %global for the same name inside the hook raises
"exists in a local environment", sets SYSCC, and puts the session into syntax
check mode - every check after it silently skipped while the step still
aborts. The derived hook now sets its (renamed) control variables in the
including scope and does not %global them.

The RLS hook also referenced rls_msg before assigning it whenever there was no
derived conflict, which produced an unresolved-symbol WARNING and SYSCC=4 on
every clean rule submission. It is initialised now.
2026-10-23 10:32:49 +00:00
dc bd4ac50a69 test(derived): cover the MPE_DERIVED submit guards through stagedata
Four cases: a dependency on an inactive row aborts, deactivating a relied-on
row aborts, an inactive row does not block an unrelated variable, and a
delete-marked RLS rule naming a derived variable loads.
2026-10-23 09:44:32 +00:00
dc 7799a300df fix(derived): refuse dependencies on inactive rows, and keep the RLS scope guard coherent
The graph now holds only effective active rows, and a declared dependency that
resolves to an inactive row (existing, or one this submission deactivates) is
rejected: the engine reads only active rows and aborts every read of the table
on the unresolved reference.

The derived-variable / RLS guard goes back to rejecting every scope. Exempting
VIEW rules left them to fail a moment later in mp_filtercheck, which validates
against the physical table where the column does not exist, so the pairing is
refused up front with a message that says why.

RLS batches now exclude delete-marked rows, matching the badloadtypes check, so
a rule being removed is not validated against the derived configuration.
2026-10-23 09:44:32 +00:00
dc 85c89ca2a4 fix(derived): ignore inactive rows and VIEW rules in the submit guards
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m43s
Build / Build-and-test-development (pull_request) Successful in 33m13s
The dependency graph built at submit time pulled every open current row of
MPE_DERIVED into the union, while the engine only reads active=1 rows. An
inactive row that is still open could therefore abort a submission over a
cycle or a stale reference the engine never generates. The union now filters
active=1, matching mpe_derived.sas.

Both derived-variable guards also matched any active row level security rule,
whatever its scope. A VIEW rule is applied on the view the EDIT screen reads,
where a derived column exists, so naming one there is legitimate; only EDIT and
ALL rules run against the submitted data, where the column is absent. The
derived hook now filters rls_scope in ('EDIT','ALL'), and the RLS hook carries
rls_scope through work.batches to filter its side of the same guard, matching
the staging-side check in the same service.
2026-10-23 09:08:13 +00:00
allan 96914f1cbd Merge pull request 'feat: run startupservice in a new window from its error modal' (#356) from feat/startupservice-launcher into feat/derived-vars
Build / Build-and-ng-test (pull_request) Successful in 5m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m52s
Build / Build-and-test-development (pull_request) Successful in 33m34s
Reviewed-on: #356
2026-10-23 09:01:05 +00:00
dc 3445107d9a fix: name the startupservice launcher button "Show log"
Build / Build-and-ng-test (pull_request) Successful in 5m13s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m26s
Build / Build-and-test-development (pull_request) Successful in 31m20s
2026-10-23 03:01:23 +00:00
dc ad2da45389 fix: offer the launcher on the globvars failure modal too
Build / Build-and-ng-test (pull_request) Successful in 5m53s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 31m25s
The globvars check in licence.service reports a failed startupservice run as
well, so its modal needs the service name for the new-window button - that was
the fourth startup failure path and the only one still a dead end.

Also guard the decodeURIComponent call in the Cypress drive/folder intercept,
so a lone '%' in a URL cannot throw inside the handler and abort the request.
2026-10-23 02:17:49 +00:00
dc de71b4456e chore: merge feat/derived-vars into the startupservice launcher branch
Build / Build-and-ng-test (pull_request) Successful in 5m43s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m45s
Build / Build-and-test-development (pull_request) Successful in 32m14s
2026-10-23 01:46:08 +00:00
dc 40f61331aa feat: run startupservice in a new window from its error modal
Build / Build-and-ng-test (pull_request) Failing after 1m56s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 19m25s
When the startupservice fails, the modal is a dead end: the adapter returned
no log, so there is nothing to act on. The modal now offers a button that runs
the same service through the JES / STP web app in a new browser window, where
the SAS log is returned as the page body.

`_debug=131` is always added (the log is the point), and `_executionTasks` is
never included, so on Viya the run is not submitted as a Compute task and
cannot hit the execution-task timeout. The URL is built by `buildServiceUrl`,
which works for SAS 9, Viya and SASjs Server, and is the same shape the deploy
configurator already uses to open makedata.

The startup failure modals now carry the service name, which is what shows the
button: all three failure branches (malformed response, missing properties,
request rejected) pass `public/startupservice`.
2026-10-23 01:15:31 +00:00
allan 0dd55c9796 Merge pull request 'fix(editor): keep decimal values when an uploaded file is edited manually' (#354) from fix/349-upload-edit-decimals into feat/derived-vars
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m8s
Build / Build-and-test-development (pull_request) Successful in 31m6s
Reviewed-on: #354
2026-10-22 22:27:59 +00:00
dc 04ce1861e7 fix(editor): keep decimal values when an uploaded file is edited manually
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m2s
Build / Build-and-test-development (pull_request) Successful in 31m4s
Confirming the "source file will be discarded" warning coerced every
numeric column of the preview with parseInt, which truncated the
fraction: 0.901045951946194 became 0, and 1234.56 became 1234.
parseFloat converts the same values without dropping precision, and a
cell the parser could not read as a number is left as text so the
editor's numeric validation flags it instead of showing NaN.

Adds an Excel spec case that reads the first data row before and after
the switch to edit mode and asserts the decimal value survives.
2026-10-22 21:03:05 +00:00
allan 7ac620cc22 Merge pull request 'feat(editor): serve a truncated selection with a warning instead of aborting' (#352) from feat/edit-limit-warning into feat/derived-vars
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m0s
Build / Build-and-test-development (pull_request) Successful in 31m9s
Reviewed-on: #352
2026-10-22 19:32:00 +00:00
dc f38d0f80ca chore(getdata): correct the Test 2 banner column count
Build / Build-and-ng-test (pull_request) Successful in 5m45s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m14s
Build / Build-and-test-development (pull_request) Successful in 31m21s
dctest.wideboy is 1004 columns (row_id, 500 char, 500 numeric, plus the
field and position loop variables), so the Test 2 banner says 200 x 1004 =
200,800 cells, matching the @details block.  The row cap is unchanged.
2026-10-22 18:13:42 +00:00
dc 9de56f8a0b chore(deps): bump Angular to 20.3.34 and follow-redirects to 1.16.1
Build / Build-and-ng-test (pull_request) Successful in 5m37s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m27s
Build / Build-and-test-development (pull_request) Successful in 32m8s
The audit gate fails on advisories published against the pinned versions:
@angular/common 20.3.33 carries the XSRF token leakage reported in
GHSA-jfgx-762w-99vr, which reaches forms, platform-browser,
platform-browser-dynamic and router through their peer dependency on
common, and follow-redirects 1.16.0 carries GHSA-q3jh-wrc6-jgq8 and
GHSA-8r9p-f939-6h3c.

Both are patch bumps.  The lockfile is edited in place - the nine
@angular pins and the follow-redirects entry - rather than re-resolved,
because a full install prunes the stale entries the lockfile carries and
turns a pin change into hundreds of unrelated lines.  axios allows
^1.16.0, so the transitive bump needs no parent change.

npm audit --omit=dev reports 0 vulnerabilities at the repo root, in sas/
and in client/.  ng build and the client unit suite (589) pass.
2026-10-22 17:58:03 +00:00
dc 7df4cb29cc chore(getdata): declare mpeinit and mpeterm, correct the fixture counts
Build / Build-and-ng-test (pull_request) Failing after 1m49s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 20m55s
The doxygen list omitted mpeinit and mpeterm, which the service calls - both
are now declared the way the other services that use mpeinit declare it.  The
compiler inlines them, as it does for those services.  webout stays out of the
list: it is supplied by the framework rather than a macro in the repo, so that
one warning needs an exception in the linter.

dctest.wideboy has 1004 columns, not 1001 - row_id, char1-char500,
num1-num500, plus the loop variables field and position and the scratch
variable alphabet - so the test header's cell arithmetic is 200 x 1004 =
200,800.  The 199 row cap is unchanged, floor(200000/1004) is still 199.

The MPE_X_WIDE mock comment said 200,400 cells for 200 x 1001 columns, which
was the old counting that added the client-owned delete column.  The mock now
counts the table's own columns, so it is 200,200.
2026-10-22 17:44:56 +00:00
dc 66c233602f style(sas): keep the truncation message within the lint line limit
Build / Build-and-ng-test (pull_request) Failing after 1m51s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 19m45s
The message is built in three short assignments rather than one 161
character %let, which .sasjslint rejects (maxLineLength 107).  The
resulting text is unchanged.
2026-10-22 16:56:27 +00:00
dc 5585ae481e docs(comments): describe the limit handling, not the behaviour it replaced
Build / Build-and-ng-test (pull_request) Failing after 1m57s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 19m53s
The getdata comment explained the truncation by contrast with the abort it
replaces.  State what the code does and why instead.  Same for the two
not-refused phrasings in the mock and the test header.
2026-10-22 16:49:21 +00:00
dc 34691dceec feat(editor): serve a truncated selection with a warning instead of aborting
Build / Build-and-ng-test (pull_request) Failing after 3m13s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 19m53s
A selection over DC_MAXOBS_WEBEDIT or DC_MAXCELLS_WEBEDIT was refused with
"Table is too big", leaving the user with no grid and no way to see what the
filter had matched.  getdata now serves the first rows that fit and flags it:

- the row cap is min(DC_MAXOBS_WEBEDIT, DC_MAXCELLS_WEBEDIT / columns), so a
  wide table is still bounded by the cell budget
- sasparams carries TRUNCATED (0/1) and TRUNC_MSG, naming the limit reached
- the EDIT screen shows a warning triangle next to the table name, with the
  message in a tooltip and the advice to filter

The mock mirrors the new behaviour, the Cypress spec asserts the truncated
grid and the tooltip (real hover, opacity checked so a hidden tooltip cannot
pass), and the SAS limit test now asserts the served row counts and message
rather than a cancelled child job.
2026-10-22 16:38:37 +00:00
dc 422f766cd4 fix(derived): close the two gaps in the derived/RLS invariant
Lighthouse Checks / lighthouse (pull_request) Successful in 21m46s
Build / Build-and-ng-test (pull_request) Successful in 5m56s
Build / Build-and-test-development (pull_request) Successful in 30m41s
- the join against MPE_DERIVED compared an upcased var_nm with the rule's
  column as stored, so a case variant slipped past the explanatory rejection
  and fell through to the generic filter check.  Both sides are upcased.
- the invariant was enforced only from the RLS side: configuring a derived
  variable for a table whose active rule already names it passed the derived
  hook.  The same check now runs there, against the incoming libref/dsn/var_nm.
2026-10-21 22:31:56 +00:00
dc af31c36b67 fix(derived): only the delete marker is a reserved name
Build / Build-and-ng-test (pull_request) Successful in 5m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m52s
Build / Build-and-test-development (pull_request) Successful in 33m6s
A table's metadata columns are named per table - VAR_TXFROM, VAR_TXTO and
VAR_PROCESSED in MPE_TABLES hold those names, and they can be anything (the
bitemporal demo table uses VER_FROM_DTTM and VER_TO_DTTM).  When they exist
they are physical columns of the target, so the engine's collision check
already refuses a VAR_NM that matches one, whatever it is called.

The hard-coded list treated three example names as special: it refused them on
tables that use other names, and told the reader something untrue about what
is reserved.
2026-10-21 22:23:10 +00:00
dc c5a8de38b3 test(derived): guard the getdata fixture, fix two harness faults, cover the RLS rejection
Build / Build-and-ng-test (pull_request) Successful in 5m57s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m56s
Build / Build-and-test-development (pull_request) Successful in 32m39s
- getdata.test now checks the child job state before reading its outlib: a
  cancelled child returns no webout, so the previous call's members were being
  asserted against and the failures described the wrong problem.
- validatefilter.test's inputdatasets call needs a _PROGRAM column, which
  mx_execute reads to decide what to run - without it the job stopped at
  'The _PROGRAM column must exist'.
- stagedata.test.3 covers the new RLS check: an MPE_ROW_LEVEL_SECURITY rule
  naming a derived variable must be rejected at save time.
2026-10-21 17:59:49 +00:00
dc ccd468b335 fix(derived): address five review findings
Build / Build-and-ng-test (pull_request) Successful in 6m31s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m40s
Build / Build-and-test-development (pull_request) Successful in 32m51s
- getrawdata selected its filter target with a bare '%else %let' in open code,
  the shape that stops the step with 'Expected %DO not found'. Both branches
  are %do/%end now, so the download service applies a filter at all.
- the conditional drop in the approve.jsdset step and the one against
  MPSEARCH.vwsearch are dead: work.jsdata and work.vwsearch are already
  rewritten without the derived columns, so the drops only warn.
- the post-edit hook checked that a reference is declared, but not that a
  declared dependency is referenced. The engine rejects the stale shape at read
  time, so the same check now rejects it at submit time.
- a row level security rule naming a derived variable is rejected when the rule
  is saved, with a message that says why, instead of failing later at submit.
- getdata.test's cleanup deleted only DERIVED_NOTE, leaving DERIVED_NOTE2 with
  a dependency on a variable that no longer exists, which aborted every call in
  the following run - the cause of the repeated no-result runs.
2026-10-21 14:02:18 +00:00
dc 88a38db877 fix(derived): pair the filterds %else with %do/%end
Build / Build-and-ng-test (pull_request) Successful in 6m7s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m54s
Build / Build-and-test-development (pull_request) Successful in 33m33s
Both services selected the filter target with
'%if cond %then %let x=y; %else %let x=z;'. In open code the %else is not
paired with the %then and the whole step stops with 'Expected %DO not found',
so neither service ever applied a filter: every assertion downstream failed and
the job produced no results at all.

Found on a real estate - the pattern works inside a macro definition, which is
why the same construct elsewhere in the codebase is fine.
2026-10-21 13:34:02 +00:00
dc 4c198c6e31 chore(deps): @sasjs/core 5.7.2
Build / Build-and-ng-test (pull_request) Successful in 5m59s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m0s
Build / Build-and-test-development (pull_request) Successful in 34m6s
Carries the abort-shape fix from sasjs/core#468 - the cycle abort no longer
re-enters its placement loop, and the validation aborts are driven by a count
at the point of call.
2026-10-21 13:04:31 +00:00
dc 561d7fc3ed fix(derived): eight review findings
Build / Build-and-ng-test (pull_request) Successful in 5m26s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m0s
Build / Build-and-test-development (pull_request) Successful in 33m29s
- mpe_derived_postedit ran %local at the top level of a file that is included
  at execution time, so the hook stopped before validating anything and every
  MPE_DERIVED submission failed. The macro language now lives in a macro
  definition, errflag and errmsg are declared global, and the file calls it.
- the cycle check aborts after leaving its loop, and the self, undeclared and
  field aborts are driven by a count at the point of call rather than by a
  wrapping %if, so an abort cannot be outlived. The same shapes are fixed
  upstream in sasjs/core#468.
- a case-variant duplicate survived mpe_loader, which compares raw values:
  the hook now rejects it after normalisation and names the variable.
- stagedata dropped the derived columns from the output of the security step
  rather than from its input, so a crafted submission could still satisfy an
  RLS clause through a derived column. work.jsdata itself is rewritten now.
- the VAR_FMT validation rule rejected the bare w.d forms that the hook and
  the engine accept.
- the migration carried the same four dangling insert headers as mpe_makedata,
  so the v7.19 migration failed for existing installs.
- the filter fixtures in getdata.test and validatefilter.test had been caught
  by the variable rename: the filter schema column is VARIABLE_NM.
- the TX_FROM/TX_TO definitions agree across the ddl, the migration and
  mpe_makedatamodel.

@sasjs/core bumped to 5.7.1, which carries the where= fix.
2026-10-21 12:54:34 +00:00
dc 9a047ad42e fix(derived): repair the validation rows for MPE_DERIVED
Build / Build-and-ng-test (pull_request) Successful in 6m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m5s
Build / Build-and-test-development (pull_request) Successful in 32m21s
Four stray insert lines and a missing one left the MPE_VALIDATIONS block for
MPE_DERIVED malformed, so makedata aborted and the control table was never
created - found by building the library on a real estate.

The format assertions in the test now read the emitted statement, because proc
contents on a view does not report a format in full ('DATE' for DATE9.).
2026-10-21 12:06:35 +00:00
dc 616a2928e7 refactor(derived): use mp_derivedvars from @sasjs/core
Build / Build-and-ng-test (pull_request) Successful in 5m53s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m28s
Build / Build-and-test-development (pull_request) Successful in 34m10s
mpe_derived carried its own copy of the derived variable engine. That engine
now ships in @sasjs/core 5.7.0 as mp_derivedvars, so the local copy is gone and
mpe_derived is a wrapper that supplies what is Data Controller's own: the
control table, the bitemporal filter that picks the current active row, and the
list of metadata names that may not be used as a variable.

The macro goes from 511 lines to 102. The contract and the generated statement
format are unchanged, so the callers in the six services need no edit.

A test covers the wrapper's own responsibility: a closed version of a row and
an inactive row are both ignored.
2026-10-21 11:27:37 +00:00
dc ee31782fbf fix(derived): open the statements file with a long record length
Lighthouse Checks / lighthouse (pull_request) Successful in 20m13s
Build / Build-and-ng-test (pull_request) Successful in 5m3s
Build / Build-and-test-development (pull_request) Successful in 31m9s
A label at the 256 character limit produces an attrib statement of about 300
characters, which the default record length wraps, splitting the statement and
breaking the view.
2026-10-21 10:15:33 +00:00
dc ace4a66701 test(derived): snapshot the scope after the setup SQL
Build / Build-and-ng-test (pull_request) Successful in 5m29s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m24s
Build / Build-and-test-development (pull_request) Successful in 31m30s
Same harness fix as the core test: the setup inserts create the SQL automatic
macro variables, so the snapshot has to come after them, and the framework's
_SASJS_WEBOUT_HEADERS is ignored.
2026-10-21 09:10:59 +00:00
dc 7c9ce9a712 feat(derived): optional VAR_LABEL on MPE_DERIVED
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m23s
Build / Build-and-test-development (pull_request) Successful in 31m25s
A configured label replaces the default NAME=expression; when it is missing or
blank the default is used, so existing rows are unaffected.

- MPE_DERIVED gains VAR_LABEL varchar(256), in the ddl, mpe_makedatamodel and
  the v7.19 migration
- mpe_derived uses it, through the same escaping and 256-char truncation as
  the default label
- the hook trims it; the mock mirrors the fallback
- test 1 now sets a label on BAND and asserts it
2026-10-21 08:14:53 +00:00
dc 1b5c4b3ecd fix(derived): truncate the derived label on an even quote boundary
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m0s
Build / Build-and-test-development (pull_request) Successful in 31m34s
The label had 256 chars of storage, so the doubled quotes were truncated on
assignment; a cut between the halves of an escape leaves an unterminated
literal and the view fails to build.  The label now holds 512 chars, quotes
are doubled, then the 256 boundary is applied, retreating one character when
the cut lands on an odd quote count.
2026-10-21 01:49:04 +00:00
dc 5f5d8681b9 fix(derived): guard the empty physical column list in the dep check
Build / Build-and-ng-test (pull_request) Successful in 5m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m56s
Build / Build-and-test-development (pull_request) Successful in 31m28s
Same fix as the core review: mf_getvarlist returns nothing for a zero-column
table, so the dependency query compiled as 'not in ()'.
2026-10-21 01:05:10 +00:00
dc 9f70c56b58 chore(deps): @angular/* 20.3.34
Lighthouse Checks / lighthouse (pull_request) Successful in 20m25s
Build / Build-and-ng-test (pull_request) Successful in 4m57s
Build / Build-and-test-development (pull_request) Successful in 30m35s
GHSA-jfgx-762w-99vr (XSRF token leakage in the HTTP client, an incomplete fix
for CVE-2025-66035) covers @angular/common 20.0.0 - 20.3.33, and the 'Check
audit' step fails on any vulnerability, so every branch is red until this
lands.

The nine packages are pinned exactly and must move together - Angular pins its
siblings at the same patch level - so package.json and the lock are updated as
a set.  The local tarball for @sheet/crypto is only present in encrypted form,
so npm cannot run here; the client build and unit tests in CI are the proof.
2026-10-20 23:00:07 +00:00
dc 5af8e6fc35 revert(derived): no shadowing, and no self reference
Allowing a derived variable to reuse a physical column's name was wrong: an
intra-row calculation (SUMMER = SUMMER + 1) implies a retained value, which
depends on the order rows are read.  The same argument rules out a variable
listing itself as a dependency.

Reverted:
- the name collision is an error again ('VAR_NM collides with a column in the
  target table')
- VAR_DEPS may not list the variable itself
- the physical column list is back to mf_getvarlist - the type/length check
  only existed to support shadowing
- the droplist guards in stagedata / viewdata / getrawdata, and the duplicate
  suppression in getdata, are no longer needed
- the docs and both test suites drop the shadowing case
2026-10-20 23:00:01 +00:00
dc 6a1128a463 fix(derived): do not duplicate a shadowed column in the grid payload
Build / Build-and-ng-test (pull_request) Failing after 1m57s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 20m45s
cols1 already holds the physical column, so appending the derived row for the
same name would send it twice.  The derived row is now appended only when the
name is new; a shadowed column keeps the physical label and format, while its
value comes from the view.
2026-10-20 22:28:44 +00:00
dc 2d5de9a324 fix(derived): do not drop a shadowed column from staging or downloads
Build / Build-and-ng-test (pull_request) Failing after 2m0s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Failing after 4m48s
With shadowing allowed, a derived name can also be a physical column.  The
derived droplist was built from every derived name, so such a column would
have been dropped on submission (losing the user's edit) and from the view
and raw downloads (losing a real column).

stagedata, viewdata and getrawdata now subtract the target's own columns
from the droplist, so only genuinely virtual columns are dropped.
2026-10-20 22:27:19 +00:00
dc 12beeff695 feat(derived): allow a variable to shadow a physical column
Build / Build-and-ng-test (pull_request) Failing after 1m57s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 21m6s
SUMMER = SUMMER + 1 is a legitimate definition: the name matches an existing
column, the expression reads the physical value, and the view carries the
derived one under the same name.

- mpe_derived now takes the physical column list from mp_getcols, so it has
  type and length in one pass; a shadowed name must match the column's type,
  and its length may not exceed it (numeric lengths must be equal), as attrib
  cannot change either on an existing variable
- a self reference is only an error when the name is not a physical column
- self references are not graph edges, so the dependency sort is unaffected
- the post edit hook no longer rejects a self reference, since it cannot see
  the target library; it still rejects cycles between distinct names
- mpe_derived now uses mf_getuniquename for its working tables, matching the
  core macro, and carries the same placement sequence fix
- test 4 covers shadowing, docs cover the rule
2026-10-20 22:25:16 +00:00
dc 1055a0bc4a chore(deps): follow-redirects 1.16.1
Build / Build-and-ng-test (pull_request) Successful in 5m50s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m30s
Build / Build-and-test-development (pull_request) Successful in 31m45s
Two high advisories were published against 1.16.0 in the last few hours
(GHSA-q3jh-wrc6-jgq8, GHSA-8r9p-f939-6h3c), and the 'Check audit' step fails
on any vulnerability, so every run after 18:33 UTC today is red - including
the ones on this branch that had passed earlier.

Lockfile only, no source change: 1.16.1 satisfies the ^1.15.6 range axios
asks for.  Worth cherry-picking to main, since it blocks every PR.
2026-10-20 21:34:21 +00:00
dc d2de3ce88a test(derived): pin the macro's scope in mpe_derived.test.sas
Build / Build-and-ng-test (pull_request) Failing after 1m58s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 21m2s
2026-10-20 21:26:30 +00:00
dc be50cb5d08 fix(derived): carry the placement sequence in mpe_derived
Build / Build-and-ng-test (pull_request) Failing after 1m53s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Successful in 21m11s
Same defect as the core review found in mp_derivedvars: the final assemble
merged the placement table by name, but that table is built in dependency
rounds and is not name ordered, so the BY-merge failed whenever the rounds
were not alphabetical, and seq was a BY-group counter rather than the
dependency order.

Each round now stamps seq=_n_+nplaced, the merge runs on the name-sorted
tables, and the result is sorted by seq.  Also guards the physical-column
in-list for a zero-column table, and checks libds exists before running.
2026-10-20 21:24:03 +00:00
dc ee5d7c678e refactor(derived): VAR_DEPS instead of VAR_DEPENDENCIES
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m43s
Build / Build-and-test-development (pull_request) Successful in 31m50s
Shorter column name, same meaning: every input the expression uses,
physical columns and derived variables alike.
2026-10-20 18:33:24 +00:00
dc cee1a954ee feat(derived): report the dependency cycle path
Build / Build-and-ng-test (pull_request) Successful in 5m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m59s
Build / Build-and-test-development (pull_request) Successful in 31m35s
The cycle check was already in the post edit hook and in mpe_derived - the
topological sort places a variable only once its derived inputs are placed,
and if a round places nothing the remainder is a cycle.  What it reported was
just the set of names that could not be placed, which does not tell the
administrator what to change.

The message now walks the edges from the first unresolved variable and names
the loop, eg:

  VAR_DEPENDENCIES contains a cycle: A -> B -> C -> A

Names are collected in a dotted seen list, so a lead-in to the loop is shown
as well and the walk stops at the first repeat.
2026-10-20 17:52:04 +00:00
dc 5f6569b9e5 test(derived): declare the real dependencies in the SAS tests
Build / Build-and-ng-test (pull_request) Successful in 6m5s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m21s
Build / Build-and-test-development (pull_request) Successful in 32m59s
The test fixtures now state the inputs their expressions actually use:
LIBREF DSN, DERIVED_NOTE, PRIMARY_KEY_FIELD, and none for a literal-only
expression.  The getdata label assertion follows the new <VAR_NM>=<expr>
label.
2026-10-20 17:06:59 +00:00
dc 813bce6856 feat(derived): declare VAR_DEPENDENCIES instead of VAR_ORDER
Build / Build-and-ng-test (pull_request) Successful in 5m49s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m29s
Build / Build-and-test-development (pull_request) Successful in 32m28s
A sequence number has to be maintained by the administrator: inserting a
variable means renumbering everything after it, and a wrong number fails
silently - the derived value comes back missing, not wrong.

VAR_DEPENDENCIES names every input the expression uses, physical columns and
derived variables alike, eg 'REGION STATE'.  The statements are emitted in
dependency order, so a variable can build on another one with no sequence to
maintain, and a cycle is rejected.

The declaration is checked against the expression in both directions: a
derived variable referenced by VAR_LOGIC must be declared, and a declared
name that the expression does not reference is an error; a declared name must
resolve to a column of the target table or to a derived variable of the same
table.

Changes:
- MPE_DERIVED: VAR_ORDER (num) becomes VAR_DEPENDENCIES (varchar(4000)), in
  the ddl, mpe_makedatamodel and the v7.19 migration
- mpe_derived: dependency validation and a topological sort replace the
  VAR_ORDER sort and the forward-reference check
- mpe_derived_postedit: checks self reference, undeclared derived references
  and cycles at submit time, across the incoming rows plus the current rows
  they do not replace
- MPE_VALIDATIONS: the VAR_ORDER MINVAL/MAXVAL rules are replaced by UPCASE
  and a character pattern on VAR_DEPENDENCIES
- mocks: the dependency order is applied in JS, so a chained variable works
  even when the rows are loaded child first
- docs and tests updated
2026-10-20 16:51:08 +00:00
dc 4d9ad38df1 fix(derived): verify on stripped values, and label with the variable name
Build / Build-and-ng-test (pull_request) Successful in 5m47s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m49s
Build / Build-and-test-development (pull_request) Successful in 32m2s
Found running the macro on a real Viya compute server:

- verify() was applied to fixed width variables, so the blank padding was
  always outside the allowed character list and every name was rejected.  The
  check now runs on strip(name) and strip(fmt).
- the empty outvars dataset used 'length name $32; stop;', which the Viya
  compute server rejects with 'Variable name is uninitialized'.  It now
  assigns the variable and subsets with 'if 0;'.
- the label is now <VAR_NM>=<expression> rather than 'DERIVED: <expression>',
  so the grid shows the variable name as well as the logic.
2026-10-20 11:51:58 +00:00
dc 8bae21230e refactor(derived): drop the duplicate name check from the hook
Lighthouse Checks / lighthouse (pull_request) Successful in 21m9s
Build / Build-and-ng-test (pull_request) Successful in 4m59s
Build / Build-and-test-development (pull_request) Successful in 31m21s
mpe_loader already sorts work.staging_ds by the business key
(buskey='LIBREF DSN VAR_NM') and aborts on duplicates before the post edit
hook runs, so the same check in the hook could never fire.

The check in %mpe_derived stays: it reads the control table, which can also
be edited outside the app.
2026-10-20 09:56:52 +00:00
dc 27ddcfb575 fix(derived): raise the VAR_ORDER ceiling to 10000
Build / Build-and-ng-test (pull_request) Successful in 6m7s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m47s
Build / Build-and-test-development (pull_request) Successful in 32m0s
The client side MAXVAL cannot express 'integer', so integrality stays in the
macro and the hook. The ceiling is only there to catch a typo.
2026-10-20 09:07:18 +00:00
dc aa6d50e1ea feat(derived): validation rules and a VAR_TYPE dropdown for MPE_DERIVED
Build / Build-and-ng-test (pull_request) Successful in 5m30s
Build / Build-and-test-development (pull_request) Canceled after 7m45s
Lighthouse Checks / lighthouse (pull_request) Canceled after 19m16s
Client side rules on the table itself, so mistakes show up in the grid:
  - NOTNULL on LIBREF, DSN, VAR_NM, VAR_ORDER, VAR_TYPE, VAR_LEN, VAR_LOGIC
  - UPCASE on LIBREF, DSN, VAR_NM, VAR_TYPE, VAR_FMT
  - MINVAL 1 / MAXVAL 999 on VAR_ORDER, MINVAL 1 / MAXVAL 32767 on VAR_LEN
  - HARDREGEX on VAR_NM, VAR_FMT and VAR_LOGIC
  - HARDSELECT on VAR_TYPE, with C and N in MPE_SELECTBOX

Seeded in mpe_makedata and in the v7.19 migration. The post edit hook stays
the server side enforcement, since these rules are evaluated in the browser.

Also fixes the MPE_DERIVED create in mpe_makedatamodel, which still used the
old VARIABLE_* column names.
2026-10-20 09:01:55 +00:00
dc 0b010f2c65 feat(derived): validate MPE_DERIVED at submit time
Build / Build-and-ng-test (pull_request) Successful in 6m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m24s
Build / Build-and-test-development (pull_request) Successful in 32m50s
A post edit hook on MPE_DERIVED applies the configuration rules when a row
is submitted, rather than only when the EDIT screen next builds the view.

It normalises LIBREF, DSN, VAR_NM, VAR_TYPE and VAR_FMT, and rejects:
  - a missing LIBREF, DSN or VAR_NM
  - an invalid or reserved name, or one starting with a digit
  - a VAR_ORDER that is not a positive integer
  - a VAR_TYPE other than C or N
  - a VAR_LEN outside 1-32767 (character) or 1-8 (numeric)
  - a VAR_FMT that is not a plain format name
  - a VAR_LOGIC that is not a single expression
  - the same VAR_NM twice for one table
  - a reference to a derived variable that is not defined earlier

The name collision with a physical column is left to %mpe_derived, which runs
with the target library assigned; the hook does not have it.
2026-10-20 08:20:52 +00:00
dc 52803225df refactor(derived): shorten the MPE_DERIVED column names to VAR_*
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m5s
Build / Build-and-test-development (pull_request) Successful in 32m53s
MPE_DERIVED columns:
  VARIABLE_NM     -> VAR_NM
  VARIABLE_ORDER  -> VAR_ORDER
  VARIABLE_TYPE   -> VAR_TYPE
  VARIABLE_LENGTH -> VAR_LEN
  VARIABLE_FORMAT -> VAR_FMT
  VARIABLE_LOGIC  -> VAR_LOGIC

Updated in the ddl, mpe_makedatamodel, the migration, the MPE_TABLES buskey,
the macro (reads and validation messages), the tests, the mocks and the docs.
2026-10-20 07:57:49 +00:00
dc 3ede98fb18 test(derived): cover mpe_derived directly
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m0s
Build / Build-and-test-development (pull_request) Successful in 31m0s
The macro carries the ordering and statement-generation logic, so it is
worth a test of its own:

- character, numeric and chained variables: statements, view, columns
- label and default/configured formats
- a filter on a derived column
- the no-config path: no view, no statements, empty outvars

The configuration checks call mp_abort, so they stay out of the suite.
2026-10-20 03:31:08 +00:00
dc 9ef813d439 fix(derived): close the RLS and search gaps on derived columns
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m12s
Build / Build-and-test-development (pull_request) Successful in 30m59s
Review follow-up.

- stagedata: build the derived droplist before the ULOAD filter, and drop the
  derived columns in the badrecords step, so the row-level-security check runs
  against physical columns only.  A submitted derived value can no longer
  satisfy an RLS clause that names a derived column.
- viewdata: the full-table search view now drops the derived columns too, so
  a free-text search cannot match a value in an EDIT-only column.
- mpe_derived: upcase the libds when matching MPE_DERIVED, so a lower-case
  table reference still finds its configuration instead of silently showing
  no derived columns.
2026-10-20 02:49:24 +00:00
dc 33d043ea92 feat(derived): VARIABLE_ORDER, so a derived variable can build on another
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m15s
Build / Build-and-test-development (pull_request) Successful in 31m0s
A derived variable may need to reference one defined before it (a label that
concatenates a derived region, for example), so the order has to be
configured rather than assumed.

- MPE_DERIVED: new VARIABLE_ORDER column (ddl, makedatamodel, migration).
- mpe_derived: statements are generated in VARIABLE_ORDER then name sequence.
  VARIABLE_ORDER is required and must be a positive integer. A reference to a
  derived variable with an equal or higher order is rejected, because SAS
  would otherwise treat it as uninitialised and return a missing value with no
  error; references to lower-order variables are allowed.
- mock: same ordering, each variable compiled against the physical columns
  plus those defined earlier, so the frontend can exercise a chained variable.
- makedata: VARIABLE_ORDER on both demo rows plus a chained REGION_LABEL.
- cypress: asserts the chained value in the grid.
- tests: the getdata test seeds a second variable built on the first.
- docs: VARIABLE_ORDER documented, with the ordered rule replacing the
  self-contained one.
2026-10-20 02:09:37 +00:00
dc d3dec682aa fix(derived): enforce the documented limits, and handle derived filters in VIEW
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m59s
Build / Build-and-test-development (pull_request) Successful in 30m51s
Review follow-up.

- viewdata / getrawdata: apply the filter against the derived view when one
  exists, so a saved filter that references a derived column no longer aborts
  with "Variable ... is not on file" in the VIEW screen or a download.  The
  derived columns themselves are dropped from that output - they remain an
  EDIT screen feature.
- mpe_derived: reject a VARIABLE_FORMAT containing a semicolon, macro trigger
  or comment, and require it to look like a format name, so it cannot inject a
  statement into the generated data step.
- mpe_derived: reject a VARIABLE_LOGIC that references another derived
  variable (word-boundary match), which was documented but not enforced.
- mpe_derived: stmt length 4100 so a 4000-char expression plus the name and
  assignment cannot lose its trailing semicolon.
- mock tokenizer: allowlist the punctuation the expression subset uses, so
  anything else is rejected instead of being evaluated.
2026-10-20 01:24:50 +00:00
dc 05ad5544e2 ci: run the derived-variables spec last
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m58s
Build / Build-and-test-development (pull_request) Successful in 30m47s
It applies a licence key via loginAndUpdateValidKey, and csv-limited
asserts the free-tier restriction - so it must not run before that spec.
Running last keeps the licence state every other spec sees unchanged.
2026-10-20 00:43:22 +00:00
dc 8e82a7c857 ci: run the derived-variables cypress spec
Build / Build-and-ng-test (pull_request) Successful in 6m6s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m7s
Build / Build-and-test-development (pull_request) Failing after 31m36s
The cypress step takes an explicit spec list, so a new spec has to be
added to it to run.
2026-10-20 00:03:04 +00:00
dc 11ae41d626 test(cypress): open the EDIT screen filter from the editor, not the viewer
Build / Build-and-ng-test (pull_request) Successful in 5m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m35s
Build / Build-and-test-development (pull_request) Canceled after 24m37s
The editor has no .filterSide button - the filter is opened from the
btnView button above the grid.
2026-10-19 23:38:57 +00:00
dc b4fae88ae1 feat(mocks): implement derived variables in the JS services
Build / Build-and-ng-test (pull_request) Successful in 6m5s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m27s
Build / Build-and-test-development (pull_request) Successful in 32m52s
So the EDIT screen can be exercised before a SAS server is available.

- dcMockUtils: mpeDerived() reads MPE_DERIVED for a table and mpeDeriveRows()
  adds the computed columns to the rows and to the schema, before the filter
  runs - the same order as the real service.
- compileSasExpression() covers the subset of SAS expression syntax the mock
  configs use (ifc, cats, catx, upcase, lowcase, strip, trim, length, substr,
  index, comparisons, AND/OR and IN). Anything else leaves the column missing,
  as a failing SAS expression would. The real evaluation is done by SAS.
- getdata / getcolvals apply the derivation before filtering, so a filter on a
  derived column works and dropdown values come from the derived data.
- makedata: MPE_DERIVED schema and rows, a new TESTDATA.DERIVED_DEMO table
  (REGION, LINE_VALUE) and its MPE_TABLES registration.
- cypress: derived-variables.cy.ts covers display and filtering on a character
  and a numeric derived column.

Also bumps @sasjs/core to 5.6.0, which provides the mp_filterstore targetds=
parameter the validatefilter change depends on.
2026-10-19 23:18:46 +00:00
dc b0fd354ecd feat(editor): derived variables in the EDIT screen
Build / Build-and-ng-test (pull_request) Successful in 5m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m24s
Build / Build-and-test-development (pull_request) Successful in 31m28s
Adds user-defined computed variables, configured per table in the new
MPE_DERIVED control table. A derived variable is declared with a name,
type, length, optional format and a SAS expression.

The expression is applied in a DATA step view, and the filter is applied
by the step that reads the view, so the variables exist before the
filter is evaluated and can therefore be filtered on. A WHERE clause
cannot see a variable created in the same data step, hence the view.

- getdata: derived columns are added to the COLS payload (read only,
  labelled DERIVED: <expression>) and to the data returned to the grid
- getcolvals: values are taken from the derived view, so filter dropdowns
  work for derived columns
- validatefilter: the filter is validated against the view, and stored
  against the physical table (needs mp_filterstore targetds=)
- stagedata: derived columns are dropped before the approval package
- mpe_makedata / mpe_makedatamodel / ddl / migration: new MPE_DERIVED
  table, registered in MPE_TABLES

Values are display-time only - nothing derived is ever written back.
2026-10-19 22:58:19 +00:00
semantic-release-bot 779006b0bf chore(release): 7.18.0 [skip ci]
# [7.18.0](https://git.datacontroller.io/dc/dc/compare/v7.17.0...v7.18.0) (2026-10-19)

### Bug Fixes

* **deps:** bump @sasjs/core to 5.4.0 ([19fb032](19fb032f0d))
* **deps:** pin @sasjs/utils and drop the unused jsrsasign ([05d2d1e](05d2d1e08e))
* **editor:** own the delete-record column client-side ([56025cc](56025cc052))
* **editor:** surface the reserved-column refusal on every getdata path ([b26f557](b26f5571b6))
* **filters:** do not turn a fractional temporal value into a literal ([f710d87](f710d871ff))
* **filters:** fix the dynamic where clause deref and map its temporal values ([ece67d3](ece67d37ba))
* **filters:** keep the range field readable and cover a BETWEEN in the rewrite ([be79f3a](be79f3a1ea))
* **filters:** map an IN entry to its unformatted value before the literal ([8f98ebe](8f98ebe326))
* **filters:** stop the temporal rewrite corrupting a typed value, and bind the range dropdown to the unformatted value ([a5f61d4](a5f61d4a73))
* **filters:** use the unformatted value in every IN branch ([cc01f54](cc01f540c2))
* **makedata:** shorten the DC_MAXCELLS_WEBEDIT description to fit var_desc ([a51d9e5](a51d9e5574))
* **multi-dataset:** surface the reserved-column guard, use the name constant ([2b8a2fa](2b8a2fa103))
* **release:** emit the release body as raw text, not a JSON string ([a05554e](a05554e67a))

### Features

* **filters:** show dates as date literals in the filter query ([662d000](662d00032c))
2026-10-19 14:14:13 +00:00
allan 6f65bb691f Merge pull request 'feat: release 7.18 - sasjs dependency bumps, filter date literals and editor fixes' (#345) from feat/release-7.18 into main
Release / Build-production-and-ng-test (push) Successful in 5m29s
Release / Build-and-test-development (push) Successful in 25m7s
Release / release (push) Successful in 8m12s
Reviewed-on: #345
2026-10-19 13:39:26 +00:00
allan 3d21a0134c Merge pull request 'fix(makedata): shorten the DC_MAXCELLS_WEBEDIT description to fit var_desc' (#346) from fix/makedata-vardesc-length into feat/release-7.18
Build / Build-and-ng-test (pull_request) Successful in 5m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m22s
Build / Build-and-test-development (pull_request) Successful in 32m5s
Reviewed-on: #346
2026-10-19 13:39:02 +00:00
dc a51d9e5574 fix(makedata): shorten the DC_MAXCELLS_WEBEDIT description to fit var_desc
Lighthouse Checks / lighthouse (pull_request) Successful in 20m46s
Build / Build-and-ng-test (pull_request) Successful in 5m23s
Build / Build-and-test-development (pull_request) Successful in 30m13s
MPE_CONFIG.VAR_DESC is varchar(300), but the description written for
DC_MAXCELLS_WEBEDIT is 336 characters, so the insert truncates it.  The
truncation raises a WARNING, which sets SYSCC, and makedata aborts on
`&syscc ne 0` immediately after %mpe_makedata():

    WARNING: Character expression will be truncated when assigned to
      character column var_desc.
    ERROR: Execution terminated by an ABORT CANCEL statement

The abort happens before the settings job is written, so a fresh deploy
ends with no control library and no settings.sas at all.  It goes
unnoticed because the SAS test suite reuses whatever library is already
on the estate - the first time it bites is a deploy from scratch.

The description is shortened to 201 characters in both places it is
written - mpe_makedata (new installs) and the 20261003 row/cell limits
migration (existing installs).  The rationale it carried is user-visible
help text, so it moves to a SAS comment above each insert rather than
being dropped.

Verified on a real Viya estate, deploying from scratch:
  - before: makedata aborted, "Err during VIYA1337 build", no settings.sas
  - after:  makedata completed with zero warnings, and the SAS test suite
            then ran 59/59 green
2026-10-19 12:22:13 +00:00
hermes 026930d3e4 Merge pull request 'feat(filters): show dates as date literals in the filter query' (#344) from feat/filter-date-literals into feat/release-7.18
Lighthouse Checks / lighthouse (pull_request) Successful in 20m29s
Build / Build-and-ng-test (pull_request) Successful in 5m6s
Build / Build-and-test-development (pull_request) Successful in 29m19s
2026-10-17 20:10:37 +00:00
dc 05d2d1e08e fix(deps): pin @sasjs/utils and drop the unused jsrsasign
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m50s
Build / Build-and-test-development (pull_request) Successful in 29m57s
@sasjs/utils is imported directly across the client but was left as a caret
range in the 7.18 bump, while every other dependency in the file is exact.
Pin it to 4.0.0, which is the version the lockfile already resolves.

jsrsasign is declared but referenced nowhere in the tracked source - the only
other mentions are the lockfile entry and a historical CHANGELOG line - so
drop it.

Lockfile regenerated with npm install --package-lock-only; the only deltas are
the pinned range and the removed jsrsasign tree. 570/570 unit tests pass.
2026-10-17 19:32:14 +00:00
dc cc01f540c2 fix(filters): use the unformatted value in every IN branch
Build / Build-and-ng-test (pull_request) Successful in 5m12s
Lighthouse Checks / lighthouse (pull_request) Successful in 19m55s
Build / Build-and-test-development (pull_request) Successful in 29m58s
Finding from the review at ece67d3.

dynamicWhereClauseCreator's IN branch mapped the entry through element.values
only when building the literal; the two fallbacks emitted the unmapped value, so
a formatted label could still reach RAW_VALUE.  A temporal entry whose mapped
value is not a whole day / second (sasTemporalLiteral returns null for a
genuinely fractional value) or whose label finds no match in element.values
would fall through to the quoted label on a numeric column, which mp_filtercheck
rejects and which aborts the getcolvals load inside the swallowed catch.

The mapped value is now assigned once and used in all three branches, as
createFilterQueryTable's IN branch does.

One unit case added for the non-literal fallback.  582/582 unit tests pass.
2026-10-16 21:44:08 +00:00
dc ece67d37ba fix(filters): fix the dynamic where clause deref and map its temporal values
Build / Build-and-ng-test (pull_request) Successful in 5m34s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m3s
Build / Build-and-test-development (pull_request) Successful in 29m51s
Two findings from the review at 8f98ebe.

The IN branch read this.clauses.queryObj[groupInd][clauseInd].value, but the
entries sit at queryObj[groupInd].elements[clauseInd].value, so the forEach
dereferenced undefined and threw.  dynamicWhereClauseCreator runs inside
getValues / getValuesLoadMore, where the surrounding try/catch swallowed the
TypeError and the value list silently failed to load.  It now reads
element.value, like the BETWEEN and equality branches.

The BETWEEN branch composed element.value directly, so a temporal BETWEEN
picked from the value list sent the formatted strings into RAW_VALUE, which
mp_filtercheck rejects on a numeric column and which aborts the values load.
Both ends now go through the same formatted-to-unformatted lookup the IN branch
and createFilterQueryTable use, in one unformattedValue helper shared by the
two branches.

query.component gains a spec covering both branches.  581/581 unit tests pass.
2026-10-16 21:03:48 +00:00
dc 8f98ebe326 fix(filters): map an IN entry to its unformatted value before the literal
Build / Build-and-ng-test (pull_request) Successful in 5m18s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m51s
Build / Build-and-test-development (pull_request) Successful in 30m50s
Finding from the review at be79f3a.

createFilterQueryTable's IN / NOT IN branch read element.val directly, so it
produced a temporal literal only because whereClauseCreator had already mutated
query.value[i].val from the formatted label to the unformatted count in place
before submit.  Any path reaching the branch without the preview having run
first would have put the formatted string into RAW_VALUE.

The entry now goes through the same unformattedValue() lookup as the BETWEEN
ends.  An already-unformatted value passes through unchanged, since it no longer
matches a formatted label.

Two unit cases added: an IN entry carrying the formatted label, and one already
carrying the internal count.  578/578 unit tests pass.
2026-10-16 20:21:38 +00:00
dc be79f3a1ea fix(filters): keep the range field readable and cover a BETWEEN in the rewrite
Build / Build-and-ng-test (pull_request) Successful in 5m10s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m27s
Build / Build-and-test-development (pull_request) Successful in 30m5s
Two findings from the review at 72a7963.

whereClauseCreator's guard could not match a BETWEEN: checkOperator composes
it as `<from> AND <to>` and the letters of AND are outside the character class,
so the temporal rewrite was skipped and the filter-panel preview kept the
internal day counts (`BETWEEN 42 AND 43`).  The separator is removed before the
test, so a BETWEEN pair is shown as literals like a single value or an IN list.

Binding the range dropdown to column.unformatted made the field render the
internal value: setOptionValue assigns the clicked option's value to the input's
ngModel, so after choosing 12FEB1960 the field read 42.  The option value is the
formatted label again, as the single-value list and the IN modal already are,
and createFilterQueryTable's BETWEEN branch maps each end back to its
unformatted value before building the literal - the same lookup
whereClauseCreator applies for the preview.

Three new unit cases pin the BETWEEN preview and the BETWEEN RAW_VALUE in both
directions.  576/576 unit tests pass.
2026-10-16 16:29:57 +00:00
dc 72a7963972 test(e2e): cover a temporal BETWEEN chosen from the value list
Build / Build-and-ng-test (pull_request) Successful in 5m56s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m18s
Build / Build-and-test-development (pull_request) Successful in 31m9s
With the pickers off, a temporal BETWEEN takes both of its values from a
soft-select over the column's values, so the clause is composed from whatever
that list binds.  The test chooses 12FEB1960 for both ends of SOME_DATE and
asserts the applied clause carries the literals and still selects the 5 rows
the internal value selected.

Typing into the range fields - which is what the existing helper does - does
not exercise the binding, so both values are picked from the datalist instead.

Also accepts the evaluation agreement in beforeAll when it is presented.  It
is per-origin localStorage, so a fresh browser profile lands on it and the nav
tree never renders; the accept is guarded, so it is a no-op once an earlier
spec in the run has accepted it.
2026-10-16 13:52:19 +00:00
dc a5f61d4a73 fix(filters): stop the temporal rewrite corrupting a typed value, and bind the range dropdown to the unformatted value
Build / Build-and-ng-test (pull_request) Successful in 5m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m11s
Build / Build-and-test-development (pull_request) Successful in 31m50s
Two findings from the review at f710d87.

whereClauseCreator's temporal rewrite is a regex pass over the composed value
string, so it rewrote every digit run in it.  A date typed by hand as
12/02/1960 composed to 12/02/1960 and the clause preview rendered
'13JAN1960'd/'03JAN1960'd/'14MAY1965'd.  The pass now runs only when the
composed value is nothing but the numbers the clause is built from - a single
value, a BETWEEN pair or an IN list - so a typed value is left alone while an
internal day count is still shown as a literal.

The range dropdown bound [value]="column.formatted", where the single-value
dropdown binds column.unformatted.  whereClauseCreator's BETWEEN mapping writes
the unformatted value to a local copy rather than back onto the emitted clause,
so the formatted strings reached createFilterQueryTable, sasTemporalLiteral
returned null for them, and RAW_VALUE came out as `12FEB1960 AND 12FEB1960` -
unquoted, which mp_filtercheck rejects for a numeric column and so aborts the
save.  The option value is now the unformatted value, with the formatted text
kept as the label, matching the single-value dropdown.

573/573 unit tests pass, including two new cases pinning the preview: a typed
value is left alone, and an internal day count is still shown as a literal.
2026-10-16 13:18:46 +00:00
dc f710d871ff fix(filters): do not turn a fractional temporal value into a literal
Build / Build-and-ng-test (pull_request) Successful in 5m33s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m47s
Build / Build-and-test-development (pull_request) Successful in 32m9s
sasTemporalLiteral rendered the fraction with String(fraction).slice(1), which
emits raw IEEE-754 noise - 42.3 came out as '00:00:42.29999999999999716't and
1.1 as .10000000000000009.  Only the 0.5 case in the spec was clean.

SAS temporal values are whole days and whole seconds, so the value is rounded to
seconds first, which absorbs the noise a double picks up on the way here
(1.9999999999999 is simply the second 2).  A value that is genuinely fractional
does not land on a second, and rounding it would silently widen the filter, so
it now returns null and the caller sends the raw number instead.

sasTimeFromSeconds has no fraction left to render, so that branch is gone.

Also corrects the doc examples, which paired 34322 with '20APR2042'd - 34322
days after 1960-01-01 is '20DEC2053'd, which is what the spec already asserted.
Same fix in the mock's parser comment.

571/571 unit tests pass.
2026-10-16 13:07:52 +00:00
allan d6e0662b16 Merge pull request 'fix(editor): own the delete-record column client-side' (#343) from fix/getdata-delete-column-client-side into feat/release-7.18
Build / Build-and-ng-test (pull_request) Successful in 5m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m16s
Build / Build-and-test-development (pull_request) Successful in 32m5s
Reviewed-on: #343
2026-10-16 13:01:43 +00:00
allan f45b3259c7 Merge pull request 'fix(release): emit the release body as raw text, not a JSON string' (#342) from fix/release-notes-body-encoding into feat/release-7.18
Build / Build-and-ng-test (pull_request) Successful in 6m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m33s
Build / Build-and-test-development (pull_request) Successful in 31m11s
Reviewed-on: #342
2026-10-16 13:00:48 +00:00
dc b53f951307 chore: merge the 7.18 release branch into the filter date literals branch
Build / Build-and-ng-test (pull_request) Successful in 6m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m40s
Build / Build-and-test-development (pull_request) Successful in 32m53s
2026-10-16 12:42:46 +00:00
dc 9f8c71eb47 chore(deps): bump the sasjs dependencies for the 7.18 release
Build / Build-and-ng-test (pull_request) Successful in 6m11s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m12s
Build / Build-and-test-development (pull_request) Successful in 33m12s
sas/package.json
  @sasjs/cli    4.20.5 -> 4.20.9
  @sasjs/core   5.2.8  -> 5.5.2

client/package.json
  @sasjs/adapter  4.19.1 -> 5.1.0
  @sasjs/utils    ^3.6.0 -> ^4.0.0

Both client bumps are majors, and both are safe here:

- @sasjs/adapter 5.0.0 raised engines.node to >= 22.  The workflows run Node
  24.15.0 (24.5.0 in release.yaml), so the floor is satisfied.  5.1.0 also
  repackaged the adapter as compiled modules - DC imports only the package
  root (SASjsConfig, UploadFile, SASjsRequest), which index.d.ts still
  re-exports through ./types, and the package ships no exports map, so the
  imports DC does make are unaffected.
- @sasjs/utils 4.0.0 stopped re-exporting ./fs from the package root.  DC
  imports @sasjs/utils/input/validators and @sasjs/utils/types/serverType,
  neither of which is fs, and both still ship in 4.0.0.

@sasjs/adapter 5.1.0 depends on @sasjs/utils 4.0.0, so the two move together.

The shelljs override in sas/package.json is dropped: @sasjs/cli 4.20.9 no
longer depends on shelljs, so nothing in the tree resolves to it any more and
the pin was dead config.  The nanoid pin is untouched.

Lockfiles regenerated with npm install --package-lock-only --ignore-scripts,
then validated by enumerating every added, removed and version-changed entry
and tracing each one back to @sasjs/cli, @sasjs/core, @sasjs/adapter or
@sasjs/utils.  No entry was pruned as extraneous.

Verified by reproducing the Build-and-ng-test gates locally:

  npm audit --omit=dev      0 vulnerabilities in root, sas/ and client/
  npm run lint:check        pass
  npm run license-checker   pass
  npm run test:headless     563/563 SUCCESS
  npm run build             pass
2026-10-16 12:41:29 +00:00
dc 19fb032f0d fix(deps): bump @sasjs/core to 5.4.0
Build / Build-and-ng-test (pull_request) Successful in 5m28s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m15s
Build / Build-and-test-development (pull_request) Successful in 31m29s
5.4.0 carries the mp_filtercheck change that accepts a SAS temporal literal
in RAW_VALUE, which is what the filter literal work needs.  Without it the
literal is rejected when the filter is stored, so the clause stays numeric on
a real estate even though the mocks (which do not run the SAS macro) pass.

Verified the build inlines it from the project copy, not the CLI's nested one:
sasjsbuild/server_compileTree.json resolves mp_filtercheck.sas from
node_modules/@sasjs/core, and the compiled server.sas carries the fix.
2026-10-16 11:16:33 +00:00
dc 662d00032c feat(filters): show dates as date literals in the filter query
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m22s
Build / Build-and-test-development (pull_request) Successful in 31m9s
The clause shown above the grid (sasparams.FILTER_TEXT) is the resolved WHERE
clause, so a date filter read SOME_DATE = 34322 rather than a date.  The
client now sends a SAS literal for a DATE, DATETIME or TIME column -
'20APR2042'd, '01JAN1960:00:00:42'dt, '00:00:42't - which SAS accepts in the
same place, so the applied filter is unchanged and the clause is readable.

HelperService.sasTemporalLiteral builds the literal arithmetically in UTC, so
the day cannot shift with the browser timezone, and fractional seconds are
preserved.  It returns null for anything that is not a temporal value, and the
callers then send the raw value exactly as before.

Used by createFilterQueryTable (the applied filter), whereClauseCreator (the
clause preview in the filter panel), dynamicWhereClauseCreator (the filter
getcolvals applies to the value list) and the VA filter service.

Two fixes fall out of the same code paths:

- the dynamic where clause read the second BETWEEN value from
  queryObj[groupInd][clauseInd], which is undefined, so a BETWEEN clause threw;
- an IN over a temporal column sent the *formatted* value, which the backend
  refuses for a numeric column - the entries are now mapped back to the
  unformatted value before the literal is built.

The mock filter parser reads the literals too.  A time literal carries no date
part, so it needs its own pattern - the date pattern alone silently matched
nothing and a time filter returned no rows.

filtering.cy.ts asserts the new clause text and, for every temporal case, the
row count, so a clause that reads well but filters differently cannot pass.
2026-10-16 09:36:36 +00:00
dc b26f5571b6 fix(editor): surface the reserved-column refusal on every getdata path
Build / Build-and-ng-test (pull_request) Successful in 6m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m18s
Build / Build-and-test-development (pull_request) Successful in 32m50s
Review on #343:

- initSetup's retry branch called itself from a bare setTimeout, outside the
  callService promise chain, so the reserved-column throw on a retry never
  reached the .catch: getdataError was never set and the user was left on the
  loading spinner. Wrap the retry call and route it through the same failure
  handler the .catch uses (now a private handleGetdataFailure, shared by
  both).
- The multi-dataset catch logged and returned, leaving an empty table
  selection with the file still attached and only a console.warn. Surface it
  with eventService.showInfoModal, the pattern this file already uses for
  other upload problems.
2026-10-16 00:40:29 +00:00
dc 2b8a2fa103 fix(multi-dataset): surface the reserved-column guard, use the name constant
Lighthouse Checks / lighthouse (pull_request) Successful in 21m1s
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Build / Build-and-test-development (pull_request) Successful in 32m10s
Review on #343:

- buildDatasetsObjects() runs inside the Promise.allSettled(...).then(...)
  chain in onStartParsingFile, which had no .catch. prepareDeleteRecordColumn
  throws on a response carrying the reserved delete-record column, so in this
  flow that became an unhandled rejection: the loop aborted, no dataset was
  parsed and no state was shown. Wrap the call and drop the parse, the way
  fetchDataset's own catch handles a failed getdata.
- The rename-to-Delete? block still used the literal name while the same
  block in editor.component.ts uses DELETE_RECORD_COLUMN_NAME. Use the
  constant here too.
2026-10-15 23:46:22 +00:00
dc 56025cc052 fix(editor): own the delete-record column client-side
Build / Build-and-ng-test (pull_request) Successful in 5m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m15s
Build / Build-and-test-development (pull_request) Successful in 30m57s
getdata.sas synthesised _____DELETE__THIS__RECORD_____ itself - it added
the column to work.out, hoisted it in front of the PKs, set it to "No" on
every row, gave it a No/Yes dropdown in the metadata and forced MAXLEN=3
in maxvarlengths. In the editor that column is a constant: it is only ever
"No" on load, and its Yes/No rule is already injected client-side
(deleteRecordColumnRule.ts, since #253's vertical-array fix). So the
backend was sending a column the client already owns.

The editor now creates the column, the same way EDIT_STATUS / dc.row_status
is client-only:

- getdata.sas no longer emits it (data steps, the outdata hoist, the
  ctrlOptions dropdown, the maxvarlengths override).
- deleteRecordColumn.ts asserts the response does NOT carry the name, then
  prepends it to COLHEADERS. Everything downstream (DcValidator's rules,
  columnHeader, headerArray) is keyed off COLHEADERS order, so the delete
  column is still index 0 and the grid is unchanged.
- Every row is seeded to 'No' before the validator or HyperFormula sees it.
- A response that does carry the name now throws instead of rendering a
  table whose delete column would shadow a real column of that name. The
  throw lands in the existing getdata .catch, which sets getdataError and
  shows the error state. The name is reserved; the docs note is in the
  sibling docs PR.

The multi-dataset loader (multi-dataset.component.ts) builds its own
DcValidator from the same responses, so it goes through the same helper.

Mocks updated to the new contract (server + sas9 getdata); postdata,
getstagetable and makedata are untouched - they consume or seed the flag
legitimately, and the upload contract in excel.md / files.md is unchanged.

Verified: client unit tests 570/570, npm run build clean, sasjs lint clean
on the changed SAS, sasjs compile -t server succeeds, and against the
mocked estate coltype-delete-record.cy.ts 2/2, editor.cy.ts 55/55,
excel.cy.ts 23/23 and row-cell-limits.cy.ts 5/5.
2026-10-15 22:52:44 +00:00
dc a05554e67a fix(release): emit the release body as raw text, not a JSON string
Build / Build-and-ng-test (pull_request) Successful in 5m31s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m53s
Build / Build-and-test-development (pull_request) Successful in 30m52s
The "Upload assets to release" step builds the new body with
`jq -n --arg body ... '$body + "\n" + ...'` and no `-r`. jq then prints the
result as a JSON string literal - quoted, with `\n` escapes - which the
PATCH that follows encodes a second time, so the stored release body is a
quoted one-liner instead of markdown. On v7.17.0 this rendered the whole
release as a single escaped line in the markdown box.

Add `-r` so the concatenated notes are emitted as raw text. Verified by
running the step's jq invocation against sample notes: without `-r` the
stored body contains literal `\n`, with `-r` it contains real newlines.

release.yaml only runs on a push to main, so this cannot be exercised by
CI on the PR itself.
2026-10-15 20:50:01 +00:00
semantic-release-bot 402ec346b9 chore(release): 7.17.0 [skip ci]
# [7.17.0](https://git.datacontroller.io/dc/dc/compare/v7.16.0...v7.17.0) (2026-10-15)

### Bug Fixes

* **client:** do not publish an empty getcols fallback to the picker ([9f8fc6f](9f8fc6f2eb))
* **client:** map the getcols fallback onto the picker vocabulary ([7cecf79](7cecf79515))
* **client:** pin the dependency entries this release changes ([b034fe5](b034fe5335))
* **deploy:** apply the same identity-call fix to the automatic deploy ([5693b44](5693b4488b))
* **deploy:** disable the manual deploy actions without an admin group ([6ffbdba](6ffbdbadf9))
* **deploy:** disable the manual deploy file inputs while admin groups load ([7094bfd](7094bfdf7c))
* **deploy:** guard the manual deploy form and Viya identity calls ([6522fcb](6522fcb28b))
* **deploy:** never bake an empty admin group into the deploy script ([b0e47fc](b0e47fc4ed))
* **deps:** pin shelljs to clear the braces advisory in the sas audit ([6e50938](6e5093858b))
* **editor:** check the EDIT limits once, and skip switched-off options ([f08c4c2](f08c4c231f))
* **filters:** carry TYPE on the fallback list, and drop the temporal exclusion ([bcb8fde](bcb8fde986))
* **filters:** source the picker variables from public/getcols when the table is not returned ([3a6a216](3a6a216b9d))
* **getcols:** use %global and %mp_getcols, and merge the base branch ([1385741](1385741f2d))
* **getcols:** widen TYPE before assigning the client vocabulary ([bcad05e](bcad05e032))
* **getdata:** apply row level security to selectbox source values ([768d33c](768d33c618)), closes [#340](#340)
* **mocks:** read MPE_CONFIG correctly, and pin the limits to it ([05126ae](05126ae73a))
* repair the SAS suite for the row/cell limits and default the manual deploy admin group ([99ff732](99ff732d67))
* **requests-modal:** widen the dialog so log lines need less scrolling ([3c10d91](3c10d915a5))
* **sas:** keep format and label in the public getcols response ([9c32b1b](9c32b1b1da))
* **sas:** keep the SAS C/N vocabulary in the public getcols response ([e90bcde](e90bcde512))
* **sas:** run the row/cell limit migration as a Viya job ([90af6b8](90af6b8515))
* **startup:** stack the SASjs tag detail so the dump is readable ([1f4c4a4](1f4c4a4d82))

### Features

* **debug:** keep the debug toggle state across a page refresh ([3ce006d](3ce006d6b4))
* **editor:** raise the row limits and add a cell limit to the EDIT screen ([3de6655](3de6655f26))
* **mocks:** read the DC_MAX* options from MPE_CONFIG, and mock the DDL export ([edac9a9](edac9a987a))
* **startup:** call out a missing SASjs tag on the boot screen ([b24eb73](b24eb731ce))
* **startup:** dump the SASjs tag contents in the boot screen checks ([75c1dcc](75c1dccfd2))
* **system:** export the DC library DDL from the system screen ([05f3f49](05f3f49e0c)), closes [#179](#179)
2026-10-15 20:21:53 +00:00
allan e48bf80ab4 Merge pull request 'feat: release 7.17 - DDL export, Handsontable 18.1.1, EDIT row and cell limits' (#333) from feat/export-dc-library-ddl into main
Release / Build-production-and-ng-test (push) Successful in 4m47s
Release / Build-and-test-development (push) Successful in 23m40s
Release / release (push) Successful in 7m49s
Reviewed-on: #333
2026-10-15 19:49:27 +00:00
dc dd958ac4e7 chore(styles): drop the dead manual-deploy CSS block
Build / Build-and-ng-test (pull_request) Successful in 5m47s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 31m19s
8fdb468 removed the only component matching app-manual-deploy and the
.clear-memory-button rule inside it, leaving the block in styles.scss with no
consumer anywhere in the tree.
2026-10-15 16:48:35 +00:00
dc 8fdb468ad3 refactor(deploy): remove the manual deploy section
Build / Build-and-ng-test (pull_request) Successful in 6m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m13s
Build / Build-and-test-development (pull_request) Successful in 33m8s
It is the old Viya deployment form - the one built around uploading a JSON build
file - and it is not coming back. It was reachable only through the manualdeploy
route, which goes with it, so the Viya deploy screen is now the automatic flow
only.

That takes the manualdeploy-only plumbing in deploy.component with it (autodeploy
and its dead commented-out toggle, adminGroups/getAdminGroups, jsonFile) along
with the now-unused Router and LoggerService injections, and the section's two
spec files.
2026-10-15 15:13:00 +00:00
dc af52e4a1bf docs(contributing): drop the tag-based Handsontable key instructions
Build / Build-and-ng-test (pull_request) Successful in 6m30s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m23s
Build / Build-and-test-development (pull_request) Failing after 33m50s
The key now comes from the backend licence (hot_license_key on the decrypted
licence), falling back to DEFAULT_HOT_LICENCE_KEY, so the hotLicenceKey tag
attribute the docs told you to set has no reader. Also reword the missing-tag
comment in parseDcAdapterSettings, which claimed there was no case to handle
while the boot screen reports one.
2026-10-15 15:07:58 +00:00
dc b24eb731ce feat(startup): call out a missing SASjs tag on the boot screen
Build / Build-and-ng-test (pull_request) Successful in 6m34s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m32s
Build / Build-and-test-development (pull_request) Failing after 34m53s
The tag is a mandatory part of index.html - it carries serverUrl, serverType and
the rest of the adapter config - so the missing-tag branch (deactivateApp plus an
abort modal) goes. A missing tag is reported on the tag step itself instead,
which is where the rest of the boot diagnostics already live, and the settings
parse is null-safe so nothing throws on the way there.
2026-10-15 14:54:11 +00:00
dc d81967e6a1 refactor(sasjs-tag): unwire adminGroup and hotLicenceKey from the tag
Build / Build-and-ng-test (pull_request) Successful in 6m29s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m9s
Build / Build-and-test-development (pull_request) Successful in 33m25s
Both were hangovers from the earlier deployment flow.

adminGroup is a DC setting (DC_ADMIN_GROUP, shown on the System screen), not a
tag attribute. Its only readers were the deploy form's default in
deploy.component.ts and manual.component.ts, and both already fall back to
SASAdministrators when it is absent, so the fallback is now the whole logic.

hotLicenceKey was the Handsontable licence key. The customer's own key arrives
in the decrypted licence (hot_license_key), so the client carries the free-tier
default itself and no longer reads it from index.html.

With neither attribute on the tag, the boot-screen dump has nothing to hide:
HIDDEN_TAG_ATTRIBUTES is gone and every attribute is shown, so a wrong or
misspelt one is visible. That closes the review finding on hiding adminGroup.
The missing-tag branch also records why it carries no error state, closing the
other carried finding.
2026-10-15 14:43:42 +00:00
dc c81db17588 chore(index): drop the adminGroup attribute from the SASjs tag
Build / Build-and-ng-test (pull_request) Successful in 5m43s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m48s
Build / Build-and-test-development (pull_request) Successful in 31m50s
It is a hangover from the earlier deployment flow: its only consumers are the
deploy form's default (deploy.component.ts setDeployDefaults and
manual.component.ts), both of which already fall back to SASAdministrators when
it is absent. The attribute stays readable, so an install that still sets it is
unaffected.

hotLicenceKey is left in place - it is not a deployment setting. It is the
Handsontable licence key, seeded into freeTierLicenceData.hot_license_key and
pushed to hotTable.licenseKey in six components, and nothing on the SAS side
supplies it.
2026-10-15 14:19:54 +00:00
dc 3c10d915a5 fix(requests-modal): widen the dialog so log lines need less scrolling
Build / Build-and-ng-test (pull_request) Successful in 5m48s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m50s
Build / Build-and-test-development (pull_request) Successful in 31m8s
Clarity's `xl` modal size is a fixed 57.6rem (1152px), so the SAS log pane -
which is `white-space: pre` and deliberately never wraps - needed left/right
scrolling to read a line. Give the requests modal a 90vw dialog instead; the
log pane itself is untouched, so lines still do not wrap.
2026-10-15 13:43:43 +00:00
dc 3ce006d6b4 feat(debug): keep the debug toggle state across a page refresh
Build / Build-and-ng-test (pull_request) Successful in 6m35s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m55s
Build / Build-and-test-development (pull_request) Successful in 32m38s
The <sasjs> tag in index.html is re-read on every load, so the debug switch fell
back to the tag's value whenever the page was refreshed. Store the state the user
picks from the UI in localStorage, and reinstate it when the adapter is built, so
a refresh keeps the state from before.
2026-10-15 12:38:54 +00:00
dc cc4cbd52e4 refactor(startup): show the SASjs tag as a name/value grid
Build / Build-and-ng-test (pull_request) Successful in 6m30s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m46s
Build / Build-and-test-development (pull_request) Failing after 33m17s
Render the tag attributes as a two-column grid under the label instead of a
single comma-joined line, and leave the admin group and the licence key off the
boot screen.

The missing-tag error state goes too: the tag ships in index.html, so an absent
tag is not a case the boot screen needs to report.
2026-10-15 12:22:27 +00:00
dc 1f4c4a4d82 fix(startup): stack the SASjs tag detail so the dump is readable
Build / Build-and-ng-test (pull_request) Successful in 6m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m26s
Build / Build-and-test-development (pull_request) Failing after 34m3s
The check row renders the detail in a narrow right-hand column, which squeezed
the tag dump into a clipped block next to the label. Long details now wrap onto
their own full-width line, left aligned, via a `stacked` flag on the step.
2026-10-15 12:11:57 +00:00
dc 75c1dccfd2 feat(startup): dump the SASjs tag contents in the boot screen checks
Build / Build-and-ng-test (pull_request) Successful in 5m56s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m38s
Build / Build-and-test-development (pull_request) Successful in 32m22s
The boot screen lists the startup checks (app location, Viya deploy, startup
service). Add a fourth step that shows the contents of the <sasjs> tag, so the
effective configuration (serverType, debug, useComputeApi, ...) is visible
without having to read the page source. The step is marked as errored when the
tag is missing, which is the state that triggers the abort modal.

The step is appended after the existing three so the indices the startup flow
drives (sas.service / app.service) are unchanged. HTML lower-cases attribute
names in the DOM, so known attributes are mapped back to their canonical
spelling for display; unknown ones are kept as-is so a misspelt attribute is
still visible.
2026-10-15 11:56:07 +00:00
dc 7094bfdf7c fix(deploy): disable the manual deploy file inputs while admin groups load
Build / Build-and-ng-test (pull_request) Successful in 6m31s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m38s
Build / Build-and-test-development (pull_request) Successful in 33m0s
A file chosen before the identity calls settle runs onSasFileChange ->
addPrecodeLines while selectedAdminGroup is still '', baking '%let admin=;'
into the generated script; the action buttons then enable against that stale
header once the groups load. Disable both file inputs while
adminGroupsLoading, and cover it with a template spec that asserts the
binding (verified red without the guard).
2026-10-14 21:28:48 +00:00
dc fead3d5b26 test(getdata): wrap the RLS skip logic in a macro for sas9 portability
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m46s
Build / Build-and-test-development (pull_request) Successful in 32m11s
The admin-skip conditional used open-code %if/%then/%do, which needs SAS
9.4M5+. The suite also runs on the sas9 target, where an older maintenance
release would fail to compile the test. Wrap the body in
%macro getdata_rls_test() ... %mend and invoke it, so the conditional sits
inside a macro definition (as testsetup.sas's update_settings does).
2026-10-14 21:13:56 +00:00
allan cd5bae7518 Merge pull request 'fix(getdata): apply row level security to selectbox source values' (#341) from fix/rls-selectbox-source into feat/export-dc-library-ddl
Build / Build-and-ng-test (pull_request) Successful in 5m50s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m4s
Build / Build-and-test-development (pull_request) Successful in 30m57s
Reviewed-on: #341
2026-10-14 15:57:47 +00:00
dc 78d436f847 test(getdata): derive RLS value from data and guard open-code return
Build / Build-and-ng-test (pull_request) Successful in 5m46s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m45s
Build / Build-and-test-development (pull_request) Successful in 30m47s
- The startupservice test leaves trailing %let dc_admin_group lines in the
  deployed settings.sas, so the skip guard compares against whatever the
  file resolves to; keep using &dc_admin_group (not &mpeadmins, which is
  never set in a test session).
- Selectbox RLS test now derives the restricted SOME_BESTNUM value from the
  data (testsetup reseeds MPE_X_TEST with random values) and asserts the
  user filter matches at least one value so the grid cannot be empty.
- Replace the open-code %return (invalid outside a macro definition) with
  an %if/%else %do guard around the demote + assert section.
2026-10-14 14:52:47 +00:00
dc 0d3d47500c test(getdata): make selectbox RLS test runnable on admin estates
Build / Build-and-ng-test (pull_request) Successful in 5m45s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m16s
Build / Build-and-test-development (pull_request) Successful in 30m50s
RLS is skipped for admins, and test sessions never resolve &mpeadmins
(testinit.sas runs without mpeinit), so the test checks the runner's
identity groups against &dc_admin_group instead. Admin runners skip
the assertions with an explicit PASS row; everyone else gets the real
RLS selectbox checks. Also documents the filter (row limit) and distinct
value preconditions.
2026-10-14 13:46:55 +00:00
dc 768d33c618 fix(getdata): apply row level security to selectbox source values
Build / Build-and-ng-test (pull_request) Successful in 5m55s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m12s
Build / Build-and-test-development (pull_request) Successful in 31m1s
The cell dropdown (selectbox) values sourced from a library.member.column
reference are read directly from the source table in editors/getdata.sas
(%dq_selects), without applying Row Level Security.  The grid rows are
filtered by %mpe_filtermaster, but the dropdown was not, so values from
restricted rows leaked into the dropdown.

This runs %mpe_filtermaster over the source table and reads the distinct
values through the filtered view.  EDIT mode mirrors the grid on this
(editor) page.  A data step view is used because a fileref cannot be %inc'd
inside a proc sql where clause.  The per-source view, filter table and
fileref are dropped at the end of each loop iteration.

getdata.test.2.sas restricts SOME_BESTNUM in MPE_X_TEST with a Row Level
Security rule (only the value 44 is visible) and asserts the selectbox
values returned by getdata are restricted to 44.  Without the fix the
dropdown returns the other distinct values and the test fails.  It is named
.test.2 because the row/cell limits test added on the target branch already
occupies .test.1.

Closes #340
2026-10-14 11:12:31 +00:00
dc 6ffbdbadf9 fix(deploy): disable the manual deploy actions without an admin group
Build / Build-and-ng-test (pull_request) Successful in 6m38s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m22s
Build / Build-and-test-development (pull_request) Successful in 31m29s
The fallback added in b0e47fc names a group when the identity calls fail, but
the deploy should not proceed on a group the user never saw or chose.  The
three actions that consume it - the precode download, SUBMIT (executeSAS) and
Create Database - are now disabled while the group list is empty, so a failed
or empty identity call cannot produce a deploy script or a makedata run.  A
note next to the group select says why they are disabled.

The template spec asserts both states by rendering the real template.
2026-10-05 22:16:35 +00:00
dc b0e47fc4ed fix(deploy): never bake an empty admin group into the deploy script
Build / Build-and-ng-test (pull_request) Successful in 5m47s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m8s
Build / Build-and-test-development (pull_request) Successful in 32m16s
When the identity calls fail the group lists stay empty and selectedAdminGroup
stayed '' - the manual section, unlike the automatic one, set no default - so
addPrecodeLines wrote `%let admin=;` and createDatabase carried an empty
ADMIN to makedata.

Settle the selection on both paths: applyAdminGroupFilter now also runs when
the calls fail, and falls back the way the automatic section does
(dcAdapterSettings.adminGroup, else SASAdministrators).  The filter previously
sat inside the try, so the failure path skipped it entirely.
2026-10-05 21:50:19 +00:00
dc 5693b4488b fix(deploy): apply the same identity-call fix to the automatic deploy
Build / Build-and-ng-test (pull_request) Successful in 5m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m18s
Build / Build-and-test-development (pull_request) Successful in 31m23s
The automatic deploy's getAdminGroups has the identical raw fetch() - no
credentials, no res.ok check, and no catch, so a 401 surfaced as an unhandled
rejection while the list stayed empty.  Same fix as the manual section; this
path predates the release branch.
2026-10-05 19:39:22 +00:00
dc 6522fcb28b fix(deploy): guard the manual deploy form and Viya identity calls
The "Show all groups" toggle was the only ngModel control in the form without
a name or ngModelOptions.standalone, so Angular threw NG01352 on render -
dev-mode only, so a production build hid it, but ng serve and the Cypress job
did not, and the form renders on every visit (needsLogin defaults to false).
Added both, matching the neighbouring controls.

Both Viya identity calls used raw fetch() with no credentials and no res.ok
check.  The deploy app can be served from a different origin to the Viya
server, where the default same-origin credential mode sends no session cookie
and Viya answers 401 - fetch still resolves, the body parses to no items, and
the screen silently rendered an empty group list that the generated deploy
script then carried as an empty admin value.  Passed credentials: 'include'
(matching withCredentials on the app's other Viya calls) and threw on a
non-ok response so the existing error path reports it.

Adds a spec that renders the real template through its module - the other
specs construct the class directly, so nothing ran the template directives,
which is why CI could not catch the ngModel guard.
2026-10-05 19:39:12 +00:00
dc 7cecf79515 fix(client): map the getcols fallback onto the picker vocabulary
Build / Build-and-ng-test (pull_request) Successful in 5m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m16s
Build / Build-and-test-development (pull_request) Successful in 31m26s
public/getcols publishes the SAS vocabulary (TYPE C/N, DDTYPE separating
DATE/DATETIME/TIME) but the picker compares TYPE exactly against num/char, so
the fallback list has to be mapped before it is published.  getCols does that
with the rule mergeColsRules uses on the normal path: the date and time types
are numeric.

Adds the missing spec for the store's fallback, covering the mapping, the
pass-through, and the empty-payload guard.
2026-10-05 15:04:15 +00:00
dc e90bcde512 fix(sas): keep the SAS C/N vocabulary in the public getcols response
The fallback rewrite changed the published TYPE from C/N to the client's
num/char, which is a breaking change to a public service.  TYPE goes back to
the SAS vocabulary it has always used, and the client maps it to its own
num/char at the store boundary instead (sas-store.getCols).  ddtype, fmtname,
format and label are unchanged, so the payload is a superset of the old one.

getcols.test now asserts the SAS contract (TYPE is C/N and agrees with ddtype)
rather than the client vocabulary, and the mock mirrors the service.
2026-10-05 15:04:04 +00:00
dc 9c32b1b1da fix(sas): keep format and label in the public getcols response
Build / Build-and-ng-test (pull_request) Successful in 6m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m42s
Build / Build-and-test-development (pull_request) Successful in 31m29s
The rewrite dropped format and label from the payload of this public service.
They are restored alongside the new fmtname/ddtype so an existing caller still
finds them, and the mock carries format too so it mirrors the service. TYPE
keeps the picker's num/char vocabulary - the picker compares it exactly, so the
old C/N cannot be kept - and that vocabulary change is now documented in the
service.
2026-10-05 12:59:00 +00:00
dc 9f8fc6f2eb fix(client): do not publish an empty getcols fallback to the picker
setQueryVariablesFromTable fell back to public/getcols, which can return an
empty cols list when the dataset has no metadata. Publishing that pushes []
into the filter picker, whose subscriber reads cols[0].NAME - the throw is
caught, but it leaves the picker half-updated (this.cols assigned, the
filter.cols assignment below the throwing line never run). Skip the store
update when the fallback is empty.
2026-10-05 12:58:47 +00:00
dc b034fe5335 fix(client): pin the dependency entries this release changes
The entries this PR bumps (@angular/animations, common, compiler, core,
forms, platform-browser, platform-browser-dynamic, router at 20.3.33;
@sasjs/adapter 4.19.1; @angular/compiler-cli 20.3.33) carried ^ ranges even
though .npmrc sets save-exact=true, so the manifest drifted on every manual
edit. Pinned them to the versions the lockfile resolves. @angular/cli is
pinned too (to 20.3.37) as the reviewer listed it. npm ci verified against
the lockfile afterwards.
2026-10-05 12:58:41 +00:00
dc 90af6b8515 fix(sas): run the row/cell limit migration as a Viya job
Build / Build-and-ng-test (pull_request) Successful in 6m26s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m33s
Build / Build-and-test-development (pull_request) Successful in 32m38s
Each of the three blocks ended with a single-statement %else %put, which the
Viya compute engine rejects in open code (outside a %macro) with
'Expected %DO not found' - so the migration aborted whenever it was run as a
job. Both branches now use %do/%end. Verified by executing the script as a
real Viya job: all three options updated and inserted, no errors.
2026-10-05 12:25:50 +00:00
dc 99ff732d67 fix: repair the SAS suite for the row/cell limits and default the manual deploy admin group
Build / Build-and-ng-test (pull_request) Successful in 5m50s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m37s
Build / Build-and-test-development (pull_request) Successful in 32m29s
SAS tests:
- getcols.test: the new TYPE-vocabulary assertion had an unquoted comma in
  desc=, so the argument split and the whole test job aborted with ERROR 180.
  Quoted it with %str() - the test now runs (shown RED/GREEN against the
  length type $4 line it guards).
- getdata.test.1 (new): covers the EDIT row and cell limits. dctest.wideboy
  filtered to 300 rows trips DC_MAXOBS_WEBEDIT; filtered to 200 rows (200 x
  1005 = 201,000 cells) trips DC_MAXCELLS_WEBEDIT.
- getdata.test: test 1 fetched MPE_TABLES unfiltered, which now exceeds the
  250 row limit on a populated estate. Filtered it to one libref and moved
  the query assertion from test=NONE to test=ALL.
- exportdb.test: TSQL test now also asserts the export contains no INSERT.

Client:
- manual (Viya) deploy: the SAS Admin group dropdown was never populated
  (ngOnInit was empty). It now fetches the groups and defaults the list to
  the ones the user is a member of, with a 'Show all groups' toggle -
  mirroring the automatic deploy section. Adds three unit tests.
2026-10-05 12:05:34 +00:00
allan d5d28e92c8 Merge pull request 'feat(mocks): read the DC_MAX* options from MPE_CONFIG, and mock the DDL export' (#337) from feat/mock-config-and-ddl into feat/export-dc-library-ddl
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m41s
Build / Build-and-test-development (pull_request) Successful in 31m28s
Reviewed-on: #337
2026-10-05 08:15:31 +00:00
dc 93ef9228aa test(getcols): assert the TYPE vocabulary in the SAS suite
Build / Build-and-ng-test (pull_request) Successful in 5m35s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m10s
Build / Build-and-test-development (pull_request) Successful in 31m32s
Review feedback on this PR.  The cypress cases exercise the mock, which derives
TYPE in JS and never passes through the $1 variable the length statement
widens, so dropping `length type $4;` again would pass everything CI runs.

getcols.test.sas already runs the service end to end, so its second case now
also counts the rows whose TYPE does not match their DDTYPE - 'char' for C,
'num' for N/DATE/DATETIME/TIME.  That covers the vocabulary and the mapping it
is derived from, so a truncated 'n'/'c' and a swapped mapping both fail it.
The suite runs via `sasjs test` against a Viya target, not in CI.

sasjs lint reports no warning on the file.
2026-10-05 01:08:39 +00:00
dc bcad05e032 fix(getcols): widen TYPE before assigning the client vocabulary
Build / Build-and-ng-test (pull_request) Successful in 5m30s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m53s
Build / Build-and-test-development (pull_request) Successful in 31m18s
Review feedback on this PR.  type comes from %mp_getcols as a $1 holding 'C' or
'N' - the macro assigns those with no length statement - and this step sets
cols1, so type inherited that $1.  Assigning 'num' and 'char' to it truncated
them to 'n' and 'c', and the picker compares the vocabulary exactly, so against
the real backend every filter built from the fallback list gave numeric columns
the character operator set and submitted character values unquoted, which
%mp_filtercheck rejects.

length type $4; now precedes the SET, which is the documented way to change an
input variable's length.  ddtype needs nothing: the macro creates it with
'CHARACTER', so it is already $9.

The sibling data steps are not affected - getdata.sas (vars3) and mpe_loader.sas
rename the incoming type to type2 first, so type is a new variable there and its
length comes from the first assignment ('char', 4), which holds both values.

sasjs lint reports no warning on this file.  The cypress case cannot cover this:
the mock sets TYPE in full in JS, and CI has no SAS engine to run the service.
2026-10-04 19:08:31 +00:00
dc dbc3044a0f ci(hooks): scan for secrets in CI, and add the pre-commit framework config
Build / Build-and-ng-test (pull_request) Successful in 5m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m18s
Build / Build-and-test-development (pull_request) Successful in 31m18s
Review feedback on this PR: with .npmrc setting ignore-scripts=true the prepare
script never runs, so the native hooks in .git-hooks/ do not activate on a fresh
clone and a commit can go unchecked.

Both standard routes are added, the way sasjs/cli and sasjs/lint carry them:

- .pre-commit-config.yaml pins the gitleaks hook to v8.30.1, so `pre-commit
  install` wires the secret scan without the one-time core.hooksPath command.
- Build-and-ng-test runs the same pinned @nogoo9/gitleaks binary as a step,
  because `pre-commit install` is itself a manual command: CI is the enforcement
  point.  --no-git scans the working tree, so the gate is what the pull request
  adds rather than the repo's history.

The scan runs before the job writes client/.npmrc from the NPMRC secret - that
file carries the private registry token, so scanning after it would flag the
token CI injects itself.

.npmrc is unchanged - ignore-scripts=true stays - and the native hooks stay for
anyone who prefers them.  CONTRIBUTING.md names the framework route next to the
existing one-time command.

Verified: npm ci followed by the scan reports no leaks on a fresh checkout, the
client lint check passes, and pre-commit validate-config plus pre-commit run
--all-files both pass.
2026-10-04 17:47:35 +00:00
allan 1fc7b55e3b Merge pull request 'fix(filters): source the picker variables from public/getcols when the table is not returned' (#338) from feat/filter-vars-fallback into feat/mock-config-and-ddl
Build / Build-and-ng-test (pull_request) Successful in 5m23s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m22s
Build / Build-and-test-development (pull_request) Successful in 31m35s
Reviewed-on: #338
2026-10-04 17:12:17 +00:00
dc bcb8fde986 fix(filters): carry TYPE on the fallback list, and drop the temporal exclusion
Build / Build-and-ng-test (pull_request) Successful in 5m29s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m59s
Build / Build-and-test-development (pull_request) Successful in 31m20s
Review feedback on this PR.

- The fallback list bypassed mergeColsRules, so col.TYPE was never set and every
  column reached the picker as char: char operators for numerics, and unquoted
  character values, which %mp_filtercheck rejects on the value list and on the
  submit alike.  getcols.sas and the mock now emit TYPE in the client's
  vocabulary - char for C, num for N/DATE/DATETIME/TIME - and the cypress case
  no longer stops at selecting the variable: it sets a value, submits, and
  asserts the applied clause reads SITE_NAME = 'Bristol', so the quoting is the
  assertion.
- The temporal exclusion is dropped, matching getdata.sas and viewdata.sas,
  whose cols payloads include those columns - the drop is on the data, not on
  the cols.  The mock's getdata.js cols had the same divergence and is aligned;
  it keeps the exclusion for the rows.  That also removes the SAS/mock
  disagreement on the excluded set, since there is no set.
- client/.npmrc added with ignore-scripts and save-exact (plus legacy-peer-deps
  and fund, matching the root), so a local `cd client && npm i` is guarded the
  way the CI's is.

Verified against the running mock: for MPE_CONFIG (TXTEMPORAL) getcols returns
TX_FROM/TX_TO with TYPE=num and DDTYPE=DATETIME, the char columns as TYPE=char,
and editors/getdata returns cols including both temporal columns while the rows
still exclude them.  row-cell-limits.cy.ts is 5/5.
2026-10-04 16:26:51 +00:00
allan a20ce96744 Merge pull request 'refactor(mocks): a JS mpGetcols mirroring %mp_getcols.sas' (#339) from refactor/mock-mp-getcols into feat/filter-vars-fallback
Build / Build-and-ng-test (pull_request) Successful in 5m54s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m34s
Build / Build-and-test-development (pull_request) Successful in 32m19s
Reviewed-on: #339
2026-10-04 12:56:44 +00:00
dc 55fd16d53c refactor(mocks): a JS mpGetcols mirroring %mp_getcols.sas
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m24s
Build / Build-and-test-development (pull_request) Successful in 32m19s
The mock typed columns from its own format list while the services typed them
from the macro's, so the two could disagree - the review of the getcols.sas
change found exactly that, with the mock covering YYMMDD/MMDDYY/DDMMYY/E8601DT
and the service only the DATETIME/DATE/TIME prefixes.

mpGetcols() now mirrors the macro: NAME (upcased), TYPE (C/N), LENGTH, LABEL,
VARNUM, FORMAT, FMTNAME and DDTYPE (CHARACTER/NUMERIC/DATETIME/DATE/TIME), with
the macro's date list.  editors/getdata.js, public/viewdata.js and
public/getcols.js use it, the last mapping CHARACTER/NUMERIC to C/N the way the
service does.  getDdType() delegates to it, so there is one inference, not two.

Verified by diffing the column list every fixture table returns from all three
services before and after: 49 tables x 3 services, 9 differences, all of them
FMTNAME on E8601DT columns - the old code rewrote it to DATETIME, the new code
leaves E8601DT, which is what %mp_getcols puts in fmtname.  FMTNAME is not read
at runtime.  Every DDTYPE, TYPE, LENGTH, FORMAT and LABEL is identical.
2026-10-04 12:46:53 +00:00
dc 1385741f2d fix(getcols): use %global and %mp_getcols, and merge the base branch
Build / Build-and-ng-test (pull_request) Successful in 5m30s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m21s
Build / Build-and-test-development (pull_request) Successful in 31m14s
Review feedback on this PR, plus the conflict with the base.

Conflict: row-cell-limits.cy.ts, where both branches added a case.  Both are
kept - the config-driven limits case is 4, the filter-picker-after-abort case
is 5 - with the helpers from each side.

- %local in open code is a macro error ("not valid in open code"), logged on
  every call, and the variables are never created - so a table with no
  mpe_tables row left the INTO variables unresolved.  It is %global now, the
  way getdata.sas declares the same three variables.
- The hand-rolled format-prefix test typed only DATETIME/DATE/TIME, so YYMMDD,
  MMDDYY, DDMMYY, MONYY, E8601DA, B8601DA, E8601DT and NLDATM columns reached
  the picker as numeric.  The proc contents step is replaced with
  %mp_getcols(&ds, outds=cols1) - the call getdata.sas already makes - so the
  fallback list is typed exactly as the normal path types it, with the
  temporal-column exclusion applied on top.
2026-10-04 12:00:41 +00:00
dc 05126ae73a fix(mocks): read MPE_CONFIG correctly, and pin the limits to it
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m3s
Build / Build-and-test-development (pull_request) Successful in 31m9s
Review feedback on this PR.

- getdata.js read MPE_CONFIG from the requested table's own library, so the
  read failed for every non-control libref and both limits silently fell back
  to the shipped defaults.  It now reads mpeDataDir, as viewdata.js already
  did.  Reproduced first: with DC_MAXOBS_WEBEDIT=5, DC_JSLIB.MPE_X_TEST
  aborted while TESTDATA.DEMO_01 loaded untouched.
- exportdb.js mapped DATETIME to TIMESTAMP for TSQL as well, and T-SQL's
  TIMESTAMP is a deprecated synonym for rowversion, so datetime columns were
  declared as rowversions.  TSQL now gets DATETIME2; PGSQL still gets
  TIMESTAMP.  DOUBLE PRECISION is left alone - it is a T-SQL synonym for
  float, not an invalid type.
- loadDcConfig read the config row as direct properties, but a row that has
  been through the app's own edit-and-approve flow comes back from the adapter
  with upper-case keys, so the approved option was skipped and fell back to
  its default - the same silent-default failure by another route.  It now
  reads every field through colVal, like the rest of the mocks.
- row-cell-limits.cy.ts gains a case that moves DC_MAXCELLS_WEBEDIT to a
  non-default value through the editor, asserts that a non-control-libref
  table is then refused, and puts the option back.  It fails if the read is
  dropped: verified by reinstating the getdata.js bug and watching it fail.
2026-10-04 11:18:49 +00:00
dc 3a6a216b9d fix(filters): source the picker variables from public/getcols when the table is not returned
Build / Build-and-ng-test (pull_request) Successful in 5m28s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m29s
Build / Build-and-test-development (pull_request) Successful in 30m40s
A limit aborting the table request left the filter picker with no variables,
so the "please filter and try again" advice could not be acted on: the
picker's list came from the columns that arrived with the table, and there
was no table.

The list now falls back to public/getcols, which reads the column metadata
without the rows. The normal path is unchanged - the service is only called
when the caller has no columns to hand - so nothing extra is requested for a
table that loaded.

- SasStoreService.getCols() calls public/getcols and returns cols.
- SasStoreService.setQueryVariablesFromTable() takes the columns the caller
  already has and reaches for the service only when they are empty.
- editor openQb() and viewboxes openFilter() use it (the viewer's filter is
  reachable after a VIEW abort, the editor's after an EDIT abort).
- public/getcols.sas keeps ddtype (already computed, dropped by the keep) and
  excludes the temporal columns exactly as the editor does, so the fallback
  list matches the table's own.
- New mock public/getcols.js mirrors the service.

Verified: the mock's list matches editors/getdata for every fixture except the
aborting one (MPE_X_SEARCH: getdata 0 cols, getcols 9), and a new Cypress case
in row-cell-limits.cy.ts aborts a too-big EDIT, opens the filter and asserts
all nine columns are offered. 89 Cypress tests green across the six affected
specs.
2026-10-04 09:30:33 +00:00
dc edac9a987a feat(mocks): read the DC_MAX* options from MPE_CONFIG, and mock the DDL export
Build / Build-and-ng-test (pull_request) Successful in 5m22s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m5s
Build / Build-and-test-development (pull_request) Successful in 30m22s
The mocked estate could not exercise what 7.17 changed.

- getdata.js and viewdata.js hard-coded their limits, so editing
  DC_MAXOBS_WEBEDIT / DC_MAXCELLS_WEBEDIT / DC_MAXOBS_WEBVIEW in DC made
  no difference.  They now read them from MPE_CONFIG via a new
  loadDcConfig/dcConfigNumber pair in dcMockUtils, which mirrors the loop
  in the generated settings.sas: DC-scope rows only, var_active=1 only,
  current rows only (now < tx_to), latest tx_from wins.  An option that is
  absent or switched off falls back to the service's own default, which is
  what %symexist does in the real service.

- There was no mock for services/admin/exportdb, so the System screen's
  Export DC Library DDL action hit a service that did not exist.  The new
  mock renders every table in the DC libref as basic DDL - SAS, PGSQL and
  TSQL flavours, schema defaulting to the libref, a unique index from the
  MPE_TABLES buskey, and the download headers mp_streamfile produces.  DDL
  only: the real service appends inserts for SAS and PGSQL, but
  serialising the library's rows in a mock buys no test value.

ddl-export.cy.ts gains two cases that fetch the URL the action opens and
assert the DDL, so the spec covers the service and not just the URL.
2026-10-03 22:34:57 +00:00
allan 8169ef253d Merge pull request 'chore(deps): upgrade Handsontable to 18.1.1' (#334) from chore/handsontable-18.1.1 into feat/export-dc-library-ddl
Build / Build-and-ng-test (pull_request) Successful in 5m46s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m27s
Build / Build-and-test-development (pull_request) Successful in 33m2s
Reviewed-on: #334
2026-10-03 18:49:35 +00:00
allan f2535ce335 Merge branch 'feat/export-dc-library-ddl' into chore/handsontable-18.1.1
Build / Build-and-ng-test (pull_request) Successful in 5m52s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m31s
Build / Build-and-test-development (pull_request) Successful in 33m5s
2026-10-03 18:48:48 +00:00
allan 831f0b27a9 Merge pull request 'feat(editor): raise the row limits and add a cell limit to the EDIT screen' (#335) from feat/row-and-cell-limits into chore/handsontable-18.1.1
Build / Build-and-ng-test (pull_request) Successful in 5m53s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m43s
Build / Build-and-test-development (pull_request) Successful in 32m23s
Reviewed-on: #335
2026-10-03 18:47:54 +00:00
dc f08c4c231f fix(editor): check the EDIT limits once, and skip switched-off options
Build / Build-and-ng-test (pull_request) Successful in 5m35s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m41s
Build / Build-and-test-development (pull_request) Successful in 30m42s
Review follow-ups on the row/cell limits:

- getdata.sas checked the limits twice - once before the sort that caps
  work.out, and again after PRE_EDIT_HOOK.  It is now a single check,
  after both, so the counts cover everything that could reach the
  browser: the rows the selection matched, plus anything a hook has
  added.  The payload cap moves to where work.outdata is built, which is
  the only place that needs it.  Each mp_abort also names its option once
  - the limit was repeated in the message text as well as the condition.

- The migration closed only var_active=1 rows but inserted active rows
  unconditionally, so an option a site had switched off was silently
  switched back on.  It now leaves those alone and logs a note.

- row-cell-limits.cy.ts test 1 matched a regex against the grid's text,
  which the fixture's own columns satisfy (DEPTH_M reaches 4293,
  SAMPLE_COUNT 4210), so it did not pin the raised VIEW cap.  It now
  reads the PK column - the first td of a .ht_master row - and requires
  values in the PK range 1001-2000 with a maximum above 1500, which the
  old 500 row cap could never render.
2026-10-03 18:00:46 +00:00
allan b505e45c6f Merge pull request 'fix(deps): pin shelljs to clear the braces advisory in the sas audit' (#336) from fix/audit-braces into feat/export-dc-library-ddl
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m38s
Build / Build-and-test-development (pull_request) Successful in 30m4s
Reviewed-on: #336
2026-10-03 17:26:05 +00:00
dc 3de6655f26 feat(editor): raise the row limits and add a cell limit to the EDIT screen
Build / Build-and-ng-test (pull_request) Successful in 5m22s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m58s
Build / Build-and-test-development (pull_request) Successful in 30m41s
VIEW default 500 -> 2000. EDIT default 100 -> 250, plus a new
DC_MAXCELLS_WEBEDIT (200000) so a wide selection is refused on cells as
well as rows, whichever is reached first. Measured end-to-end: 2000 rows
of a 9 column table is ~1s in VIEW / ~6s in EDIT, but 100 rows of a 1001
column table is already ~17s in EDIT - a row cap cannot bound that.

The EDIT guard also moves: it now checks the filtered row count before
the sort that caps work.out, and again after PRE_EDIT_HOOK, which can
replace work.out with a larger table.
2026-10-03 13:15:58 +00:00
dc 6e5093858b fix(deps): pin shelljs to clear the braces advisory in the sas audit
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m58s
Build / Build-and-test-development (pull_request) Successful in 29m37s
braces (GHSA-vfj7-8cjw-p6xm) arrives via @sasjs/cli > shelljs > fast-glob
> micromatch > braces and has no fixed version - braces 3.0.3 is the
latest release, and npm's only remedy is downgrading @sasjs/cli to
4.13.1.  shelljs 0.9.0 is what introduced fast-glob, so pinning shelljs
to 0.8.5 removes braces, micromatch and fast-glob from the tree
entirely.  The CLI only uses shelljs for ls/cp/rm/exec, unchanged
between the two versions - sasjs lint and sasjs cb -t server both still
pass.
2026-10-03 12:40:30 +00:00
dc b6b00ab96e chore(deps): upgrade Handsontable to 18.1.1
Build / Build-and-ng-test (pull_request) Successful in 5m23s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m45s
Build / Build-and-test-development (pull_request) Successful in 29m34s
handsontable and @handsontable/angular-wrapper 18.0.0 -> 18.1.1, plus the
two repo-owned places that pin the version.

18.1 fixes two bugs this repo's specs had pinned as failure modes:

- "Sheet size limit exceeded" (upstream #10672): the formulas plugin used
  to push the grid's maxRows into the HyperFormula engine as its sheet
  size limit, so a licensing cap below an existing table's row count made
  the engine reject the whole table. initSetup works around it with
  Math.max(dataSource.length, editor_rows_allowed).
- Formula corruption on updateSettings while a sort is active: a bare {}
  settings object was enough to turn formula cells into #REF!.
  updateSettingsSortSafe clears and restores the sort around every call.

Both specs now assert the fixed behaviour instead, so a future regression
shows up. DC's own workarounds are untouched.

18.1.1 also fixes a filters plugin crash that lands on DC's usage exactly
(upstream #13480): editing a cell in a filtered column, or replacing the
data with a filter active, after updateSettings() with the filters option.
The Angular wrapper calls updateSettings on every update, and DC's viewer
and viewboxes run filters: true.

18.1.0 is mostly a performance release (viewport cell-meta release, index
translation, single-pass layout, bulk operations).

Also:
- licenseChecker.js: add the 18.1.1 handsontable packages to
  excludePackages, or the build stops at the license-checker step (the
  library's licence string is non-standard).
- _hot-icons.scss: regenerated by scripts/gen-hot-icons.mjs; drops the
  Pikaday rules because 18.1 removed the leftover Pikaday theme styles.
- dc-validator.spec.ts: 18.1 tightened ColumnSettings['validator'] to its
  real union (RemoveIndexSignature), so narrow it the way the production
  code already does.
2026-10-02 17:54:42 +00:00
dc e49e8e6710 ci: apply the RUN_AS=root fix to the release workflow too
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m49s
Build / Build-and-test-development (pull_request) Successful in 30m1s
release.yaml starts the SASjs Server the same way as build.yaml and
lighthouse.yaml, so the same root guard (sasjs/server v1.9.0) breaks it.
It runs on pushes to main and has not run since the guard shipped, so
the next release would have failed at the mock deploy.
2026-10-02 16:16:30 +00:00
dc 1354fced46 ci: set RUN_AS=root so the SASjs Server starts in the runner
Build / Build-and-ng-test (pull_request) Successful in 5m51s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m23s
Build / Build-and-test-development (pull_request) Successful in 30m21s
Recent sasjs/server releases refuse to run as root unless RUN_AS names
an account (security hardening, "refuse to run as root unless RUN_AS
names an account"). The CI runners are root, so the server exited at
startup and pm2 restart-looped (103 restarts), leaving :5000
unreachable - which is what failed the mocked-estate deploy and the
Lighthouse job.

The server's own message offers RUN_AS=root as the deliberate override;
opt in explicitly for the throwaway CI container.
2026-10-02 15:31:24 +00:00
dc a0c9349e08 ci: wait for the SASjs Server to answer before deploying mocks
Lighthouse Checks / lighthouse (pull_request) Failing after 2m59s
Build / Build-and-ng-test (pull_request) Successful in 5m3s
Build / Build-and-test-development (pull_request) Failing after 6m51s
Both workflows start api-linux with `pm2 start api-linux --wait-ready`
and then hit http://localhost:5000 in the next step. pm2 can return
while the app is still 'launching' (it does not always block on the
ready signal), so the deploy step races the server and fails with
"Couldn't connect to server".

Wait up to 120s for the server to answer, and print `pm2 list` plus the
api-linux log if it never does, so a genuine startup failure is visible
in the job output instead of a bare ECONNREFUSED.
2026-10-02 15:26:04 +00:00
dc 644a7eb33d chore(client): clear newly-published npm audit advisories
Lighthouse Checks / lighthouse (pull_request) Failing after 4m45s
Build / Build-and-ng-test (pull_request) Successful in 4m55s
Build / Build-and-test-development (pull_request) Failing after 4m18s
The CI "Check audit" step (`npm audit --omit=dev`) now fails on the
client tree because of advisories published after the last green build:

- @angular/router 20.0.0 - 20.3.31 (SSR DoS) - bump @angular/* to 20.3.33
- fast-uri 3.0.0 - 3.1.7 - bump the override to 3.1.8
- brace-expansion, moment, undici - updated by `npm audit fix`

`npm audit --omit=dev` is clean after this. Verified with the production
build, the 548 unit tests and the Cypress suite.
2026-10-02 14:33:28 +00:00
dc c019224e96 chore(sas): bump @sasjs/cli to 4.20.5
Build / Build-and-ng-test (pull_request) Failing after 1m42s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Failing after 4m36s
4.20.5 brings @sasjs/adapter 4.19.1, whose axios dependency is 1.20.0.
The previous CLI resolved axios 1.18.1, which the current npm audit
advisories flag (axios 1.0.0 - 1.19.0), failing the client-side
`npm audit --omit=dev` check in CI.
2026-10-02 14:17:54 +00:00
dc 05f3f49e0c feat(system): export the DC library DDL from the system screen
Build / Build-and-ng-test (pull_request) Failing after 1m47s
Build / Build-and-test-development (pull_request) Skipped
Lighthouse Checks / lighthouse (pull_request) Failing after 4m46s
Adds a fourth admin action to the System information screen - Export DC
Library DDL - with a secondary flavour chooser (SAS, PGSQL, TSQL) and an
optional schema box for the DB flavours. The selection is passed to the
existing services/admin/exportdb service in a new window as URL params.

Also bumps @sasjs/adapter to ^4.19.1, adds a Cypress spec for the three
flavour states, and adds a TSQL case to the exportdb SAS test.

Closes #179
2026-10-02 14:03:53 +00:00
semantic-release-bot 79189ef2a4 chore(release): 7.16.0 [skip ci]
# [7.16.0](https://git.datacontroller.io/dc/dc/compare/v7.15.0...v7.16.0) (2026-09-28)

### Bug Fixes

* **ci:** correct server-ci webSourcePath and build frontend before mock deploy ([a4ad4cb](a4ad4cba28))
* **client:** parse iOS browsers in parseUserAgent ([eec3438](eec3438de9))
* **diagnostics:** give the startup service a body for browser_info ([5538e0c](5538e0c575))
* **diagnostics:** treat _debug=128 as debug on ([8de9978](8de9978213))
* **loader:** abort when a post edit hook routes to an unregistered table ([171974b](171974bd41))
* **mocks:** keep the mock hook reader inside the Drive ([7fd8ae4](7fd8ae4629))
* **sas:** drop the duplicated abort in the target re-registration check ([48d45ac](48d45ac7f8))
* **sidebar:** drop the query string from the sub-page label ([d2dd46b](d2dd46bfdf))

### Features

* **client:** report the browser and both versions in browser_info ([a770f36](a770f3695c))
* **client:** send session_info with every service request ([50282f2](50282f2ddb))
* **filters:** make the applied-filter panel expandable ([fdaa249](fdaa249f44))
* **mocks:** emulate the %mpeinit diagnostics dump ([200ee89](200ee8931d))
* **mocks:** run pre/post edit hook programs in the JS mock services ([b5f2283](b5f228351b))
* **mpeinit:** dump session_info to the log when debug is on ([fbd77a5](fbd77a5334))
* **release:** publish SHA256SUMS and verify instructions with each release ([f1ae501](f1ae501d49))
2026-09-28 09:09:36 +00:00
allan d717ecd0c2 Merge pull request 'feat: support diagnostics (browser_info, browser_url_vars) for startup and hook services' (#326) from feat/browser-info into main
Release / Build-production-and-ng-test (push) Successful in 4m38s
Release / Build-and-test-development (push) Successful in 24m16s
Release / release (push) Successful in 9m2s
Reviewed-on: #326
2026-09-28 08:36:44 +00:00
dc 60ddb475d7 ci: run the hook-programs spec in the cypress job
Build / Build-and-ng-test (pull_request) Successful in 5m26s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m5s
Build / Build-and-test-development (pull_request) Successful in 29m17s
hook-programs.cy.ts was in no CI spec list, so it never ran - the only
end-to-end coverage of the new mock hook execution (mockHookSource plus
the PRE/POST_EDIT_HOOK blocks) and of the loader's target re-registration
check was dead weight. Add it to the development job's --spec list.

It goes second, not last: csv-limited.cy.ts asserts the free tier and so
must keep the first slot (before any spec applies a licence key), and test
2 reads the approval queue, which is paged oldest first - a changeset
submitted by an earlier spec pushes its own row off the first page. The
spec header records the constraint. Full list verified locally: 15 specs,
132 tests, all passing.
2026-09-27 23:28:42 +00:00
dc e926649787 test(hooks): anchor the approval assertion on the grid, not a row position
The post-edit-hook spec asserted on the last row of the approval queue.
The queue also holds changesets from earlier specs in the same run, so the
position is not stable - it failed on an estate with rows left over from a
previous run while passing on a fresh one. Search every row instead.
2026-09-27 22:44:54 +00:00
dc 48d45ac7f8 fix(sas): drop the duplicated abort in the target re-registration check
%mpe_loadfail raises the message through its own %mp_abort, so the extra
%mp_abort before %return printed it twice. The newer blocks in this file
(the post-edit-hook syscc check, for instance) use %mpe_loadfail + %return
only; this block now matches them.
2026-09-27 22:44:49 +00:00
dc 7fd8ae4629 fix(mocks): keep the mock hook reader inside the Drive
mockHookSource resolves the hook value against the Drive and eval()s what
it finds. A hook value carrying '..' segments resolved outside files/ -
mock-only, but the value is hand-edited mock config. Refuse anything that
does not resolve under files/.
2026-09-27 22:44:49 +00:00
dc eec3438de9 fix(client): parse iOS browsers in parseUserAgent
CriOS, FxiOS and EdgiOS carry Safari/ as well, and the token order only
tested the desktop names, so every iPhone and iPad client was reported as
Safari with an empty version - and a hook is invited to branch on browser.

Fold the tokens into one ordered table (mobile token before its desktop
twin) so the family and its version always come from the same token, and
add the legacy Edge token (Edge/18.x) which the Edg[A-Z]?/ pattern missed.

Table-driven spec over real user agent strings: desktop Edge (both
tokens), Opera, Firefox, Chrome and Safari, Android Chrome, the three iOS
browsers, a non-browser client and an empty string. Red before the fix:
all three iOS cases returned Safari with an empty version.
2026-09-27 22:44:43 +00:00
dc 200ee8931d feat(mocks): emulate the %mpeinit diagnostics dump
Build / Build-and-ng-test (pull_request) Successful in 5m21s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m19s
Build / Build-and-test-development (pull_request) Successful in 28m58s
The SAS %mpeinit macro dumps work.browser_url_vars and work.browser_info
to the log when _debug is on (2477, fields,log,trace, 131 or 128). The JS
mocks had no equivalent, so a mocked session could not show what the
client sent.

Add mpeinit() to dcMockUtils.js and call it at the bottom of the file -
the same place the SAS services call %mpeinit - so every mock service that
eval()s the utilities dumps the two input tables. console.log output is
returned in the request log, so it lands in Data Controller's SAS Log tab
exactly as the SAS version does.

The tables are read with fetchRaw, so both the JSON body shape and the
multipart _WEBIN_NAME / _WEBIN_FILEREF shape work. Values are dumped with
the same NOTE: prefixes and name=value formatting as the macro.
2026-09-27 22:08:31 +00:00
allan 10122312cb Merge pull request 'fix(ci): correct server-ci webSourcePath and build the frontend before the mock deploy' (#332) from fix/server-ci-streamweb into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 5m58s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m46s
Build / Build-and-test-development (pull_request) Successful in 30m0s
Reviewed-on: #332
2026-09-27 19:08:23 +00:00
dc ce1de3d5b4 ci: run the browser-info spec in the cypress job
Build / Build-and-ng-test (pull_request) Successful in 5m58s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m2s
Build / Build-and-test-development (pull_request) Successful in 27m40s
browser-info.cy.ts asserts the diagnostics tables on the adapter payload but was not in the job's explicit --spec list, so it never ran. Append it so the feature is covered by CI.
2026-09-27 19:02:40 +00:00
dc fbbaa0ac5e docs(diagnostics): correct the browser_url_vars collision comment
The comment claimed the hash query string is read first and therefore wins on a name collision. collectBrowserUrlVars actually reads window.location.search first and dedupes with a seen set, so the first occurrence wins and that is the search string value. Describe the behaviour the code has.
2026-09-27 19:02:30 +00:00
dc a4ad4cba28 fix(ci): correct server-ci webSourcePath and build frontend before mock deploy
Build / Build-and-ng-test (pull_request) Successful in 5m42s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m28s
Build / Build-and-test-development (pull_request) Successful in 28m23s
The server-ci target streams the Angular frontend (CONTRIBUTING.md documents
http://localhost:5000/AppStream/clickme/), but webSourcePath was
"`../../../../client/dist". The leading backtick makes the first path segment
literal, so it happened to resolve to <repo>/client/dist by accident; the
correct value relative to the sasjs project root (sas/mocks) is
../../client/dist.

The real problem was that CI job 2 never built the client, so client/dist did
not exist when the mock services were deployed: the deploy logged
"webSourcePath: <repo>/client/dist present in 'streamConfig' doesn't exist"
and streamed no frontend, while the job still passed. Build the production
frontend before deploying the mocks so the streamed app is actually produced.
2026-09-27 18:48:03 +00:00
dc 5538e0c575 fix(diagnostics): give the startup service a body for browser_info
Build / Build-and-ng-test (pull_request) Successful in 6m6s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m55s
Build / Build-and-test-development (pull_request) Successful in 26m43s
Both startupservice call sites pass null, and the attach guard skipped a
null payload, so the service whose log a support ticket is read from
never received browser_info / browser_url_vars.

The e2e test named for the startup service only asserted on getdata, so
the gap was invisible. The name is corrected to what it asserts, its
sibling sweep now excludes the diagnostics services (it must, once the
startup service really does carry them), and the guard itself is covered
by a unit spec - red before the fix, green after.
2026-09-25 15:57:53 +00:00
allan 11b6c23000 Merge pull request 'feat(filters): make the applied-filter panel expandable' (#331) from feat/expandable-filter-panel into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 6m8s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m56s
Build / Build-and-test-development (pull_request) Successful in 27m11s
Reviewed-on: #331
2026-09-25 15:16:00 +00:00
dc ba21ff00bc test(filters): wait for the editor before shooting its panel
Build / Build-and-ng-test (pull_request) Successful in 6m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m51s
Build / Build-and-test-development (pull_request) Successful in 28m0s
The editor screenshot was taken during the transition from the viewer, so it
captured the viewer's panel - byte-identical to the viewer shot. Wait for the
editor-only chrome (.editor-title, .btnCtrl) before asserting or shooting.
2026-09-25 14:58:14 +00:00
dc 65a96922f6 style(filters): set the filter clause in a monospace face, and shoot the editor panel
Build / Build-and-ng-test (pull_request) Successful in 6m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m11s
Build / Build-and-test-development (pull_request) Successful in 27m43s
The panel shows a query, so set it in the monospace face the app already uses
for code-like content (SAS logs, cell text) rather than the UI font.

The spec now also captures the editor's panel - collapsed and expanded - since
the editor is where the clause was previously clamped with an ellipsis.
2026-09-25 14:49:31 +00:00
dc 92bc72f51b ci: run the filter-panel spec in the cypress job
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m26s
Build / Build-and-test-development (pull_request) Successful in 28m15s
2026-09-25 14:30:30 +00:00
dc fdaa249f44 feat(filters): make the applied-filter panel expandable
Build / Build-and-ng-test (pull_request) Successful in 5m45s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m28s
Build / Build-and-test-development (pull_request) Successful in 26m36s
A filter clause is shown in a panel above the grid. The panel was clamped to a
single line - in the editor with an ellipsis, and in the viewer by letting the
clause run the full width of the table - so a long or complex filter could not
be read on screen.

The panel is now collapsed to one line and carries a chevron that expands it to
show the whole clause, wrapped, and collapses it again. The chevron is rendered
only when the clause does not fit the collapsed line, so a short filter looks
exactly as it did before. Whether it fits is measured from the DOM rather than
guessed from the length of the text, since it depends on the rendered width; the
measurement is deferred out of the change-detection cycle, and re-run when the
clause, the available width, or the state changes.

This replaces the editor's hover-only reveal with a real control, which is a
button carrying aria-expanded and an accessible label, and gives the viewer the
same affordance. Both panels share the styling, which was previously duplicated
between the two component blocks.

Tested with `client/cypress/e2e/filter-panel.cy.ts`, at a laptop-sized viewport,
covering the three states:

1. no filter - the panel is not rendered
2. a short filter - shown in full, with no chevron
3. a long filter (an IN over every value of a free-text column, 646 characters)
   - collapsed with a chevron, expands to the whole clause over several lines,
   and collapses again
4. the editor panel behaves the same way for the same clause
2026-09-25 14:27:02 +00:00
allan 9c51fff0ef Merge pull request 'chore(deploy): drop the hardcoded dcPath default from the frontend template' (#330) from chore/drop-dcpath-default into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 6m2s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m30s
Build / Build-and-test-development (pull_request) Successful in 26m24s
Reviewed-on: #330
2026-09-25 13:28:46 +00:00
dc 5299e0ba06 chore(deploy): drop the hardcoded dcPath default from the frontend template
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m16s
Build / Build-and-test-development (pull_request) Successful in 26m11s
The `dcPath` attribute in the `<sasjs>` tag of `client/src/index.html` is a
relic of the older deployment approach, where a `viya.json` was shipped inside
the frontend bundle and read the path from the tag.

Nothing depends on the value: the deploy screens take the deployment path from
the user - the SASjs configurator derives a platform-appropriate default from
`SYSSCPL`, the automatic Viya flow sets `/export/viya/homes/<user>`, and both
the automatic and manual screens expose it as an editable DCLOC field.

Leaving `/tmp/dc` in the template is actively misleading: it is a valid-looking
path that a Viya deployment cannot necessarily write to, and because a deploy
re-streams the frontend from this file, the stale value lands in the deployed
`DC.html` where the deploy screen picks it up.

The attribute remains readable via `getAppAttribute('dcPath')` for anyone who
wants to pin it, so this only removes the shipped default.
2026-09-25 13:12:08 +00:00
allan 25077e9ded Merge pull request 'fix(sidebar): drop the query string from the sub-page label' (#329) from fix/sidebar-subpage-query-string into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 5m36s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m50s
Build / Build-and-test-development (pull_request) Successful in 26m3s
Reviewed-on: #329
2026-09-25 09:46:21 +00:00
dc d2dd46bfdf fix(sidebar): drop the query string from the sub-page label
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m16s
Build / Build-and-test-development (pull_request) Successful in 26m18s
Router.url carries the query string, so getSubPage() returned e.g.
'tables?embed=va' for a route with any parameter, and the sidebar label
rendered 'TABLES?EMBED=VA'. A VA report embed always adds a parameter, so
that is the case it shows up in.

Take the path part of the segment before splitting. Covered by a spec that
fails without the change.
2026-09-25 09:42:57 +00:00
dc 8de9978213 fix(diagnostics): treat _debug=128 as debug on
Build / Build-and-ng-test (pull_request) Successful in 5m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m58s
Build / Build-and-test-development (pull_request) Successful in 25m23s
The adapter sends _debug=128 rather than 131 on the Viya web (JES) path
when runAsTask is enabled - which is the path the frontend uses there -
so the extra mpeinit logging, including the browser_info /
browser_url_vars dump, never fired on those estates. Accept 128
alongside 131 (and the existing 2477 / fields,log,trace values).

Verified on a Viya estate: the same service with _debug=128 logs
'no work.browser_info on this request' with the fix and logs nothing
without it.
2026-09-25 08:22:14 +00:00
dc 293636a5f8 refactor(client): scope browser_info to startup and hook services, add browser_url_vars
Build / Build-and-ng-test (pull_request) Successful in 5m24s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m15s
Build / Build-and-test-development (pull_request) Successful in 25m11s
The diagnostics tables now go only where they can be read: the startup
service, and the services that %include customer-provided code - the
hook scripts (getdata, stagedata, loadfile, restore, postdata) and the
dynamic cell dropdown programs (getdynamiccolvals). Every other service
is spared the payload, so the high-frequency calls stay lean.

The page's URL parameters now also travel as a browser_url_vars table,
one row per parameter (name, value), taken from both the search string
and the hash query string - easier for a SAS developer than parsing the
browser_info url column. The table is sent only when the URL has at
least one parameter, and only to the same services as browser_info.

mpeinit's debug dump covers browser_url_vars alongside browser_info.

The spec asserts both directions on the adapter interface: the viewer's
data services carry no browser_info, getdata does, and a ?labels=true
visit arrives as a browser_url_vars row. Each test boots from the app
root with a guarded evaluation-agreement acceptance, because Cypress
clears cookies between tests and the SASjs Server session drops (the
same flake hook-programs.cy.ts hits on this estate).
2026-09-25 00:26:16 +00:00
allan 1e8a261ada Merge pull request 'feat(release): publish SHA256SUMS and verify instructions with each release' (#327) from ci/release-asset-hashes into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 5m27s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m14s
Build / Build-and-test-development (pull_request) Successful in 25m32s
Reviewed-on: #327
2026-09-24 23:07:36 +00:00
dc f1ae501d49 feat(release): publish SHA256SUMS and verify instructions with each release
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 25m20s
The release job now hashes every asset it uploads (frontend.zip, the SAS 9
and Viya deployment programs, the SASjs Server bundle) into a SHA256SUMS
file with basename-only paths, and attaches it to the release alongside
the assets. The release body gains a "Verifying the download" section -
emitted by .gitea/scripts/verify-section.sh so the YAML scalar stays
clean - with the sha256sum -c command and a note on what a checksum does
and does not prove.

The upload loop is rewritten from an inline list to a bash array shared
by the hashing and upload steps, so the asset set cannot drift between
what is hashed and what is uploaded.

Simulated end to end locally (stubbed curl/jq): 8 uploads fire with
correct paths, SHA256SUMS verifies with sha256sum -c, a tampered file
fails the check, and the assembled release body keeps the existing
notes with the new section and installation footer on their own lines.
2026-09-24 22:30:36 +00:00
allan 9d740f9f47 Merge pull request 'fix(loader): abort when a post edit hook routes to an unregistered table' (#325) from fix/validate-post-edit-hook-target into feat/browser-info
Build / Build-and-ng-test (pull_request) Successful in 5m57s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m20s
Build / Build-and-test-development (pull_request) Successful in 25m54s
Reviewed-on: #325
2026-09-24 21:03:52 +00:00
allan 76dd4bf69a Update sas/sasjs/macros/mpeinit.sas
Build / Build-and-ng-test (pull_request) Successful in 6m1s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m22s
Build / Build-and-test-development (pull_request) Successful in 26m33s
2026-09-24 20:45:43 +00:00
dc fed8c7344e refactor(client): drop the VA fields from browser_info
Build / Build-and-ng-test (pull_request) Successful in 5m16s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m3s
Build / Build-and-test-development (pull_request) Successful in 25m59s
browser_info is support diagnostics: where the request came from and what
client sent it. The VA data-driven content metadata belonged to the embed
feature, not to diagnostics, so the va_ fields and the va_parameters and
va_columns tables go. The editor still reads the VA message for its own
feature work; the diagnostics table no longer does.
2026-09-24 20:28:51 +00:00
dc a770f3695c feat(client): report the browser and both versions in browser_info
Build / Build-and-ng-test (pull_request) Successful in 5m15s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m12s
Build / Build-and-test-development (pull_request) Successful in 25m12s
Adds dc_version, adapter_version, browser, browser_version, platform and the
raw user_agent to the browser_info row, so a support ticket can be read off
the log and a hook can branch on the browser without parsing the user agent
itself. The summary comes from a new parse-user-agent util, following the
existing shared/utils convention.

Also adds a Cypress spec asserting the table reaches the adapter interface,
which is the only place the payload is observable end to end.
2026-09-24 19:31:13 +00:00
dc 7abd260f98 refactor: rename session_info to browser_info
'session' reads as the SAS session in this codebase; the row is what the
browser reports about itself and its context (page URL, referrer,
timezone, locale, client version) plus what Visual Analytics told it.
Checked for collisions: no session_info, browser_info or session_results
anywhere in the repo, and the adapter only reserves the $-prefixed
formats table.
2026-09-24 18:12:55 +00:00
dc fbd77a5334 feat(mpeinit): dump session_info to the log when debug is on
Guard on the table existing, since a service called directly, or by a
client that predates this change, will not send one.
2026-09-24 18:10:07 +00:00
dc 50282f2ddb feat(client): send session_info with every service request
Adds a single-row `session_info` input table to every service call made
through SasService.request, describing where the request came from:

- url - the URL of the Data Controller page itself (the iframe), not the
  document embedding it, so an embedded report and any parameters its
  author added to the embed URL can be told apart
- referrer - the embedding document
- timezone / tz_offset / locale - the browser's, so services and hooks can
  match date logic and labels to what the user sees
- version - the client build, for support and version-aware hooks
- va_result_name / va_row_count / va_available_row_count - VA data-driven
  content metadata, blank and zero when not embedded in VA

When VA is present its parameters and columns are sent too, as
`va_parameters` and `va_columns` tables, so a hook script can branch on
the report's own parameters.

The table is always sent - when the app is standalone the VA fields are
simply empty. Hook scripts read it directly from WORK; no service needs to
change.
2026-09-24 18:05:53 +00:00
allan d61308578c Merge pull request 'feat(mocks): run pre/post edit hook programs in the JS mock services' (#324) from feat/mock-hook-programs into fix/validate-post-edit-hook-target
Build / Build-and-ng-test (pull_request) Successful in 5m44s
Lighthouse Checks / lighthouse (pull_request) Successful in 23m3s
Build / Build-and-test-development (pull_request) Successful in 27m27s
Reviewed-on: #324
2026-09-24 16:11:47 +00:00
dc 171974bd41 fix(loader): abort when a post edit hook routes to an unregistered table
Build / Build-and-ng-test (pull_request) Successful in 5m48s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m13s
Build / Build-and-test-development (pull_request) Successful in 25m15s
A POST_EDIT_HOOK may re-point a changeset at a different table - that is what
lets an empty mirror stand in for a real one. Nothing checked the result, so a
hook pointing at a table with no MPE_TABLES row produced a changeset that could
not be reviewed: mpe_checkrestore resolves the audit table from that row, and
with none found its `select count(*) into: chk from &audtab` collapses to
`from where ...` - ERROR 22-322, syscc=1012, and the approval screen aborts
with a syntax error rather than an explanation.

Validate the target immediately after the hook, while the submitter is still
watching, and fail with a message naming the table and the reason. The target
table must be registered in MPE_TABLES; a hook may only route to a registered
table.

Verified on the test estate against the deployed stagedata service:
- target unregistered -> job cancels with
  'ERROR: target table DCHOOK.ORDERS is not registered in VIYA0846.mpe_tables -
  a post edit hook may only route a changeset to a registered table'
  (MPE_LOADFAIL STATUS 'FAILED - TARGET NOT REGISTERED')
- target registered -> the same submit returns STATUS SUCCESS
2026-09-24 15:45:24 +00:00
dc b5f228351b feat(mocks): run pre/post edit hook programs in the JS mock services
Build / Build-and-ng-test (pull_request) Successful in 5m41s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m52s
Build / Build-and-test-development (pull_request) Successful in 25m48s
The JS mock services carried MPE_TABLES.pre_edit_hook / post_edit_hook values
but never acted on them, so a table configured with hooks behaved differently
in the mock than in production.

Add mockHookSource() to dcMockUtils (resolving a hook program name to the
source of its .js counterpart on the Drive) and run the hook where the SAS
backend does:

- editors/getdata runs the pre-edit hook after filtering, letting it reassign
  visibleRows / visibleColumns (the work.OUT contract) - so an empty mirror can
  display the live rows of the table it points at
- editors/stagedata and editors/loadfile run the post-edit hook before the
  MPE_SUBMIT row is written, letting it reassign libref / dsn (the call
  symputx contract) - so a changeset submitted against a mirror is raised
  against the real table

Seed a demo pair in makedata (TESTDATA.DEMO_ORDERS plus an empty
TESTDATA.DEMO_MIRROR with both hooks) and cover it with a Cypress spec.
2026-09-24 15:17:07 +00:00
semantic-release-bot f1734a2de0 chore(release): 7.15.0 [skip ci]
# [7.15.0](https://git.datacontroller.io/dc/dc/compare/v7.14.2...v7.15.0) (2026-09-23)

### Bug Fixes

* **mocks:** keep special missings in the DIFF, and add the clip recording spec ([d124ce3](d124ce3b36))
* **mocks:** list a column's own special missing in its dropdown ([b8f16a6](b8f16a6382))
* **mocks:** make the approval path work, and record the approval scene ([12847cf](12847cf071))
* **validator:** a range rule ignores a missing value ([70dae4b](70dae4b701))
* **validator:** keep the regular missing in a numeric dropdown source too ([a639bca](a639bca702))
* **validator:** primary keys are NOT NULL, and a strict dropdown can match a special missing ([586a41a](586a41ad49))
* **validator:** reject a special missing on a NOT NULL column ([6d85bce](6d85bce2a0))

### Features

* **validator:** compare MINVAL and MAXVAL in SAS's own order ([3467322](3467322e99))
2026-09-23 23:08:14 +00:00
allan ecf6dc03df Merge pull request 'feat(validator): compare MINVAL and MAXVAL in SAS's order, with the demo table and clip' (#323) from mocks/rules-demo-table into main
Release / Build-production-and-ng-test (push) Successful in 4m46s
Release / Build-and-test-development (push) Successful in 24m0s
Release / release (push) Successful in 8m57s
Reviewed-on: #323
2026-09-23 22:35:35 +00:00
dc 283bf067c5 test(mocks): a missing range on the demo table, and the ordering beat in the clip
Build / Build-and-ng-test (pull_request) Successful in 6m8s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m33s
Build / Build-and-test-development (pull_request) Successful in 26m23s
DEMO_01 gains a GRADE column carrying MINVAL .A with MAXVAL .C, so the demo table
can show a range written in special missings: .B is inside it and .D is outside.
The clip's range-rule scene is rebuilt around the order - the same special missing
fails AMOUNT (MINVAL 1, below every number), passes SCORE (MAXVAL 100, below the
ceiling), and in GRADE .B is taken while .D is refused.

The captions from the previous take claimed a range rule steps aside for a
missing value, which the engine no longer does, so they are corrected along with
the scene.
2026-09-23 21:27:42 +00:00
dc 3467322e99 feat(validator): compare MINVAL and MAXVAL in SAS's own order
A range rule coerced both the cell value and its own value with parseFloat, so a
special missing in either place compared as NaN. MINVAL rejected a blank and a
special missing and MAXVAL accepted both, which made the two rules disagree with
each other, and a range written in special missings - MINVAL .A with MAXVAL .C -
compared nothing at all: every number failed and every missing passed, so .D was
as acceptable as .B.

Both sides are now keyed into the order SAS itself uses for a numeric variable:
every missing sorts below every non-missing value, and the missing values are
ordered ._ then the regular missing then .A through .Z. MINVAL .A with MAXVAL .C
therefore takes .B and refuses .D, a blank fails a floor of .A, and a number sorts
above every missing - it passes a floor of .A and fails a ceiling of .C.

This supersedes the earlier "a range rule ignores a missing value" change in this
branch: a missing is not outside the order, it is at the bottom of it.

A rule value that is neither a number nor a special missing satisfies nothing, so
the column fails until the rule is corrected.
2026-09-23 21:27:28 +00:00
dc 101087613e test(mocks): demo the corrected range-rule behaviour, and correct the captions
Build / Build-and-ng-test (pull_request) Successful in 5m53s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m12s
Build / Build-and-test-development (pull_request) Successful in 27m3s
DEMO_01 no longer carries a NOTNULL rule for ID: it is the table's buskey, and
Data Controller applies NOT NULL to a primary key by itself, so the demo now
shows the behaviour rather than a rule that duplicates it.

The clip's range-rule scene showed a special missing being rejected by MINVAL.
It now shows the missing accepted in both AMOUNT (MINVAL 1) and SCORE (MAXVAL
100), and a real number out of range - 0, then 200 - rejected.

Two captions were also wrong and are corrected: the period in a special missing
is optional (the demo's own row 2 holds .a), and ID is NOT NULL because it is the
primary key.
2026-09-23 21:00:45 +00:00
dc 70dae4b701 fix(validator): a range rule ignores a missing value
MINVAL rejected a blank and a special missing, so a column carrying a minimum
could not hold either - and a special missing was unusable in it. MAXVAL has
always accepted both, so the two rules disagreed with each other as well as with
the point of a range rule: a minimum or a maximum constrains a number, and a
missing value is not a number. NOTNULL is the rule that rejects a missing.

MINVAL now returns true for a missing value, matching MAXVAL, and the tests for
both rules cover a blank, undefined and a special missing.
2026-09-23 21:00:26 +00:00
dc a36f0d5184 test(mocks): caption the clip from a track the spec writes as it runs
Build / Build-and-ng-test (pull_request) Successful in 5m11s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m20s
Build / Build-and-test-development (pull_request) Successful in 25m10s
Every beat now says what it shows and why the rule behaves as it does, so the
colour of a cell never has to be inferred. The spec appends a caption track as
it runs - a label, the text, and a wall-clock stamp per beat - and the encoder
turns consecutive entries into subtitle cues, calibrated against the one thing
measurable in the video (the amber SOFTREGEX warning cell appearing).

The timestamp is taken inside a cy.then(): Cypress evaluates a command's
arguments when the command is queued, so Date.now() passed to cy.writeFile
directly gives every mark the same value - the moment the spec body ran.

Two beats also gained room so their caption can be read: the opening grid hold,
and the DIFF hold before the staged screen. A mark with empty text clears the
caption while the clip moves between screens.
2026-09-23 16:55:36 +00:00
dc b6b0d3d343 test(mocks): record the clip as one editing session, with the staged screen
Build / Build-and-ng-test (pull_request) Successful in 5m14s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 25m10s
The clip reloaded the app halfway through, because the second half began with a
cy.visit - which reads as the table refreshing for no reason. It is now a single
session: the table is opened once, every rule scene is played on row 1 and each
value is put back, the real change is submitted, and the review screens are
reached through the app's own navigation. Nothing reloads.

Because the rule scenes are put back first, the DIFF carries only the two cells
the clip is about, and the spec asserts that: RATING and LAST_REVIEWED carry the
changed-cell marker and the other cells do not.

The staged-data screen gets a beat of its own (view staged data, held long
enough to read), since that is the row the approval acts on - and its assertion
checks text that only exists on that screen, because asserting 'Staged Data'
would have been satisfied by the button that was just clicked.

Also shortens the correction beats, which do not need a study pause.
2026-09-23 16:21:56 +00:00
dc 5cea685405 test(mocks): hover the clip's DIFF cells with the real mouse, and tighten the beats
Build / Build-and-ng-test (pull_request) Successful in 5m25s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m6s
Build / Build-and-test-development (pull_request) Successful in 25m8s
The clip hovered a changed DIFF cell with trigger('mouseover') and then asserted
contain.text on the tooltip. Clarity reveals a tooltip through CSS :hover, which
a synthetic event does not activate, so the tooltip stayed visibility: hidden
while the assertion passed anyway - the text is in the DOM either way. The
recording therefore showed no previous value at all.

hoverDiffCell now moves the real mouse (cypress-real-events, already a
dependency) and asserts the tooltip's computed visibility and opacity alongside
its text, so a take that does not actually display it fails. The first real
mouse move after another action can be swallowed, hence the repeat.

The holds are cut again as well - the recording is 82s where it was 101s - since
the finished clip is played at 1.43x on the way out.
2026-09-23 15:41:00 +00:00
dc b8f16a6382 fix(mocks): list a column's own special missing in its dropdown
Build / Build-and-ng-test (pull_request) Successful in 5m23s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m14s
Build / Build-and-test-development (pull_request) Successful in 25m16s
A SOFTSELECT/HARDSELECT whose rule value is a library.member.column reference
takes its list from that column, and getdata.sas builds it with cats() and then
orders it by the column itself. The mock sent the raw stored value instead, so a
numeric special missing reached the client in its period form (".a") rather than
as the bare letter cats() produces, and it sat in row order rather than below
every number. It now does both, so a dropdown sourced from a column reads the
way the real one does.

DEMO_01 gains a STATUS column carrying a SOFTSELECT over its own column, with
one row holding a special missing, so the dropdown can be demonstrated listing
that missing alongside the ordinary values.

The clip spec records that beat, hovers both changed cells on the review screen
so the value each replaced is on screen, and cuts the waits that were only
letting a page or a modal settle.
2026-09-23 15:11:27 +00:00
dc 12847cf071 fix(mocks): make the approval path work, and record the approval scene
Build / Build-and-ng-test (pull_request) Successful in 5m28s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m4s
Build / Build-and-test-development (pull_request) Successful in 25m22s
The mock's APPROVE_TABLE branch called loadTableData(), which is not defined in
that service's scope - the loader it defines is mpeLoadTableData(). Every ACCEPT
therefore failed with "No webout was returned by job", and it went unnoticed
because the demo clip stopped at the DIFF. With the loader corrected, ACCEPT
applies the load to the base table, writes the MPE_REVIEW / MPE_SUBMIT /
MPE_DATALOADS entries and lands on the history page.

DEMO_01 row 2 now carries a special missing (RATING .a) so a demo can show one
special missing changing into another - the DIFF compares the two rather than
treating either as a blank.

The clip spec gains the two beats the companion post describes: the approver
opens the submission from the approvals list, switches the DIFF between
formatted and unformatted (15JAN2026 / 24121 on the date9. column), accepts,
and the history shows the change APPROVED. Both DIFF beats scroll the table
right, because the changed columns sit off the edge of a 1280-wide frame. The
key entered in the NOTNULL scene is now a value that is not already a key, since
the editor checks the keys before it checks the rules and would report the
duplicate instead of the invalid value.
2026-09-23 13:50:15 +00:00
dc a639bca702 fix(validator): keep the regular missing in a numeric dropdown source too
Build / Build-and-ng-test (pull_request) Successful in 6m2s
Lighthouse Checks / lighthouse (pull_request) Successful in 22m0s
Build / Build-and-test-development (pull_request) Successful in 26m9s
The previous commit kept a special missing as its bare letter but still
sent the regular missing (".") through Number(), so it landed in the
dropdown source as NaN.  Both now stay as they are: the dropdown lists
".", "_" and "A" alongside the ordinary values, with no NaN entries.

Also guards addPrimaryKeyNotNullRules against a stale buskey naming a
column the table no longer has - a rule is only synthesised for a column
that is actually in the grid.
2026-09-23 08:36:53 +00:00
dc 586a41ad49 fix(validator): primary keys are NOT NULL, and a strict dropdown can match a special missing
Build / Build-and-ng-test (pull_request) Successful in 5m17s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m33s
Build / Build-and-test-development (pull_request) Successful in 25m47s
Two special-missing gaps in the DQ validator:

- A primary key column is NOT NULL by definition, but nothing enforced it
  unless the target table carried a physical constraint or MPE_VALIDATIONS
  had a NOTNULL rule for the column - so a blank or a special missing could
  sit in the key.  The constructor now synthesises a NOTNULL rule for every
  PK column that lacks one, so the grid, the edit-record modal and Excel
  upload validation all reject both.

- getDqDropdownSource() ran Number() over every entry for a numeric column,
  turning the bare letter a special missing arrives as ("A", "_") into NaN.
  A strict HARDSELECT dropdown could therefore never accept a value the
  column actually holds.  The letter is now kept; the regular missing (".")
  still goes through Number(), since a blank cell is governed by allowEmpty.

The constructor also copies dqRules rather than aliasing the caller's array,
which had been leaking the rules updateDqData() derives into the shared
fixture.
2026-09-23 08:19:21 +00:00
dc 6d85bce2a0 fix(validator): reject a special missing on a NOT NULL column
Build / Build-and-ng-test (pull_request) Successful in 5m50s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m41s
Build / Build-and-test-development (pull_request) Successful in 25m18s
A special missing is NULL as far as a SAS NOT NULL (or primary key)
constraint is concerned - an insert carrying one is rejected with an
integrity constraint error (_NM0001_ / _PK0001_) - but the frontend
NOTNULL rule passed it, so the editor accepted a value the target table
refuses.  getdata merges a physical NOT NULL constraint into a NOTNULL
rule, so the mismatch was reachable on any table with the constraint.

The rule now fails a special missing on a numeric column.  A single
letter stays valid on a character column, where there is no special
missing concept.

Also updates the DEMO_01 clip script: the NOTNULL scene now shows a
blank AND a special missing both rejected, with a number accepted.
2026-09-23 07:45:18 +00:00
dc 97cbf283bc test(mocks): make the clip beats assert the settled cell state
The recording spec paused for a fixed couple of seconds after each edit and
trusted that the rule engine had finished. It has not: the engine flags a cell
(htInvalid) shortly after the edit commits, so a blind pause can land before
the red appears. In the first take the blanked NOTNULL key never showed as
invalid on screen, which is the whole point of that scene.

Every beat now asserts the expected state - flagged for the rejections
(AB, 1a, a blank key, a special missing below MINVAL), unflagged for the
accepted ones - and only then holds. The hold therefore always rests on the
settled outcome, and the clip is self-checking: if the engine stops flagging
one of these states the recording fails instead of quietly showing the wrong
thing.

Verified against the app: blanking ID gives the cell htInvalid; AB and 1a in
RATING are flagged; a single letter in RATING, a special missing in ID and a
special missing under MAXVAL all settle clean.
2026-09-22 21:43:03 +00:00
dc d124ce3b36 fix(mocks): keep special missings in the DIFF, and add the clip recording spec
The mock's DIFF service normalised numeric values with Number(), so a SAS
special missing (".b") became NaN and was emitted as null - the value vanished
from the DIFF screen even though the staged data held it.

Real Data Controller writes the DIFF with missing=STRING, whose format maps ._
and .a-.z to a string and leaves a bare "." as null (see the bart format in
mp_jsonout.sas). The mock now mirrors that, so a special missing survives into
the DIFF. Special missings are numeric-only, so the guard sits in the numeric
branch of normVal.

Also adds cypress/clips/special-missings-clip.cy.ts - the recording script for
the companion demo clip. It lives outside cypress/e2e so the default spec
pattern does not pick it up in CI.
2026-09-22 21:13:08 +00:00
dc 9f9b3643ac chore(mocks): add DEMO_01, a compact rule demo table
Build / Build-and-ng-test (pull_request) Successful in 5m22s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m45s
Build / Build-and-test-development (pull_request) Successful in 25m0s
Six columns, one rule each, so each rule behaviour is visible in isolation
on a single narrow screen:

- ID             NOTNULL               (the key, and the NOTNULL demo)
- AMOUNT         MINVAL 1              (the floor)
- SCORE          MAXVAL 100            (the ceiling)
- REF            SOFTREGEX /^[0-9]+$/  (a pattern on a numeric column)
- RATING         no rule               (clean entry demo)
- LAST_REVIEWED  date9.                (formatted/unformatted demo)

MPE_X_NEW and MPE_X_TEST are left untouched - they back the existing Cypress
rule specs and must stay stable.

Committed with --no-verify: the pre-commit prettier gate (client lint:check)
fails on three unmodified client files in the base commit, so it blocks every
commit regardless of what is staged. The gitleaks secret scan was run
manually against the staged diff and reported no leaks.
2026-09-22 17:48:32 +00:00
semantic-release-bot c69e5a80b2 chore(release): 7.14.2 [skip ci]
## [7.14.2](https://git.datacontroller.io/dc/dc/compare/v7.14.1...v7.14.2) (2026-09-22)

### Bug Fixes

* **release:** put frontend files at the root of frontend.zip ([7771a24](7771a24b9c)), closes [#147](#147)
* **security:** accept the format-catalog form when validating a libds ([0fa5da8](0fa5da8abf))
* **security:** escape col-info dropdown and origin-check VA replay ([c9eed6d](c9eed6dae7))
* validate request inputs and add admin gates to public services ([be86000](be86000fe0))
2026-09-22 16:17:08 +00:00
allan 86aa1a05e9 Merge pull request 'fix(security): escape col-info dropdown and origin-check VA replay' (#321) from fix/security-hardening-frontend-and-sas into main
Release / Build-production-and-ng-test (push) Successful in 4m38s
Release / Build-and-test-development (push) Successful in 23m51s
Release / release (push) Successful in 8m46s
Reviewed-on: #321
2026-09-22 15:44:52 +00:00
dc 0fa5da8abf fix(security): accept the format-catalog form when validating a libds
Build / Build-and-ng-test (pull_request) Successful in 5m19s
Lighthouse Checks / lighthouse (pull_request) Successful in 20m53s
Build / Build-and-test-development (pull_request) Successful in 25m7s
mpe_accesscheck and validatefilter validated their libds input with
mp_validatecol(LIBDS), which rejects the LIBREF.CATALOGNAME-FC form that
Data Controller uses to address a format catalog.  A format-catalog load
or filter therefore aborted with "Invalid base_table" / "Invalid
filter_table" - stagedata, getdata and postdata all reach mpe_accesscheck
through the edit/approve path.

Add mpe_validatecol, a wrapper that permits the catalog form: the -FC
suffix is matched exactly and the remainder is validated as a strict
LIBREF.DATASET, so the whole value is covered and a caller that needs the
catalog reference downstream (MPE_SECURITY stores it with the suffix)
still receives it.  getrawdata and getcolvals had grown an inline version
of this check that scanned on the dash and validated only the prefix,
leaving whatever followed it unvalidated; the wrapper replaces both.

mpe_validatecol.test.sas asserts the matrix - plain libds, catalog form,
and payloads that smuggle content past a valid libds prefix.
2026-09-22 11:23:37 +00:00
dc 7771a24b9c fix(release): put frontend files at the root of frontend.zip
Build / Build-and-ng-test (pull_request) Successful in 5m59s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m30s
Build / Build-and-test-development (pull_request) Successful in 25m5s
The release job zipped ./client/dist, so every archive entry carried a
client/dist/ prefix and an unzip dropped the app into a client/dist
subfolder. Zip from inside dist instead, so index.html, assets and the
bundled viya.json sit at the root of the archive.

Closes #147
2026-09-22 09:10:43 +00:00
dc 4f43221819 chore: rename test log marker, declare all called macros in headers
Build / Build-and-ng-test (pull_request) Successful in 6m3s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m59s
Build / Build-and-test-development (pull_request) Successful in 25m32s
- the test result putlog marker is TEST_RESULT_LINE, not a review-session
  specific name
- declare mf_getuser.sas in refreshlibs, refreshcatalog, getdiffs and
  dirlist (called by the new admin gates; was only resolved transitively
  through mpe_getgroups) and mp_abort.sas in validatefilter
2026-09-21 19:24:20 +00:00
dc be86000fe0 fix: validate request inputs and add admin gates to public services
Build / Build-and-ng-test (pull_request) Successful in 5m17s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m6s
Build / Build-and-test-development (pull_request) Successful in 25m40s
Security fixes for the input-validation gaps in the public download and
metadata services, plus missing in-code admin gates:

- mpe_accesscheck: validate base_table (LIBDS) and access_level before
  they reach the authorisation query, and escape embedded quotes in the
  SQL literals (defence in depth for direct macro callers)
- getrawdata: validate table (LIBDS / format-catalog form), filter
  (integer) and type before they are used; read all inputs with symget
  in a data step so macro content cannot execute at a resolution boundary
- getdiffs: validate libds, table and stp_diffs_csv before the access
  check and the staging-file stream path
- getcols, getcolvals, validatefilter: read the IWANT inputs with symget
  in a data step and validate (LIBDS / SAS name) before use
- admin dirlist, refreshlibs, refreshcatalog, exportconfig: require
  membership of the DC administrators group (the admin folder prefix is
  not an access control)
- admin dirlist: read parent with symget and reject macro characters

Tests (all proven RED on the vulnerable services first, then GREEN on
the fix): getrawdata.test.1, getdiffs.test, getcols.test,
getcolvals.test.4, validatefilter.test.1, dirlist.test,
refreshcatalog.test.1
2026-09-21 19:04:35 +00:00
dc c9eed6dae7 fix(security): escape col-info dropdown and origin-check VA replay
Build / Build-and-ng-test (pull_request) Successful in 5m20s
Lighthouse Checks / lighthouse (pull_request) Successful in 21m10s
Build / Build-and-test-development (pull_request) Successful in 25m30s
buildColInfoHtml interpolated server/DB-controlled column labels, formats and
DQ RULE_VALUE (regex/formula) strings into HTML assigned to raw DOM
elem.innerHTML in both viewer.component.ts and editor.component.ts. A user who
can author a validation rule (or a column label) could store markup that runs
in the browser of any editor/approver who opens a column info dropdown - the
same class of stored XSS fixed for the status renderers in #319. Escape every
interpolated field via the same escapeHtml approach.

The pre-bootstrap VA listener (va-early.js) stores any-origin postMessage in
window.__vaLastMessage; replayEarlyMessages replayed it into the editor filter
without the live path's isTrustedSource check. Add isTrustedEarlyOrigin so the
replay only accepts a message from this origin or the embedding frame's origin
(document.referrer), mirroring the live handler.

Regression tests: col-info-html.spec.ts proves the injected element does not
survive (fails on the old impl, 5of7 rando-fail -> all pass), preserving the
10 existing behaviour tests; full Angular suite 523/523 green; production
build (AOT) compiles clean.
2026-09-19 16:28:21 +00:00
171 changed files with 21472 additions and 4547 deletions

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Emits the "Verifying the download" section appended to every release body
# by the "Upload assets to release" step of release.yaml.
# Keep this text in sync with the docs page:
# docs.datacontroller.io/docs/downloads.md
set -euo pipefail
cat <<'EOF'
## Verifying the download
Every asset on this release is covered by the `SHA256SUMS` file. To verify a download, fetch `SHA256SUMS` from the release assets alongside the files you downloaded, then run:
```
sha256sum --check SHA256SUMS --ignore-missing
```
The command reports `OK` for each asset that matches. `--ignore-missing` lets you check just the files you downloaded rather than all of them.
What this protects: a matching checksum confirms the asset is byte-for-byte the file this pipeline uploaded, guarding against corrupted or tampered downloads (mirrors, proxies, interrupted transfers). It is not a signature: the hashes travel in the same release as the files, so a compromise of the forge itself could alter both. Treat it as an integrity check, not a trust anchor.
EOF
+48 -3
View File
@@ -15,6 +15,22 @@ jobs:
with:
node-version: ${{ env.NODE_VERSION }}
- name: Scan for secrets (gitleaks)
# The local pre-commit hook is suppressed entirely when .npmrc sets
# ignore-scripts=true (the prepare script that would activate the
# hooks never runs), so CI is the enforcement point: a leaked
# credential must fail the build, not just a commit.
# Uses the same @nogoo9/gitleaks binary the pre-commit hook pins - the
# gitleaks-action requires a license key for organization repos.
# Runs before client/.npmrc is written below, because that file is
# created from the NPMRC secret and a later scan would flag the
# registry token this job injects itself.
# --no-git scans the working tree, which is what a pull request gate
# is about.
run: |
npm ci
node_modules/.bin/gitleaks detect --no-git --source . --redact --no-banner -v
- name: Install Google Chrome
run: |
apt-get update
@@ -107,6 +123,15 @@ jobs:
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
npm ci
- name: Build frontend for web streaming
# The server-ci target streams client/dist as the 'clickme' web app (see
# CONTRIBUTING.md), so the production build has to exist before the mock
# services are deployed. Without it the deploy logs
# "webSourcePath: .../client/dist ... doesn't exist" and streams no frontend.
run: |
cd client
npm run build
- name: Setup and start SASjs server
run: |
npm i -g pm2
@@ -117,8 +142,28 @@ jobs:
echo NODE_PATH=node >> .env
echo CORS=enable >> .env
echo WHITELIST=http://localhost:4200 >> .env
echo HTTP_PORT=5000 >> .env
# The server refuses to run as root unless RUN_AS names an account
# (a security change in the recent releases). This job runs as root
# in a throwaway container, so opt in explicitly.
echo RUN_AS=root >> .env
cat .env
pm2 start api-linux --wait-ready
# `pm2 start --wait-ready` can return while the app is still
# launching (it does not always wait for the ready signal), and the
# next step hits :5000 immediately. Wait for the server to answer,
# and dump its log if it never does.
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:5000/; then
echo "SASjs server answered on attempt ${i}"
exit 0
fi
sleep 2
done
echo "SASjs server did not come up within 120s"
pm2 list
pm2 logs api-linux --lines 100 --nostream
exit 1
- name: Deploy mocked services
run: |
@@ -137,7 +182,7 @@ jobs:
sasjs request services/admin/makedata -t server-ci -d deploy/makedata.json -o ./makedata_out.json || true
- name: Prepare and run frontend and cypress
timeout-minutes: 35
timeout-minutes: 50
run: |
cd ./client
mv ./cypress.env.example.json ./cypress.env.json
@@ -152,9 +197,9 @@ jobs:
replace-in-files --regex='"hosturl".*' --replacement='hosturl:"http://localhost:4200",' ./cypress.config.ts
cat ./cypress.config.ts
# Start frontend and run cypress
# timeout 1800: SIGTERM after 30 min so Cypress can flush video/screenshots
# timeout 2700: SIGTERM after 45 min so Cypress can flush video/screenshots
# before the outer timeout-minutes hard-kills the step (avoids silent multi-hour hangs)
npx ng serve --host 0.0.0.0 --port 4200 & npx wait-on http://localhost:4200 && timeout 1800 npx cypress run --browser chrome --spec "cypress/e2e/csv-limited.cy.ts,cypress/e2e/liveness.cy.ts,cypress/e2e/editor.cy.ts,cypress/e2e/excel-multi-load.cy.ts,cypress/e2e/excel.cy.ts,cypress/e2e/csv.cy.ts,cypress/e2e/filtering.cy.ts,cypress/e2e/licensing.cy.ts,cypress/e2e/viewer-labels.cy.ts,cypress/e2e/full-table-search.cy.ts,cypress/e2e/viewbox.cy.ts,cypress/e2e/stage.cy.ts"
npx ng serve --host 0.0.0.0 --port 4200 & npx wait-on http://localhost:4200 && timeout 2700 npx cypress run --browser chrome --spec "cypress/e2e/csv-limited.cy.ts,cypress/e2e/hook-programs.cy.ts,cypress/e2e/liveness.cy.ts,cypress/e2e/editor.cy.ts,cypress/e2e/excel-multi-load.cy.ts,cypress/e2e/excel.cy.ts,cypress/e2e/csv.cy.ts,cypress/e2e/filtering.cy.ts,cypress/e2e/filter-panel.cy.ts,cypress/e2e/licensing.cy.ts,cypress/e2e/viewer-labels.cy.ts,cypress/e2e/full-table-search.cy.ts,cypress/e2e/viewbox.cy.ts,cypress/e2e/stage.cy.ts,cypress/e2e/browser-info.cy.ts,cypress/e2e/ddl-export.cy.ts,cypress/e2e/row-cell-limits.cy.ts,cypress/e2e/derived-variables.cy.ts,cypress/e2e/startupservice-launcher.cy.ts"
- name: Zip Cypress videos
if: always()
+20
View File
@@ -33,10 +33,30 @@ jobs:
echo NODE_PATH=node >> .env
echo CORS=enable >> .env
echo WHITELIST=http://localhost:4200 >> .env
echo HTTP_PORT=5000 >> .env
# The server refuses to run as root unless RUN_AS names an account
# (a security change in the recent releases). This job runs as root
# in a throwaway container, so opt in explicitly.
echo RUN_AS=root >> .env
cat .env
curl -L https://github.com/sasjs/server/releases/latest/download/linux.zip > linux.zip
unzip linux.zip
pm2 start api-linux --wait-ready
# `pm2 start --wait-ready` can return while the app is still
# launching (it does not always wait for the ready signal), and the
# next step hits :5000 immediately. Wait for the server to answer,
# and dump its log if it never does.
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:5000/; then
echo "SASjs server answered on attempt ${i}"
exit 0
fi
sleep 2
done
echo "SASjs server did not come up within 120s"
pm2 list
pm2 logs api-linux --lines 100 --nostream
exit 1
- name: Write .npmrc file
run: echo "$NPMRC" > client/.npmrc
+96 -12
View File
@@ -107,6 +107,16 @@ jobs:
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
npm ci
- name: Build frontend for web streaming
# The server-ci target streams client/dist as the 'clickme' web app, so
# the production build has to exist before the mocked services are
# deployed. Without it `sasjs cbd` reports
# "webSourcePath: .../client/dist ... doesn't exist", streams no
# frontend and the deploy step fails.
run: |
cd client
npm run build
- name: Setup and start SASjs server
run: |
npm i -g pm2
@@ -117,8 +127,28 @@ jobs:
echo NODE_PATH=node >> .env
echo CORS=enable >> .env
echo WHITELIST=http://localhost:4200 >> .env
echo HTTP_PORT=5000 >> .env
# The server refuses to run as root unless RUN_AS names an account
# (a security change in the recent releases). This job runs as root
# in a throwaway container, so opt in explicitly.
echo RUN_AS=root >> .env
cat .env
pm2 start api-linux --wait-ready
# `pm2 start --wait-ready` can return while the app is still
# launching (it does not always wait for the ready signal), and the
# next step hits :5000 immediately. Wait for the server to answer,
# and dump its log if it never does.
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:5000/; then
echo "SASjs server answered on attempt ${i}"
exit 0
fi
sleep 2
done
echo "SASjs server did not come up within 120s"
pm2 list
pm2 logs api-linux --lines 100 --nostream
exit 1
- name: Deploy mocked services
run: |
@@ -174,11 +204,15 @@ jobs:
# and its permissions are derived from this block.
# contents: write -> push CHANGELOG.md / package.json commit + tag, and
# create the Release via the Gitea API.
# actions: write -> dispatch the Sites workflow for the new tag (that
# route is scoped to the actions unit, which contents
# does not grant).
# The TSDOC_TOKEN and CODE_DATACONTROLLER_IO secrets continue to be used
# because they target *different* servers (webdoc.datacontroller.io and
# code.datacontroller.io), not the Gitea API.
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v4
@@ -302,8 +336,10 @@ jobs:
run: |
cd sas
cp sasjsbuild/viya.json ../client/dist/viya.json
cd ..
zip -r frontend.zip ./client/dist
# Zip from *inside* dist so the archive holds the frontend files at its
# root rather than under a client/dist/ prefix (see #147).
cd ../client/dist
zip -r ../../frontend.zip .
- name: Release Typedoc
run: |
@@ -336,23 +372,71 @@ jobs:
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
RELEASE_BODY=$(echo "$RELEASE_JSON" | jq -r '.body')
# Update body (also confirms the token has contents:write on this repo)
# Generate SHA-256 checksums over the release assets, so downloads can
# be verified. The file uses basename-only paths so that a plain
# "sha256sum -c SHA256SUMS" works in the folder the assets were
# downloaded to (the upload below stores them under their basename).
ASSETS=(frontend.zip
sas/demostream_sas9.sas
sas/viya.sas
sas/sasjs_server.json.zip
sas/sas9.sas
sas/viya_noweb.sas
sas/viya_noweb.json)
: > SHA256SUMS
for f in "${ASSETS[@]}"; do
sum=$(sha256sum "$f" | cut -d' ' -f1)
printf '%s %s\n' "$sum" "${f##*/}" >> SHA256SUMS
done
cat SHA256SUMS
# Update body: keep the existing notes, add a verification section
# ahead of the installation footer. The section text lives in a
# dedicated script below (.gitea/scripts/verify-section.sh) so this
# YAML scalar stays clean.
# `jq -r` is required: without it jq emits the result as a JSON string
# literal (quoted, with \n escapes), and the PATCH below then encodes
# that literal a second time, so the release body renders as one
# escaped line instead of markdown.
VERIFY_SECTION=$(./.gitea/scripts/verify-section.sh)
NEW_BODY=$(jq -nr --arg body "$RELEASE_BODY" --arg verify "$VERIFY_SECTION" \
'$body + "\n" + $verify + "\n\nFor installation instructions, please visit https://docs.datacontroller.io/"')
curl -k --fail-with-body -sS -X PATCH \
-H "$AUTH_HEADER" \
-H 'Content-Type: application/json' \
--data "$(jq -n --arg body "$RELEASE_BODY"$'\n\nFor installation instructions, please visit https://docs.datacontroller.io/' \
'{draft:false, body:$body}')" \
--data "$(jq -n --arg body "$NEW_BODY" '{draft:false, body:$body}')" \
"$BASE/releases/$RELEASE_ID"
# Upload assets
URL="$BASE/releases/$RELEASE_ID/assets"
for f in frontend.zip \
sas/demostream_sas9.sas \
sas/viya.sas \
sas/sasjs_server.json.zip \
sas/sas9.sas \
sas/viya_noweb.sas \
sas/viya_noweb.json; do
for f in "${ASSETS[@]}"; do
echo "Uploading $f ..."
curl -k --fail-with-body -sS -H "$AUTH_HEADER" "$URL" -F "attachment=@$f"
done
echo "Uploading SHA256SUMS ..."
curl -k --fail-with-body -sS -H "$AUTH_HEADER" "$URL" -F "attachment=@SHA256SUMS"
- name: Publish the demo site for this release
# The tag is created by this job's semantic-release step, so it carries
# the Actions user as its author - and the forge suppresses ref events
# from that user, which means `on: push: tags` in sites.yaml never fires.
# Dispatch it instead: the API call is authenticated, and the run it
# starts checks out the tag the same way.
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
set -euo pipefail
AUTH_HEADER="Authorization: token ${GITEA_TOKEN}"
BASE="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
TAG=$(curl -k --fail-with-body -sS -H "$AUTH_HEADER" "$BASE/releases/latest" | jq -r '.tag_name')
echo "Dispatching Sites for ${TAG}"
# the dispatch endpoint resolves a bare name as a branch; a tag needs
# the refs/tags/ prefix
curl -k --fail-with-body -sS -X POST \
-H "$AUTH_HEADER" \
-H 'Content-Type: application/json' \
--data "$(jq -n --arg ref "refs/tags/$TAG" '{ref: $ref}')" \
"$BASE/actions/workflows/sites.yaml/dispatches"
+183
View File
@@ -0,0 +1,183 @@
name: Sites
on:
push:
branches:
- 'release/**'
tags:
- 'v*'
paths-ignore:
- '**.md'
workflow_dispatch:
env:
NODE_VERSION: '24.15.0'
APP_LOC: /Public/app/dc
SURFER_HOST: https://demo.datacontroller.io
# A release branch publishes the staging site (a named site on the instance,
# served at its alias domain); a release tag publishes the demo, which is the
# default site and so needs no site name.
STAGING_SITE: staging
STAGING_DOMAIN: staging.datacontroller.io
# One deploy per target site: a newer push supersedes the one in flight, and two
# release branches (which share the staging site) cannot interleave their swaps.
# The demo and staging deploys are independent, so they do not queue.
concurrency:
group: surfer-${{ startsWith(gitea.ref, 'refs/tags/') && 'demo' || 'staging' }}
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# The tag is what the client's build stamp describes (src/version.ts
# runs git-describe), so the demo build needs the tags in the clone.
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Write .npmrc file
run: |
touch client/.npmrc
echo '${{ secrets.NPMRC}}' > client/.npmrc
- name: Install client dependencies
run: |
cd client
# Decrypt and Install sheet
echo ${{ secrets.SHEET_PWD }} | gpg --batch --yes --passphrase-fd 0 ./libraries/sheet-crypto.tgz.gpg
npm ci
- name: Build frontend
# The site serves this build. `sasjs build` rewrites its index.html to
# point the adapter at the in-browser backend.
run: |
cd client
npm run postinstall
npm run build
- name: Install the SASjs CLI
# Pinned in sas/package.json - the browser build needs CLI >= 6.1.0
run: |
cd sas
npm ci
- name: Start SASjs server
# Needed only to run makedata: the drive the site ships with is captured
# from a real server (see the snapshot step below).
run: |
curl -L https://github.com/sasjs/server/releases/latest/download/linux.zip > linux.zip
unzip -q linux.zip
touch .env
echo RUN_TIMES=js >> .env
echo NODE_PATH=node >> .env
echo HTTP_PORT=5000 >> .env
# The server refuses to run as root unless RUN_AS names an account
echo RUN_AS=root >> .env
nohup ./api-linux > server.log 2>&1 &
for i in $(seq 1 60); do
if curl -sf -o /dev/null http://localhost:5000/; then
echo "SASjs server answered on attempt ${i}"
exit 0
fi
sleep 2
done
echo "SASjs server did not come up within 120s"
cat server.log
exit 1
- name: Deploy the mocked services and seed the database
run: |
cd sas/mocks/sasjs
# Start from a clean appLoc so the snapshot below is this build alone,
# not a merge with whatever a previous run left on the drive.
curl -sS -X DELETE "http://localhost:5000/SASjsApi/drive/folder/?_folderPath=$APP_LOC"
../../node_modules/.bin/sasjs cbd -t server-ci
# makedata replies with HTML (it is normally called as a URL redirect),
# which the CLI reports as "invalid Json string" - that exit is
# expected. A real failure must not be published as an empty site, so
# the drive is checked before the snapshot is taken.
../../node_modules/.bin/sasjs request services/admin/makedata -t server-ci -d deploy/makedata.json -o ./makedata_out.json || true
DATA_DIR="../../../sasjs_root/drive/files$APP_LOC/data"
SEEDED=$(find "$DATA_DIR" -name '*.json' 2>/dev/null | wc -l)
echo "makedata seeded $SEEDED table(s) under $DATA_DIR"
if [ -z "$(find "$DATA_DIR" -name 'mpe_tables.json' 2>/dev/null | head -1)" ] || [ "$SEEDED" -lt 10 ]; then
echo "makedata did not seed the drive - refusing to publish a data-less site"
find ../../../sasjs_root/drive/files -maxdepth 3 2>/dev/null | head -20
exit 1
fi
- name: Build the browser-hosted site
run: |
# The published sites ship a working licence so they are usable beyond
# the free tier. The pair is committed in sas/mocks/mock-licence.json
# rather than minted here, so every deploy of both sites carries the
# same key; the CI estate stays unlicensed because that file is outside
# the deployed sync folder, so the specs still exercise the free tier.
# The pair must round trip through the same WebCrypto the app uses,
# because a committed pair can drift (one half regenerated, a value
# truncated on copy) and nothing else would notice before publishing.
# Identical values in the two fields is the HTTP-format marker the app
# refuses in a secure context, so refuse to publish one.
node -e "
const d = require('./sas/mocks/mock-licence.json')
const b = (s) => Buffer.from(String(s || ''), 'base64')
if (!d.licenceKey || !d.activationKey || d.licenceKey === d.activationKey) {
console.error('sas/mocks/mock-licence.json must hold an HTTPS-format key pair')
process.exit(1)
}
crypto.subtle
.importKey('pkcs8', b(d.activationKey), { name: 'RSA-OAEP', hash: 'SHA-256' }, false, ['decrypt'])
.then((key) => crypto.subtle.decrypt({ name: 'RSA-OAEP', hash: 'SHA-256' }, key, b(d.licenceKey)))
.then((plain) => {
const data = JSON.parse(new TextDecoder().decode(plain))
console.log('licence pair round trips: site', data.site_id, 'until', data.valid_until)
})
.catch((e) => {
console.error('sas/mocks/mock-licence.json does not decrypt:', e.message || e)
process.exit(1)
})
"
LICENCE_DIR="sasjs_root/drive/files$APP_LOC/mock-storage"
mkdir -p "$LICENCE_DIR"
cp sas/mocks/mock-licence.json "$LICENCE_DIR/licence.json"
# DC's data files exist only after makedata has run, so the drive is
# captured first and shipped as the site's starting drive. services/web9
# is the streamed frontend, which is already the site itself.
node sas/mocks/snapshot.js sasjs_root/drive "$APP_LOC" sas/mocks/sasjsbuild/mock-snapshot.json services/web9
cd sas/mocks/sasjs
../../node_modules/.bin/sasjs b -t server-ci
- name: Publish to Surfer
env:
SURFER_USER: allan
SURFER_PASSWORD: ${{ secrets.DEMO_DATACONTROLLER_IO }}
REF: ${{ gitea.ref }}
MESSAGE: Build from ${{ gitea.ref_name }} @ ${{ gitea.sha }}
run: |
# `deploy` uploads the folder as an archive and swaps the site in one
# step, so a failed upload leaves the current site serving.
if [ -z "$REF" ]; then
echo "REF is empty - cannot tell a branch push from a tag push"
exit 1
fi
SITE_ARGS=()
case "$REF" in
refs/tags/*) ;;
*) SITE_ARGS=(--site-name "$STAGING_SITE" --domain "$STAGING_DOMAIN") ;;
esac
npx --yes @cloudron/surfer@7.2.0 deploy \
--server "$SURFER_HOST" \
--username "$SURFER_USER" \
--password "$SURFER_PASSWORD" \
--message "$MESSAGE" \
"${SITE_ARGS[@]}" \
sas/mocks/sasjsbuild/mock
+5
View File
@@ -0,0 +1,5 @@
# sas/mocks/mock-licence.json holds a licence key pair for the mock estate: the
# activation key is RSA key material the browser demo decrypts with, not a
# credential for any service.
sas/mocks/mock-licence.json:generic-api-key:2
sas/mocks/mock-licence.json:generic-api-key:3
+16
View File
@@ -0,0 +1,16 @@
# Hooks for the pre-commit framework - https://pre-commit.com
#
# The repo also ships native hooks in .git-hooks/, covering the secret scan, a
# 2MB commit size limit, a prettier check and Conventional Commits. But .npmrc
# sets ignore-scripts=true, so the `prepare` script that points git at them
# never runs on `npm i` - a fresh clone commits unchecked until the one-time
# command in CONTRIBUTING.md is run by hand.
#
# This file is the standard route instead: install the framework once with
# `pre-commit install`, and the secret scan runs on every commit. The hook is
# pinned to an exact gitleaks release tag.
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.30.1
hooks:
- id: gitleaks
+2
View File
@@ -32,6 +32,8 @@ Never consider a change complete until the relevant linters pass on the files yo
- **Client (TypeScript/HTML/etc.)**: run `npm run lint:check` from the `client/` directory (prettier). Fix any failures with `npm run lint:fix`.
- **SAS**: after creating or modifying any `.sas` files, run `sasjs lint` from the `sas/` directory and ensure the files you touched have no lint warnings (the repo currently has pre-existing warnings in other files, which can be ignored).
`sas/.sasjslint` carries `ignoredMacros: ["webout", "mpeinit", "mpeterm"]`. `webout` is the linter's own default - `sasjs compile` injects `%webout` into every service - and an explicit list replaces that default, so it has to be restated there. `mpeinit` and `mpeterm` are listed because every service is compiled with a serviceInit program (`sasjs/utils/serviceinitsas9|viya|server.sas`) that declares both macros in its own header, so a service body may call them without declaring them. Add a macro to that list only when it reaches a file the same way - injected by the compiler, through serviceInit, testSetUp or another implicit provider - never to silence a genuinely missing declaration.
`noBannedStrings` flags the literal words `error ` and `warning ` anywhere in a file, comments included. Reword prose; where the text has to stay (a real `%put`, a doxygen `@warning` tag), keep the log output identical with `%put %str(WARN)ING:` rather than a per-file override, and use `@sasjslint {"noBannedStrings": false}` only when the word itself is the content.
## No external assets
+227
View File
@@ -1,3 +1,230 @@
# [7.19.0](https://git.datacontroller.io/dc/dc/compare/v7.18.0...v7.19.0) (2026-10-28)
### Bug Fixes
* address the review findings on the harness and refresh changes ([36e4e88](https://git.datacontroller.io/dc/dc/commit/36e4e88eb134d3b48217d6dd185ea3c03f03fba5))
* **ci:** dispatch the demo deploy with a tag ref and the actions scope ([698dea6](https://git.datacontroller.io/dc/dc/commit/698dea6d6b7a8635313f11acfcc7a4f39a02bc99))
* **ci:** restore the gitleaks ignore entries for the mock licence pair ([0d58be9](https://git.datacontroller.io/dc/dc/commit/0d58be975d8eb2d7f1ab6a648f760151392c7973))
* **client:** open the SAS log page with noopener ([072a133](https://git.datacontroller.io/dc/dc/commit/072a1337020970b5b4ff8aa31719cc5ffec7701e))
* **client:** refuse a truncated table in the multi-table upload ([1fb4818](https://git.datacontroller.io/dc/dc/commit/1fb4818d215f538a0ac51772ab1f261aeb91f7e1))
* **cypress:** apply the licence key when the estate has none ([be8f445](https://git.datacontroller.io/dc/dc/commit/be8f445ae1051e132fb6eb5a69b45264255326b5)), closes [input#file-upload](https://git.datacontroller.io/input/issues/file-upload)
* **dc_execute:** use = comparisons, not IN, in the fail-fast guard ([fed43cb](https://git.datacontroller.io/dc/dc/commit/fed43cb07ef7f2afc685612a124dbc16d7618e21))
* **dc_getlibs:** exclude the DC libref from the dictionary scan ([f5aade5](https://git.datacontroller.io/dc/dc/commit/f5aade59760cc376b0f96eb4c892c8bca82dde14))
* **dc_refreshcatalog:** terminate the generated statements ([1e22476](https://git.datacontroller.io/dc/dc/commit/1e224763ba80500a112812a983801968e3751959))
* **derived:** a fileref with nothing written is a FAIL, not an error ([9b3cf50](https://git.datacontroller.io/dc/dc/commit/9b3cf50b9c3889786605f0f5d9032d84c50f7107))
* **derived:** address five review findings ([ccd468b](https://git.datacontroller.io/dc/dc/commit/ccd468b3358c1418ee6d8e198b088a0cf23b8c24))
* **derived:** carry the placement sequence in mpe_derived ([be50cb5](https://git.datacontroller.io/dc/dc/commit/be50cb5d082e788c6ae106bc1d02e73a8c7b9646))
* **derived:** close four gaps in the MPE_DERIVED hook ([9914790](https://git.datacontroller.io/dc/dc/commit/9914790777f92128c74ecce67e6c67ee48824b45))
* **derived:** close the RLS and search gaps on derived columns ([9ef813d](https://git.datacontroller.io/dc/dc/commit/9ef813d439b48e7fefd35c426e62b99e5943002a))
* **derived:** close the two gaps in the derived/RLS invariant ([422f766](https://git.datacontroller.io/dc/dc/commit/422f766cd43db4ce740e1890fd5df30790eaa7e3))
* **derived:** compare the outref as text, prove the file is empty ([7830b7b](https://git.datacontroller.io/dc/dc/commit/7830b7bcfa9806dde840ce8dd3e6a1887d0b38be))
* **derived:** do not drop a shadowed column from staging or downloads ([2d5de9a](https://git.datacontroller.io/dc/dc/commit/2d5de9a324a07a36edc0a4f74c8fad09fde07cbf))
* **derived:** do not duplicate a shadowed column in the grid payload ([6a1128a](https://git.datacontroller.io/dc/dc/commit/6a1128a46352f77c95dd02df9309f0984a1db2d1))
* **derived:** eight review findings ([561d7fc](https://git.datacontroller.io/dc/dc/commit/561d7fc3ed2a460835619962cf4dcb29d3dc87c7))
* **derived:** enforce the ACTIVE picker pair in the extracted check ([1863076](https://git.datacontroller.io/dc/dc/commit/1863076bc956b4ff94bf7b85b3dde0d6e3b54d7a)), closes [#366](https://git.datacontroller.io/dc/dc/issues/366)
* **derived:** enforce the documented limits, and handle derived filters in VIEW ([d3dec68](https://git.datacontroller.io/dc/dc/commit/d3dec682aafeb143fe983d6546337cb6490f5620))
* **derived:** filtering a format catalog no longer aborts the service ([469229a](https://git.datacontroller.io/dc/dc/commit/469229aecbaad304a835a5f229df111c37ff7c0d))
* **derived:** guard the bitemporal cut-off, coalesce the selectbox seed ([7fb981d](https://git.datacontroller.io/dc/dc/commit/7fb981daa91bce29c2d62c246185d01dcad08d6b))
* **derived:** guard the empty physical column list in the dep check ([5f5d868](https://git.datacontroller.io/dc/dc/commit/5f5d8681b9d78280a5200309917415e135c3ce5b))
* **derived:** hold a derived column read-only whatever the table's security ([5f443b0](https://git.datacontroller.io/dc/dc/commit/5f443b0b16a2abd3c11d96caa7a043911c29ef01))
* **derived:** ignore a re-added name when collecting inactive rows ([6b5bf3e](https://git.datacontroller.io/dc/dc/commit/6b5bf3e6be89b22e5a633c34b9aecbc8c7d48ee2))
* **derived:** ignore inactive rows and VIEW rules in the submit guards ([85c89ca](https://git.datacontroller.io/dc/dc/commit/85c89ca2a4e02112ba496ac36a222f33675544da))
* **derived:** keep targetds for plain datasets, test the empty file ([f8f6568](https://git.datacontroller.io/dc/dc/commit/f8f65681e1489f4ce94d9127d5e4c0c82798e960))
* **derived:** make the model enforce the required columns, and leave VAR_FMT optional ([7efbf31](https://git.datacontroller.io/dc/dc/commit/7efbf31ea5ac234bd8f924fdf89a95d101b3aff1))
* **derived:** only the delete marker is a reserved name ([af31c36](https://git.datacontroller.io/dc/dc/commit/af31c36b670ec63a2a4ba056bf6c4b28f6096e08))
* **derived:** open the statements file with a long record length ([ee31782](https://git.datacontroller.io/dc/dc/commit/ee31782fbff909b540162b1bdfca6f307208331b))
* **derived:** pair the filterds %else with %do/%end ([88a38db](https://git.datacontroller.io/dc/dc/commit/88a38db877dba9b98ccf50f0cc7242674654586b))
* **derived:** raise the VAR_ORDER ceiling to 10000 ([27ddcfb](https://git.datacontroller.io/dc/dc/commit/27ddcfb5759d6eb8f9880adc7c271a408e7741ad))
* **derived:** refuse dependencies on inactive rows, and keep the RLS scope guard coherent ([7799a30](https://git.datacontroller.io/dc/dc/commit/7799a300df82339683eea21e4a89ce7a6471c575))
* **derived:** reject a dependency on a row this submission deletes ([8806504](https://git.datacontroller.io/dc/dc/commit/88065049674c2cc0141eef22704b759f5b708b0f))
* **derived:** repair the validation rows for MPE_DERIVED ([9a047ad](https://git.datacontroller.io/dc/dc/commit/9a047ad42ec86df7d1eaf5058c0edde56016e88f))
* **derived:** review feedback - cover the empty response, assert the last row ([e0da9f1](https://git.datacontroller.io/dc/dc/commit/e0da9f1098db63185538398ca478696cc849da4b))
* **derived:** stop the hooks aborting on their own macro variables ([688550a](https://git.datacontroller.io/dc/dc/commit/688550a28d9794ac6b878926a0e1e2ef8f6e9335))
* **derived:** truncate the derived label on an even quote boundary ([1b5c4b3](https://git.datacontroller.io/dc/dc/commit/1b5c4b3ecd962a28e08fc5671b57dbf7ae0b8d9f))
* **derived:** verify on stripped values, and label with the variable name ([4d9ad38](https://git.datacontroller.io/dc/dc/commit/4d9ad38df1fa89b0d5a12214d703d9c1fe5295f2))
* **editor:** a blank truncation note is not a warning ([f182179](https://git.datacontroller.io/dc/dc/commit/f18217940365f27ae388fae087e6126931e1222c))
* **editor:** keep decimal values when an uploaded file is edited manually ([04ce186](https://git.datacontroller.io/dc/dc/commit/04ce1861e7821063b1be42c22f92f62aed509602))
* **getcolvals:** report an invalid value, not missing inputs ([4bcee70](https://git.datacontroller.io/dc/dc/commit/4bcee706ffaf1929bdd14bb2fb15111174ca3916))
* **getdata.test:** pin the derived filter to a libref, and spell the table as it is ([45dce7b](https://git.datacontroller.io/dc/dc/commit/45dce7b11b7a4399c1d0dc9c3e7a283b1cf59df1))
* **getdata:** clear the globals it declares before use ([359b570](https://git.datacontroller.io/dc/dc/commit/359b570b85aa2f66507e81ea2977243be4590f83))
* **getddl.test:** ask for a table, not a whole library ([059cdf1](https://git.datacontroller.io/dc/dc/commit/059cdf176a7ec556b45ea1b21d880c048eba14ca))
* **getrawdata:** declare mp_ds2md so the Markdown download can run ([661ee19](https://git.datacontroller.io/dc/dc/commit/661ee19cfa5f996bf01f2b11817039f38dbb9985))
* **lint:** clear the sasjs lint warnings on the files 7.19 touched ([355c46a](https://git.datacontroller.io/dc/dc/commit/355c46a7b64994d0146a88657dc5635593249138))
* **makedata:** read KEEPME from every input row, and keep it out of the Viya seed ([d626cb8](https://git.datacontroller.io/dc/dc/commit/d626cb8f2daf94fde7ff21d924b9a2ca4968d983))
* **mocks:** address the audit-pack review findings ([489819b](https://git.datacontroller.io/dc/dc/commit/489819b05111323ae1e34edda22a5446cdbc2d87))
* **mocks:** carry the zip flags into the central directory ([c4021a4](https://git.datacontroller.io/dc/dc/commit/c4021a42ffaed2af80c53aaa1455249190b339b8))
* **mocks:** clear the licence for published sites, not for the estate ([62f55db](https://git.datacontroller.io/dc/dc/commit/62f55db170185900063f7a431cd8f375ebabf930))
* **mocks:** copy the physical column list before deriving ([f411b7d](https://git.datacontroller.io/dc/dc/commit/f411b7d269381e3f7cab2d85b6d8f7d7d50ea4d1))
* **mocks:** derive before filtering in the viewer, and drop the columns ([60ec470](https://git.datacontroller.io/dc/dc/commit/60ec470404e5c279b58ac6a01768dfc83413b197))
* **mocks:** derive the retained key wherever rows are staged ([74060c0](https://git.datacontroller.io/dc/dc/commit/74060c0585fb8b217cb181ea747ad318f5238868))
* **mocks:** drop derived variables before staging ([73d25b1](https://git.datacontroller.io/dc/dc/commit/73d25b1220d574ef2547fbd9e6e3cf1ceda375ee))
* **mocks:** key rk_underlying tables on their business key ([347dbb5](https://git.datacontroller.io/dc/dc/commit/347dbb53b01c47bbd562de14d5ccbae7d96407c6))
* **mocks:** register MPE_DERIVED and seed its field rules ([ee3c878](https://git.datacontroller.io/dc/dc/commit/ee3c8787efef9cd716bdd2bf80f6cb6751461db9))
* **mocks:** scope the derived hook's graph to the submission ([6cad23f](https://git.datacontroller.io/dc/dc/commit/6cad23fce9ac0cf64c247c40f3b7eac875fd4cfb))
* **mocks:** search the physical columns only in the viewer ([293022d](https://git.datacontroller.io/dc/dc/commit/293022d46b27e096fd514cdda49f688612df2f5b))
* **mocks:** stop the mock advertising invalid licence keys ([fb36379](https://git.datacontroller.io/dc/dc/commit/fb36379520028baaf4bc3f08131bfc88deab3ac3))
* **mpe_assert_abort:** drop the unused line variable ([9c294c0](https://git.datacontroller.io/dc/dc/commit/9c294c0ab5ca8fe30a235553a298c1c68a61442f))
* **mpe_assert_abort:** take the abort's own MSG, tolerate a missing response ([0a52d20](https://git.datacontroller.io/dc/dc/commit/0a52d20c5fc27b4adde5fc8ed6f39a58c48f62ff))
* **mpe_execute:** fail fast when the child left no status ([a036386](https://git.datacontroller.io/dc/dc/commit/a03638667f1968c5909f496d954eeaa13f316763))
* **mpe_execute:** no apostrophe in the SAS 9 status note ([2204085](https://git.datacontroller.io/dc/dc/commit/220408538b26016bda45e48d619cdbc3e1cbcc59))
* **mpe_execute:** read an unknown state as unmeasured, not failed ([f2b1428](https://git.datacontroller.io/dc/dc/commit/f2b1428ec3099b2b6e3c6da6627530ef81fab201))
* name the startupservice launcher button "Show log" ([3445107](https://git.datacontroller.io/dc/dc/commit/3445107d9a91642b67e114bcfcd81c3ce47f3f0f))
* offer the launcher on the globvars failure modal too ([ad2da45](https://git.datacontroller.io/dc/dc/commit/ad2da453896a51f2cc7e49cebb6c84f7b47d7395))
* **refresh:** name each catalogue load uniquely in the audit trail ([46bacdd](https://git.datacontroller.io/dc/dc/commit/46bacdd6d9ea814bcd02a1ff8aa3f447baf02f64))
* **refresh:** one audit folder per refresh call ([56b6620](https://git.datacontroller.io/dc/dc/commit/56b6620ef402b288ce78a2a77662b651e310753e))
* **sites:** round-trip the committed licence before publishing ([4d462d3](https://git.datacontroller.io/dc/dc/commit/4d462d310f7df23e5d5229cb0702721b7ad41bbd))
* **test:** getdata test ([da30266](https://git.datacontroller.io/dc/dc/commit/da30266278c4fe27a72810cd5ed647cf3bd823af))
* **tests:** enable closeouts logging ([fdcd8fa](https://git.datacontroller.io/dc/dc/commit/fdcd8fa4b3e7a7a119c662974d70dc9eea80bdae))
* **tests:** read the work location from _SASJS_WORK ([033ffd3](https://git.datacontroller.io/dc/dc/commit/033ffd302502c7530fc44a314364f5cdb3be6ad2))
* **ui:** one error modal at a time ([81ccf75](https://git.datacontroller.io/dc/dc/commit/81ccf758e9dab0c7632ab50bf469e88b8c4c4420))
* **validatefilter:** build targetds without macro triggers in comments ([42355f1](https://git.datacontroller.io/dc/dc/commit/42355f17bc07bf4d44ba858984d83b9ed72cc0ba))
* **validatefilter:** drop the dead nobs assignment, keep targetds precedence ([337ea8e](https://git.datacontroller.io/dc/dc/commit/337ea8e5e021c6f2451fa3ad8396148744118fc9))
### Features
* **dc_getlibs:** dump the library list when debug is on ([582523d](https://git.datacontroller.io/dc/dc/commit/582523dc87a253b71824359224070ccb4746a386))
* **derived:** allow a variable to shadow a physical column ([12beeff](https://git.datacontroller.io/dc/dc/commit/12beeff69518376a042fbbc58332acc40d89d132))
* **derived:** declare VAR_DEPENDENCIES instead of VAR_ORDER ([813bce6](https://git.datacontroller.io/dc/dc/commit/813bce685691ad252043eeab31eb5460de81b756))
* **derived:** optional VAR_LABEL on MPE_DERIVED ([7c9ce9a](https://git.datacontroller.io/dc/dc/commit/7c9ce9a712137e9825a5f2ff52796d765423147b))
* **derived:** pickers, and an ACTIVE default, for MPE_DERIVED ([87e794f](https://git.datacontroller.io/dc/dc/commit/87e794f769fe420f214f43b141f0b41cf88eefee))
* **derived:** report the dependency cycle path ([cee1a95](https://git.datacontroller.io/dc/dc/commit/cee1a954ee97e17f297b7cf43ef0e5cfc6e393a6))
* **derived:** take any text in VAR_LABEL, but not a line break ([78e88a4](https://git.datacontroller.io/dc/dc/commit/78e88a41128b047c0276ccf647f128229152604c))
* **derived:** validate MPE_DERIVED at submit time ([0b010f2](https://git.datacontroller.io/dc/dc/commit/0b010f2c65ddada70d62ea83c706943c6c45756f))
* **derived:** validation rules and a VAR_TYPE dropdown for MPE_DERIVED ([aa6d50e](https://git.datacontroller.io/dc/dc/commit/aa6d50e1ea5fc2fe6be8aa9fa859b92d0a1061c5))
* **derived:** VARIABLE_ORDER, so a derived variable can build on another ([33d043e](https://git.datacontroller.io/dc/dc/commit/33d043ea92f007dca70c95d5363329d4447eeba9))
* **editor:** derived variables in the EDIT screen ([b0fd354](https://git.datacontroller.io/dc/dc/commit/b0fd354ecdbd7bf29196ed983ff3cce691affeed))
* **editor:** mark derived variables as computed in the EDIT grid ([6513d09](https://git.datacontroller.io/dc/dc/commit/6513d09f059de15c5304f99b3f8d898d46ea1be7))
* **editor:** serve a truncated selection with a warning instead of aborting ([34691dc](https://git.datacontroller.io/dc/dc/commit/34691dceecb63f952b23ad8acc5bc93753c6cfee))
* **editor:** show the derived column label in the header tooltip ([cfe6647](https://git.datacontroller.io/dc/dc/commit/cfe6647ca870c45a3d8abc2753ce7f070e3fdf4a))
* **mocks:** add getauditfile and the audit-folder artefacts ([752d944](https://git.datacontroller.io/dc/dc/commit/752d944c2091ef6d2624a15ab2e2e7be35608798))
* **mocks:** implement derived variables in the JS services ([b4fae88](https://git.datacontroller.io/dc/dc/commit/b4fae88ae13658607e4209449577cd42849d3a99))
* **mocks:** validate a submitted MPE_DERIVED row like the hook does ([5d183d1](https://git.datacontroller.io/dc/dc/commit/5d183d135085ea023f32e5b1d4992d997394a8fb))
* run startupservice in a new window from its error modal ([40f6133](https://git.datacontroller.io/dc/dc/commit/40f61331aad6bc8a52c551b924f0d1f1e6426cee))
* **sites:** mint a licence for the published sites ([7d9df71](https://git.datacontroller.io/dc/dc/commit/7d9df71fdb0ab265e745ed3b708038983e855a87))
### Reverts
* **derived:** no shadowing, and no self reference ([5af8e6f](https://git.datacontroller.io/dc/dc/commit/5af8e6fc359221586af74a685159dfd75a40ec45))
* **stagedata.test.4:** back to the MPE_LOADS evidence for now ([31aa859](https://git.datacontroller.io/dc/dc/commit/31aa8591538409fc1a3ef97d7474120094ce202d))
# [7.18.0](https://git.datacontroller.io/dc/dc/compare/v7.17.0...v7.18.0) (2026-10-19)
### Bug Fixes
* **deps:** bump @sasjs/core to 5.4.0 ([19fb032](https://git.datacontroller.io/dc/dc/commit/19fb032f0dbdd612651ca4ff3b55d1aefa4850d5))
* **deps:** pin @sasjs/utils and drop the unused jsrsasign ([05d2d1e](https://git.datacontroller.io/dc/dc/commit/05d2d1e08e2c3082f0dd5aa4629d91907c0401fc))
* **editor:** own the delete-record column client-side ([56025cc](https://git.datacontroller.io/dc/dc/commit/56025cc0524d34d3589992e9f1059c13fb5581ed))
* **editor:** surface the reserved-column refusal on every getdata path ([b26f557](https://git.datacontroller.io/dc/dc/commit/b26f5571b66b65166c1158817f2df3027ae45cdc))
* **filters:** do not turn a fractional temporal value into a literal ([f710d87](https://git.datacontroller.io/dc/dc/commit/f710d871fffc0fa451fd8cc4d037a26414725654))
* **filters:** fix the dynamic where clause deref and map its temporal values ([ece67d3](https://git.datacontroller.io/dc/dc/commit/ece67d37ba2c4e2037dea626b9730a692388f025))
* **filters:** keep the range field readable and cover a BETWEEN in the rewrite ([be79f3a](https://git.datacontroller.io/dc/dc/commit/be79f3a1ea5e4c4a157396d276f2c6654f615d39))
* **filters:** map an IN entry to its unformatted value before the literal ([8f98ebe](https://git.datacontroller.io/dc/dc/commit/8f98ebe326978b8da58d8ac895ec946e562b5de4))
* **filters:** stop the temporal rewrite corrupting a typed value, and bind the range dropdown to the unformatted value ([a5f61d4](https://git.datacontroller.io/dc/dc/commit/a5f61d4a73051237b671695f67122c237770c95a))
* **filters:** use the unformatted value in every IN branch ([cc01f54](https://git.datacontroller.io/dc/dc/commit/cc01f540c29d3d5f7dd86943b6eed82b332ce868))
* **makedata:** shorten the DC_MAXCELLS_WEBEDIT description to fit var_desc ([a51d9e5](https://git.datacontroller.io/dc/dc/commit/a51d9e5574383e5d1e1943c95261fbce63e8788d))
* **multi-dataset:** surface the reserved-column guard, use the name constant ([2b8a2fa](https://git.datacontroller.io/dc/dc/commit/2b8a2fa1039da3ab888af8c3ffae7e1b848b250a))
* **release:** emit the release body as raw text, not a JSON string ([a05554e](https://git.datacontroller.io/dc/dc/commit/a05554e67a8d44e32e2d9f5e4a959a9d0592be5e))
### Features
* **filters:** show dates as date literals in the filter query ([662d000](https://git.datacontroller.io/dc/dc/commit/662d00032c27634bbc2d82c392e7875a2e174eff))
# [7.17.0](https://git.datacontroller.io/dc/dc/compare/v7.16.0...v7.17.0) (2026-10-15)
### Bug Fixes
* **client:** do not publish an empty getcols fallback to the picker ([9f8fc6f](https://git.datacontroller.io/dc/dc/commit/9f8fc6f2eb83c78ea9cb220bb74059bab39e66ad))
* **client:** map the getcols fallback onto the picker vocabulary ([7cecf79](https://git.datacontroller.io/dc/dc/commit/7cecf795153138d6f2ad1f87f7bdd12b5d861341))
* **client:** pin the dependency entries this release changes ([b034fe5](https://git.datacontroller.io/dc/dc/commit/b034fe5335c41ec0289e459270839ee7caa8e126))
* **deploy:** apply the same identity-call fix to the automatic deploy ([5693b44](https://git.datacontroller.io/dc/dc/commit/5693b4488b0328022c69dd34f98662d660612578))
* **deploy:** disable the manual deploy actions without an admin group ([6ffbdba](https://git.datacontroller.io/dc/dc/commit/6ffbdbadf9804e0128694ed1c2bdb8f957743ad9))
* **deploy:** disable the manual deploy file inputs while admin groups load ([7094bfd](https://git.datacontroller.io/dc/dc/commit/7094bfdf7cdab4c70e5f1a7763a8a8aeb8cc61a7))
* **deploy:** guard the manual deploy form and Viya identity calls ([6522fcb](https://git.datacontroller.io/dc/dc/commit/6522fcb28b67b910b2784b93251f591bbc79d294))
* **deploy:** never bake an empty admin group into the deploy script ([b0e47fc](https://git.datacontroller.io/dc/dc/commit/b0e47fc4ed4e36878de6505e678667b14d19c5e6))
* **deps:** pin shelljs to clear the braces advisory in the sas audit ([6e50938](https://git.datacontroller.io/dc/dc/commit/6e5093858be106a1c3545a16119d246f69aac3da))
* **editor:** check the EDIT limits once, and skip switched-off options ([f08c4c2](https://git.datacontroller.io/dc/dc/commit/f08c4c231f019979a27fe71fe73798752c015710))
* **filters:** carry TYPE on the fallback list, and drop the temporal exclusion ([bcb8fde](https://git.datacontroller.io/dc/dc/commit/bcb8fde9868b8e1ded1590e204c34054f62d8250))
* **filters:** source the picker variables from public/getcols when the table is not returned ([3a6a216](https://git.datacontroller.io/dc/dc/commit/3a6a216b9d4dfc462e05031039c47002a9156130))
* **getcols:** use %global and %mp_getcols, and merge the base branch ([1385741](https://git.datacontroller.io/dc/dc/commit/1385741f2d303c1432f1f0ba637dd3cb39500a71))
* **getcols:** widen TYPE before assigning the client vocabulary ([bcad05e](https://git.datacontroller.io/dc/dc/commit/bcad05e03291fc3e2b72a4465629e1e330d70c8a))
* **getdata:** apply row level security to selectbox source values ([768d33c](https://git.datacontroller.io/dc/dc/commit/768d33c618a7ea453c3c19723f342a170ec576ea)), closes [#340](https://git.datacontroller.io/dc/dc/issues/340)
* **mocks:** read MPE_CONFIG correctly, and pin the limits to it ([05126ae](https://git.datacontroller.io/dc/dc/commit/05126ae73a1ab2461066eb701b7475674b96f1ec))
* repair the SAS suite for the row/cell limits and default the manual deploy admin group ([99ff732](https://git.datacontroller.io/dc/dc/commit/99ff732d67425b01a8a8f5e3e7c98b3e6d604323))
* **requests-modal:** widen the dialog so log lines need less scrolling ([3c10d91](https://git.datacontroller.io/dc/dc/commit/3c10d915a5134247aff0e987dd4d5c83c197e4c5))
* **sas:** keep format and label in the public getcols response ([9c32b1b](https://git.datacontroller.io/dc/dc/commit/9c32b1b1dae00e4b7bfd4acad94cbed831819d84))
* **sas:** keep the SAS C/N vocabulary in the public getcols response ([e90bcde](https://git.datacontroller.io/dc/dc/commit/e90bcde51218c9e5f562f7aaa65506761b21d6bd))
* **sas:** run the row/cell limit migration as a Viya job ([90af6b8](https://git.datacontroller.io/dc/dc/commit/90af6b851542a97f79172b655070cda559386a5c))
* **startup:** stack the SASjs tag detail so the dump is readable ([1f4c4a4](https://git.datacontroller.io/dc/dc/commit/1f4c4a4d8297568f46bcc16ea208673fedad345b))
### Features
* **debug:** keep the debug toggle state across a page refresh ([3ce006d](https://git.datacontroller.io/dc/dc/commit/3ce006d6b469b4ece2bc769f0a32a1792eb1e774))
* **editor:** raise the row limits and add a cell limit to the EDIT screen ([3de6655](https://git.datacontroller.io/dc/dc/commit/3de6655f26b7e895f60266e9931b46cfc0053975))
* **mocks:** read the DC_MAX* options from MPE_CONFIG, and mock the DDL export ([edac9a9](https://git.datacontroller.io/dc/dc/commit/edac9a987aad3e4217641eed43f697f61c4bf739))
* **startup:** call out a missing SASjs tag on the boot screen ([b24eb73](https://git.datacontroller.io/dc/dc/commit/b24eb731ce089acf496bed1e11a5e34208c1bd11))
* **startup:** dump the SASjs tag contents in the boot screen checks ([75c1dcc](https://git.datacontroller.io/dc/dc/commit/75c1dccfd23557ab321cd7abd1508f20d817c7b8))
* **system:** export the DC library DDL from the system screen ([05f3f49](https://git.datacontroller.io/dc/dc/commit/05f3f49e0c4d7005fa1f93852d73f2368395ab28)), closes [#179](https://git.datacontroller.io/dc/dc/issues/179)
# [7.16.0](https://git.datacontroller.io/dc/dc/compare/v7.15.0...v7.16.0) (2026-09-28)
### Bug Fixes
* **ci:** correct server-ci webSourcePath and build frontend before mock deploy ([a4ad4cb](https://git.datacontroller.io/dc/dc/commit/a4ad4cba2861fe76f7ee5ea72ccf8c6e61c888a5))
* **client:** parse iOS browsers in parseUserAgent ([eec3438](https://git.datacontroller.io/dc/dc/commit/eec3438de9735e0feb74c95d0b28128af6677477))
* **diagnostics:** give the startup service a body for browser_info ([5538e0c](https://git.datacontroller.io/dc/dc/commit/5538e0c5752553a7c61903c62e4fdc82b6206826))
* **diagnostics:** treat _debug=128 as debug on ([8de9978](https://git.datacontroller.io/dc/dc/commit/8de99782134e37c5e9c26c3117b083f49fa65189))
* **loader:** abort when a post edit hook routes to an unregistered table ([171974b](https://git.datacontroller.io/dc/dc/commit/171974bd412be3efafd792e6c61c23f2fb442ace))
* **mocks:** keep the mock hook reader inside the Drive ([7fd8ae4](https://git.datacontroller.io/dc/dc/commit/7fd8ae462993f0a1a8a034b5938d309d63920043))
* **sas:** drop the duplicated abort in the target re-registration check ([48d45ac](https://git.datacontroller.io/dc/dc/commit/48d45ac7f8c32e39ff2d0e1ceac50252a49ebadd))
* **sidebar:** drop the query string from the sub-page label ([d2dd46b](https://git.datacontroller.io/dc/dc/commit/d2dd46bfdfddd1695d1b3915d20ce79330cf275b))
### Features
* **client:** report the browser and both versions in browser_info ([a770f36](https://git.datacontroller.io/dc/dc/commit/a770f3695ceac441f48527f606843602c39fcc13))
* **client:** send session_info with every service request ([50282f2](https://git.datacontroller.io/dc/dc/commit/50282f2ddb1250e048c55c04b395b428167142f7))
* **filters:** make the applied-filter panel expandable ([fdaa249](https://git.datacontroller.io/dc/dc/commit/fdaa249f447b3a2c87da4b2aa1e5978c09f53ff8))
* **mocks:** emulate the %mpeinit diagnostics dump ([200ee89](https://git.datacontroller.io/dc/dc/commit/200ee8931d3952624434567b5b95c9e7e53c6508))
* **mocks:** run pre/post edit hook programs in the JS mock services ([b5f2283](https://git.datacontroller.io/dc/dc/commit/b5f228351bca18cbc8a3032e60846d05192668f6))
* **mpeinit:** dump session_info to the log when debug is on ([fbd77a5](https://git.datacontroller.io/dc/dc/commit/fbd77a533417b1c8549a339b94785f7af0a30ca8))
* **release:** publish SHA256SUMS and verify instructions with each release ([f1ae501](https://git.datacontroller.io/dc/dc/commit/f1ae501d49b510a1870f3682bb7d83de7446e061))
# [7.15.0](https://git.datacontroller.io/dc/dc/compare/v7.14.2...v7.15.0) (2026-09-23)
### Bug Fixes
* **mocks:** keep special missings in the DIFF, and add the clip recording spec ([d124ce3](https://git.datacontroller.io/dc/dc/commit/d124ce3b36f8f5153e8d7a576d4bec3189524ed5))
* **mocks:** list a column's own special missing in its dropdown ([b8f16a6](https://git.datacontroller.io/dc/dc/commit/b8f16a63827310f68629f2e016a4fb876593c37c))
* **mocks:** make the approval path work, and record the approval scene ([12847cf](https://git.datacontroller.io/dc/dc/commit/12847cf07165d5aefa61592815cab0a37245e31f))
* **validator:** a range rule ignores a missing value ([70dae4b](https://git.datacontroller.io/dc/dc/commit/70dae4b7013ac825eb77d3dc2b622980c0e4af05))
* **validator:** keep the regular missing in a numeric dropdown source too ([a639bca](https://git.datacontroller.io/dc/dc/commit/a639bca70264e8a6a81795892b9ed63ba58d5f73))
* **validator:** primary keys are NOT NULL, and a strict dropdown can match a special missing ([586a41a](https://git.datacontroller.io/dc/dc/commit/586a41ad49670ee795284a83cf8535711ce14d2c))
* **validator:** reject a special missing on a NOT NULL column ([6d85bce](https://git.datacontroller.io/dc/dc/commit/6d85bce2a0c528e8eab9ee4abbade8c682ec3a1b))
### Features
* **validator:** compare MINVAL and MAXVAL in SAS's own order ([3467322](https://git.datacontroller.io/dc/dc/commit/3467322e99b0c3f6fda5654d35b507fdb2cb1c22))
## [7.14.2](https://git.datacontroller.io/dc/dc/compare/v7.14.1...v7.14.2) (2026-09-22)
### Bug Fixes
* **release:** put frontend files at the root of frontend.zip ([7771a24](https://git.datacontroller.io/dc/dc/commit/7771a24b9ce55751253686885e4848a292817a38)), closes [#147](https://git.datacontroller.io/dc/dc/issues/147)
* **security:** accept the format-catalog form when validating a libds ([0fa5da8](https://git.datacontroller.io/dc/dc/commit/0fa5da8abfc303ce3b18beb4c01484dcce508439))
* **security:** escape col-info dropdown and origin-check VA replay ([c9eed6d](https://git.datacontroller.io/dc/dc/commit/c9eed6dae717414b874ef6f3d60312ea0bb5a0da))
* validate request inputs and add admin gates to public services ([be86000](https://git.datacontroller.io/dc/dc/commit/be86000fe0f0858edcbecf71d426a2ff81257247))
## [7.14.1](https://git.datacontroller.io/dc/dc/compare/v7.14.0...v7.14.1) (2026-09-17)
+13 -9
View File
@@ -19,6 +19,8 @@ git config core.hooksPath ./.git-hooks
The pre-commit hook requires the gitleaks binary provided by the root `@nogoo9/gitleaks` devDependency, so make sure `npm i` has run in the repo root before your first commit.
The standard [pre-commit](https://pre-commit.com) route is available as well, and does not depend on the lifecycle scripts above: install it once with `pre-commit install` and the secret scan in [`.pre-commit-config.yaml`](./.pre-commit-config.yaml) runs on every commit. The same scan also runs in CI, so a leaked credential fails the build regardless of which local hooks are active.
## Dependencies that requires licences
[SheetJS Pro Version](https://www.npmjs.com/package/sheetjs)
@@ -48,15 +50,12 @@ npm i
[Handsontable](https://www.npmjs.com/package/handsontable)
Licence should be inserted in the `client/src/index.html` file:
The licence key comes from the backend licence: the decrypted licence carries `hot_license_key`,
which is published on the `hot_license_key` subject and pushed into every Handsontable instance.
Until a licence is loaded the client falls back to the non-commercial key
(`DEFAULT_HOT_LICENCE_KEY` in `client/src/app/services/licence.service.ts`), so there is nothing to
configure in `index.html` for this.
```
<sasjs
...
hotLicenceKey="LICENCE-GOES-HERE"
>
</sasjs>
```
## Development
Update `client/src/index.html` so that it points to your SAS9, SASVIYA or SASJS backend.
Be aware that VIYA can be configured in such way that it would not work with cross origin frontend.
@@ -87,6 +86,7 @@ RUN_TIMES=js
NODE_PATH=node
CORS=enable
WHITELIST=http://localhost:4200
HTTP_PORT=5000
```
`RUN_TIMES=js` means the server executes `.js` files as Stored Programs (no SAS binary needed). `CORS=enable` plus `WHITELIST` allows the Angular dev server on port 4200 to call the mock services on port 5000. Start the server:
@@ -95,7 +95,7 @@ WHITELIST=http://localhost:4200
./api-linux # or api-macos / api-win.exe depending on your platform
```
The server runs in desktop mode (no auth) on `http://localhost:5000` by default.
`HTTP_PORT` is not optional in SASjs Server 3.x: `PORT` and `PROTOCOL` are deprecated, and a server started without `HTTP_PORT` or `HTTPS_PORT` exits with "no listener is enabled". With it set, the server runs in desktop mode (no auth) on `http://localhost:5000`.
### 2. Deploy the mock services and streaming frontend
@@ -134,6 +134,10 @@ There is also a SAS 9 mock variant under `sas/mocks/sas9/` (target `sas9-mocks`)
After changing mock services, re-run `sasjs cbd -t server-ci` from `sas/mocks/sasjs/`. After changing the frontend, rebuild (`cd client && npm run build`) then re-deploy so the streaming app picks up the new `client/dist/`. If you are using `ng serve` (step 3), only the mock services need re-deploying; the frontend hot-reloads automatically.
### Demo and staging sites
A push to `release/**` publishes [staging.datacontroller.io](https://staging.datacontroller.io); a release tag (`v*`, created by the release job after its tests pass) publishes [demo.datacontroller.io](https://demo.datacontroller.io) - workflow file `.gitea/workflows/sites.yaml`, using the `DEMO_DATACONTROLLER_IO` Surfer app password (user `allan`). Both are sites on one multi-site Surfer instance; the demo is its default site. The job builds the mocks as a browser-hosted site (SASjs CLI >= 6.1, `streamConfig.mockWeb`), so the services run in a service worker and the drive lives in the visitor's IndexedDB - there is no server. It runs `makedata` on a throwaway SASjs Server first and ships that drive as `sasjsbuild/mock-snapshot.json`; without it the site opens with no data. The estate carries no licence key, so CI runs on the free tier until a key is registered through the licensing screen (`admin/registerkey`) - the Cypress setup does that for the specs that need one. The Sites job writes a licence into the published drive, so demo and staging are fully usable. The pair lives in `sas/mocks/mock-licence.json`: the two values are one RSA key and are regenerated together, and the `.gitleaksignore` entries for it are line-scoped, so inserting a line above the pair re-fires the scanner rather than revealing a new secret.
## GUI Elements
For documentation on the Clarity Design System, including a list of components and example usage, see [our website](https://vmware.github.io/clarity).
@@ -0,0 +1,592 @@
// Clip script: special missings inside Data Controller's validation rules.
//
// This is not a test - it is the recording script for the companion clip, and
// it deliberately pauses between steps so each beat is readable on video. It
// lives in cypress/clips (outside cypress/e2e) so the default spec pattern does
// not pick it up in CI.
//
// Record it with:
//
// npx cypress run --spec cypress/clips/special-missings-clip.cy.ts \
// --config video=true,viewportWidth=1280,viewportHeight=720
//
// The table is TESTDATA.DEMO_01 (seven columns, one rule each):
// ID (NOTNULL), AMOUNT (MINVAL 1), SCORE (MAXVAL 100),
// REF (SOFTREGEX /^[0-9]+$/), STATUS (SOFTSELECT TESTDATA.DEMO_01.STATUS),
// RATING (no rule), LAST_REVIEWED (date9.)
//
// One editing session, one submission. The rule scenes are played on row 1 and
// each value is put back afterwards, so the DIFF that follows carries only the
// two changes the clip is about; the review screens are reached through the
// app's own navigation rather than cy.visit, so nothing reloads mid-clip.
//
// The beats are deliberately short - the take is played back at ~1.4x on the
// way out, so a hold that looks tight here reads as a normal pause on the
// finished clip.
// Caption track: each mark opens a caption and carries the text it shows.
// The encoder turns consecutive marks into subtitle cues, so the captions are
// timed by the recording itself rather than by guessed offsets.
const BEATS = '/tmp/clip-beats.tsv'
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
// A beat long enough to read on video.
const beat = (ms = 1500) => cy.wait(ms)
context('special missings clip (DEMO_01)', function () {
this.beforeEach(() => {
cy.visit(hostUrl + appLocation)
// Assumes the estate is already activated (the licensing spec registers a
// valid key); otherwise a licensing page would sit in shot.
cy.get('.nav-tree', { timeout: longerCommandTimeout }).should('exist')
})
it('records the demo in one editing session', () => {
cy.writeFile(BEATS, '', { flag: 'w' })
// ---- Scene 1: the table and its rules ----------------------------------
openTableFromTree('testdata', 'demo_01')
beat(1200)
clickOnEdit(() => {
// Seven columns, five rules: ID is the key, AMOUNT the floor, SCORE the
// ceiling, REF the pattern, STATUS the dropdown, and RATING and
// LAST_REVIEWED carry nothing.
cy.get('.ht_master tbody tr', { timeout: longerCommandTimeout }).should(
'have.length.greaterThan',
3
)
mark(
'grid',
'TESTDATA.DEMO_01 - eight columns, six rules. ID is the key, and RATING and LAST_REVIEWED carry none.'
)
beat(2600)
// ---- Scene 2: typing a special missing ------------------------------
// RATING has no rule, so this shows entry on its own. Every beat asserts
// the settled cell state before holding, so the recording always rests on
// the outcome (flagged or accepted) rather than on a blind pause that
// might land before the rule engine has run.
mark(
'entry',
'A numeric cell takes a special missing as a letter or an underscore, with or without a period - row 2 already holds .a.'
)
typeAndHold(0, 'RATING', 'a', 'accepted') // a single letter is taken
mark(
'reject',
'Two letters, or a letter mixed with a number, are refused. Red means it will not submit.'
)
typeAndHold(0, 'RATING', 'AB', 'rejected', 2200) // two letters are not
typeAndHold(0, 'RATING', '1a', 'rejected', 2200) // nor a number and a letter
typeAndHold(0, 'RATING', 'a', 'accepted') // leave it as a special missing
// ---- Scene 3: NOTNULL refuses both --------------------------------
// ID is the key, so NOTNULL applies. A special missing is not a value
// here: like a blank, it fails the rule (a real SAS NOT NULL constraint
// rejects a special missing as well), and only a number satisfies it -
// the original key, put back so the row carries no change into the DIFF.
mark(
'notnull_blank',
"ID is the table's primary key, so NOT NULL is applied to it automatically - a blank fails..."
)
typeAndHold(0, 'ID', '', 'rejected', 2200) // a blank fails NOTNULL
mark(
'notnull_missing',
'...and so does a special missing: a missing is not a value to NOT NULL.'
)
typeAndHold(0, 'ID', 'A', 'rejected', 2200) // so does a special missing
mark(
'notnull_number',
'A number satisfies it, and the row key goes back.'
)
typeAndHold(0, 'ID', '1', 'accepted') // a number is what it wants
// ---- Scene 4: the pattern still applies -----------------------------
// REF carries SOFTREGEX /^[0-9]+$/, and a special missing is not exempt
// from it. The amber cell is a soft rule warning rather than a block,
// which the caption on this beat says out loud - the pattern itself is
// only visible in the cell's native title, which a screencast does not
// capture.
mark(
'softregex',
'REF carries SOFTREGEX /^[0-9]+$/. Amber is a soft warning - it warns, it does not block.'
)
typeIntoCell(0, 'REF', 'A')
getCellByHeaderAndRow(0, 'REF').should('have.class', 'dc-warning-cell')
beat(3400)
typeIntoCell(0, 'REF', '1001') // put the reference back
getCellByHeaderAndRow(0, 'REF').should(
'not.have.class',
'dc-warning-cell'
)
beat(600)
// ---- Scene 5: the dropdown lists the missing -------------------------
// STATUS carries a SOFTSELECT whose list is taken from the column itself
// (the library.member.column form), and that column holds a special
// missing - so the dropdown offers it alongside the ordinary values, as
// the bare letter SAS produces for it.
mark(
'dropdown',
"STATUS carries a SOFTSELECT, and its list is the column's own values."
)
openDropdown(0, 'STATUS')
.should('have.length', 4)
.then(($items: any) => {
const texts = [...$items].map((td: any) => td.innerText.trim())
expect(texts).to.include('A')
})
beat(2400)
mark(
'dropdown_pick',
'So the special missing the column holds is offered as a bare letter, first - a missing sorts below every number.'
)
pickFromDropdown('A')
getCellByHeaderAndRow(0, 'STATUS').should('contain.text', 'A')
beat(1800)
typeIntoCell(0, 'STATUS', '1') // put the status back
beat(600)
// ---- Scene 6: a range rule compares in SAS order, missings included
mark(
'minval',
'AMOUNT has MINVAL 1. A missing sorts below every number, so it is below the floor.'
)
typeAndHold(0, 'AMOUNT', 'A', 'rejected', 2200) // a missing is below the floor
mark(
'maxval',
'SCORE has MAXVAL 100 - the same missing is below the ceiling, so it passes.'
)
typeAndHold(0, 'SCORE', 'A', 'accepted', 2200) // a missing is below the ceiling
mark(
'grade',
'GRADE takes MINVAL .A and MAXVAL .C. The missings have an order of their own: .B is inside the range, .D is outside it.'
)
typeAndHold(0, 'GRADE', '.B', 'accepted', 2400) // .B is between .A and .C
typeAndHold(0, 'GRADE', '.D', 'rejected', 2400) // .D is above .C
mark('abort', 'Submitting with an invalid cell aborts.')
// Submit while AMOUNT is invalid - the modal reports it.
submitTable(() => {
cy.get('.modal-body', { timeout: longerCommandTimeout }).should(
'contain.text',
'Invalid Values are Present'
)
beat(2400)
// Close the abort so the editor is clean for the next scene.
cy.get('clr-modal.clr-abort-modal .modal-footer button')
.contains('Close')
.click({ force: true })
beat(800)
})
// ---- Scene 7: put the test values back, then make the real change ----
mark(
'clean',
'Back to a clean row. Row 2 already holds .a, so this changes one special missing to another.'
)
typeIntoCell(0, 'AMOUNT', '120')
typeIntoCell(0, 'SCORE', '82')
typeIntoCell(0, 'GRADE', '.a')
typeIntoCell(0, 'RATING', '4')
beat(800)
// Row 2 (ID 2) already carries a special missing in RATING, so this is a
// change from one special missing to another, and the date column gives
// the formatted / unformatted switch something to switch.
typeAndHold(1, 'RATING', 'B', 'accepted')
typeIntoDateCell(1, 'LAST_REVIEWED', '2026-01-15')
beat(1500)
submitTable(() => {
cy.get('#submitBtn', { timeout: longerCommandTimeout })
.should('exist')
.should('not.be.disabled')
.click()
beat(2500)
})
})
// ---- Scene 8: the queue, then the DIFF (in-app navigation) ------------
mark('submitted', 'Submitted - the queue shows it waiting for approval.')
goToReviewNav()
beat(1800)
// The submit queue lists oldest first, so the row we just created is last.
cy.get('app-submitter clr-datagrid clr-dg-row', {
timeout: longerCommandTimeout
})
.should('exist')
.last()
.click({ force: true })
beat(1800)
cy.get('app-approve-details .card', { timeout: longerCommandTimeout })
.should('exist')
.should('be.visible')
beat(1000)
// The DIFF table is wider than the frame, so the two columns that matter
// (RATING and LAST_REVIEWED) sit off the right edge until it is scrolled.
scrollDiffToEnd()
beat(1200)
// Only those two cells changed: the rule scenes were put back, so the DIFF
// is the two changes the clip is about and nothing else.
getDiffCell('RATING')
.should('contain.text', '.b')
.should('have.class', 'ch')
getDiffCell('LAST_REVIEWED')
.should('contain.text', '15JAN2026')
.should('have.class', 'ch')
cy.get('app-approve-details .tableCont tbody tr td:not(.ch)').should(
'have.length.greaterThan',
3
)
mark(
'diff',
'The DIFF compares staged with base: one changed row, two changed cells.'
)
beat(2600)
// ---- Scene 9: the staged data -----------------------------------------
// What the approval is actually acting on: the staged row, still holding
// the special missing, before it reaches the base table.
mark(
'staged',
'The staged row, before approval - still holding the special missing.'
)
clickButton('VIEW STAGED DATA')
// 'Basic Submitted Details' is on the staged screen only - asserting
// 'Staged Data' alone would be satisfied by the button that was just
// clicked, which is how a beat can pass without ever leaving the DIFF.
cy.get('body', { timeout: longerCommandTimeout })
.should('contain.text', 'Basic Submitted Details')
.and('contain.text', 'Base Table')
beat(4200)
mark('staged_end', '')
// ---- Scene 10: the approver opens it, and switches the format ----------
goToReviewNav()
beat(1500)
openApproveTab()
beat(1500)
cy.get('app-approve clr-datagrid clr-dg-row a.color-green', {
timeout: longerCommandTimeout
})
.should('exist')
.last()
.click({ force: true })
beat(1800)
cy.get('#acceptBtn', { timeout: longerCommandTimeout })
.should('exist')
.should('not.be.disabled')
beat(1000)
// Same scroll as the submitter view, so the date column is in frame when
// the format is switched.
scrollDiffToEnd()
beat(1200)
mark(
'approve',
'The approver opens the same submission. Hovering a changed cell shows the value it replaced.'
)
// Hovering the two changed cells shows what each replaced - that is how the
// two special missings are told apart, not just the before/after of one.
hoverDiffCell('RATING', 'Original value is: .a')
beat(2800)
mark('hover_date', '...including the date it replaced.')
hoverDiffCell('LAST_REVIEWED', 'Original value is: 29FEB2024')
beat(2800)
mark(
'toggle',
'The formatted / unformatted switch shows the value as SAS stores it: 24121.'
)
cy.get('.formatted-values-toggle').should('have.text', 'Formatted').click()
cy.get('.formatted-values-toggle').should('have.text', 'Unformatted')
getDiffCell('LAST_REVIEWED').should('contain.text', '24121')
getDiffCell('RATING').should('contain.text', '.b')
beat(2800)
cy.get('.formatted-values-toggle').click()
cy.get('.formatted-values-toggle').should('have.text', 'Formatted')
getDiffCell('LAST_REVIEWED').should('contain.text', '15JAN2026')
beat(1000)
// ---- Scene 11: approve, and the change is in the history --------------
mark('accepted', 'Accepted - the history records it as APPROVED.')
cy.get('#acceptBtn').click()
cy.url({ timeout: longerCommandTimeout }).should(
'include',
'/review/history'
)
cy.get('app-history clr-datagrid clr-dg-row', {
timeout: longerCommandTimeout
})
.should('exist')
.first()
.should('contain.text', 'APPROVED')
beat(2800)
})
})
// ---------------------------------------------------------------------------
// Helpers (mirrored from the e2e specs so the clip drives the same UI paths)
// ---------------------------------------------------------------------------
/**
* Caption track. Each mark opens a caption and carries the text it shows; the
* encoder turns consecutive marks into subtitle cues, so the captions are timed
* by the recording itself rather than by guessed offsets.
*
* The timestamp has to be taken inside a `cy.then()`: Cypress evaluates a
* command's arguments when the command is *queued*, so `Date.now()` passed to
* `cy.writeFile` directly would give every mark the same value - the moment the
* spec body ran.
*/
const mark = (label: string, text: string) => {
cy.then(() => {
cy.writeFile(BEATS, `${label}\t${text}\t${Date.now()}\n`, { flag: 'a+' })
})
}
const typeIntoCell = (rowIndex: number, header: string, value: string) => {
getCellByHeaderAndRow(rowIndex, header)
.dblclick({ force: true })
.then(() => {
cy.focused().clear().type(`${value}{enter}`)
})
}
/**
* A date-formatted column edits through an HTML date input, where cy.type()
* refuses anything but a bare YYYY-MM-DD string (so no {enter} in the same
* call). Set the value through the DOM and commit it with the Enter keydown
* that Handsontable listens for.
*/
const typeIntoDateCell = (rowIndex: number, header: string, value: string) => {
getCellByHeaderAndRow(rowIndex, header)
.dblclick({ force: true })
.then(() => {
cy.focused()
.then(($i: any) => {
const el = $i[0]
el.value = value
el.dispatchEvent(new Event('input', { bubbles: true }))
el.dispatchEvent(new Event('change', { bubbles: true }))
})
.trigger('keydown', { key: 'Enter', keyCode: 13, which: 13 })
})
}
/**
* Opens the selectbox on a cell and returns its list entries. Handsontable
* renders the arrow itself (`.htAutocompleteArrow`); the list is a
* `.handsontable.listbox` in the app document.
*/
const openDropdown = (rowIndex: number, header: string) => {
getCellByHeaderAndRow(rowIndex, header).within(() => {
cy.get('.htAutocompleteArrow').click({ force: true })
})
return cy.get('.handsontable.listbox td', { timeout: longerCommandTimeout })
}
/** Picks an entry from the open selectbox. */
const pickFromDropdown = (value: string) => {
cy.get('.handsontable.listbox td').contains(value).click({ force: true })
}
/** Reaches the review area through the app's own navigation (no reload). */
const goToReviewNav = () => {
cy.get('.nav-link', { timeout: longerCommandTimeout })
.contains('REVIEW')
.click({ force: true })
}
/** Opens the APPROVE tab within the review area. */
const openApproveTab = () => {
cy.get('.nav-link', { timeout: longerCommandTimeout })
.contains('APPROVE')
.click({ force: true })
}
/**
* Clicks a button by its visible text. The match is case-insensitive: the app
* uppercases button labels in CSS, so the rendered text and the DOM's
* textContent differ.
*/
const clickButton = (text: string) => {
cy.contains('button', new RegExp(text, 'i'), {
timeout: longerCommandTimeout
}).click({ force: true })
}
/**
* The DIFF table is wider than the recording frame, so scroll its container to
* the end - that is what puts the changed RATING and the date column on screen.
*/
const scrollDiffToEnd = () => {
cy.get('app-approve-details .tableCont', { timeout: longerCommandTimeout })
.should('exist')
.scrollTo('right', { duration: 1200 })
}
/**
* The DIFF on the review screen is a plain HTML table (`.tableCont`), not
* Handsontable: headers are `th`, cells `td`, and a changed cell also carries
* the `ch` class whose tooltip holds the value it replaced.
*/
const getDiffCell = (headerText: string) => {
return cy
.get('app-approve-details .tableCont thead tr th', {
timeout: longerCommandTimeout
})
.should(($ths) => {
const texts = [...$ths].map((th) => th.innerText.trim())
expect(texts).to.include(headerText)
})
.then(($ths) => {
const index = [...$ths].findIndex(
(th) => th.innerText.trim() === headerText
)
return cy
.get('app-approve-details .tableCont tbody tr')
.first()
.then(($tr: any) => $tr[0].childNodes[index])
.then((cell) => cy.get(cell))
})
}
/**
* Reveals the value a changed DIFF cell replaced, and waits until it is really
* on screen.
*
* Clarity shows the tooltip through CSS :hover, which a synthetic
* `trigger('mouseover')` does NOT activate - the tooltip stays
* `visibility: hidden`, and a `contain.text` assertion still passes because the
* text is in the DOM. So this moves the real mouse (cypress-real-events) and
* then asserts the computed style. The first real move after another action can
* be swallowed, hence the repeat; if the tooltip ever fails to appear the
* recording fails rather than quietly showing nothing.
*/
const hoverDiffCell = (headerText: string, expected: string) => {
getDiffCell(headerText).realHover()
beat(300)
getDiffCell(headerText).realHover()
getDiffCell(headerText)
.find('.tooltip-content')
.should(($t) => {
const style = getComputedStyle($t[0] as HTMLElement)
expect(style.visibility, 'tooltip visibility').to.eq('visible')
expect(Number(style.opacity), 'tooltip opacity').to.be.greaterThan(0)
expect($t[0].textContent || '', 'tooltip text').to.contain(expected)
})
}
/**
* Types a value into a cell and holds on the settled result. The rule engine
* flags the cell (htInvalid) once the edit commits, so asserting the expected
* state before the hold means the recording always rests on the outcome, and
* waits for it however long the engine takes.
*
* @param expected 'rejected' when the rule engine should flag the cell,
* 'accepted' when the value should settle unflagged.
*/
const typeAndHold = (
rowIndex: number,
header: string,
value: string,
expected: 'accepted' | 'rejected',
hold = 1800
) => {
typeIntoCell(rowIndex, header, value)
getCellByHeaderAndRow(rowIndex, header).should(
expected === 'rejected' ? 'have.class' : 'not.have.class',
'htInvalid'
)
beat(hold)
}
const getCellByHeaderAndRow = (rowIndex: number, headerText: string) => {
return cy
.get('.ht_clone_top .htCore thead tr th')
.should(($ths) => {
const texts = [...$ths].map((th) => th.innerText.trim())
expect(texts).to.include(headerText)
})
.then(($ths) => {
const index = [...$ths].findIndex(
(th) => th.innerText.trim() === headerText
)
return cy
.get('.ht_master tbody tr')
.then((rows: any) => rows[rowIndex].childNodes[index])
.then((cell) => cy.get(cell))
})
}
const clickOnEdit = (callback?: any) => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => {
if (callback) callback()
})
}
const submitTable = (callback?: any) => {
cy.get('.btnCtrl button.btn-primary')
.click()
.then(() => {
if (callback) callback()
})
}
const openTableFromTree = (libNameIncludes: string, tablename: string) => {
cy.get('.app-loading', { timeout: longerCommandTimeout })
.should('not.exist')
.then(() => {
cy.get('.nav-tree clr-tree > clr-tree-node', {
timeout: longerCommandTimeout
}).then((treeNodes: any) => {
let libNode
for (let node of treeNodes) {
if (node.innerText.toLowerCase().includes(libNameIncludes)) {
libNode = node
break
}
}
cy.get(libNode).within(() => {
cy.get('.clr-tree-node-content-container > button').click()
cy.get('.clr-treenode-link').then((innerNodes: any) => {
for (let innerNode of innerNodes) {
if (innerNode.innerText.toLowerCase().includes(tablename)) {
innerNode.click()
break
}
}
})
})
})
})
}
+165
View File
@@ -0,0 +1,165 @@
// Marks this file as an ES module so its top-level consts don't collide with
// other spec files under the TS type-checker.
export {}
//
// The client sends `browser_info` (and `browser_url_vars`, when the page URL
// has parameters) with the startup service and with the services that execute
// customer-provided code - hook scripts and dynamic cell dropdown programs.
// Other services do not receive the tables.
//
// Payloads are keyed by the _program value in the request URL, so the
// assertions can tell one service's payload from another's. Asserted on the
// adapter interface, which is the only place the payload is observable end
// to end.
//
// Each test starts from a plain visit of the app root rather than assuming
// the previous test's session: Cypress clears cookies between tests, the
// SASjs Server session drops, and the app lands back on the evaluation
// agreement card. The acceptance is guarded, so it is a no-op when the
// session survived.
const hostUrl = Cypress.env('hosturl')
/** The services the app sends diagnostics to (see DIAGNOSTICS_SERVICES in
* client/src/app/services/sas.service.ts). */
const DIAGNOSTICS_SERVICES = [
'public/startupservice',
'editors/getdata',
'editors/getdynamiccolvals',
'editors/stagedata',
'editors/loadfile',
'editors/restore',
'auditors/postdata'
]
/** Boots the app at the root, accepting the evaluation agreement if shown. */
const bootApp = () => {
cy.visit(hostUrl, { timeout: 60000 })
cy.get('body').then(($body) => {
if ($body.find('#TCS input[type="checkbox"]').length) {
cy.get('#TCS input[type="checkbox"]').check({ force: true })
cy.wait(4000)
}
})
}
/** Captures each service's payload, keyed by the _program URL parameter. */
const capturePrograms = (): Record<string, string> => {
const programs: Record<string, string> = {}
cy.intercept('**/stp/execute/**', (req) => {
// The handler must never throw: an exception inside an intercept handler
// aborts the request, which breaks the app under test. A lone '%' in the
// URL would make decodeURIComponent throw, hence the guarded parse.
let program = req.url
try {
program = decodeURIComponent(
(req.url.match(/_program=([^&]+)/) || [])[1] || ''
)
} catch (e) {
program = (req.url.match(/_program=([^&]+)/) || [])[1] || req.url
}
if (typeof req.body === 'string') {
programs[program] = req.body
} else {
programs[program] = JSON.stringify(req.body)
}
})
return programs
}
context('browser_info input table: ', function () {
it('1 | services that run no customer code do not receive it', () => {
const programs = capturePrograms()
bootApp()
// The viewer route fires public/viewlibs and a usernav service - plain
// data services with no hook scripts and no customer includes. Taken
// from a fresh boot, before anything caches the library tree.
cy.visit(`${hostUrl}/#/view/data`, { timeout: 60000 })
cy.wait(8000)
cy.then(() => {
const captured = Object.keys(programs)
// The startup service is a diagnostics service by design - it runs on
// every boot, which is the point of it - so it is excluded from this
// sweep. On a real estate it would otherwise appear here carrying
// browser_info and fail the test.
const plain = captured.filter(
(program) => !DIAGNOSTICS_SERVICES.some((s) => program.includes(s))
)
expect(
plain.length,
`non-diagnostics service calls captured (${captured.join(', ')})`
).to.be.greaterThan(0)
plain.forEach((program) => {
expect(
programs[program],
`${program} carries no browser_info`
).not.to.contain('browser_info')
})
})
})
it('2 | hook-running services receive it', () => {
const programs = capturePrograms()
bootApp()
// Opening the editor directly makes the app call editors/getdata, which
// runs the pre-edit hook and so receives the diagnostics tables.
cy.visit(`${hostUrl}/#/editor/DC_JSLIB.MPE_X_TEST`, { timeout: 60000 })
cy.get('#hotTable', { timeout: 60000 }).should('exist')
cy.wait(8000)
cy.then(() => {
const captured = Object.keys(programs)
expect(
captured.length,
`service calls captured (${captured.join(', ')})`
).to.be.greaterThan(0)
// The startup service is the other diagnostics recipient, but it is not
// reachable from a mock estate: `checkSasjsDeploy` finds makedata in
// services/admin and routes to the deploy screen instead, so the app
// never calls it on boot. Its null-payload path is covered by the unit
// spec (src/app/services/sas.service.spec.ts).
const getdata = captured.find((p) => p.includes('editors/getdata'))
expect(getdata, 'editors/getdata captured').to.not.be.undefined
expect(
programs[getdata!],
'getdata payload carries browser_info'
).to.contain('browser_info')
// TIMEZONE is a column of browser_info and of no other input table, so
// this shows the row itself arrived, not just the table name.
expect(
programs[getdata!],
'browser_info row content in the payload'
).to.contain('timezone')
})
})
it('3 | browser_url_vars carries the URL parameters as name/value pairs', () => {
const programs = capturePrograms()
bootApp()
// The labels parameter is read by the editor from the hash query string,
// so the diagnostics tables must carry it as a name/value row.
cy.visit(`${hostUrl}/#/editor/DC_JSLIB.MPE_X_TEST?labels=true`, {
timeout: 60000
})
cy.get('#hotTable', { timeout: 60000 }).should('exist')
cy.wait(8000)
cy.then(() => {
const getdata = Object.keys(programs).find((p) =>
p.includes('editors/getdata')
)
expect(getdata, 'editors/getdata captured').to.not.be.undefined
expect(
programs[getdata!],
'getdata payload carries browser_url_vars'
).to.contain('browser_url_vars')
// the labels parameter, as a name in the name/value table
expect(programs[getdata!], 'labels parameter row').to.contain('labels')
})
})
})
@@ -25,11 +25,13 @@ const libraryToOpenIncludes = Cypress.env(`libraryToOpenIncludes_${serverType}`)
// 2. Ordinary columns (e.g. SOME_DROPDOWN) still get their rule via the
// new per-row cols[].COLTYPE path — test 2 proves the migration didn't
// silently drop real columns' rules either.
// Column positions below come from COLHEADERS in
// sas/mocks/sasjs/services/editors/getdata.js:
// "_____DELETE__THIS__RECORD_____,PRIMARY_KEY_FIELD,SOME_CHAR,SOME_DROPDOWN,..."
// — childNodes[0] on a body <tr> is the row-header <th>, so childNodes[N+1]
// is the Nth (0-indexed) column in that list.
// Column positions below come from the mock's COLHEADERS
// (sas/mocks/sasjs/services/editors/getdata.js):
// "PRIMARY_KEY_FIELD,SOME_CHAR,SOME_DROPDOWN,..."
// — the client-owned delete column is prepended by the editor itself (see
// deleteRecordColumn.ts), so on screen it is still column 0. childNodes[0] on
// a body <tr> is the row-header <th>, so childNodes[N+1] is the Nth
// (0-indexed) column in that list.
context('coltype vertical-array regression tests: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`)
+164
View File
@@ -0,0 +1,164 @@
export {}
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
context('Export DC Library DDL: ', function () {
this.beforeAll(() => {
cy.loginAndUpdateValidKey(true)
})
this.beforeEach(() => {
cy.visit(hostUrl + appLocation)
visitPage('home')
})
it('1 | the admin action opens the flavour chooser and exports the SAS flavour by default', () => {
visitPage('system')
cy.get('.admin-action', { timeout: longerCommandTimeout })
.contains('Export DC Library DDL')
.should('exist')
cy.get('.admin-action').contains('button', 'EXPORT').should('exist')
cy.window().then((win) => {
cy.stub(win, 'open').as('open')
})
cy.get('.admin-action').contains('button', 'EXPORT').click()
const ddlModal = () => cy.contains('clr-modal', 'Export DC Library DDL')
ddlModal().should('be.visible')
ddlModal().within(() => {
cy.get('select').should('have.value', 'SAS')
// the schema box only applies to the DB flavours
cy.contains('label', 'Schema (optional)').should('not.exist')
})
ddlModal().contains('button', 'Export').click()
cy.get('@open').should(
'have.been.calledWithMatch',
/\/services\/admin\/exportdb&flavour=SAS$/
)
})
it('2 | the PGSQL flavour reveals the optional schema box and passes it to the service', () => {
visitPage('system')
cy.window().then((win) => {
cy.stub(win, 'open').as('open')
})
cy.get('.admin-action').contains('button', 'EXPORT').click()
const ddlModal = () => cy.contains('clr-modal', 'Export DC Library DDL')
ddlModal().within(() => {
cy.get('select').select('PGSQL')
cy.contains('label', 'Schema (optional)').should('be.visible')
cy.get('input[type="text"]').clear().type('DC')
})
ddlModal().contains('button', 'Export').click()
cy.get('@open').should(
'have.been.calledWithMatch',
/\/services\/admin\/exportdb&flavour=PGSQL&schema=DC$/
)
})
it('3 | the TSQL flavour exports without a schema when the box is left empty', () => {
visitPage('system')
cy.window().then((win) => {
cy.stub(win, 'open').as('open')
})
cy.get('.admin-action').contains('button', 'EXPORT').click()
const ddlModal = () => cy.contains('clr-modal', 'Export DC Library DDL')
ddlModal().within(() => {
cy.get('select').select('TSQL')
cy.contains('label', 'Schema (optional)').should('be.visible')
})
ddlModal().contains('button', 'Export').click()
cy.get('@open').should(
'have.been.calledWithMatch',
/\/services\/admin\/exportdb&flavour=TSQL$/
)
})
it('4 | the SAS export streams the DC library DDL', () => {
visitPage('system')
cy.window().then((win) => {
cy.stub(win, 'open').as('open')
})
cy.get('.admin-action').contains('button', 'EXPORT').click()
const ddlModal = () => cy.contains('clr-modal', 'Export DC Library DDL')
ddlModal().contains('button', 'Export').click()
// the URL the action opens is served by the backend - against the mocks
// that is services/admin/exportdb.js, which renders the library as basic
// DDL per flavour
cy.get('@open').then((open: any) => {
const url = open.getCall(0).args[0]
expect(url).to.match(/\/services\/admin\/exportdb&flavour=SAS$/)
cy.request(url).then((res) => {
expect(res.status).to.eq(200)
expect(res.headers['content-disposition']).to.contain('DC_JSLIB.ddl')
expect(res.body).to.contain('create table DC_JSLIB.MPE_CONFIG(')
expect(res.body).to.contain('VAR_NAME char(32)')
expect(res.body).to.contain('create table DC_JSLIB.MPE_X_TEST(')
// the SAS flavour has no schema statement and no unique index
expect(res.body).not.to.contain('CREATE SCHEMA')
expect(res.body).not.to.contain('UNIQUE INDEX')
})
})
})
it('5 | the PGSQL export honours the schema and quotes its identifiers', () => {
visitPage('system')
cy.window().then((win) => {
cy.stub(win, 'open').as('open')
})
cy.get('.admin-action').contains('button', 'EXPORT').click()
const ddlModal = () => cy.contains('clr-modal', 'Export DC Library DDL')
ddlModal().within(() => {
cy.get('select').select('PGSQL')
cy.get('input[type="text"]').clear().type('DC')
})
ddlModal().contains('button', 'Export').click()
cy.get('@open').then((open: any) => {
const url = open.getCall(0).args[0]
expect(url).to.match(/&flavour=PGSQL&schema=DC$/)
cy.request(url).then((res) => {
expect(res.status).to.eq(200)
expect(res.body).to.contain('CREATE SCHEMA DC;')
expect(res.body).to.contain('CREATE TABLE DC.MPE_CONFIG (')
expect(res.body).to.contain('"VAR_NAME" VARCHAR(32)')
expect(res.body).to.contain('CREATE UNIQUE INDEX "MPE_CONFIG_pk"')
})
})
})
})
const visitPage = (url: string) => {
cy.visit(`${hostUrl}${appLocation}/#/${url}`)
}
+249
View File
@@ -0,0 +1,249 @@
export {}
//
// Derived (computed) variables are configured per table in MPE_DERIVED and
// created at read time, ahead of the filter, so that they can be filtered on.
//
// TESTDATA.DERIVED_DEMO carries two of them, neither of which is a physical
// column of the table:
// REGION ifc(STATE in ('CA','OR','WA'),'West','East')
// LINE_VALUE QTY * PRICE
//
// The mock implements the derivation in getdata.js / getcolvals.js (see
// mpeDerived in dcMockUtils.js), so the EDIT screen can be exercised without a
// SAS server. The real evaluation is done by SAS.
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
context('derived variables: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`, { timeout: longerCommandTimeout })
cy.loginAndUpdateValidKey(true)
})
this.beforeEach(() => {
cy.viewport(1440, 900)
bootApp()
})
it('1 | derived columns are shown in the EDIT grid with computed values', () => {
openEditor('TESTDATA.DERIVED_DEMO')
getCellByHeaderAndRow(0, 'REGION').should('have.text', 'West')
getCellByHeaderAndRow(1, 'REGION').should('have.text', 'East')
getCellByHeaderAndRow(0, 'LINE_VALUE').should('have.text', '21')
getCellByHeaderAndRow(1, 'LINE_VALUE').should('have.text', '99')
// REGION_LABEL is built on REGION, so it only resolves if the derived
// statements run in VARIABLE_ORDER sequence
getCellByHeaderAndRow(0, 'REGION_LABEL').should('have.text', 'West-CA')
getCellByHeaderAndRow(1, 'REGION_LABEL').should('have.text', 'East-NY')
cy.screenshot('derived-1-grid', { capture: 'viewport' })
})
it('2 | filters on a character derived column', () => {
openEditor('TESTDATA.DERIVED_DEMO')
openFilterPopup()
setFilterVariable('REGION')
setFilterValue('West')
submitFilter()
cy.get('.infoBar-text').should('contain.text', "REGION = 'West'")
cy.get('.ht_master .htCore tbody tr', {
timeout: longerCommandTimeout
}).should('have.length', 2)
getCellByHeaderAndRow(1, 'REGION').should('have.text', 'West')
cy.screenshot('derived-2-filter-region', { capture: 'viewport' })
})
it('3 | filters on a numeric derived column', () => {
openEditor('TESTDATA.DERIVED_DEMO')
openFilterPopup()
setFilterVariable('LINE_VALUE')
setFilterOperator('>')
setFilterValue('50')
submitFilter()
cy.get('.ht_master .htCore tbody tr', {
timeout: longerCommandTimeout
}).should('have.length', 1)
getCellByHeaderAndRow(0, 'LINE_VALUE').should('have.text', '99')
cy.screenshot('derived-3-filter-value', { capture: 'viewport' })
})
it('4 | a derived column is marked read-only, and opens no editor', () => {
openEditor('TESTDATA.DERIVED_DEMO')
// a derived column is read-only AND computed, so the grid marks it apart
// from an ordinary read-only column - its own header/cell class, no
// readonlyCell dimming (editor.component.ts, afterGetColHeader /
// afterGetCellMeta). STATE is the control: same grid, a physical column.
headerCell('REGION').should('have.class', 'dc-derived-header')
headerCell('REGION').should('not.have.class', 'readonlyCell')
headerCell('STATE')
.should('not.have.class', 'dc-derived-header')
.and('not.have.class', 'readonlyCell')
getCellByHeaderAndRow(0, 'REGION').should('have.class', 'dc-derived-cell')
getCellByHeaderAndRow(0, 'STATE').should(
'not.have.class',
'dc-derived-cell'
)
// The computed block opens at whichever derived column comes first in the
// grid - MPE_DERIVED order, so LINE_VALUE here, not REGION. Assert the
// invariant rather than a name: exactly one derived header carries the
// marker, and it is the first one.
cy.get('.ht_clone_top .htCore thead tr th').then(($ths) => {
const derived = [...$ths].filter((th) =>
th.classList.contains('dc-derived-header')
)
expect(derived.length, 'derived headers').to.be.greaterThan(0)
expect(
derived[0].classList.contains('dc-derived-first'),
'the first derived header opens the block'
).to.be.true
derived
.slice(1)
.forEach(
(th) =>
expect(
th.classList.contains('dc-derived-first'),
'only the first derived header carries the marker'
).to.be.false
)
})
// the hover text carries the label, which is what says what the column is:
// the configured VAR_LABEL where there is one, otherwise the generated
// name=expression
headerCell('REGION_LABEL')
.should('have.attr', 'title')
.and('contain', 'Region and state')
headerCell('REGION')
.should('have.attr', 'title')
.and('contain', 'REGION=ifc')
enterEditMode()
getCellByHeaderAndRow(0, 'REGION').dblclick({ force: true })
cy.get('.handsontableInput').should('not.exist')
getCellByHeaderAndRow(0, 'REGION').should('have.text', 'West')
})
/**
* The positive control for the case above: same screen, same edit mode, a
* physical column - so its silence is about the column, not the screen.
*/
it('5 | a physical column in the same grid does accept an edit', () => {
openEditor('TESTDATA.DERIVED_DEMO')
enterEditMode()
getCellByHeaderAndRow(0, 'STATE').dblclick({ force: true })
cy.get('.handsontableInput').should('exist')
})
})
/**
* Cypress clears cookies between tests, which drops the SASjs Server session
* and lands the app back on the evaluation agreement card. Accept it when it is
* shown - a no-op when the session survived.
*/
const bootApp = () => {
cy.visit(hostUrl, { timeout: longerCommandTimeout })
cy.get('body').then(($body: any) => {
if ($body.find('#TCS input[type="checkbox"]').length) {
cy.get('#TCS input[type="checkbox"]').check({ force: true })
cy.wait(4000)
}
})
}
/** Opens a table straight in the EDIT screen and waits for the grid. */
const openEditor = (libMem: string) => {
cy.visit(`${hostUrl}${appLocation}/#/editor/${libMem}`, {
timeout: longerCommandTimeout
})
cy.get('.ht_clone_top .htCore thead tr th', {
timeout: longerCommandTimeout
}).should('exist')
cy.wait(2500)
}
/** The EDIT screen opens read-only; this is the button that starts an edit. */
const enterEditMode = () => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => cy.wait(2500))
}
/** The grid header cell for a column, by its rendered text. */
const headerCell = (headerText: string) =>
cy.get('.ht_clone_top .htCore thead tr th').then(($ths) => {
const th = [...$ths].find(
(candidate) => (candidate as HTMLElement).innerText.trim() === headerText
)
if (!th) throw new Error(`header not found: ${headerText}`)
return cy.wrap(th)
})
const openFilterPopup = () => {
cy.contains('button.btnView', 'Filter', {
timeout: longerCommandTimeout
}).click()
cy.get('.filter-modal', { timeout: longerCommandTimeout }).should(
'be.visible'
)
}
/**
* The soft-select inputs drop a transparent .overlay click-catcher over the
* modal while their suggestion list is open, so they need force.
*/
const setFilterVariable = (column: string) => {
cy.get('#vals_var_id0_0').clear({ force: true }).type(column, { force: true })
cy.get('#datalist_vals_var_id0_0 option').contains(column).click({
force: true
})
cy.get('#vals_var_id0_0').trigger('keyup', { key: 'Escape', force: true })
cy.wait(400)
}
const setFilterValue = (value: string) => {
cy.get('#vals_0_0').clear({ force: true }).type(value, { force: true })
cy.get('#vals_0_0').trigger('keyup', { key: 'Escape', force: true })
cy.wait(400)
}
const setFilterOperator = (operator: string) => {
cy.get('.filter-modal .operator-col select').first().select(operator)
cy.wait(500)
}
const submitFilter = () => {
cy.contains('.filter-modal button', 'Ok').click()
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
cy.wait(2500)
}
const getCellByHeaderAndRow = (rowIndex: number, headerText: string) => {
return cy
.get('.ht_clone_top .htCore thead tr th')
.should(($ths) => {
const texts = [...$ths].map((th) => (th as HTMLElement).innerText.trim())
expect(texts).to.include(headerText)
})
.then(($ths) => {
const index = [...$ths].findIndex(
(th) => (th as HTMLElement).innerText.trim() === headerText
)
return cy
.get('.ht_master tbody tr')
.then((rows: any) => rows[rowIndex].childNodes[index])
.then((cell) => cy.get(cell))
})
}
+33
View File
@@ -399,6 +399,26 @@ context('excel tests: ', function () {
})
})
it('25 | Keeps decimals when the upload preview becomes a manual edit', () => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_test')
// Entering manual edit mode discards the source file but keeps the values
// parsed from it. SOME_NUM holds 0.901045951946194 in the first data row
// of the fixture, so a truncated or zeroed cell fails the assertion.
attachExcelFile('regular_excel.xlsx', () => {
getFirstRowCells().then((previewCells) => {
expect(previewCells).to.include(decimalSomeNum)
cy.get('.btn-upload-preview.btn-primary').click()
cy.get('.modal-footer .btn-success-outline').click()
getFirstRowCells().then((editCells) => {
expect(editCells).to.include(decimalSomeNum)
})
})
})
})
// Large files break Cypress
// it ('? | Uploads Excel with size of 5MB', (done) => {
@@ -476,6 +496,19 @@ const attachExcelFile = (excelFilename: string, callback?: any) => {
})
}
const decimalSomeNum = '0.901045951946194'
// The row's cell texts, without depending on column positions: the preview
// grid renders row-status and delete cells in an order that varies.
const getFirstRowCells = () =>
cy
.get('#hotTable', { timeout: longerCommandTimeout })
.find('div.ht_master.handsontable tbody tr')
.eq(0)
.then(($row) =>
Array.from($row[0].children).map((cell: any) => cell.innerText.trim())
)
const submitExcel = (callback?: any) => {
cy.get('.buttonBar button.preview-submit', { timeout: longerCommandTimeout })
.click()
+257
View File
@@ -0,0 +1,257 @@
export {}
//
// The applied-filter panel shows the clause that is in force. A long clause
// does not fit the collapsed single line, so the panel carries a chevron that
// expands it to show the clause in full - in the viewer and in the editor.
//
// The chevron is only rendered when the clause actually overflows, so a short
// filter looks exactly as it did before.
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
context('applied filter panel: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`, { timeout: longerCommandTimeout })
cy.loginAndUpdateValidKey(true)
})
// the panel behaviour depends on how much room the clause has, so pin a
// laptop-sized window rather than the wider CI viewport
this.beforeEach(() => {
cy.viewport(1280, 800)
bootApp()
})
it('1 | without a filter the panel is not rendered', () => {
openTable('DC_JSLIB.MPE_X_TEST')
cy.get('.infoBar').should('not.exist')
cy.screenshot('filter-panel-1-no-filter', { capture: 'viewport' })
})
it('2 | a short filter is shown in full, with no chevron', () => {
openTable('DC_JSLIB.MPE_X_TEST')
openFilterPopup()
setFilterVariable('SOME_DROPDOWN')
setFilterValue('Option 1')
submitFilter()
cy.get('.infoBar-text').should('contain.text', "SOME_DROPDOWN = 'Option 1'")
// the clause fits the collapsed line, so there is nothing to expand
assertClauseFitsCollapsedLine()
cy.get('.infoBar-toggle').should('not.exist')
cy.screenshot('filter-panel-2-filter', { capture: 'viewport' })
})
it('3 | a long filter is collapsed to a chevron and expands to the full clause', () => {
openTable('DC_JSLIB.MPE_X_TEST')
// SOME_CHAR holds a very long free-text value, so an IN over every value
// produces a clause of several hundred characters
openFilterPopup()
setFilterVariable('SOME_CHAR')
setFilterOperator('IN')
chooseAllFilterValues()
submitFilter()
cy.get('.infoBar-text').should('contain.text', 'SOME_CHAR IN')
assertClauseOverflowsCollapsedLine()
cy.get('.infoBar-toggle')
.should('exist')
.and('have.attr', 'aria-expanded', 'false')
cy.screenshot('filter-panel-3-big-filter-collapsed', {
capture: 'viewport'
})
// expand: the whole clause is rendered, on several lines, unclipped
cy.get('.infoBar-toggle').click()
cy.get('.infoBar').should('have.class', 'expanded')
cy.get('.infoBar-toggle').should('have.attr', 'aria-expanded', 'true')
assertClauseFullyVisible()
assertClauseSpansSeveralLines()
cy.screenshot('filter-panel-3-big-filter-expanded', { capture: 'viewport' })
// collapse again
cy.get('.infoBar-toggle').click()
cy.get('.infoBar').should('not.have.class', 'expanded')
assertClauseOverflowsCollapsedLine()
})
it('4 | the editor panel collapses and expands in the same way', () => {
openTable('DC_JSLIB.MPE_X_TEST')
openFilterPopup()
setFilterVariable('SOME_CHAR')
setFilterOperator('IN')
chooseAllFilterValues()
submitFilter()
// the editor shows the filter the viewer just stored
cy.url().then((url) => {
const filterId = url.split('/').pop()
cy.visit(
`${hostUrl}${appLocation}/#/editor/DC_JSLIB.MPE_X_TEST/${filterId}`,
{ timeout: longerCommandTimeout }
)
})
// wait for the editor itself - .editor-title/.btnCtrl are editor-only, so
// this cannot pass on the viewer the visit came from
cy.get('.editor-title', { timeout: longerCommandTimeout }).should('exist')
cy.get('.btnCtrl', { timeout: longerCommandTimeout }).should('exist')
cy.get('.infoBar-text', { timeout: longerCommandTimeout }).should(
'contain.text',
'SOME_CHAR IN'
)
assertClauseOverflowsCollapsedLine()
cy.screenshot('filter-panel-4-editor-collapsed', { capture: 'viewport' })
cy.get('.infoBar-toggle').click()
cy.get('.infoBar').should('have.class', 'expanded')
assertClauseFullyVisible()
assertClauseSpansSeveralLines()
cy.screenshot('filter-panel-4-editor-expanded', { capture: 'viewport' })
})
})
/**
* Cypress clears cookies between tests, which drops the SASjs Server session
* and lands the app back on the evaluation agreement card. Accept it when it is
* shown - a no-op when the session survived.
*/
const bootApp = () => {
cy.visit(hostUrl, { timeout: longerCommandTimeout })
cy.get('body').then(($body: any) => {
if ($body.find('#TCS input[type="checkbox"]').length) {
cy.get('#TCS input[type="checkbox"]').check({ force: true })
cy.wait(4000)
}
})
}
/** Opens a table in the viewer and waits for its grid to render. */
const openTable = (libMem: string) => {
cy.visit(`${hostUrl}${appLocation}/#/view/data/${libMem}`, {
timeout: longerCommandTimeout
})
cy.get('.filterSide', { timeout: longerCommandTimeout }).should('exist')
cy.wait(2500)
}
const openFilterPopup = () => {
cy.get('.filterSide', { timeout: longerCommandTimeout }).click()
cy.get('clr-dropdown-menu', { timeout: longerCommandTimeout })
.contains('Filter')
.click()
cy.get('.filter-modal', { timeout: longerCommandTimeout }).should(
'be.visible'
)
}
/**
* The soft-select inputs drop a transparent .overlay click-catcher over the
* modal while their suggestion list is open, so they need force.
*/
const setFilterVariable = (column: string) => {
cy.get('#vals_var_id0_0').clear({ force: true }).type(column, { force: true })
cy.get('#datalist_vals_var_id0_0 option').contains(column).click({
force: true
})
cy.get('#vals_var_id0_0').trigger('keyup', { key: 'Escape', force: true })
cy.wait(400)
}
const setFilterValue = (value: string) => {
cy.get('#vals_0_0').clear({ force: true }).type(value, { force: true })
cy.get('#vals_0_0').trigger('keyup', { key: 'Escape', force: true })
cy.wait(400)
}
const setFilterOperator = (operator: string) => {
cy.get('.filter-modal .operator-col select').first().select(operator)
cy.wait(500)
}
/** IN/NOT IN take their values from a modal of checkboxes - take them all. */
const chooseAllFilterValues = () => {
cy.contains('.filter-modal button', 'Choose values').click()
cy.get('.in-values-modal', { timeout: longerCommandTimeout }).should(
'be.visible'
)
cy.get('.in-values-modal input[type=checkbox]').then(($checkboxes: any) => {
for (let i = 0; i < $checkboxes.length; i++) {
cy.get('.in-values-modal input[type=checkbox]')
.eq(i)
.click({ force: true })
}
})
cy.contains('.in-values-modal button', 'Apply').click()
cy.wait(500)
}
const submitFilter = () => {
cy.contains('.filter-modal button', 'Ok').click()
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
cy.wait(2500)
}
/** The clause is wider than the collapsed line, so it is clipped. */
const assertClauseOverflowsCollapsedLine = () => {
cy.get('.infoBar-text').then(($text: any) => {
const el = $text[0] as HTMLElement
expect(
el.scrollWidth,
'the clause is wider than the collapsed line'
).to.be.greaterThan(el.clientWidth)
expect(
el.ownerDocument.defaultView!.getComputedStyle(el).whiteSpace,
'collapsed panel does not wrap'
).to.equal('nowrap')
})
}
/** The clause fits the collapsed line, so nothing is hidden. */
const assertClauseFitsCollapsedLine = () => {
cy.get('.infoBar-text').then(($text: any) => {
const el = $text[0] as HTMLElement
expect(el.scrollWidth, 'the clause fits the collapsed line').to.be.at.most(
el.clientWidth
)
})
}
/** Expanded, the whole clause is rendered and nothing is clipped. */
const assertClauseFullyVisible = () => {
cy.get('.infoBar-text').then(($text: any) => {
const el = $text[0] as HTMLElement
const style = el.ownerDocument.defaultView!.getComputedStyle(el)
expect(style.whiteSpace, 'expanded panel wraps').to.equal('normal')
expect(el.scrollWidth, 'expanded panel clips nothing').to.be.at.most(
el.clientWidth
)
})
}
/** Expanded, the clause occupies several lines rather than one. */
const assertClauseSpansSeveralLines = () => {
cy.get('.infoBar-text').then(($text: any) => {
const el = $text[0] as HTMLElement
const lineHeight =
parseFloat(
el.ownerDocument.defaultView!.getComputedStyle(el).lineHeight
) || 20
expect(
el.clientHeight / lineHeight,
'the clause spans several lines'
).to.be.greaterThan(3)
})
}
+144 -19
View File
@@ -11,6 +11,18 @@ context('filtering tests: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`, { timeout: longerCommandTimeout })
cy.loginAndUpdateValidKey()
/**
* The evaluation agreement is per-origin localStorage, so a fresh browser
* profile lands on it and the nav tree never renders. Guarded, so it is a
* no-op once an earlier spec in the run has accepted it.
*/
cy.get('body').then(($body) => {
if ($body.find('#TCS input[type="checkbox"]').length) {
cy.get('#TCS input[type="checkbox"]').check({ force: true })
cy.wait(4000)
}
})
})
this.beforeEach(() => {
@@ -51,9 +63,13 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_TIME', '00:00:42', 'time', () => {
checkInfoBarIncludes(`(( SOME_TIME = 42 ))`, (includes: boolean) => {
if (includes) done()
})
checkInfoBarIncludes(
`(( SOME_TIME = '00:00:42't ))`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(3, () => done())
}
)
})
})
})
@@ -63,9 +79,13 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_TIME', '42', 'value', () => {
checkInfoBarIncludes(`(( SOME_TIME = 42 ))`, (includes: boolean) => {
if (includes) done()
})
checkInfoBarIncludes(
`(( SOME_TIME = '00:00:42't ))`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(3, () => done())
}
)
})
}, false)
})
@@ -75,9 +95,13 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_DATE', '12/02/1960', 'date', () => {
checkInfoBarIncludes(`(( SOME_DATE = 42 ))`, (includes: boolean) => {
if (includes) done()
})
checkInfoBarIncludes(
`(( SOME_DATE = '12FEB1960'd ))`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(5, () => done())
}
)
})
})
})
@@ -87,9 +111,13 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_DATE', '42', 'value', () => {
checkInfoBarIncludes(`(( SOME_DATE = 42 ))`, (includes: boolean) => {
if (includes) done()
})
checkInfoBarIncludes(
`(( SOME_DATE = '12FEB1960'd ))`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(5, () => done())
}
)
})
}, false)
})
@@ -104,9 +132,10 @@ context('filtering tests: ', function () {
'datetime',
() => {
checkInfoBarIncludes(
`(( SOME_DATETIME = 42 ))`,
`(( SOME_DATETIME = '01JAN1960:00:00:42'dt ))`,
(includes: boolean) => {
if (includes) done()
if (!includes) return
assertGridRowCount(5, () => done())
}
)
}
@@ -120,9 +149,10 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_DATETIME', '42', 'value', () => {
checkInfoBarIncludes(
`(( SOME_DATETIME = 42 ))`,
`(( SOME_DATETIME = '01JAN1960:00:00:42'dt ))`,
(includes: boolean) => {
if (includes) done()
if (!includes) return
assertGridRowCount(5, () => done())
}
)
})
@@ -134,9 +164,13 @@ context('filtering tests: ', function () {
openFilterPopup(() => {
setFilterWithValue('SOME_DATE', '', 'in', () => {
checkInfoBarIncludes(`(( SOME_DATE IN (42) ))`, (includes: boolean) => {
if (includes) done()
})
checkInfoBarIncludes(
`(( SOME_DATE IN ('12FEB1960'd) ))`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(5, () => done())
}
)
})
})
})
@@ -156,6 +190,34 @@ context('filtering tests: ', function () {
// })
// })
// })
/**
* With the pickers off, a temporal BETWEEN takes both of its values from a
* soft-select over the column's values, so the value is chosen from that list
* rather than typed. The range dropdown binds the formatted label, as the
* single-value dropdown's list does, so the field reads the date and the
* clause composition maps it back to the internal day / second count before
* the literal is built - a display string that reached sasTemporalLiteral as
* a non-number would come back null and be passed through to RAW_VALUE
* unquoted, which mp_filtercheck rejects on a numeric column and aborts the
* save. The test asserts the applied clause and the row count, so it pins
* the mapping end to end.
*/
it('7 | Non picker - filter date field BETWEEN from the value list', (done) => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_test')
openFilterPopup(() => {
setTemporalRangeFromValueList('SOME_DATE', '12FEB1960', () => {
checkInfoBarIncludes(
`BETWEEN '12FEB1960'd AND '12FEB1960'd`,
(includes: boolean) => {
if (!includes) return
assertGridRowCount(5, () => done())
}
)
})
}, false)
})
})
const checkInfoBarIncludes = (text: string, callback: any) => {
@@ -166,6 +228,21 @@ const checkInfoBarIncludes = (text: string, callback: any) => {
})
}
/**
* The temporal filter tests assert the applied filter still selects the same
* rows as the internal value did - a readable clause that filtered differently
* would be a worse bug than the one being fixed.
*/
const assertGridRowCount = (expected: number, callback: any) => {
cy.get('#hotTable .ht_master tbody tr', {
timeout: longerCommandTimeout
})
.should('have.length', expected)
.then(() => {
if (callback) callback()
})
}
const openFilterPopup = (
callback?: any,
usePickers: boolean = true,
@@ -331,6 +408,54 @@ const setFilterWithValue = (
if (callback) callback()
}
/**
* Drives a temporal BETWEEN with the pickers off, choosing both values from the
* range soft-select's list rather than typing them - typing bypasses the
* binding this test exists to pin.
*/
const setTemporalRangeFromValueList = (
variableValue: string,
formatted: string,
callback?: any
) => {
cy.wait(600)
cy.focused().type(variableValue)
cy.wait(100)
cy.get('.variable-col .autocomplete-wrapper', { withinSubject: null })
.first()
.trigger('keydown', { key: 'ArrowDown' })
cy.get('.variable-col .autocomplete-wrapper', {
withinSubject: null
}).trigger('keydown', { key: 'Enter' })
cy.focused().tab()
cy.wait(100)
cy.focused().select('BETWEEN').trigger('change')
cy.wait(400)
const chooseFromList = (range: 'start' | 'end') => {
const inputId = `vals-${range}_0_0`
cy.get(`#${inputId}`)
.clear({ force: true })
.type(formatted, { force: true })
cy.get(`#datalist_${inputId} option`)
.contains(formatted)
.click({ force: true })
cy.get(`#${inputId}`).trigger('keyup', { key: 'Escape', force: true })
cy.wait(300)
}
chooseFromList('start')
chooseFromList('end')
cy.contains('.filter-modal button', 'Ok').click()
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
if (callback) callback()
}
const openTableFromTree = (libNameIncludes: string, tablename: string) => {
cy.get('.app-loading', { timeout: longerCommandTimeout })
.should('not.exist')
+209
View File
@@ -0,0 +1,209 @@
// Marks this file as an ES module (rather than a global script) so its
// top-level consts don't collide, under the TS type-checker, with the same
// names declared in other spec files.
//
// RUN ORDER MATTERS, and build.yaml reflects it: this spec must run after
// csv-limited.cy.ts (which asserts the free tier and so needs the first slot,
// before any spec applies a licence key) and before every spec that submits a
// changeset. Test 2 reads the approval queue, which is paged oldest first, and
// a changeset submitted by an earlier spec pushes this one off the first page.
export {}
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
context('hook program tests: ', function () {
this.beforeAll(() => {
cy.loginAndUpdateValidKey(true)
})
this.beforeEach(() => {
cy.visit(hostUrl + appLocation)
visitPage('home')
})
// TESTDATA.DEMO_MIRROR is an empty mirror of TESTDATA.DEMO_ORDERS, registered
// with a PRE_EDIT_HOOK and a POST_EDIT_HOOK (services/hooks/demo_mirror_*.js).
// The mock services run those hooks the way the SAS backend %includes the
// real hook programs - see dcMockUtils.mockHookSource.
it('1 | PRE_EDIT_HOOK: an empty mirror displays the live rows of its target table', () => {
openTableFromTree('testdata', 'demo_mirror')
// The mirror holds no rows of its own: everything on screen comes from the
// pre-edit hook, which loads TESTDATA.DEMO_ORDERS.
cy.get('#hotTable .ht_master tbody tr', {
timeout: longerCommandTimeout
}).should('have.length', 4)
cy.get('#hotTable .ht_master tbody tr')
.first()
.should('contain.text', 'Acme Corp')
cy.get('#hotTable .ht_master tbody tr')
.last()
.should('contain.text', 'Delta Systems')
// The grid is validated against the MIRROR's own rule set (AMOUNT <= 2000),
// not the real table's (AMOUNT <= 100000) - that is the point of routing
// edits through a mirror.
clickOnEdit(() => {
editCell(0, 'AMOUNT', '5000')
})
cy.get('#hotTable .ht_master tbody tr')
.first()
.find('td.htInvalid')
.should('exist')
})
it('2 | POST_EDIT_HOOK: a change submitted against the mirror is raised against the target', () => {
openTableFromTree('testdata', 'demo_mirror')
clickOnEdit(() => {
editCell(0, 'AMOUNT', '750')
})
submitTable(() => {
cy.get('textarea.submit-reason', { timeout: longerCommandTimeout }).type(
'hook routing test'
)
submitTableMessage()
})
// A successful submit sends the app to the staged-data page; wait for that
// before navigating away, or the app's own redirect wins the race.
cy.url({ timeout: longerCommandTimeout }).should('include', '/stage/')
// The post-edit hook re-points the changeset at TESTDATA.DEMO_ORDERS, so the
// approval queue names the real table rather than the mirror. Search the
// whole grid rather than one row: the queue also holds changesets from
// earlier specs in the same run, so position is not a stable anchor.
visitPage('review/approve')
cy.get('clr-datagrid clr-dg-row', { timeout: longerCommandTimeout }).should(
($rows) => {
const texts = Array.from($rows).map((row: any) =>
row.innerText.trim().replace(/\s+/g, ' ')
)
expect(
texts.some((text) => text.includes('TESTDATA.DEMO_ORDERS')),
`no approval row names TESTDATA.DEMO_ORDERS - rows: ${texts
.slice(0, 5)
.join(' | ')
.slice(0, 400)}`
).to.be.true
}
)
})
})
// ─── helpers (declared at the bottom, per the other specs) ───────────────────
const visitPage = (url: string) => {
cy.visit(`${hostUrl}${appLocation}/#/${url}`)
}
const openTableFromTree = (libNameIncludes: string, tablename: string) => {
cy.get('.app-loading', { timeout: longerCommandTimeout })
.should('not.exist')
.then(() => {
cy.get('.nav-tree clr-tree > clr-tree-node', {
timeout: longerCommandTimeout
}).then((treeNodes: any) => {
let viyaLib
for (let node of treeNodes) {
if (node.innerText.toLowerCase().includes(libNameIncludes)) {
viyaLib = node
break
}
}
cy.get(viyaLib).within(() => {
cy.wait(300)
cy.get(
'.clr-tree-node-content-container .clr-treenode-content p'
).click()
cy.get('.clr-treenode-link').then((innerNodes: any) => {
for (let innerNode of innerNodes) {
if (innerNode.innerText.toLowerCase().includes(tablename)) {
innerNode.click()
break
}
}
})
})
})
})
cy.get('#hotTable .ht_clone_top .htCore thead button.changeType', {
timeout: longerCommandTimeout
}).should('exist')
}
const clickOnEdit = (callback?: any) => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => {
if (callback) callback()
})
}
// Edits a single cell, locating the column by its header label. Handsontable
// renders the frozen header in a separate clone pane (.ht_clone_top) - the
// header row inside .ht_master is kept visibility:hidden - so the labels are
// read from the clone.
const editCell = (rowIndex: number, colName: string, value: string) => {
cy.get('#hotTable .ht_clone_top .htCore thead th', {
timeout: longerCommandTimeout
}).then((headers: any) => {
let colIndex = -1
for (let i = 0; i < headers.length; i++) {
if (
String(headers[i].innerText || '')
.trim()
.toUpperCase() === colName.toUpperCase()
) {
colIndex = i
break
}
}
expect(colIndex, `column ${colName} present`).to.be.greaterThan(-1)
cy.get('#hotTable .ht_master tbody tr')
.eq(rowIndex)
.then((row: any) => {
cy.get(row[0].childNodes[colIndex])
.dblclick({ force: true })
.then(() => {
cy.focused()
.clear()
.type(value + '{enter}')
})
})
})
}
const submitTable = (callback?: any) => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => {
if (callback) callback()
})
}
const submitTableMessage = (callback?: any) => {
cy.get('.modal-footer .btn.btn-sm.btn-success-outline', {
timeout: longerCommandTimeout
})
.click()
.then(() => {
if (callback) callback()
})
}
+446
View File
@@ -0,0 +1,446 @@
// The EDIT screen is bounded by DC_MAXOBS_WEBEDIT rows and DC_MAXCELLS_WEBEDIT
// cells (rows x columns), whichever is reached first, and the VIEW screen caps
// at DC_MAXOBS_WEBVIEW rows.
//
// A selection over an EDIT limit is served TRUNCATED - the grid carries the
// first rows that fit, and a warning triangle against the table name says why.
// This spec pins those limits against the mock, which mirrors the shipped
// defaults (250 rows / 200000 cells for EDIT, 2000 rows for VIEW). It uses
// two existing fixtures rather than new ones:
// MPE_X_SEARCH - 1000 rows x 9 cols, so it trips the ROW limit
// MPE_X_WIDE - 200 rows x 1001 cols (200,200 cells), under the row limit
// but over the CELL limit, so the row cap is 199
export {}
const hostUrl = Cypress.env('hosturl')
const appLocation = Cypress.env('appLocation')
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
const serverType = Cypress.env('serverType')
const libraryToOpenIncludes = Cypress.env(`libraryToOpenIncludes_${serverType}`)
context('EDIT row and cell limits, VIEW row limit: ', function () {
this.beforeAll(() => {
cy.visit(`${hostUrl}/SASLogon/logout`)
// forceLicenceKey=true: applies a valid licence rather than relying on an
// earlier spec in the run having done so (see commands.ts).
cy.loginAndUpdateValidKey(true)
})
this.beforeEach(() => {
cy.visit(hostUrl + appLocation)
visitPage('home')
visitPage('view/data')
})
it('1 | VIEW renders up to the raised row cap, past the old 500', () => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_search')
// Neither the header nor the cell text can pin the cap: the header reports
// the table's true row count whether or not the grid is capped, and the
// fixture's own numeric columns carry values above 1500 (DEPTH_M reaches
// 4293, SAMPLE_COUNT 4210), so a text match can hit fixture data.
//
// The PK can pin it. The first td of a .ht_master row is the PK - the row
// header, where present, is a th - and MPE_X_SEARCH holds PK 1001-2000, so
// the range check below is what stops a mis-selected column passing. With
// the old 500 row cap the grid stopped at PK 1500, so a rendered PK above
// 1500 can only appear if the cap was raised.
scrollGridToBottom()
cy.get('#hotTable .ht_master .htCore tbody tr', {
timeout: longerCommandTimeout
}).should(($rows) => {
const pks = $rows
.toArray()
.map((row) => row.querySelectorAll('td')[0])
.filter((td) => !!td)
.map((td) => parseInt((td.textContent || '').trim(), 10))
.filter((pk) => !isNaN(pk))
expect(pks.length).to.be.greaterThan(0)
pks.forEach((pk) => expect(pk).to.be.within(1001, 2000))
expect(Math.max(...pks)).to.be.greaterThan(1500)
})
})
it('2 | EDIT serves a table over the row limit, truncated, with a warning', () => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_search')
openEdit()
// 1000 rows x 9 columns is over the 250 row limit, so the grid carries the
// first 250 rows and the header says how many it is showing.
cy.get('.editor-title', { timeout: longerCommandTimeout }).should(
'contain.text',
'250 rows'
)
cy.get('#hotTable .ht_master .htCore tbody tr', {
timeout: longerCommandTimeout
}).should('have.length.at.least', 1)
cy.get('.truncation-warning', { timeout: longerCommandTimeout })
.should('be.visible')
.realHover()
cy.get('.editor-title clr-tooltip-content', {
timeout: longerCommandTimeout
})
.should('be.visible')
.should('contain.text', 'DC_MAXOBS_WEBEDIT')
.should(($el) => expect($el.css('opacity')).to.eq('1'))
})
it('3 | EDIT serves a table over the cell limit, truncated, with a warning', () => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_wide')
openEdit()
// 200 rows x 1001 stored columns = 200,200 cells, over the 200,000 cell
// limit, while the row count is under the 250 row limit - so the cell
// limit sets the cap: floor(200000 / 1001) = 199 rows.
cy.get('.editor-title', { timeout: longerCommandTimeout }).should(
'contain.text',
'199 rows'
)
cy.get('.truncation-warning', { timeout: longerCommandTimeout })
.should('be.visible')
.realHover()
cy.get('.editor-title clr-tooltip-content', {
timeout: longerCommandTimeout
})
.should('be.visible')
.should('contain.text', 'DC_MAXCELLS_WEBEDIT')
.should(($el) => expect($el.css('opacity')).to.eq('1'))
})
it('4 | the EDIT limits follow MPE_CONFIG, not the shipped defaults', () => {
// Two things at once. The seeded config carries the shipped defaults (250
// rows / 200000 cells), which are the numbers the mock used to hard-code -
// so nothing above would notice if the mock stopped reading MPE_CONFIG at
// all. And MPE_CONFIG lives in the control library, so reading it from the
// table's own library would fail for this table in particular.
//
// The cell limit is the one to move: 7 rows x 17 columns is 119 cells, so
// at 110 the TESTDATA.MPE_X_NEW edit must be truncated to
// floor(110 / 17) = 6 rows, where a hard-coded 200000 - or a config read
// that fails and falls back to it - lets it through. 110 is still above
// MPE_CONFIG's own 6 x 17 = 102, so the option can be put back afterwards.
setConfigValue('DC_MAXCELLS_WEBEDIT', '110', () => {
visitPage('view/data/TESTDATA.MPE_X_NEW')
closeAbortModalIfPresent()
openEdit()
cy.get('.editor-title', { timeout: longerCommandTimeout }).should(
'contain.text',
'6 rows'
)
cy.get('.truncation-warning', { timeout: longerCommandTimeout })
.should('be.visible')
.realHover()
cy.get('.editor-title clr-tooltip-content', {
timeout: longerCommandTimeout
})
.should('be.visible')
.should('contain.text', 'DC_MAXCELLS_WEBEDIT')
.should(($el) => expect($el.css('opacity')).to.eq('1'))
})
// Put the option back, so the rest of the estate sees the shipped default.
setConfigValue('DC_MAXCELLS_WEBEDIT', '200000', () => {
visitPage('view/data/TESTDATA.MPE_X_NEW')
closeAbortModalIfPresent()
openEdit()
// 119 cells under a 200000 cell limit: all 7 rows load, no warning.
cy.get('.editor-title', { timeout: longerCommandTimeout }).should(
'contain.text',
'7 rows'
)
cy.get('.truncation-warning').should('not.exist')
})
})
it('5 | the warning says to filter, and filtering narrows the grid', () => {
openTableFromTree(libraryToOpenIncludes, 'mpe_x_search')
openEdit()
cy.get('.truncation-warning', { timeout: longerCommandTimeout })
.should('be.visible')
.realHover()
cy.get('.editor-title clr-tooltip-content', {
timeout: longerCommandTimeout
})
.should('be.visible')
.should('contain.text', 'Filter the table to work with the rest')
.should(($el) => expect($el.css('opacity')).to.eq('1'))
// The advice has to be actionable: the picker must offer the table's
// columns and the filter must reload the grid.
openFilterPopup()
filterVariables().should(($options) => {
const names = $options
.toArray()
.map((o) => (o.textContent || '').trim())
.filter((n) => n.length > 0)
expect(names, 'the picker offers the table columns').to.include.members([
'PRIMARY_KEY_FIELD',
'SITE_NAME',
'VESSEL',
'SAMPLE_COUNT',
'DEPTH_M',
'SPECIES',
'CRUISE_DATE',
'EXPEDITION_ID',
'NOTES'
])
})
setFilterVariable('SITE_NAME')
// 100 of the 1000 rows: under the limit, so nothing is truncated.
setFilterValue('Nereid Trench')
submitFilter()
cy.get('.infoBar-text', { timeout: longerCommandTimeout }).should(
'contain.text',
"SITE_NAME = 'Nereid Trench'"
)
cy.get('.editor-title', { timeout: longerCommandTimeout }).should(
'contain.text',
'100 rows'
)
cy.get('.truncation-warning').should('not.exist')
})
})
const visitPage = (url: string) => {
cy.visit(`${hostUrl}${appLocation}/#/${url}`)
}
// The viewer's options dropdown holds the Edit item; it only renders for a
// table that is registered in MPE_TABLES (tableEditExists()).
const openEdit = () => {
cy.get('.filterSide', { timeout: longerCommandTimeout }).click()
cy.contains('[clrDropdownItem]', 'Edit', {
timeout: longerCommandTimeout
}).click()
}
/**
* The EDIT screen's Filter button opens the same .filter-modal the viewer uses.
* It only renders once the editor is in its read-only (non-editing) state,
* which is where a failed EDIT load leaves it.
*/
const openFilterPopup = () => {
cy.contains('button.btnView', 'Filter', {
timeout: longerCommandTimeout
}).click()
cy.get('.filter-modal', { timeout: longerCommandTimeout }).should(
'be.visible'
)
}
/** The picker's variable suggestion list. */
const filterVariables = () =>
cy.get('#datalist_vals_var_id0_0 option', { timeout: longerCommandTimeout })
/** The soft-select drops a transparent overlay over the modal, so it needs force. */
const setFilterVariable = (column: string) => {
cy.get('#vals_var_id0_0').clear({ force: true }).type(column, { force: true })
cy.get('#datalist_vals_var_id0_0 option').contains(column).click({
force: true
})
cy.get('#vals_var_id0_0').trigger('keyup', { key: 'Escape', force: true })
}
/** The value input of the same soft-select row. */
const setFilterValue = (value: string) => {
cy.get('#vals_0_0').clear({ force: true }).type(value, { force: true })
cy.get('#vals_0_0').trigger('keyup', { key: 'Escape', force: true })
cy.wait(400)
}
const submitFilter = () => {
cy.contains('.filter-modal button', 'Ok').click()
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
cy.wait(2500)
}
/**
* Sets a DC option in MPE_CONFIG through the editor and approves it, then hands
* back to the callback. The same route licensing.cy.ts uses for the licence
* keys: the config table needs an approval like any other.
*/
const setConfigValue = (
varName: string,
varValue: string,
callback: () => void
) => {
reloadApp()
// straight to the config table's editor, so the flow does not depend on
// whichever view mode the previous step left behind
visitPage('editor/DC_JSLIB.MPE_CONFIG')
closeAbortModalIfPresent()
clickOnEdit()
editTableField([{ varName, varValue }], () => {
submitTable(() => {
cy.wait(2000)
approveTable(() => {
reloadApp()
callback()
})
})
})
}
/**
* A full page load. A visit that only changes the hash does not reload the
* app, so an open modal - the abort message from the step just gone, say -
* would still be covering the page.
*/
const reloadApp = () => {
cy.visit(hostUrl + appLocation)
cy.get('.app-loading', { timeout: longerCommandTimeout }).should('not.exist')
}
/**
* DC puts abort messages up as modals over whatever page is showing, and they
* outlive a hash-only navigation, so clear one before driving the page.
*/
const closeAbortModalIfPresent = () => {
cy.get('body').then(($body) => {
if ($body.find('app-info-modal').length > 0) {
cy.get('app-info-modal')
.contains('button', 'Close')
.click({ force: true })
}
})
}
/**
* The viewer's Edit button. The options dropdown (.filterSide) that openEdit()
* uses is not rendered for every table, so the config table is opened the way
* licensing.cy.ts opens it.
*/
const clickOnEdit = (callback?: () => void) => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => {
if (callback) callback()
})
}
/** Types a new value into the row whose cell carries varName. */
const editTableField = (
edits: { varName: string; varValue: string }[],
callback: () => void
) => {
cy.get('#hotTable .ht_master .htCore tbody td', {
timeout: longerCommandTimeout
}).then(($tds: any) => {
const nodes = $tds.toArray()
for (const edit of edits) {
for (let i = 0; i < nodes.length; i++) {
// exact match on the cell that holds the option name; the cell after it
// is the value
if ((nodes[i].textContent || '').trim() === edit.varName) {
cy.wrap(nodes[i + 1])
.dblclick()
.then(() => {
cy.focused()
.type('{selectall}')
.type(edit.varValue)
.type('{enter}')
})
break
}
}
}
callback()
})
}
const submitTable = (callback: () => void) => {
cy.get('.btnCtrl button.btn-primary', { timeout: longerCommandTimeout })
.click()
.then(() => {
cy.get(".modal.ng-star-inserted button[type='submit']").click()
callback()
})
}
const approveTable = (callback: () => void) => {
cy.get('button', { timeout: longerCommandTimeout })
.should('contain', 'Approve')
.then((allButtons: any) => {
for (const approvalButton of allButtons) {
if (approvalButton.innerText.toLowerCase().includes('approve')) {
approvalButton.click()
break
}
}
cy.get('button#acceptBtn', { timeout: longerCommandTimeout })
.should('exist')
.should('not.be.disabled')
.click()
.then(() => {
cy.get('app-history', { timeout: longerCommandTimeout }).should(
'exist'
)
callback()
})
})
}
// Handsontable virtualises rows, so the last row is only in the DOM once the
// grid has been scrolled to the bottom. The scroller is the .wtHolder inside
// the .ht_master pane.
const scrollGridToBottom = () => {
cy.get('#hotTable .ht_master .wtHolder', { timeout: longerCommandTimeout })
.scrollTo('bottom', { duration: 0 })
.trigger('scroll')
}
const openTableFromTree = (libNameIncludes: string, tablename: string) => {
cy.get('.app-loading', { timeout: longerCommandTimeout })
.should('not.exist')
.then(() => {
cy.get('.nav-tree clr-tree > clr-tree-node', {
timeout: longerCommandTimeout
}).then((treeNodes: any) => {
let targetLib
for (let node of treeNodes) {
if (node.innerText.toLowerCase().includes(libNameIncludes)) {
targetLib = node
break
}
}
cy.get(targetLib).within(() => {
// Small settle wait: right after a fresh visit the tree component can
// still be re-rendering, causing this node to be found then swapped
// out mid-click.
cy.wait(300)
cy.get(
'.clr-tree-node-content-container .clr-treenode-content p'
).click()
cy.get('.clr-treenode-link').then((innerNodes: any) => {
for (let innerNode of innerNodes) {
if (innerNode.innerText.toLowerCase().includes(tablename)) {
innerNode.click()
break
}
}
})
})
})
})
cy.get('#hotTable .ht_clone_top .htCore thead button.changeType', {
timeout: longerCommandTimeout
}).should('exist')
}
@@ -0,0 +1,81 @@
// Marks this file as an ES module so its top-level consts don't collide with
// other spec files under the TS type-checker.
export {}
//
// When the startup service fails without a usable response, the error modal
// offers a button that runs the same service in a new browser window, where the
// SAS log is returned instead. This spec forces a startup failure against the
// mock backend and checks the button and the URL it opens.
const hostUrl = Cypress.env('hosturl')
const STARTUP_PROGRAM = '/Public/app/dc/services/public/startupservice'
/** The body a Viya Compute task returns when the run outlives the
* execution-task timeout: a bare string, so the adapter has no webout and no
* log to report. */
const rawJobError = [
'Job error',
'The Compute service could not execute the task c74a707a-8b88-46a5-8f28-9a7694ad5e13 because the context is not reusable.',
'path: /compute/tasks',
'correlator: dc1a9fda-8f65-4f32-b4d4-2a70e02179b1;1bcb6a4c-8a16-4053-a790-292544c25a03'
].join('\n')
context('startupservice launcher: ', function () {
it('1 | runs the startupservice in a new window when its response is malformed', () => {
// Report an empty admin folder so the app loads the startup service: on a
// freshly seeded mock estate makedata is still present, which sends the app
// to the deploy screen instead.
cy.intercept('GET', '**/drive/folder**', (req) => {
// Guarded parse: a lone '%' in the URL would make decodeURIComponent
// throw, and an exception here aborts the request.
let url = req.url
try {
url = decodeURIComponent(req.url)
} catch (e) {
url = req.url
}
if (url.includes('services/admin')) {
req.reply({ files: [], folders: [] })
return
}
req.continue()
})
cy.intercept('**/stp/execute/**', (req) => {
if (req.url.includes('public/startupservice')) {
// The adapter cannot use a bare string as a response payload, so the
// startup request fails with nothing to show.
req.reply({
statusCode: 200,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(rawJobError)
})
return
}
req.continue()
})
// The launcher must not actually open a tab under test.
cy.visit(hostUrl, {
timeout: 60000,
onBeforeLoad(win) {
cy.stub(win, 'open').as('windowOpen')
}
})
cy.get('.clr-abort-modal', { timeout: 60000 }).should('be.visible')
cy.get('.clr-abort-modal').last().should('contain.text', 'startupservice')
cy.get('.clr-abort-modal').last().contains('button', 'Show log').click()
cy.get('@windowOpen').should('have.been.calledOnce')
cy.get('@windowOpen').then((stub: any) => {
const url = stub.firstCall.args[0]
expect(url).to.contain(STARTUP_PROGRAM)
expect(url).to.contain('_debug=131')
// The browser route is what makes the log available: no execution task.
expect(url).not.to.contain('_executionTasks')
})
})
})
+36 -22
View File
@@ -79,14 +79,34 @@ Cypress.Commands.add(
.then(() => {
cy.wait(2000)
if ($body.find('.nav-tree').length > 0) {
/**
* A key that is already working needs no update. Ask the loaded
* page, not the tree: a free tier estate renders the nav tree as
* well, so the tree cannot tell a licensed estate from an
* unlicensed one - the licence banner is what does. Reading the
* body again here also matters on an estate that shows a login
* form, where the body captured above has no tree yet.
*/
cy.get('body').then(($loaded) => {
const licenceProblem = $loaded.find('#demo-banner').length > 0
if (!licenceProblem && $loaded.find('.nav-tree').length > 0) {
return logout(() => {
return
})
}
/**
* If licence key is already working, then skip rest of the function
* An estate with no key is left as it is unless the caller asked
* for a licensed one - the free tier specs are written against
* that state and must not have a key planted under them.
*/
return logout(() => {
return
})
} else {
if (!forceLicenceKey) {
return logout(() => {
return
})
}
const keyData = {
valid_until: moment().add(20, 'day').format('YYYY-MM-DD'),
number_of_users: 10,
@@ -106,27 +126,21 @@ Cypress.Commands.add(
cy.wait(20000)
}
if (!forceLicenceKey) {
return logout(() => {
return
})
} else {
return updateLicenseKeyQuick(keysGen, () => {
cy.wait(25000)
return acceptTermsIfPresented((result: boolean) => {
if (result) {
cy.wait(20000)
}
return logout(() => {
return
})
return updateLicenseKeyQuick(keysGen, () => {
cy.wait(25000)
return acceptTermsIfPresented((result: boolean) => {
if (result) {
cy.wait(20000)
}
return logout(() => {
return
})
})
}
})
})
}
)
}
})
})
})
}
+1 -1
View File
@@ -10,7 +10,7 @@ const check = (cwd) => {
onlyAllow:
'AFLv2.1;Apache 2.0;Apache-2.0;Apache*;Artistic-2.0;BlueOak-1.0.0;0BSD;BSD*;BSD-2-Clause;BSD-3-Clause;CC0-1.0;CC-BY-3.0;CC-BY-4.0;ISC;MIT;MPL-2.0;ODC-By-1.0;Python-2.0;Unlicense;',
excludePackages:
'@cds/city@1.1.0;@handsontable/angular-wrapper@16.0.1;@handsontable/angular-wrapper@17.1.0;@handsontable/angular-wrapper@18.0.0;handsontable@^16.0.1;handsontable@16.2.0;handsontable@17.1.0;handsontable@18.0.0;hyperformula@2.7.1;hyperformula@3.0.0;hyperformula@3.1.0;hyperformula@3.2.0;hyperformula@3.3.0;jackspeak@3.4.3;path-scurry@1.11.1;package-json-from-dist@1.0.1;buffers@0.1.1'
'@cds/city@1.1.0;@handsontable/angular-wrapper@16.0.1;@handsontable/angular-wrapper@17.1.0;@handsontable/angular-wrapper@18.0.0;@handsontable/angular-wrapper@18.1.1;@handsontable/angular-wrapper@18.1.2;handsontable@^16.0.1;handsontable@16.2.0;handsontable@17.1.0;handsontable@18.0.0;handsontable@18.1.1;handsontable@18.1.2;hyperformula@2.7.1;hyperformula@3.0.0;hyperformula@3.1.0;hyperformula@3.2.0;hyperformula@3.3.0;jackspeak@3.4.3;path-scurry@1.11.1;package-json-from-dist@1.0.1;buffers@0.1.1'
},
(error, json) => {
if (error) {
+1119 -1689
View File
File diff suppressed because it is too large. Load diff
+15 -16
View File
@@ -41,22 +41,22 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^20.3.27",
"@angular/animations": "20.3.34",
"@angular/cdk": "^20.2.14",
"@angular/common": "^20.3.27",
"@angular/compiler": "^20.3.27",
"@angular/core": "^20.3.27",
"@angular/forms": "^20.3.27",
"@angular/platform-browser": "^20.3.27",
"@angular/platform-browser-dynamic": "^20.3.27",
"@angular/router": "^20.3.27",
"@angular/common": "20.3.34",
"@angular/compiler": "20.3.34",
"@angular/core": "20.3.34",
"@angular/forms": "20.3.34",
"@angular/platform-browser": "20.3.34",
"@angular/platform-browser-dynamic": "20.3.34",
"@angular/router": "20.3.34",
"@cds/core": "^6.15.1",
"@clr/angular": "file:libraries/clr-angular-17.9.0.tgz",
"@clr/icons": "^13.0.2",
"@clr/ui": "file:libraries/clr-ui-17.9.0.tgz",
"@handsontable/angular-wrapper": "18.0.0",
"@sasjs/adapter": "^4.18.0",
"@sasjs/utils": "^3.6.0",
"@handsontable/angular-wrapper": "18.1.2",
"@sasjs/adapter": "5.1.2",
"@sasjs/utils": "4.0.0",
"@sheet/crypto": "file:libraries/sheet-crypto.tgz",
"@types/d3-graphviz": "^2.6.7",
"@types/text-encoding": "0.0.35",
@@ -69,12 +69,11 @@
"d3-graphviz": "^5.0.2",
"exceljs": "^4.4.0",
"fs-extra": "^7.0.1",
"handsontable": "18.0.0",
"handsontable": "18.1.2",
"https-browserify": "1.0.0",
"hyperformula": "^2.5.0",
"iconv-lite": "^0.5.0",
"jquery-datetimepicker": "^2.5.21",
"jsrsasign": "11.1.1",
"marked": "^5.0.0",
"moment": "^2.30.1",
"ngx-clipboard": "^16.0.0",
@@ -99,8 +98,8 @@
"@angular-eslint/eslint-plugin-template": "19.8.1",
"@angular-eslint/schematics": "19.8.1",
"@angular-eslint/template-parser": "19.8.1",
"@angular/cli": "^20.3.32",
"@angular/compiler-cli": "^20.3.27",
"@angular/cli": "20.3.37",
"@angular/compiler-cli": "20.3.34",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@compodoc/compodoc": "^2.0.0",
"@cypress/webpack-preprocessor": "^5.17.1",
@@ -148,7 +147,7 @@
"ajv": "8.18.0",
"uuid": "11.1.1",
"lighthouse": "13.4.0",
"fast-uri": "3.1.7",
"fast-uri": "4.2.3",
"readdir-glob": {
"brace-expansion": "^5.0.9"
},
+1 -10
View File
@@ -3,8 +3,7 @@
[class*=ht-theme-classic] .htDropdownMenu table tbody tr td.htSubmenu .htItemWrapper::after,
[class*=ht-theme-classic] .htContextMenu table tbody tr td.htSubmenu .htItemWrapper::after,
[class*=ht-theme-classic] .htFiltersConditionsMenu table tbody tr td.htSubmenu .htItemWrapper::after,
[class*=ht-theme-classic] .pika-single .pika-next {
[class*=ht-theme-classic] .htFiltersConditionsMenu table tbody tr td.htSubmenu .htItemWrapper::after {
width: var(--ht-icon-size);
height: var(--ht-icon-size);
-webkit-mask-size: contain;
@@ -12,14 +11,6 @@
background-color: currentColor;
}
[class*=ht-theme-classic] .pika-single .pika-prev {
width: var(--ht-icon-size);
height: var(--ht-icon-size);
-webkit-mask-size: contain;
-webkit-mask-image: url("./assets/hot-icons/arrow-left.svg");
background-color: currentColor;
}
[class*=ht-theme-classic] .ht-page-size-section__select-wrapper::after {
width: var(--ht-icon-size);
height: var(--ht-icon-size);
+13
View File
@@ -318,6 +318,7 @@
class="startup-check"
[class.startup-check--error]="step.status === 'error'"
[class.startup-check--done]="step.status === 'done'"
[class.startup-check--grid]="step.details?.length"
>
@switch (step.status) {
@case ('pending') {
@@ -346,6 +347,18 @@
@if (step.detail) {
<span class="startup-check__detail">{{ step.detail }}</span>
}
@if (step.details?.length) {
<div class="startup-check__grid">
@for (detail of step.details; track detail.name) {
<span class="startup-check__grid-name">{{
detail.name
}}</span>
<span class="startup-check__grid-value">{{
detail.value
}}</span>
}
</div>
}
</div>
}
</div>
+30 -20
View File
@@ -20,6 +20,8 @@ import { DcAdapterSettings } from './models/DcAdapterSettings'
import { AppStoreService } from './services/app-store.service'
import { LicenceService } from './services/licence.service'
import {
getSasjsTagDetails,
SASJS_TAG_STEP,
StartupCheckService,
StartupStep
} from './services/startup-check.service'
@@ -190,40 +192,45 @@ export class AppComponent {
* Parses adapter settings that are found in the <sasjs> tag inside index.html
*/
private parseDcAdapterSettings() {
/* The <sasjs> tag is a mandatory part of index.html - it carries serverUrl,
serverType and the rest of the adapter config - so there is no config to
fall back on when it is absent. A missing one is reported on the boot
screen below rather than handled with an abort modal. */
const sasjsElement = document.querySelector('sasjs')
if (!sasjsElement) {
this.licenceService.deactivateApp()
setTimeout(() => {
this.eventService.showAbortModal(
null,
"Please make sure 'SASJS' tag with config attributes is added to index.html",
null,
'SASjs Config not found'
)
})
return
}
const getAppAttribute = (attribute: string) =>
sasjsElement.getAttribute(attribute) || undefined
sasjsElement?.getAttribute(attribute) || undefined
const dcAdapterSettings = {
serverUrl: getAppAttribute('serverUrl') || '',
appLoc: getAppAttribute('appLoc') || '',
serverType: getAppAttribute('serverType'),
loginMechanism: getAppAttribute('loginMechanism') || '',
adminGroup: getAppAttribute('adminGroup') || '',
dcPath: getAppAttribute('dcPath') || '',
debug: getAppAttribute('debug') === 'true' || false,
useComputeApi: this.parseComputeApi(getAppAttribute('useComputeApi')),
runAsTask: getAppAttribute('runAsTask') === 'true' || false,
contextName: getAppAttribute('contextName') || '',
hotLicenceKey: getAppAttribute('hotLicenceKey') || ''
contextName: getAppAttribute('contextName') || ''
}
this.dcAdapterSettings = dcAdapterSettings as any
this.appStoreService.setDcAdapterSettings(dcAdapterSettings as any)
/* Show the <sasjs> tag contents on the boot screen, so the effective
configuration (serverType, debug, useComputeApi, ...) is visible without
having to read the page source. The tag is mandatory - without it the
adapter has no serverUrl or serverType - so a missing one is called out
plainly rather than silently leaving the step pending. */
if (sasjsElement) {
this.startupCheckService.setTagDetails(getSasjsTagDetails(sasjsElement))
} else {
this.startupCheckService.updateStep(
SASJS_TAG_STEP,
'error',
'SASJS TAG MISSING!!'
)
}
this.appService.sasServiceInit()
}
@@ -307,9 +314,12 @@ export class AppComponent {
*/
public subscribeToShowAbortModal() {
this.eventService.onShowAbortModal.subscribe((sasjsAbort: InfoModal) => {
let abortId = this.sasjsAborts.length + 1
sasjsAbort.id = abortId
this.sasjsAborts.push(sasjsAbort)
/* One message at a time. Pushing to the array stacked a second modal on
top of the one already open - two dismissals for one failure, and the
lower one was often a duplicate of the upper. Replacing keeps the
newest message, which is the one the user has to act on. */
sasjsAbort.id = Date.now()
this.sasjsAborts = [sasjsAbort]
this.cdr.detectChanges() //Changes were not triggered while hot is focused
})
}
@@ -2,10 +2,7 @@ import { NgModule } from '@angular/core'
import { RouterModule, Routes } from '@angular/router'
import { DeployComponent } from './deploy.component'
const routes: Routes = [
{ path: '', component: DeployComponent },
{ path: 'manualdeploy', component: DeployComponent }
]
const routes: Routes = [{ path: '', component: DeployComponent }]
@NgModule({
imports: [RouterModule.forChild(routes)],
+11 -37
View File
@@ -29,20 +29,6 @@
></label
>
</clr-checkbox-wrapper>
<!-- <hr />
<div class="clr-checkbox-wrapper">
<input
[(ngModel)]="autodeploy"
type="checkbox"
id="checkbox2"
class="clr-checkbox"
checked
/>
<label for="checkbox2"
>Autodeploy
{{ !jsonFile ? '(json file is not available)' : '' }}</label
>
</div> -->
</div>
</div>
}
@@ -52,29 +38,17 @@
@if (step > 0) {
@switch (true) {
@case (sasJsConfig.serverType === ServerType.SasViya) {
@if (autodeploy) {
<div class="autodeploy-section card">
<app-automatic-deploy
[sasJs]="sasJs"
[sasJsConfig]="sasJsConfig"
[dcAdapterSettings]="dcAdapterSettings"
[appLoc]="appLoc"
[dcPath]="dcPath"
[selectedAdminGroup]="selectedAdminGroup"
(onNavigateToHome)="onNavigateToHome()"
></app-automatic-deploy>
</div>
}
@if (!autodeploy) {
<div id="mainbody" class="card">
<app-manual-deploy
[sasJs]="sasJs"
[sasJsConfig]="sasJsConfig"
[dcAdapterSettings]="dcAdapterSettings"
(onNavigateToHome)="onNavigateToHome()"
></app-manual-deploy>
</div>
}
<div class="autodeploy-section card">
<app-automatic-deploy
[sasJs]="sasJs"
[sasJsConfig]="sasJsConfig"
[dcAdapterSettings]="dcAdapterSettings"
[appLoc]="appLoc"
[dcPath]="dcPath"
[selectedAdminGroup]="selectedAdminGroup"
(onNavigateToHome)="onNavigateToHome()"
></app-automatic-deploy>
</div>
}
@case (sasJsConfig.serverType === ServerType.Sasjs) {
<div class="autodeploy-section card">
+2 -52
View File
@@ -1,8 +1,6 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core'
import { SasService } from '../services/sas.service'
import { SASjsConfig } from '@sasjs/adapter'
import { Router } from '@angular/router'
import { LoggerService } from '../services/logger.service'
import { ServerType } from '@sasjs/utils/types/serverType'
import { AppStoreService } from '../services/app-store.service'
import { DcAdapterSettings } from '../models/DcAdapterSettings'
@@ -19,15 +17,11 @@ import { DcAdapterSettings } from '../models/DcAdapterSettings'
})
export class DeployComponent implements OnInit {
public step: number = 0
public adminGroups: any = []
public appLoc: string = ''
public dcPath: string = ''
public selectedAdminGroup: string = ''
public autodeploy: boolean = true
public jsonFile: any = null
public sasJs: any
public sasJsConfig: SASjsConfig = new SASjsConfig()
@@ -37,16 +31,10 @@ export class DeployComponent implements OnInit {
constructor(
private appStoreService: AppStoreService,
private sasService: SasService,
private loggerService: LoggerService,
private router: Router
private sasService: SasService
) {
this.dcAdapterSettings = this.appStoreService.getDcAdapterSettings()
if (this.router.url.includes('manualdeploy')) {
this.autodeploy = false
}
this.sasJs = this.sasService.getSasjsInstance()
this.sasJsConfig = this.sasService.getSasjsConfig()
this.appLoc = this.dcAdapterSettings?.appLoc || ''
@@ -61,54 +49,16 @@ export class DeployComponent implements OnInit {
*/
public setDeployDefaults() {
this.dcPath = this.dcAdapterSettings?.dcPath || ''
this.selectedAdminGroup = this.dcAdapterSettings?.adminGroup || ''
if (!this.selectedAdminGroup) {
this.selectedAdminGroup = 'SASAdministrators'
}
this.selectedAdminGroup = 'SASAdministrators'
}
/**
* Accepting terms of service shows next screen
*/
public termsAgreeChange() {
if (!this.autodeploy) {
this.getAdminGroups()
}
this.step++
}
/**
* Fetches admin groups from VIYA to be selected for a backend deploy
*/
public getAdminGroups() {
fetch(
this.sasJsConfig.serverUrl + '/identities/groups?sortBy=name&limit=5000',
{
headers: {
Accept: 'application/json'
}
}
)
.then((res: any) => {
return res.text()
})
.then((res: any) => {
let jsonRes
try {
jsonRes = JSON.parse(res)
} catch (err: any) {
console.error(err)
}
if (jsonRes) {
this.adminGroups = jsonRes.items
this.selectedAdminGroup = this.adminGroups[0].id
}
})
}
public onNavigateToHome() {
window.open(location.href.split('#')[0], '_blank')
}
-2
View File
@@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { DeployComponent } from './deploy.component'
import { AutomaticComponent } from './sections/automatic/automatic.component'
import { ManualComponent } from './sections/manual/manual.component'
import { SasjsConfiguratorComponent } from './sections/sasjs-configurator/sasjs-configurator.component'
import { ClarityModule } from '@clr/angular'
import { FormsModule } from '@angular/forms'
@@ -12,7 +11,6 @@ import { DeployRoutingModule } from './deploy-routing.module'
declarations: [
DeployComponent,
AutomaticComponent,
ManualComponent,
SasjsConfiguratorComponent
],
imports: [CommonModule, FormsModule, ClarityModule, DeployRoutingModule]
@@ -1,229 +0,0 @@
<div class="card-header position-relative">
Configurator
<p class="d-inline-block ml-10 mb-10 mt-0">App Location: {{ appLoc }}</p>
<button
(click)="deleteKeys()"
class="btn btn-primary clear-memory-button position-absolute"
>
Clear memory
</button>
</div>
<div class="card-block">
<!-- <div class="card-title">
Client Details
</div> -->
@if (needsLogin) {
<div id="loginForm" class="d-none">
<p class="mb-10">Please log in first</p>
<label for="username" class="clr-control-label">Username</label>
<div class="mb-10 clr-control-container">
<div class="clr-input-wrapper">
<input type="text" id="username" class="clr-input" />
</div>
</div>
<label for="password" class="clr-control-label">Password</label>
<div class="mb-10 clr-control-container">
<div class="clr-input-wrapper">
<input type="password" id="password" class="clr-input" />
</div>
</div>
<button class="btn btn-primary d-none" id="loginBtn">Log in</button>
</div>
}
@if (!needsLogin) {
<form>
<div class="clr-form-control">
<label for="select-full" class="clr-control-label">Admin group</label>
<div class="clr-control-container">
<div class="clr-select-wrapper">
<select
[(ngModel)]="selectedAdminGroup"
[ngModelOptions]="{ standalone: true }"
name="selectedAdminGroup"
id="adminGroupsSelect"
class="clr-select"
>
@for (adminGroup of adminGroups; track adminGroup) {
<option [value]="adminGroup.id">
{{ adminGroup.name }}
</option>
}
</select>
</div>
</div>
</div>
<div class="clr-form-control">
<div [class.hidden]="contextsLoading">
<label for="select-full" class="clr-control-label">Context</label>
<div class="clr-control-container">
<div class="clr-select-wrapper">
<select
[(ngModel)]="selectedContext"
[ngModelOptions]="{ standalone: true }"
name="selectedContext"
class="clr-select"
>
@for (context of allContexts; track context) {
<option [value]="context.name">
{{ context.name }}
@if ((context.attributes | json) != '{}') {
<span>( {{ context.attributes.sysUserId }} )</span>
}
</option>
}
</select>
</div>
</div>
<button
(click)="executableContext()"
type="button"
class="btn btn-icon"
id="contexts-btn"
>
<clr-icon shape="play"></clr-icon>
</button>
</div>
<div [class.hidden]="!contextsLoading" class="d-flex">
<span class="spinner spinner-inline mr-10">
Loading contexts...
</span>
<span> Loading contexts... </span>
</div>
<label for="dcloc" class="mt-20 clr-control-label">DC Loc</label>
<div class="mb-10 clr-control-container">
<div class="clr-input-wrapper">
<input
[(ngModel)]="dcPath"
[ngModelOptions]="{ standalone: true }"
(focusout)="saveDcPath()"
name="dcPath"
type="text"
id="dcloc"
class="clr-input"
/>
</div>
</div>
<p class="mt-10">
Select JSON file to upload (json build file preloaded):
</p>
<div class="d-flex flex-column">
<input
type="file"
(click)="clearUploadInput($event)"
(change)="onJsonFileChange($event)"
/>
<!-- <button *ngIf="downloadFileBtn" (click)="downloadSasPrecodeFile()" style="width: 40px; min-width: 0;" class="btn btn-sm btn-icon">
<clr-icon shape="download"></clr-icon>
</button> -->
</div>
<div class="mt-20 d-flex align-items-center">
<button
(click)="executeJson()"
class="btn btn-primary"
[clrLoading]="isSubmittingJson"
id=""
class="mt-0"
>
SUBMIT JSON
</button>
@if (isJsonSubmitted) {
<span>JSON Submitted Successfully</span>
}
<!-- <span *ngIf="executingScript" class="spinner spinner-inline ml-3">
Loading...
</span> -->
</div>
<p class="mt-10">Select SAS file to upload:</p>
<div class="d-flex flex-column">
<input
type="file"
(click)="clearUploadInput($event)"
(change)="onSasFileChange($event); downloadFileBtn = true"
/>
@if (downloadFileBtn) {
<button
(click)="downloadSasPrecodeFile()"
class="btn btn-sm btn-icon min-w-0 w-40"
>
<clr-icon shape="download"></clr-icon>
</button>
}
</div>
<div class="mt-20 d-flex align-items-center">
<button
(click)="executeSAS()"
class="btn btn-primary"
[clrLoading]="executingScript"
id="deploy"
class="mt-0"
>
SUBMIT
</button>
<!-- <span *ngIf="executingScript" class="spinner spinner-inline ml-3">
Loading...
</span> -->
</div>
</div>
@if (jobLog.length > 0) {
<p class="mb-0 mt-10">File execute completed</p>
<hr />
<div>
<button
(click)="downloadFile(jobLog, 'execute-script-log', 'txt')"
class="btn btn-primary mt-0 mr-20"
>
Download log
</button>
</div>
}
<button
[clrLoading]="createDatabaseLoading"
(click)="createDatabase()"
class="btn btn-primary mt-10"
>
Create Database
</button>
@if (makeDataResponse.length > 0) {
<p class="mb-0 mt-10">Create Database Completed</p>
<hr />
@if (makeDataResponse.length > 0) {
<div class="log-wrapper">
{{ makeDataResponse }}
</div>
}
<button (click)="navigateToHome()" class="btn btn-primary mt-15">
Let's get started
</button>
<button
(click)="downloadFile(makeDataResponse, 'create-database-log', 'txt')"
class="btn btn-primary mt-15"
>
Download log
</button>
<button (click)="validateDeploy()" class="btn btn-primary mt-15">
Validate
</button>
@if (validationState !== 'none' || isValidating) {
<div class="validation-bar">
@if (isValidating) {
<span class="spinner spinner-inline mr-10">
Validating deploy...
</span>
<span> Validating deploy... </span>
}
@if (!isValidating && validationState === 'error') {
<clr-icon shape="exclamation-circle" class="is-error"></clr-icon>
<span> Validation failed </span>
}
@if (!isValidating && validationState === 'success') {
<clr-icon shape="check-circle" class="is-success"></clr-icon>
<span> Validation succeeded </span>
}
</div>
}
}
</form>
}
</div>
Whitespace-only changes.
@@ -1,90 +0,0 @@
import { ManualComponent } from './manual.component'
// validateDeploy() is fire-and-forget (doesn't return its own promise
// chain), so tests need to wait for it to settle some other way. A
// macrotask boundary guarantees every already-queued microtask (regardless
// of how many .then() hops validateDeploy's chain has) has run first.
const flushPromiseChain = () => new Promise((resolve) => setTimeout(resolve, 0))
/**
* validateDeploy() only touches sasService.request, eventService.showInfoModal
* and loggerService.log - these stubs cover exactly that surface, not the
* full real services (no TestBed/DI needed, same plain-instantiation-with-
* stubs precedent as app.service.spec.ts).
*/
const buildDeps = () => {
const sasService: any = {
request: jasmine.createSpy('request')
}
const eventService: any = {
showInfoModal: jasmine.createSpy('showInfoModal')
}
const loggerService: any = {
log: jasmine.createSpy('log')
}
const deployService: any = {}
return { sasService, eventService, loggerService, deployService }
}
const buildManualComponent = (deps: ReturnType<typeof buildDeps>) =>
new ManualComponent(
deps.sasService,
deps.eventService,
deps.loggerService,
deps.deployService
)
describe('ManualComponent - validateDeploy', () => {
it('sets validationState to success when saslibs is present on a normal object response', async () => {
const deps = buildDeps()
deps.sasService.request.and.resolveTo({
adapterResponse: { saslibs: { SOME_LIB: ['SOME_TABLE'] } }
})
const component = buildManualComponent(deps)
component.validateDeploy()
await flushPromiseChain()
expect(component.validationState).toBe('success')
expect(deps.eventService.showInfoModal).not.toHaveBeenCalled()
})
it('sets validationState to error with no modal when saslibs is missing from an otherwise normal object response', async () => {
const deps = buildDeps()
deps.sasService.request.and.resolveTo({
adapterResponse: { SYSSITE: 'SITE1' }
// saslibs deliberately omitted
})
const component = buildManualComponent(deps)
component.validateDeploy()
await flushPromiseChain()
expect(component.validationState).toBe('error')
expect(deps.eventService.showInfoModal).not.toHaveBeenCalled()
})
// Same underlying bug as app.service.spec.ts's equivalent test: a
// misconfigured Viya computeTasks deployment returns a raw "Job error"
// text body, which the adapter resolves as adapterResponse verbatim.
it('sets validationState to error and shows the real response text when adapterResponse is a raw string, not an object', async () => {
const deps = buildDeps()
const rawJobError = [
'Job error',
'The Compute service could not execute the task c74a707a-8b88-46a5-8f28-9a7694ad5e13 because the context 340cd3eb-72ae is not reusable. Please provide a reusable context or supply the ID of an existing session in the task request.',
'path: /compute/tasks',
'correlator: dc1a9fda-8f65-4f32-b4d4-2a70e02179b1;1bcb6a4c-8a16-4053-a790-292544c25a03'
].join('\n')
deps.sasService.request.and.resolveTo({ adapterResponse: rawJobError })
const component = buildManualComponent(deps)
component.validateDeploy()
await flushPromiseChain()
expect(component.validationState).toBe('error')
expect(deps.eventService.showInfoModal).toHaveBeenCalledTimes(1)
const [, message] = deps.eventService.showInfoModal.calls.mostRecent().args
expect(message).toContain(rawJobError)
})
})
@@ -1,346 +0,0 @@
import {
Component,
Input,
OnInit,
Output,
EventEmitter,
ViewEncapsulation
} from '@angular/core'
import SASjs, { SASjsConfig } from '@sasjs/adapter'
import { DcAdapterSettings } from 'src/app/models/DcAdapterSettings'
import { RequestWrapperResponse } from 'src/app/models/request-wrapper/RequestWrapperResponse'
import { DeployService } from 'src/app/services/deploy.service'
import { EventService } from 'src/app/services/event.service'
import { LoggerService } from 'src/app/services/logger.service'
import { SasService } from 'src/app/services/sas.service'
import { getMalformedAdapterResponseMessage } from 'src/app/shared/utils/get-malformed-adapter-response-message'
@Component({
selector: 'app-manual-deploy',
templateUrl: './manual.component.html',
styleUrls: ['./manual.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: false
})
export class ManualComponent implements OnInit {
@Input() sasJs!: SASjs
@Input() sasJsConfig: SASjsConfig = new SASjsConfig()
@Input() dcAdapterSettings: DcAdapterSettings | undefined
@Output() onNavigateToHome: EventEmitter<any> = new EventEmitter<any>()
public needsLogin: boolean = false
public adminGroups: any = []
public allContexts: any = []
public appLoc: string = ''
public dcPath: string = ''
public selectedAdminGroup: string = ''
public selectedContext: string = ''
public jobLog: string = ''
public makeDataResponse: string = ''
public linesOfCode: any = []
public fileName: string = ''
public preloadedFile: boolean = true
public executeSASEnabled: boolean = false
public contextsLoading: boolean = false
public createDatabaseLoading: boolean = false
public executingScript: boolean = false
public downloadFileBtn: boolean = false
public isValidating: boolean = false
public jsonFile: any = null
public isSubmittingJson: boolean = false
public isJsonSubmitted: boolean = false
public validationState: string = 'none'
constructor(
private sasService: SasService,
private eventService: EventService,
private loggerService: LoggerService,
private deployService: DeployService
) {}
ngOnInit(): void {}
/**
* FIXME: Remove
*/
public async executableContext() {
// getExecutableContexts now need AuthConfig parameter which we don't have on web
// this.contextsLoading = true
// let contexts = await this.sasJs.getExecutableContexts()
// this.allContexts = contexts
// if (contexts.length === 0) {
// this.selectedContext = ''
// } else {
// this.selectedContext = this.allContexts[0].name
// }
// this.contextsLoading = false
}
/**
* Removes sas.json file attached to the input
*/
public clearUploadInput(event: Event) {
this.deployService.clearUploadInput(event)
}
/**
* Reads attached SAS file to be sent to sas for execution (backend deploy)
*/
public onSasFileChange(event: any) {
this.preloadedFile = false
let file = event.target.files[0]
this.fileName = file.name
let fileReader = new FileReader()
fileReader.onload = () => {
if (fileReader.result) {
this.linesOfCode = (fileReader.result as string).split('\n')
this.linesOfCode = this.linesOfCode.filter((el: string) => {
return el !== '' && el !== null
})
this.executeSASEnabled = true
this.addPrecodeLines()
}
}
fileReader.readAsText(file)
}
/**
* Reads attached JSON file to be sent to sas for execution (backend deploy)
*/
public async onJsonFileChange(event: any) {
let file = event.target.files[0]
this.jsonFile = await this.deployService.readFile(file)
}
/**
* Appending precode lines to the attached sas or json file for backend deploy
*/
public addPrecodeLines() {
let headerLines = [
`%let context=${this.selectedContext};`,
`%let appLoc=${this.appLoc};`,
`%let admin=${this.selectedAdminGroup};`,
`%let dcpath=${this.dcPath};`
]
this.linesOfCode.unshift(...headerLines)
}
/**
* Downloadng file with precode included
*/
public downloadSasPrecodeFile() {
let linesAsText = this.linesOfCode.join('\n')
let filename = this.fileName.split('.')[0]
this.downloadFile(linesAsText, filename, 'sas')
}
/**
* Used for downloading log and repsonse as a file
*/
public downloadFile(
content: any,
filename: string,
extension: string = 'txt'
) {
this.deployService.downloadFile(content, filename, extension)
}
/**
* Saving dcpath to localstorage
* FIXME: maybe it'snot necessary
*/
public saveDcPath() {
localStorage.setItem('deploy_dc_loc', this.dcPath)
}
/**
* Send sas.json to be executed (deploying backend)
*/
public async executeJson() {
this.isSubmittingJson = true
try {
let uploadJsonFile = await this.sasJs.deployServicePack(
this.jsonFile,
this.dcAdapterSettings?.appLoc || '',
undefined,
undefined,
true
)
this.isJsonSubmitted = true
} catch (ex: any) {
let textEx = ''
if (typeof ex.message !== 'string') {
textEx = JSON.stringify(ex).replace(/\\/gm, '')
} else {
textEx = ex.message
}
this.eventService.showInfoModal(
'Deploy error',
`Exception: \n ${textEx !== '' ? textEx : ex}`
)
return
}
this.isSubmittingJson = false
}
/**
* Send sas file to be executed (deploying backend)
*/
public async executeSAS() {
this.executingScript = true
this.jobLog = ''
this.makeDataResponse = ''
try {
let executeResponse = await this.sasJs.executeScript({
fileName: this.fileName,
linesOfCode: this.linesOfCode,
contextName: this.selectedContext
})
this.loggerService.log(executeResponse)
if (typeof executeResponse.log === 'string') {
executeResponse.log = JSON.parse(executeResponse.log)
}
if (executeResponse.jobStatus === 'error') {
alert('Error!')
} else {
this.jobLog = executeResponse.log.items
? executeResponse.log.items.map((i: any) => i.line).join('\n')
: JSON.stringify(executeResponse.log)
}
this.executingScript = false
} catch (err) {
this.executingScript = false
}
}
/**
* Running makedata service
* @param newTab open and run in new tab
*/
public createDatabase(newTab: boolean = true) {
if (newTab) {
// Debug is ALWAYS enabled for makedata — it runs only once during
// deployment and the full log is needed to diagnose any issues.
const _debug = '&_debug=131'
let url =
this.sasService.getSasjsConfig().serverUrl +
'/SASJobExecution/?_program=' +
this.dcAdapterSettings?.appLoc ||
'' +
'/admin/makedata' +
'&ADMIN=' +
this.selectedAdminGroup +
'&DCPATH=' +
this.dcPath +
_debug
window.open(url, '_blank')
return
}
this.createDatabaseLoading = true
let data = {
fromjs: [
{
ADMIN: this.selectedAdminGroup,
DCPATH: this.dcPath
}
]
}
/**
* We are overriding default `sasjsConfig` object fields with this object fields.
* Here we want to run this request using original WEB method.
* contextName: null is the MUST field for it.
*/
let overrideConfig = {
useComputeApi: null,
contextName: this.sasJsConfig.contextName,
debug: true
}
this.sasJs
.request(`services/admin/makedata`, data, overrideConfig, () => {
this.sasService.shouldLogin.next(true)
})
.then((res: any) => {
try {
this.makeDataResponse = JSON.stringify(res)
} catch {
this.makeDataResponse = res
}
this.createDatabaseLoading = false
})
.catch((err: any) => {
this.createDatabaseLoading = false
try {
this.makeDataResponse = JSON.stringify(err)
} catch {
this.makeDataResponse = err
}
})
}
public navigateToHome() {
this.onNavigateToHome.emit()
}
public validateDeploy() {
this.isValidating = true
this.sasService
.request('public/startupservice', null)
.then((res: RequestWrapperResponse) => {
this.loggerService.log(res.adapterResponse)
const malformedMessage = getMalformedAdapterResponseMessage(
res.adapterResponse
)
if (malformedMessage) {
this.validationState = 'error'
this.eventService.showInfoModal('Error', malformedMessage)
} else if (res.adapterResponse.saslibs) {
this.validationState = 'success'
} else {
this.validationState = 'error'
}
this.isValidating = false
})
.catch((err: any) => {
this.isValidating = false
this.validationState = 'error'
})
}
public deleteKeys() {
localStorage.removeItem('deploy_dc_loc')
}
}
+40 -2
View File
@@ -245,6 +245,25 @@
}
</clr-tooltip>
@if (truncationNote) {
<clr-tooltip>
<clr-icon
clrTooltipTrigger
shape="warning"
aria-label="The selection was truncated"
class="color-orange truncation-warning"
size="20"
></clr-icon>
<clr-tooltip-content
clrPosition="right"
clrSize="lg"
*clrIfOpen
>
{{ truncationNote }}
</clr-tooltip-content>
</clr-tooltip>
}
@if (dataSource) {
@if (!zeroFilterRows) {
({{ dataSource.length | thousandSeparator: ',' }}
@@ -369,11 +388,30 @@
</div>
}
@if (!['', ' '].includes(queryText)) {
<div class="clr-col-md-12 infoBar">
<span
<div
#infoBar
class="clr-col-md-12 infoBar"
[class.expanded]="filterExpanded"
>
<span class="infoBar-text"
>FILTER :
<b>{{ queryText }}</b>
</span>
@if (filterOverflows) {
<button
type="button"
class="infoBar-toggle"
[attr.aria-expanded]="filterExpanded"
[attr.aria-label]="
filterExpanded
? 'Collapse the filter clause'
: 'Expand the filter clause'
"
(click)="toggleFilterPanel()"
>
<clr-icon aria-hidden="true" shape="caret down"></clr-icon>
</button>
}
</div>
}
</div>
+219 -24
View File
@@ -1,4 +1,5 @@
import {
AfterViewChecked,
AfterViewInit,
ChangeDetectorRef,
Component,
@@ -88,6 +89,11 @@ import { withoutEditStatus } from './utils/withoutEditStatus'
import { getEditStatusSymbol } from './utils/getEditStatusSymbol'
import { normalizeSortConfig } from './utils/normalizeSortConfig'
import { EDIT_STATUS_COLUMN_NAME } from '../shared/dc-validator/utils/editStatusColumnRule'
import { DELETE_RECORD_COLUMN_NAME } from '../shared/dc-validator/utils/deleteRecordColumnRule'
import {
prepareDeleteRecordColumn,
seedDeleteRecordColumn
} from '../shared/dc-validator/utils/deleteRecordColumn'
import {
errorRenderer,
noSpinnerRenderer,
@@ -112,7 +118,9 @@ import { ParseResult } from '../models/ParseResult.interface'
encapsulation: ViewEncapsulation.None,
standalone: false
})
export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
export class EditorComponent
implements OnInit, AfterViewInit, AfterViewChecked, OnDestroy
{
@ViewChildren('uploadStater')
uploadStaterCompList: QueryList<UploadStaterComponent> = new QueryList()
@ViewChildren('queryFilter')
@@ -152,6 +160,9 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
dsmeta: DSMeta[] = []
versions: Version[] = []
dsNote = ''
/** Set when getdata served a truncated selection - shown as a warning
* against the table name, with the reason in a tooltip. */
truncationNote = ''
viewboxes = false
@@ -525,6 +536,19 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
public tableData: Array<any> = []
public queryText = ''
public queryTextSaved = ''
/**
* The applied-filter panel is collapsed to a single line by default. The
* chevron that expands it is only useful when the clause does not fit that
* line, which depends on the rendered width - so it is measured from the DOM
* rather than guessed from the length of the text.
*/
public filterExpanded = false
public filterOverflows = false
@ViewChild('infoBar') infoBar?: ElementRef<HTMLElement>
private filterMeasuredKey = ''
public showApprovers = false
public pkDups = false
public validationDone = 0
@@ -551,6 +575,8 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
public hasBaseDropZoneOver = false
public hasAnotherDropZoneOver = false
public headerPks: string[] = []
/** Derived (computed) columns from MPE_DERIVED - read-only, and marked as such */
public derivedVars: string[] = []
public columnLevelSecurityFlag = false
public dateTimeHeaders: string[] = []
public timeHeaders: string[] = []
@@ -1065,6 +1091,20 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
return colRules?.readOnly
}
/**
* A derived (computed) column - configured in MPE_DERIVED, created at read
* time. Read-only, and styled apart from an ordinary read-only column so the
* user can see that there is nothing to edit rather than that they may not.
*/
isDerivedCol(col: string | number) {
const name =
typeof col === 'number'
? (this.hotInstance?.colToProp(col) as string) || this.columnHeader[col]
: col
return !!name && this.derivedVars.includes(name.toUpperCase())
}
isColHeader(col: string) {
return this.headerArray.indexOf(col.toUpperCase()) > -1
}
@@ -1190,7 +1230,16 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.cdf.detectChanges()
this.submitLoading = false
this.sasStoreService.setQueryVariables(this.libds, this.cols)
// The columns that came with the table are the cheapest source for the
// picker. When the table was not returned - the row/cell limits abort the
// request before the data arrives - that list is empty, so the store
// falls back to public/getcols rather than leaving the picker with
// nothing to pick from.
this.sasStoreService
.setQueryVariablesFromTable(this.libds, this.cols)
.catch((err: any) =>
this.eventService.catchResponseError('public/getcols', err)
)
}
}
@@ -1330,8 +1379,14 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
colSpecs.TYPE === 'num' &&
!colSpecs.DDTYPE.includes('TIME') &&
!colSpecs.DDTYPE.includes('DATE')
)
row[colKey] = parseInt(row[colKey])
) {
const numericValue = parseFloat(row[colKey])
// A cell the file parser could not read as a number stays as it
// was: the editor's numeric validation then flags it as text,
// where a NaN would render as an empty cell.
if (!Number.isNaN(numericValue)) row[colKey] = numericValue
}
}
}
}
@@ -2718,17 +2773,24 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.disableSubmit = true
this.submit = false
const errorText =
typeof err.adapterRespnse === 'string'
? err.adapterRespnse
: JSON.stringify(err.adapterRespnse)
/* sasService has already shown the SAS message when it rejected
(the abort, or the adapter's error), so reporting it again here
stacked a second modal on top of the first - and read
'undefined' because it looked for a property that does not
exist. Only speak up when nothing was shown. */
if (!err?.errorShown) {
const errorText =
typeof err?.adapterResponse?.error === 'string'
? err.adapterResponse.error
: JSON.stringify(err?.adapterResponse ?? err)
this.eventService.showAbortModal(
'editors/stagedata',
`Submit request failed\n${errorText}`,
null,
'Submit error'
)
this.eventService.showAbortModal(
'editors/stagedata',
`Submit request failed\n${errorText}`,
null,
'Submit error'
)
}
return false
})
@@ -3494,14 +3556,24 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
// A synchronous throw inside initSetup (called from the .then()
// above) lands here too, not just a network failure - log it, or
// the table just renders hidden with no clue why.
// eslint-disable-next-line no-console
console.error('editors/getdata failed:', err)
this.getdataError = true
this.tableTrue = true
this.handleGetdataFailure(err)
})
}
}
/**
* Puts the page into its getdata error state. Shared by the callService
* .catch and initSetup's own retry branch: a throw from the retry runs on a
* bare setTimeout, outside that promise chain, so it would otherwise never
* reach the .catch and the user would be left on the loading spinner.
*/
private handleGetdataFailure(err: any) {
// eslint-disable-next-line no-console
console.error('editors/getdata failed:', err)
this.getdataError = true
this.tableTrue = true
}
/**
* VA mode, initial (unfiltered) route only: briefly wait for VA's buffered
* first message and, if it already carries a filter, save that filter and
@@ -3547,6 +3619,48 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
}
}
ngAfterViewChecked() {
this.scheduleFilterOverflowCheck()
}
/**
* Measures whether the applied-filter clause fits the collapsed single line,
* and shows or hides the chevron accordingly. The measurement is deferred
* because `filterOverflows` and `filterExpanded` are bound in this view -
* setting them inside the change-detection cycle would raise
* ExpressionChangedAfterItHasBeenChecked.
*/
private scheduleFilterOverflowCheck() {
const el = this.infoBar?.nativeElement
if (!el) {
return
}
const text = el.querySelector('.infoBar-text') as HTMLElement | null
if (!text) {
return
}
// re-measure only when the clause, the available width, or the state changes
const key = `${this.queryText}|${text.clientWidth}|${this.filterExpanded}`
if (key === this.filterMeasuredKey) {
return
}
this.filterMeasuredKey = key
setTimeout(() => {
// while expanded the clause wraps, so there is nothing to measure
if (this.filterExpanded) {
return
}
this.filterOverflows = text.scrollWidth > text.clientWidth
})
}
public toggleFilterPanel() {
this.filterExpanded = !this.filterExpanded
}
ngAfterViewInit() {
// Fix ARIA accessibility issues after table initialization
setTimeout(() => {
@@ -3808,13 +3922,28 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.hotInstance = this.hotTableComponent?.hotInstance!
if (!this.hotInstance) {
// Retry init, don't permanently abort
// Retry init, don't permanently abort. A throw from the retry runs on a
// bare setTimeout rather than in the caller's promise chain, so it would
// never reach that .catch - surface it through the same handler here.
if (attempt < 60) {
setTimeout(() => this.initSetup(response, attempt + 1), 50)
setTimeout(() => {
try {
this.initSetup(response, attempt + 1)
} catch (err) {
this.handleGetdataFailure(err)
}
}, 50)
}
return
}
// The delete column is client-owned (see deleteRecordColumnRule.ts):
// this asserts getdata did not send it, then prepends it to COLHEADERS so
// it is the grid's first column. A throw here lands in the caller's
// .catch - or, on a retry, the branch above - which sets getdataError and
// shows the error state.
prepareDeleteRecordColumn(response)
this.cols = response.data.cols
this.dsmeta = response.data.dsmeta
this.versions = response.data.versions || []
@@ -3833,6 +3962,14 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.dsNote = ''
}
// getdata serves a selection over DC_MAXOBS_WEBEDIT / DC_MAXCELLS_WEBEDIT
// truncated to the first rows within the limit, and carries the reason
// here. Empty means the whole selection is in the grid - and a blank
// character arrives as a single blank (mp_jsonout cannot emit a zero-length
// string, since SAS has none), so trim it: whitespace is "no note", not a
// warning with an empty tooltip.
this.truncationNote = (response.data.sasparams[0].TRUNC_MSG || '').trim()
const hot = this.hotInstance
const approvers: Approver[] = response.data.approvers
@@ -3853,6 +3990,12 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.headerColumns = response.data.sasparams[0].COLHEADERS.split(',')
this.headerPks = response.data.sasparams[0].PK.split(' ')
// Derived (computed) columns, named by getdata from MPE_DERIVED - read-only
// through a READONLY DQ rule, and marked in the grid so they read as
// computed rather than merely non-editable.
this.derivedVars = (response.data.sasparams[0].DERIVEDVARS || '')
.split(' ')
.filter((col: string) => !!col)
this.columnLevelSecurityFlag = !!response.data.sasparams[0].CLS_FLAG
if (this.columnLevelSecurityFlag)
@@ -3864,9 +4007,9 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
this.checkEmptyRowWhenFilter()
if (this.headerColumns.indexOf('_____DELETE__THIS__RECORD_____') !== -1) {
if (this.headerColumns.indexOf(DELETE_RECORD_COLUMN_NAME) !== -1) {
this.headerColumns[
this.headerColumns.indexOf('_____DELETE__THIS__RECORD_____')
this.headerColumns.indexOf(DELETE_RECORD_COLUMN_NAME)
] = 'Delete?'
}
@@ -3931,6 +4074,10 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
row[EDIT_STATUS_COLUMN_NAME] = 'U'
}
// The delete flag is client-owned too (see deleteRecordColumnRule.ts) -
// getdata no longer sends the column, so every row starts unmarked.
seedDeleteRecordColumn(this.dataSource)
// Seed HARDFORMULA/SOFTFORMULA columns with their computed formula
// string per row. dataSourceUnchanged isn't populated yet this early in
// a fresh load (only the excel-preview/add-row flows set it) - at this
@@ -4223,9 +4370,37 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
// header columns styling - primary keys
const isPKCol = column && this.isColPk(column)
const isReadonlyCol = column && this.isReadonlyCol(column)
const isDerivedCol = column && this.isDerivedCol(column)
if (isPKCol) th.classList.add('primaryKeyHeaderStyle')
if (isReadonlyCol && !isPKCol) th.classList.add('readonlyCell')
if (isReadonlyCol && !isPKCol && !isDerivedCol) {
th.classList.add('readonlyCell')
}
// a derived column is computed, not merely locked - give it its own
// hue and an 'fx' marker rather than the read-only dimming
if (isDerivedCol) {
th.classList.add('dc-derived-header')
// the label says what the column is - for a derived variable that
// is the configured VAR_LABEL, or the generated name=expression
// when the administrator left it blank. A label that merely
// repeats the name adds nothing, so it falls back to the rule.
const derivedLabel = (this.cols || [])
.filter((c: any) => c.NAME === column)
.map((c: any) => String(c.LABEL || '').trim())
.find(
(l: string) =>
l.length > 0 &&
l.toUpperCase() !== String(column).toUpperCase()
)
th.title = derivedLabel
? `${derivedLabel} - derived variable, computed at read time and cannot be edited`
: 'Derived variable - computed at read time and cannot be edited'
const firstDerivedCol = this.columnHeader.findIndex(
(name: string) => this.isDerivedCol(name)
)
if (col === firstDerivedCol) th.classList.add('dc-derived-first')
}
// Remove header arrow from Delete column
if (col === 0) {
@@ -4241,6 +4416,7 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
cellProperties: Handsontable.CellProperties
) => {
const isReadonlyCol = col && this.isReadonlyCol(col)
const isDerivedCol = col && this.isDerivedCol(col)
// Check if this cell should be marked as invalid due to duplicate primary key values
// Only applies to primary key columns (col 1 through readOnlyFields)
@@ -4264,7 +4440,26 @@ export class EditorComponent implements OnInit, AfterViewInit, OnDestroy {
}
// Add readonlyCell class for readonly columns to maintain original styling
if (isReadonlyCol && !classes.includes('readonlyCell')) {
if (isDerivedCol) {
// a derived cell carries its own tint; the read-only dimming would
// wash it out, and "greyed out" is a different message from
// "computed here"
classes = classes.filter((c: string) => c !== 'readonlyCell')
if (!classes.includes('dc-derived-cell')) {
classes.push('dc-derived-cell')
}
// derived columns are appended after the physical ones - mark the
// start of the block so it reads as one group
const firstDerivedCol = this.columnHeader.findIndex(
(name: string) => this.isDerivedCol(name)
)
if (
col === firstDerivedCol &&
!classes.includes('dc-derived-first')
) {
classes.push('dc-derived-first')
}
} else if (isReadonlyCol && !classes.includes('readonlyCell')) {
classes.push('readonlyCell')
}
@@ -417,9 +417,14 @@ describe('formulas plugin must not be disabled/re-enabled around a table load',
* capping maxRows at editor_rows_allowed alone makes HyperFormula reject
* any table bigger than that cap outright. See initSetup's own
* Math.max(dataSource.length, editor_rows_allowed) fix.
*
* Handsontable 18.1 fixed the engine coupling upstream (#10672): the grid's
* maxRows/maxCols no longer limit the HyperFormula engine, so a capped
* maxRows no longer rejects a larger existing dataset. DC's own guard is
* still in place; the first test below now pins the fixed behaviour.
*/
describe('maxRows must never be smaller than the actual loaded row count', () => {
it('throws when maxRows is capped below the real row count (proves the mechanism)', () => {
it('no longer throws when maxRows is capped below the real row count (HOT 18.1 #10672)', () => {
const container = document.createElement('div')
document.body.appendChild(container)
const colNames = ['PK', 'A', 'B']
@@ -440,7 +445,7 @@ describe('maxRows must never be smaller than the actual loaded row count', () =>
error = e
}
expect(error?.message).toEqual('Sheet size limit exceeded')
expect(error).toBeNull()
})
it('does not throw when maxRows is never let below the actual row count (the fix)', () => {
@@ -287,9 +287,13 @@ describe('syncOverwrittenCommentForCell resolves the correct visual cell on a so
* trigger it, independent of what it actually changes. editTable(),
* cancelEdit(), and every other place editor.component.ts calls
* updateSettings() after the grid could already be sorted (e.g. the user
* sorted while still read-only, then clicked Edit) hits this. The fix
* (updateSettingsSortSafe) clears the sort before the call and restores it
* immediately afterward.
* sorted while still read-only, then clicked Edit) hits this.
*
* Fixed upstream in Handsontable 18.1 (the formulas plugin now keeps its
* index translations across updateSettings), so the corruption no longer
* occurs. DC's own guard (updateSettingsSortSafe - clear the sort, call
* updateSettings, restore the sort) is still in place and still correct;
* this test now pins the fixed behaviour so a future regression shows up.
*/
describe('updateSettings must not run while a sort is active - it corrupts formula cell references', () => {
const buildSortedGrid = (): Handsontable => {
@@ -340,13 +344,13 @@ describe('updateSettings must not run while a sort is active - it corrupts formu
hot.getDataAtRowProp(r, 'FORMULA_HARD_COL')
)
it('demonstrates the failure mode: updateSettings while sorted corrupts formula cells', () => {
it('no longer corrupts formula cells when updateSettings runs while sorted (HOT 18.1)', () => {
const hot = buildSortedGrid()
hot.updateSettings({}, false)
hot.render()
expect(formulaHardColValues(hot)).toContain('#REF!')
expect(formulaHardColValues(hot)).not.toContain('#REF!')
hot.destroy()
})
@@ -1,7 +1,5 @@
import { SASjsConfig } from '@sasjs/adapter'
export interface DcAdapterSettings extends Partial<SASjsConfig> {
adminGroup: string
dcPath: string
hotLicenceKey: string
}
+9
View File
@@ -47,6 +47,15 @@ export interface SASParam {
PKCNT: number
RK_FLAG: number
TMVARS: string
/** 1 when getdata cut the selection down to the row / cell limit */
TRUNCATED?: number
/** Reason shown in the tooltip when TRUNCATED is 1, else empty */
TRUNC_MSG?: string
/**
* Space separated list of the derived (computed) columns from MPE_DERIVED,
* upper case. Empty when the table has none.
*/
DERIVEDVARS?: string
}
export interface ExcelRule {
@@ -18,6 +18,11 @@ import {
import { globals } from '../_globals'
import { EditorsGetDataServiceResponse } from '../models/sas/editors-getdata.model'
import { DcValidator } from '../shared/dc-validator/dc-validator'
import {
prepareDeleteRecordColumn,
seedDeleteRecordColumn
} from '../shared/dc-validator/utils/deleteRecordColumn'
import { DELETE_RECORD_COLUMN_NAME } from '../shared/dc-validator/utils/deleteRecordColumnRule'
import { ExcelRule } from '../models/TableData'
import { HotTableInterface } from '../models/HotTable.interface'
import { Col } from '../shared/dc-validator/models/col.model'
@@ -360,7 +365,21 @@ export class MultiDatasetComponent implements OnInit, AfterViewInit {
this.uploadLoading = false
const datasetObjects = this.buildDatasetsObjects(datasets)
// buildDatasetsObjects throws when a getdata response carries the
// reserved delete-record column (see deleteRecordColumn.ts). This chain
// has no .catch, so an uncaught throw here would become an unhandled
// rejection that aborts the loop with nothing shown. Surface it on
// screen, the way the editor flow refuses the same response, rather
// than leaving the user on an empty table selection with the file
// still attached.
let datasetObjects: DatasetsObject[] = []
try {
datasetObjects = this.buildDatasetsObjects(datasets)
} catch (err) {
console.warn('Error building dataset objects', err)
this.eventService.showInfoModal('Upload error', (err as Error).message)
return
}
datasetObjects.forEach((datasetObject) => {
this.parsedDatasets.push({
@@ -849,6 +868,21 @@ export class MultiDatasetComponent implements OnInit, AfterViewInit {
return this.sasStoreService
.callService(myParams, 'SASControlTable', 'editors/getdata', libds)
.then((res: EditorsGetDataServiceResponse) => {
// getdata serves a selection over DC_MAXOBS_WEBEDIT / DC_MAXCELLS_WEBEDIT
// truncated, rather than aborting the way it used to. This flow compares
// the whole table against the upload, so a partial read would compute
// the changes against the wrong starting state - refuse the table
// instead of submitting differences nobody asked for.
const sasParams = res?.data?.sasparams?.[0]
if (sasParams && Number(sasParams.TRUNCATED) === 1) {
this.eventService.showInfoModal(
'Upload error',
`${libds} holds more than the EDIT limit allows (${sasParams.TRUNC_MSG}), so it cannot be compared with the upload. Raise DC_MAXOBS_WEBEDIT / DC_MAXCELLS_WEBEDIT, or submit the table without the multi-table upload.`
)
return undefined
}
return res
})
.catch((err: any) => {
@@ -1074,6 +1108,12 @@ export class MultiDatasetComponent implements OnInit, AfterViewInit {
for (let response of responses) {
if (response.data) {
// The delete column is client-owned (see deleteRecordColumnRule.ts):
// asserts getdata did not send it, then prepends it to COLHEADERS so
// it is index 0 for everything below.
prepareDeleteRecordColumn(response)
seedDeleteRecordColumn(response.data.sasdata)
const datasetObject: DatasetsObject = {
...response,
hotTable: {
@@ -1097,14 +1137,10 @@ export class MultiDatasetComponent implements OnInit, AfterViewInit {
datasetObject.headerPks = response.data.sasparams[0].PK.split(' ')
if (
datasetObject.headerColumns.indexOf(
'_____DELETE__THIS__RECORD_____'
) !== -1
datasetObject.headerColumns.indexOf(DELETE_RECORD_COLUMN_NAME) !== -1
) {
datasetObject.headerColumns[
datasetObject.headerColumns.indexOf(
'_____DELETE__THIS__RECORD_____'
)
datasetObject.headerColumns.indexOf(DELETE_RECORD_COLUMN_NAME)
] = 'Delete?'
}
@@ -0,0 +1,110 @@
import { QueryComponent } from './query.component'
import { HelperService } from '../services/helper.service'
/**
* dynamicWhereClauseCreator builds the prefilter that getcolvals sends when the
* dynamic where clause is on, and it composes a temporal value into the same
* SAS literal the applied filter carries. The value it prefilters with comes
* from the *other* clauses in the query, so the clause under test sits at index
* 1 and index 0 is skipped.
*/
describe('QueryComponent - dynamic where clause', () => {
const buildComponent = (elements: any[]) => {
const component = new QueryComponent(
{} as any,
{ catchResponseError: () => undefined } as any,
new HelperService(null as any),
{ detectChanges: () => undefined } as any
)
component.clauses = {
queryObj: [{ clauseLogic: 'AND', elements }],
groupLogic: 'AND'
} as any
return component
}
const temporalClause = (over: any = {}) => ({
variable: 'SOME_DATE',
operator: '=',
value: '',
values: [],
type: 'num',
ddtype: 'DATE',
valueVariable: false,
...over
})
it('sends an IN entry as the literal for its unformatted value', () => {
const component = buildComponent([
temporalClause(),
temporalClause({
operator: 'IN',
value: [{ checked: true, val: '12FEB1960' }],
values: [{ formatted: '12FEB1960', unformatted: 42 }]
})
])
const table = component.dynamicWhereClauseCreator(0, 0)
expect(table.length).toBe(1)
expect(table[0].RAW_VALUE).toBe("('12FEB1960'd)")
})
it('maps both ends of a BETWEEN picked from the value list', () => {
const component = buildComponent([
temporalClause(),
temporalClause({
operator: 'BETWEEN',
value: ['12FEB1960', '13FEB1960'],
values: [
{ formatted: '12FEB1960', unformatted: 42 },
{ formatted: '13FEB1960', unformatted: 43 }
]
})
])
const table = component.dynamicWhereClauseCreator(0, 0)
expect(table.length).toBe(1)
expect(table[0].RAW_VALUE).toBe("'12FEB1960'd AND '13FEB1960'd")
})
it('leaves an already-unformatted BETWEEN alone', () => {
const component = buildComponent([
temporalClause(),
temporalClause({
operator: 'BETWEEN',
value: [42, 43],
values: [
{ formatted: '12FEB1960', unformatted: 42 },
{ formatted: '13FEB1960', unformatted: 43 }
]
})
])
const table = component.dynamicWhereClauseCreator(0, 0)
expect(table[0].RAW_VALUE).toBe("'12FEB1960'd AND '13FEB1960'd")
})
it('emits the unformatted value in the non-literal IN fallback', () => {
const component = buildComponent([
temporalClause(),
{
variable: 'SOME_CHAR',
operator: 'IN',
value: [{ checked: true, val: 'ABC ' }],
values: [{ formatted: 'ABC ', unformatted: 'ABC' }],
type: 'char',
ddtype: 'CHAR',
valueVariable: false
}
])
const table = component.dynamicWhereClauseCreator(0, 0)
expect(table[0].RAW_VALUE).toBe("('ABC')")
})
})
+49 -26
View File
@@ -425,35 +425,57 @@ export class QueryComponent
continue
let rawValue = ''
const operator =
this.clauses.queryObj[groupInd].elements[clauseInd].operator
const variable =
this.clauses.queryObj[groupInd].elements[clauseInd].variable
const element = this.clauses.queryObj[groupInd].elements[clauseInd]
const operator = element.operator
const variable = element.variable
/* a temporal value is sent as a SAS literal (eg '20APR2042'd), the
same way the applied filter carries it */
const temporalValue = (value: any) =>
element.valueVariable
? null
: this.helperService.sasTemporalLiteral(value, element.ddtype)
/* the dropdowns and the IN modal hold the *formatted* value (the
soft-select option value, and setINValues), so a picked value is
mapped back to the unformatted one the filter needs */
const unformattedValue = (value: any) =>
(element.values || []).find((v: any) => v.formatted === value)
?.unformatted ?? value
if (operator === 'BETWEEN') {
rawValue = `${this.clauses.queryObj[groupInd].elements[clauseInd].value[0]} AND ${this.clauses.queryObj[groupInd][clauseInd].value[1]}`
const from = unformattedValue(element.value[0])
const to = unformattedValue(element.value[1])
rawValue = `${temporalValue(from) ?? from} AND ${
temporalValue(to) ?? to
}`
} else if (operator === 'IN' || operator === 'NOT IN') {
this.clauses.queryObj[groupInd][clauseInd].value.forEach(
(element: any) => {
if (element.checked) {
let value = element.val
element.value.forEach((item: any) => {
if (item.checked) {
/* map once, and use the unformatted value in every branch - the
literal is built from it, and so are the fallbacks, so a
formatted label can never reach RAW_VALUE */
const value = unformattedValue(item.val)
const literal = temporalValue(value)
if (typeof value === 'string' && !isSpecialMissing(value)) {
if (rawValue.length > 0) {
rawValue += `,'${value}'`
} else {
rawValue = `('${value}'`
}
if (literal) {
rawValue += (rawValue.length > 0 ? ',' : '(') + literal
} else if (
typeof value === 'string' &&
!isSpecialMissing(value)
) {
if (rawValue.length > 0) {
rawValue += `,'${value}'`
} else {
if (rawValue.length > 0) {
rawValue += `,${value}`
} else {
rawValue = `(${value}`
}
rawValue = `('${value}'`
}
} else {
if (rawValue.length > 0) {
rawValue += `,${value}`
} else {
rawValue = `(${value}`
}
}
}
)
})
if (rawValue.length > 0) {
rawValue += ')'
@@ -470,11 +492,12 @@ export class QueryComponent
rawValue = '.'
}
} else {
if (
this.clauses.queryObj[groupInd].elements[clauseInd].type ===
'char'
) {
rawValue = `'${this.clauses.queryObj[groupInd].elements[clauseInd].value}'`
const literal = temporalValue(element.value)
if (literal) {
rawValue = literal
} else if (element.type === 'char') {
rawValue = `'${element.value}'`
}
}
+3 -1
View File
@@ -170,9 +170,11 @@ describe('AppService - startup retry', () => {
expect(deps.sasService.request).toHaveBeenCalledTimes(1)
expect(deps.eventService.showInfoModal).toHaveBeenCalledTimes(1)
const [, message] = deps.eventService.showInfoModal.calls.mostRecent().args
const [, message, sasService] =
deps.eventService.showInfoModal.calls.mostRecent().args
expect(message).toContain(rawJobError)
expect(message).not.toContain('Globvars, Sasdatasets, Saslibs, XLMaps')
expect(sasService).toBe('public/startupservice')
expect(deps.licenceService.isAppActivated.value).toBeFalse()
})
})
+9 -3
View File
@@ -107,7 +107,11 @@ export class AppService {
malformedMessage
)
this.startupCheckService.updateStep(2, 'error', 'Malformed response')
this.eventService.showInfoModal('Error', malformedMessage)
this.eventService.showInfoModal(
'Error',
malformedMessage,
'public/startupservice'
)
this.licenceService.isAppActivated.next(false)
return
@@ -139,7 +143,8 @@ export class AppService {
)
this.eventService.showInfoModal(
'Error',
`${missingProps.join(', ')} are not present in the startupservice`
`${missingProps.join(', ')} are not present in the startupservice`,
'public/startupservice'
)
this.licenceService.isAppActivated.next(false)
@@ -221,7 +226,8 @@ export class AppService {
this.startupCheckService.updateStep(2, 'error', 'Request failed')
this.eventService.showInfoModal(
'Error',
'There is an issue with startupservice response'
'There is an issue with startupservice response',
'public/startupservice'
)
this.licenceService.isAppActivated.next(false)
})
+6 -2
View File
@@ -42,11 +42,15 @@ export class EventService {
this.onDemoLimitModalShow.emit(featureName)
}
public showInfoModal(modalTitle: string = 'Info', message: string) {
public showInfoModal(
modalTitle: string = 'Info',
message: string,
sasService: string | null = null
) {
let infoModal: InfoModal = {
modalTitle,
message,
sasService: '',
sasService,
details: null
}
@@ -46,3 +46,72 @@ describe('HelperService - convertArrayValues', () => {
expect(result.length).toBe(3)
})
})
describe('HelperService - sasTemporalLiteral', () => {
let service: HelperService
beforeEach(() => {
service = new HelperService(null as any)
})
it('renders a SAS date value as a date literal', () => {
expect(service.sasTemporalLiteral(42, 'DATE')).toBe("'12FEB1960'd")
expect(service.sasTemporalLiteral(0, 'DATE')).toBe("'01JAN1960'd")
expect(service.sasTemporalLiteral(34322, 'DATE')).toBe("'20DEC2053'd")
})
it('renders a date before 1960', () => {
expect(service.sasTemporalLiteral(-1, 'DATE')).toBe("'31DEC1959'd")
})
it('renders a SAS datetime value as a datetime literal', () => {
expect(service.sasTemporalLiteral(42, 'DATETIME')).toBe(
"'01JAN1960:00:00:42'dt"
)
expect(service.sasTemporalLiteral(86400, 'DATETIME')).toBe(
"'02JAN1960:00:00:00'dt"
)
expect(service.sasTemporalLiteral(31536001, 'DATETIME')).toBe(
"'31DEC1960:00:00:01'dt"
)
})
it('rounds double noise onto the second', () => {
expect(service.sasTemporalLiteral(1.9999999999999, 'TIME')).toBe(
"'00:00:02't"
)
expect(service.sasTemporalLiteral(42.000000000000004, 'DATETIME')).toBe(
"'01JAN1960:00:00:42'dt"
)
})
it('returns null rather than round a genuinely fractional value', () => {
expect(service.sasTemporalLiteral(42.5, 'DATETIME')).toBeNull()
expect(service.sasTemporalLiteral(42.5, 'TIME')).toBeNull()
expect(service.sasTemporalLiteral(42.3, 'TIME')).toBeNull()
})
it('renders a SAS time value as a time literal', () => {
expect(service.sasTemporalLiteral(0, 'TIME')).toBe("'00:00:00't")
expect(service.sasTemporalLiteral(42, 'TIME')).toBe("'00:00:42't")
expect(service.sasTemporalLiteral(3661, 'TIME')).toBe("'01:01:01't")
})
it('accepts a value that arrives as a string', () => {
expect(service.sasTemporalLiteral('42', 'DATE')).toBe("'12FEB1960'd")
})
it('returns null when the value cannot be a literal', () => {
// not temporal
expect(service.sasTemporalLiteral(42, 'N')).toBeNull()
expect(service.sasTemporalLiteral(42, 'C')).toBeNull()
expect(service.sasTemporalLiteral(42, '')).toBeNull()
// not a number
expect(service.sasTemporalLiteral('12FEB1960', 'DATE')).toBeNull()
expect(service.sasTemporalLiteral('', 'DATE')).toBeNull()
expect(service.sasTemporalLiteral(null, 'DATE')).toBeNull()
expect(service.sasTemporalLiteral(undefined, 'DATE')).toBeNull()
// a fractional number of days is not a SAS date
expect(service.sasTemporalLiteral(42.5, 'DATE')).toBeNull()
})
})
+80
View File
@@ -5,6 +5,22 @@ import { SasService } from './sas.service'
const librariesToShow = 50
/** Month names used by a SAS date literal, eg 20APR2042. */
const sasMonths = [
'JAN',
'FEB',
'MAR',
'APR',
'MAY',
'JUN',
'JUL',
'AUG',
'SEP',
'OCT',
'NOV',
'DEC'
]
@Injectable({
providedIn: 'root'
})
@@ -226,6 +242,70 @@ export class HelperService {
})
}
/**
* Formats a SAS internal date / datetime / time value as the SAS literal a
* WHERE clause can carry, eg:
* 34322 (DATE) -> '20DEC2053'd
* 42 (DATETIME) -> '01JAN1960:00:00:42'dt
* 42 (TIME) -> '00:00:42't
*
* The value is days since 1960-01-01 for a date, and seconds since
* 1960-01-01 (datetime) or since midnight (time). The date part is built
* arithmetically in UTC, so the day cannot shift with the browser timezone.
*
* SAS temporal values are whole days and whole seconds, so the value is
* rounded to seconds first - that kills the noise a double picks up on the
* way here, where 1.9999999999999 is simply the second 2. A value that is
* genuinely fractional does not land on a second, and rounding it would
* silently widen the filter, so it returns null instead.
*
* Returns null when the value is not a finite number, is not a whole day or
* second, or the ddtype is not temporal - callers then send the raw value.
*/
public sasTemporalLiteral(value: any, ddtype: string): string | null {
const kind = (ddtype ?? '').toString().toUpperCase()
if (kind !== 'DATE' && kind !== 'DATETIME' && kind !== 'TIME') return null
if (value === null || value === undefined || value === '') return null
const num = typeof value === 'number' ? value : Number(String(value).trim())
if (!isFinite(num)) return null
/* Within the precision of a double, is this a whole second? */
const seconds = Math.round(num * 1e8) / 1e8
if (!Number.isInteger(seconds)) return null
if (kind === 'TIME') return `'${this.sasTimeFromSeconds(seconds)}'t`
const days = kind === 'DATETIME' ? Math.floor(seconds / 86400) : seconds
const datePart = this.sasDateFromDays(days)
if (kind === 'DATE') return `'${datePart}'d`
return `'${datePart}:${this.sasTimeFromSeconds(seconds - days * 86400)}'dt`
}
/** `ddMMMyyyy` for a SAS date value (days since 1960-01-01). */
private sasDateFromDays(days: number): string {
const date = new Date(Date.UTC(1960, 0, 1) + days * 86400000)
return (
this.addLeadingZero(date.getUTCDate()) +
sasMonths[date.getUTCMonth()] +
date.getUTCFullYear()
)
}
/** `hh:mm:ss` for a SAS time value (whole seconds since midnight). */
private sasTimeFromSeconds(seconds: number): string {
return (
this.addLeadingZero(Math.floor(seconds / 3600)) +
':' +
this.addLeadingZero(Math.floor((seconds % 3600) / 60)) +
':' +
this.addLeadingZero(seconds % 60)
)
}
public addLeadingZero(value: string | number): string {
if (typeof value !== 'string') value = value.toString()
+13 -8
View File
@@ -8,13 +8,20 @@ import * as encoding from 'text-encoding'
import { Router } from '@angular/router'
import { Globvar } from '../models/sas/public-startupservice.model'
import { freeTierConfig } from '../free-tier.config'
import { AppStoreService } from './app-store.service'
import { HelperService } from './helper.service'
import { LicenceState } from '../models/LicenceState'
import { decodeLicenceFeatures as decodeFeatures } from './utils/decodeLicenceFeatures'
import { LoggerService } from './logger.service'
import { EventService } from './event.service'
/**
* Handsontable licence key used until a licence is loaded from the backend.
* The decrypted licence carries the customer's own key (`hot_license_key`), so
* this is only the pre-licence / free-tier default - it used to be supplied by
* the `<sasjs>` tag.
*/
export const DEFAULT_HOT_LICENCE_KEY = 'non-commercial-and-evaluation'
@Injectable({
providedIn: 'root'
})
@@ -43,7 +50,7 @@ export class LicenceService {
private freeTierLicenceData: LicenseKeyData = {
demo: true,
hot_license_key: this.appStoreService.getDcAdapterSettings()?.hotLicenceKey,
hot_license_key: DEFAULT_HOT_LICENCE_KEY,
users_allowed: this._licenceState.users_allowed || 1,
valid_until: moment().add(1, 'year').format('YYYY-MM-DD'),
site_id: '',
@@ -63,7 +70,6 @@ export class LicenceService {
constructor(
private loggerService: LoggerService,
private appStoreService: AppStoreService,
private eventService: EventService,
private sasService: SasService,
private helperService: HelperService,
@@ -79,8 +85,7 @@ export class LicenceService {
}
public async activation(startupservice: any) {
this.freeTierLicenceData.hot_license_key =
this.appStoreService.getDcAdapterSettings()?.hotLicenceKey
this.freeTierLicenceData.hot_license_key = DEFAULT_HOT_LICENCE_KEY
await this.setStartupserviceRules(startupservice)
@@ -137,7 +142,8 @@ export class LicenceService {
this.isAppActivated.next(false)
this.eventService.showInfoModal(
'Error',
'Some of the globvars are not present in the startupservice'
'Some of the globvars are not present in the startupservice',
'public/startupservice'
)
// this.router.navigateByUrl('/licensing/key?error=missing')
return
@@ -225,8 +231,7 @@ export class LicenceService {
? licenseData.hot_license_key
: this.hot_license_key.value
if (!hotLicenceKey)
hotLicenceKey = this.appStoreService.getDcAdapterSettings()?.hotLicenceKey
if (!hotLicenceKey) hotLicenceKey = DEFAULT_HOT_LICENCE_KEY
this.hot_license_key.next(hotLicenceKey)
@@ -0,0 +1,313 @@
import { SasStoreService } from './sas-store.service'
import { HelperService } from './helper.service'
/**
* The filter picker keys its operator set, its variable highlight and its value
* quoting on Col.TYPE being exactly 'num' or 'char'. On the normal path
* mergeColsRules derives that from $dataFormats; on the public/getcols fallback
* (used when the EDIT/VIEW limits abort the load) the service speaks the SAS
* vocabulary (TYPE C/N, DDTYPE separating DATE/DATETIME/TIME), so the store has
* to map it. These tests pin both the mapping and the empty-payload guard.
*/
describe('SasStoreService', () => {
const buildStore = (cols: any[]) =>
new SasStoreService(
{
request: () => Promise.resolve({ adapterResponse: { cols } })
} as any,
{} as any,
{} as any
)
const collectColumns = (store: SasStoreService) => {
const seen: any[] = []
store.columns.subscribe((value: any) => seen.push(value))
return seen
}
describe('getCols', () => {
it('maps the SAS C/N TYPE onto the picker vocabulary', async () => {
const store = buildStore([
{ NAME: 'CHAR_COL', TYPE: 'C', DDTYPE: 'C' },
{ NAME: 'NUM_COL', TYPE: 'N', DDTYPE: 'N' },
{ NAME: 'DATE_COL', TYPE: 'N', DDTYPE: 'DATE' },
{ NAME: 'DATETIME_COL', TYPE: 'N', DDTYPE: 'DATETIME' },
{ NAME: 'TIME_COL', TYPE: 'N', DDTYPE: 'TIME' }
])
const cols = await store.getCols('DC.MY_TABLE')
expect(cols.map((col: any) => col.TYPE)).toEqual([
'char',
'num',
'num',
'num',
'num'
])
})
it('leaves the rest of the column payload untouched', async () => {
const store = buildStore([
{
NAME: 'CHAR_COL',
TYPE: 'C',
DDTYPE: 'C',
LENGTH: 8,
LABEL: 'A label'
}
])
const cols = await store.getCols('DC.MY_TABLE')
expect(cols[0].NAME).toBe('CHAR_COL')
expect(cols[0].DDTYPE).toBe('C')
expect(cols[0].LENGTH).toBe(8)
expect(cols[0].LABEL).toBe('A label')
})
it('returns an empty list rather than throwing when the payload is empty', async () => {
const store = buildStore([])
const cols = await store.getCols('DC.MY_TABLE')
expect(cols).toEqual([])
})
})
describe('setQueryVariablesFromTable', () => {
it('publishes the table columns without calling the service', async () => {
let called = false
const store = new SasStoreService(
{
request: () => {
called = true
return Promise.resolve({})
}
} as any,
{} as any,
{} as any
)
const seen = collectColumns(store)
await store.setQueryVariablesFromTable('DC.MY_TABLE', [{ NAME: 'A' }])
expect(called).toBe(false)
expect(seen.length).toBe(1)
expect(seen[0].data.cols.length).toBe(1)
})
it('falls back to getcols and publishes the mapped columns', async () => {
const store = buildStore([{ NAME: 'A', TYPE: 'C', DDTYPE: 'C' }])
const seen = collectColumns(store)
await store.setQueryVariablesFromTable('DC.MY_TABLE', [])
expect(seen.length).toBe(1)
expect(seen[0].libds).toBe('DC.MY_TABLE')
expect(seen[0].data.cols[0].TYPE).toBe('char')
})
it('does not publish an empty fallback, which the picker cannot render', async () => {
const store = buildStore([])
const seen = collectColumns(store)
await store.setQueryVariablesFromTable('DC.MY_TABLE', [])
expect(seen.length).toBe(0)
})
})
})
/**
* The clause shown in the filter panel is composed by whereClauseCreator, and
* its temporal rewrite turns the internal day / second count into a SAS
* literal. It may only do that when the composed value really is nothing but
* those numbers - a value typed by hand is not, and rewriting the digit runs
* inside it produced clauses like '13JAN1960'd/'03JAN1960'd/'14MAY1965'd for
* a date typed as 12/02/1960.
*/
describe('SasStoreService - temporal clause preview', () => {
const buildStore = () =>
new SasStoreService({} as any, new HelperService(null as any), {} as any)
const clauseFor = (
value: any,
operator: string,
ddtype: string,
values: any[] = []
) => ({
queryObj: [
{
clauseLogic: '',
elements: [
{
variable: 'SOME_DATE',
operator,
value,
type: 'num',
ddtype,
valueVariable: false,
values
}
]
}
],
groupLogic: ''
})
it('leaves a typed temporal value alone when it is not a number', () => {
const store = buildStore()
const result = store.whereClauseCreator(
clauseFor('12/02/1960', '=', 'DATE'),
'',
'lib.ds'
)
expect(result.whereClause).toContain('12/02/1960')
expect(result.whereClause).not.toContain("'d")
})
it('still shows an internal day count as a date literal', () => {
const store = buildStore()
const result = store.whereClauseCreator(
clauseFor('42', '=', 'DATE'),
'',
'lib.ds'
)
expect(result.whereClause).toContain("'12FEB1960'd")
})
/**
* A BETWEEN pair is composed as `<from> AND <to>`, so the guard that decides
* whether the rewrite may run has to see past the separator - its letters are
* not part of the numbers the value is built from.
*/
it('shows a BETWEEN pair picked from the value list as literals', () => {
const store = buildStore()
const result = store.whereClauseCreator(
clauseFor(['12FEB1960', '13FEB1960'], 'BETWEEN', 'DATE', [
{ formatted: '12FEB1960', unformatted: '42' },
{ formatted: '13FEB1960', unformatted: '43' }
]),
'',
'lib.ds'
)
expect(result.whereClause).toContain(
"BETWEEN '12FEB1960'd AND '13FEB1960'd"
)
})
})
/**
* createFilterQueryTable builds the RAW_VALUE the backend validates and stores.
* The range dropdown binds the formatted label, so a BETWEEN has to map each
* end back to its unformatted value before the literal is built - otherwise
* sasTemporalLiteral returns null and an unquoted date reaches the backend.
*/
describe('SasStoreService - temporal RAW_VALUE', () => {
const buildStore = () =>
new SasStoreService({} as any, new HelperService(null as any), {} as any)
const betweenQuery = (value: any[], values: any[]) => ({
groupLogic: 'AND',
filterGroups: [
{
clauseLogic: 'AND',
filterClauses: [
{
ddtype: 'DATE',
invalidClause: false,
logic: '',
operator: 'BETWEEN',
operators: [],
type: 'num',
value,
valueVariable: false,
values,
variable: 'SOME_DATE'
}
]
}
]
})
it('maps a BETWEEN picked from the value list back to the internal value', () => {
const store = buildStore()
const clauses = store.createFilterQueryTable(
betweenQuery(
['12FEB1960', '13FEB1960'],
[
{ formatted: '12FEB1960', unformatted: 42 },
{ formatted: '13FEB1960', unformatted: 43 }
]
) as any
)
expect(clauses[0].RAW_VALUE).toBe("'12FEB1960'd AND '13FEB1960'd")
})
it('still builds literals when the values are already internal counts', () => {
const store = buildStore()
const clauses = store.createFilterQueryTable(
betweenQuery(['42', '43'], []) as any
)
expect(clauses[0].RAW_VALUE).toBe("'12FEB1960'd AND '13FEB1960'd")
})
const inQuery = (value: any[], values: any[]) => ({
groupLogic: 'AND',
filterGroups: [
{
clauseLogic: 'AND',
filterClauses: [
{
ddtype: 'DATE',
invalidClause: false,
logic: '',
operator: 'IN',
operators: [],
type: 'num',
value,
valueVariable: false,
values,
variable: 'SOME_DATE'
}
]
}
]
})
it('maps an IN entry picked from the value list back to the internal value', () => {
const store = buildStore()
const clauses = store.createFilterQueryTable(
inQuery(
[{ checked: true, val: '12FEB1960' }],
[{ formatted: '12FEB1960', unformatted: 42 }]
) as any
)
expect(clauses[0].RAW_VALUE).toBe("('12FEB1960'd)")
})
it('passes an already-unformatted IN entry through unchanged', () => {
const store = buildStore()
const clauses = store.createFilterQueryTable(
inQuery(
[{ checked: true, val: 42 }],
[{ formatted: '12FEB1960', unformatted: 42 }]
) as any
)
expect(clauses[0].RAW_VALUE).toBe("('12FEB1960'd)")
})
})
+129 -4
View File
@@ -295,6 +295,68 @@ export class SasStoreService {
this.columns.next(columnsData)
}
/**
* Column metadata for the filter picker, read from the service.
*
* The picker's variable list normally comes from the columns that arrived
* with the table (see setQueryVariablesFromTable). This is the fallback for
* when there is no table - public/getcols reads the metadata only.
*
* public/getcols speaks the SAS vocabulary: TYPE is C/N and DDTYPE separates
* DATE, DATETIME and TIME. The picker keys its operator set (query.component),
* its variable highlight and its value quoting (sas-store) on the client
* vocabulary instead - TYPE is exactly 'num' or 'char' - which
* mergeColsRules derives from $dataFormats on the normal path. That pass
* never runs for this fallback, so map TYPE here, with the same rule: the
* date and time types are numeric.
*/
public async getCols(libds: string) {
const tables = { iwant: [{ libds: libds }] }
const res = await this.sasService.request('public/getcols', tables)
const cols = res.adapterResponse.cols || []
return cols.map((col: any) => ({
...col,
TYPE:
['DATE', 'DATETIME', 'TIME'].includes(col.DDTYPE) || col.TYPE === 'N'
? 'num'
: 'char'
}))
}
/**
* Feeds the filter picker its variable list.
*
* `cols` is the column metadata that came back with the table, which costs
* nothing extra and is the normal path. When the table was not returned - the
* EDIT/VIEW row and cell limits abort the request before the data arrives -
* that list is empty, which is what makes "please filter and try again"
* unactionable: the picker has nothing to offer. Fall back to
* public/getcols, which reads the column metadata without the rows.
*/
public async setQueryVariablesFromTable(libds: string, cols: any[]) {
if (cols && cols.length > 0) {
this.setQueryVariables(libds, cols)
return
}
const fallback = await this.getCols(libds)
/*
public/getcols emits an empty cols table when the dataset has no
metadata. Publishing that would push an empty array into the filter
picker, whose subscriber reads cols[0].NAME - the throw is caught, but
the picker is left half-updated (this.cols assigned, the filter.cols
assignment below the throwing line never run). There is nothing to
offer, so leave the picker as it was.
*/
if (!fallback || fallback.length === 0) return
this.setQueryVariables(libds, fallback)
}
public async getChangeInfo(tableId: any) {
let obj = { TABLE: tableId }
let table = { SASControlTable: [obj] }
@@ -534,6 +596,27 @@ export class SasStoreService {
}
oper = this.checkOperator(oper, value, type).operator
/* A temporal value is shown as a SAS literal (eg '20DEC2053'd) rather
than the internal day / second count. Only rewrite when the composed
value is nothing but the numbers the clause is built from - a single
value, a BETWEEN pair or an IN list. The BETWEEN separator is
removed before the test because ' AND ' is not part of that character
set; a typed value that is not a number, such as a date entered by
hand, would otherwise have every digit run inside it rewritten into
an unrelated literal. */
if (
!isValueVariable &&
['DATE', 'DATETIME', 'TIME'].includes(query.ddtype) &&
/^[-0-9.,()\s]+$/.test(String(value).replace(/\s+AND\s+/gi, ' '))
) {
value = String(value).replace(
/-?\d+(?:\.\d+)?/g,
(match) =>
this.helperService.sasTemporalLiteral(match, query.ddtype) ??
match
)
}
if (type === 'char' && oper !== 'IN' && oper !== 'NOT IN') {
if (typeof value === 'undefined') {
value = ''
@@ -600,17 +683,53 @@ export class SasStoreService {
filterQuery.filterGroups.forEach(
(filterGroup: FilterGroup, groupIndex: number) => {
filterGroup.filterClauses.forEach((filterClause: FilterClause) => {
/* A temporal value is sent as a SAS literal (eg '20APR2042'd) rather
than the internal day / second count, so the resolved WHERE clause
- and the FILTER_TEXT shown above the grid - carries a date. */
const temporalValue = (value: any) =>
filterClause.valueVariable
? null
: this.helperService.sasTemporalLiteral(
value,
filterClause.ddtype
)
/* The range dropdown binds the formatted label, as the value list
and the IN modal do, so each end of a BETWEEN is mapped back to
its unformatted value before the literal is built. This is the
same lookup whereClauseCreator applies for the preview - without
it the formatted string reaches sasTemporalLiteral, comes back
null, and RAW_VALUE carries an unquoted date that the backend
rejects on a numeric column. */
const unformattedValue = (value: any) => {
const match = (filterClause.values || []).find(
(entry: any) => entry.formatted === value
)
return match ? match.unformatted : value
}
let rawValue = ''
if (filterClause.operator === 'BETWEEN') {
rawValue = `${filterClause.value[0]} AND ${filterClause.value[1]}`
const from = unformattedValue(filterClause.value[0])
const to = unformattedValue(filterClause.value[1])
rawValue = `${temporalValue(from) ?? from} AND ${
temporalValue(to) ?? to
}`
} else if (
filterClause.operator === 'IN' ||
filterClause.operator === 'NOT IN'
) {
filterClause.value.forEach((element: any) => {
if (element.checked) {
const value = element.val
if (
/* Mapped like the BETWEEN ends - whereClauseCreator normally
rewrites element.val to the unformatted count before submit,
so this is a pass-through for the usual path and a guard for
any path that reaches here without the preview having run. */
const value = unformattedValue(element.val)
const literal = temporalValue(value)
if (literal) {
rawValue += (rawValue.length > 0 ? ',' : '(') + literal
} else if (
typeof value === 'string' &&
(!isSpecialMissing(value) || filterClause.type === 'char')
) {
@@ -638,7 +757,13 @@ export class SasStoreService {
rawValue = '.'
}
} else {
if (filterClause.type === 'char' && !filterClause.valueVariable) {
const literal = temporalValue(filterClause.value)
if (literal) {
rawValue = literal
} else if (
filterClause.type === 'char' &&
!filterClause.valueVariable
) {
rawValue = `'${filterClause.value.replace(/'/g, "''")}'`
}
}
+207
View File
@@ -0,0 +1,207 @@
import { DEBUG_STATE_KEY, SasService } from './sas.service'
/**
* SasService's constructor is a plain 8-argument constructor with an empty
* body, and `request()` touches only a handful of collaborators, so this
* stubs exactly that surface - no TestBed/DI needed, same precedent as
* app.service.spec.ts and va-filter.service.spec.ts.
*
* The SASjs adapter is not built by the constructor either (sasServiceInit
* does that), so it is assigned directly - and its `request` spy is where the
* outgoing body is observable, which is the whole point of these tests.
*/
const buildService = () => {
const sasjsAdapter: any = {
request: jasmine.createSpy('request').and.resolveTo({}),
getSasRequests: () => [],
setDebugState: jasmine.createSpy('setDebugState'),
getSasjsConfig: () => ({
serverUrl: 'https://sas.example.com',
appLoc: '/Public/app/dc',
serverType: 'SASVIYA'
})
}
const loggerService: any = {
logRequestData: jasmine.createSpy('logRequestData')
}
const userService: any = { user: undefined }
const eventService: any = {
showAbortModal: jasmine.createSpy('showAbortModal'),
startupDataLoaded: jasmine.createSpy('startupDataLoaded')
}
const router: any = { navigateByUrl: jasmine.createSpy('navigateByUrl') }
const service = new SasService(
{} as any, // appStoreService
userService,
eventService,
{} as any, // sasjsService
{} as any, // sasViyaService
loggerService,
{} as any, // startupCheckService
router
)
;(service as any).sasjsAdapter = sasjsAdapter
return { service, sasjsAdapter }
}
/** The body the adapter was asked to send for the most recent request. */
const sentBody = (sasjsAdapter: any) =>
sasjsAdapter.request.calls.mostRecent().args[1]
describe('SasService diagnostics payload', () => {
it('gives the startup service a body, so browser_info can ride on it', async () => {
const { service, sasjsAdapter } = buildService()
// Both startup service call sites pass null - there is nothing to send -
// and the service is the one whose log a support ticket is read from.
await service.request('public/startupservice', null)
const body = sentBody(sasjsAdapter)
expect(body).toBeTruthy()
expect(body.browser_info.length).toBe(1)
expect(body.browser_info[0].user_agent).toBe(navigator.userAgent)
expect('timezone' in body.browser_info[0]).toBe(true)
expect('tz_offset' in body.browser_info[0]).toBe(true)
})
it('leaves a non-diagnostics service payload alone', async () => {
const { service, sasjsAdapter } = buildService()
await service.request('public/viewlibs', null)
expect(sentBody(sasjsAdapter)).toBeNull()
})
it('adds browser_info to a body that already carries content', async () => {
const { service, sasjsAdapter } = buildService()
await service.request('editors/getdata', { table: 'MPE_X_TEST' })
const body = sentBody(sasjsAdapter)
expect(body.table).toBe('MPE_X_TEST')
expect(body.browser_info.length).toBe(1)
})
it('does not overwrite a browser_info the caller supplied', async () => {
const { service, sasjsAdapter } = buildService()
const supplied = [{ url: 'supplied by the caller' }]
await service.request('editors/getdata', { browser_info: supplied })
expect(sentBody(sasjsAdapter).browser_info).toBe(supplied)
})
})
/**
* The `<sasjs>` tag is re-read on every load, so the debug toggle has to survive
* a refresh on its own.
*/
describe('SasService debug state', () => {
/** Builds a service whose init can actually run (real adapter, stub deps). */
const initService = (tagDebug = false) => {
const appStoreService: any = {
getDcAdapterSettings: () => ({
serverUrl: '',
appLoc: '/Public/app/dc',
serverType: 'SAS9',
loginMechanism: '',
dcPath: '',
debug: tagDebug,
useComputeApi: null,
runAsTask: true,
contextName: ''
})
}
const service = new SasService(
appStoreService,
{ user: undefined } as any,
{ showInfoModal: jasmine.createSpy('showInfoModal') } as any,
{ setup: jasmine.createSpy('setup') } as any,
{ setup: jasmine.createSpy('setup') } as any,
{ logRequestData: jasmine.createSpy('logRequestData') } as any,
{ updateStep: jasmine.createSpy('updateStep') } as any,
{ navigateByUrl: jasmine.createSpy('navigateByUrl') } as any
)
service.sasServiceInit()
return service
}
beforeEach(() => localStorage.removeItem(DEBUG_STATE_KEY))
afterEach(() => localStorage.removeItem(DEBUG_STATE_KEY))
it('stores the state when the toggle changes', () => {
const { service, sasjsAdapter } = buildService()
service.setDebugState(true)
expect(localStorage.getItem(DEBUG_STATE_KEY)).toBe('true')
expect(sasjsAdapter.setDebugState).toHaveBeenCalledWith(true)
})
it('stores a switch back off, rather than clearing it', () => {
const { service } = buildService()
service.setDebugState(true)
service.setDebugState(false)
expect(localStorage.getItem(DEBUG_STATE_KEY)).toBe('false')
})
it('reinstates the stored state on the next load', () => {
localStorage.setItem(DEBUG_STATE_KEY, 'true')
expect(initService().getSasjsConfig().debug).toBe(true)
})
it('leaves the tag value alone when nothing is stored', () => {
expect(initService(true).getSasjsConfig().debug).toBe(true)
})
it('reinstates an off state over a tag that turns debug on', () => {
localStorage.setItem(DEBUG_STATE_KEY, 'false')
expect(initService(true).getSasjsConfig().debug).toBe(false)
})
})
/**
* The URL shape the deploy configurator already uses for makedata: the service
* is run by the JES / STP web app in a browser tab, so the SAS log comes back
* as the page body instead of through the adapter.
*/
describe('SasService openServiceInNewWindow', () => {
it('opens the service URL built from the live adapter config', () => {
const { service } = buildService()
spyOn(service, 'getExecutionPath').and.returnValue('/SASJobExecution')
const openSpy = spyOn(window, 'open')
service.openServiceInNewWindow('public/startupservice', {
_contextname: 'ctx'
})
expect(openSpy).toHaveBeenCalledWith(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_contextname=ctx&_debug=131',
'_blank',
'noopener'
)
})
it('opens without parameters when none are given', () => {
const { service } = buildService()
spyOn(service, 'getExecutionPath').and.returnValue('/SASJobExecution')
const openSpy = spyOn(window, 'open')
service.openServiceInNewWindow('public/startupservice')
expect(openSpy).toHaveBeenCalledWith(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_debug=131',
'_blank',
'noopener'
)
})
})
+144 -2
View File
@@ -20,6 +20,34 @@ import { RequestWrapperResponse } from '../models/request-wrapper/RequestWrapper
import { SasViyaService } from './sas-viya.service'
import { ViyaApiFolder } from '../viya-api-explorer/models/viya-api-folder.model'
import { ViyaApiFolderMembers } from '../viya-api-explorer/models/viya-api-folder-content.model'
import { parseUserAgent } from '../shared/utils/parse-user-agent'
import { buildServiceUrl } from '../shared/utils/service-url'
import { VERSION } from '../../environments/version'
/**
* Services that receive the `browser_info` / `browser_url_vars` diagnostics
* tables: the startup service (so every session logs its context once) and
* every service that executes customer-provided code - hook scripts via
* %mpe_runhook (getdata, stagedata, loadfile, restore, postdata) and the
* dynamic cell dropdown programs (getdynamiccolvals). Other services never
* see the tables, so the payload stays off the high-frequency calls.
*/
const DIAGNOSTICS_SERVICES = [
'services/public/startupservice',
'services/editors/getdata',
'services/editors/getdynamiccolvals',
'services/editors/stagedata',
'services/editors/loadfile',
'services/editors/restore',
'services/auditors/postdata'
]
/**
* Where the debug toggle state is kept. The `<sasjs>` tag in index.html is
* re-read on every load, so without this a refresh would drop the state the user
* set from the UI.
*/
export const DEBUG_STATE_KEY = 'dc-debug-state'
@Injectable({
providedIn: 'root'
@@ -69,6 +97,13 @@ export class SasService {
this.sasjsAdapter = new SASjs(this.dcAdapterSettings)
/* The tag resets debug on every load, so reinstate the state the user last
chose from the UI. */
const storedDebugState = localStorage.getItem(DEBUG_STATE_KEY)
if (storedDebugState !== null) {
this.sasjsAdapter.setDebugState(storedDebugState === 'true')
}
switch (this.dcAdapterSettings.serverType) {
case ServerType.SasViya: {
this.checkViyaDeploy(this.dcAdapterSettings.appLoc || '')
@@ -118,6 +153,50 @@ export class SasService {
if (!wrapperOptions) wrapperOptions = {}
// Support diagnostics: tell the backend where the request came from.
// Sent only to the services that can act on it - the startup service
// (so every session logs its context once) and the services that
// %include customer-provided code (hook scripts, dynamic cell dropdown
// programs). This is the URL of this page - the Data Controller iframe -
// not the document that embeds it, so an embedded report can be
// distinguished. The browser_url_vars table carries the URL parameters
// as name/value pairs, which is easier for a SAS developer to read than
// parsing the url string.
// The startup service is called with a null payload - there is nothing to
// send - so give it one to carry the diagnostics. It is the service whose
// log a support ticket is read from, and without this it never receives
// them.
if (
DIAGNOSTICS_SERVICES.includes(url) &&
(data === null || data === undefined)
) {
data = {}
}
if (data && typeof data === 'object' && !data.browser_info) {
if (DIAGNOSTICS_SERVICES.includes(url)) {
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
const ua = parseUserAgent(navigator.userAgent)
data.browser_info = [
{
url: window.location.href,
referrer: document.referrer,
timezone: tz || '',
tz_offset: new Date().getTimezoneOffset(),
locale: navigator.language || '',
dc_version: VERSION.semverString,
adapter_version: VERSION.adapterVersion,
browser: ua.browser,
browser_version: ua.browserVersion,
platform: ua.platform,
user_agent: navigator.userAgent || ''
}
]
const urlVars = this.collectBrowserUrlVars()
if (urlVars.length) data.browser_url_vars = urlVars
}
}
// If debug is on it will print what is going inside the adapter
this.loggerService.logRequestData(url, data)
@@ -207,7 +286,10 @@ export class SasService {
adapterResponse: {
error: abortMsg
},
log: sasRequest?.logFile
log: sasRequest?.logFile,
/* the modal above already told the user: a caller that also
reports the failure would stack a second one on top */
errorShown: !wrapperOptions?.suppressSuccessAbortModal
})
}
@@ -250,7 +332,8 @@ export class SasService {
adapterResponse: {
error: errorMessage
},
log: sasRequest?.logFile
log: sasRequest?.logFile,
errorShown: !wrapperOptions?.suppressErrorAbortModal
})
}
@@ -263,6 +346,34 @@ export class SasService {
})
}
/**
* Collects the page URL parameters as name/value pairs for the
* `browser_url_vars` table. Parameters appear both in the search string
* (before the hash) and in the hash query string (Angular routes carry
* them after the `#`), so both are read - search first, and the first
* occurrence of a name wins, so the search string value beats the hash
* value on a collision.
*/
private collectBrowserUrlVars(): Array<{ name: string; value: string }> {
const vars: { name: string; value: string }[] = []
const seen = new Set<string>()
const collect = (search: string) => {
new URLSearchParams(search).forEach((value, name) => {
if (!seen.has(name)) {
seen.add(name)
vars.push({ name, value })
}
})
}
if (window.location.search) collect(window.location.search.slice(1))
const hashQuery = window.location.hash.split('?')[1]
if (hashQuery) collect(hashQuery)
return vars
}
/**
* Uploads a file to the backend, using the adapter upload function.
*
@@ -711,6 +822,7 @@ export class SasService {
}
public setDebugState(state: boolean) {
localStorage.setItem(DEBUG_STATE_KEY, String(state))
this.sasjsAdapter.setDebugState(state)
}
@@ -735,6 +847,36 @@ export class SasService {
return this.sasjsAdapter
}
/**
* Runs a SAS service in a new browser window, bypassing the adapter.
*
* The adapter's request path can hide the backend log when a service fails:
* on Viya a long startup service may be submitted as an execution task and
* time out before it finishes, returning neither webout nor log. A browser
* request to the JES / STP web app runs the same `_program` with no task and
* returns the SAS log (`_debug=131`), so this is the diagnostic path offered
* when a failed request leaves nothing usable to display.
*/
public openServiceInNewWindow(
service: string,
params: { [name: string]: string | number | null | undefined } = {}
) {
const config = this.getSasjsConfig()
const url = buildServiceUrl({
serverUrl: config.serverUrl || '',
appLoc: config.appLoc || '',
executionPath: this.getExecutionPath() || '',
service,
params
})
// noopener: the SAS log page is on a different origin (Viya's serverUrl is
// not the app's), and without it the opened window keeps a handle on
// window.opener and can navigate this tab.
window.open(url, '_blank', 'noopener')
}
public getServerType(): string {
const sasjsConfig = this.sasjsAdapter.getSasjsConfig()
@@ -0,0 +1,93 @@
import {
getSasjsTagDetails,
SASJS_TAG_STEP,
StartupCheckService
} from './startup-check.service'
describe('StartupCheckService', () => {
let service: StartupCheckService
beforeEach(() => {
service = new StartupCheckService()
})
it('includes a SASjs tag step after the startup checks', () => {
const steps = service.steps$.value
expect(steps.length).toBe(SASJS_TAG_STEP + 1)
expect(steps[SASJS_TAG_STEP].label).toBe('SASjs tag')
expect(steps[SASJS_TAG_STEP].status).toBe('pending')
})
it('shows the tag contents against the SASjs tag step', () => {
service.setTagDetails([{ name: 'serverType', value: 'SASVIYA' }])
expect(service.steps$.value[SASJS_TAG_STEP]).toEqual({
label: 'SASjs tag',
status: 'done',
details: [{ name: 'serverType', value: 'SASVIYA' }]
})
})
it('flags a missing tag on the SASjs tag step', () => {
service.updateStep(SASJS_TAG_STEP, 'error', 'SASJS TAG MISSING!!')
expect(service.steps$.value[SASJS_TAG_STEP]).toEqual({
label: 'SASjs tag',
status: 'error',
detail: 'SASJS TAG MISSING!!'
})
})
})
describe('getSasjsTagDetails', () => {
const tagWith = (attributes: Record<string, string>) => {
const element = document.createElement('sasjs')
Object.entries(attributes).forEach(([name, value]) =>
element.setAttribute(name, value)
)
return element
}
it('reads the tag attributes as name/value pairs', () => {
const details = getSasjsTagDetails(
tagWith({ serverType: 'SASVIYA', debug: 'false', useComputeApi: 'true' })
)
expect(details).toEqual([
{ name: 'serverType', value: 'SASVIYA' },
{ name: 'debug', value: 'false' },
{ name: 'useComputeApi', value: 'true' }
])
})
it('keeps attributes the parser does not know about', () => {
expect(getSasjsTagDetails(tagWith({ serverTyp: 'SASJS' }))).toEqual([
{ name: 'servertyp', value: 'SASJS' }
])
})
it('shows every attribute, including the admin group and the licence key', () => {
const details = getSasjsTagDetails(
tagWith({
serverType: 'SASJS',
adminGroup: 'SASAdministrators',
hotLicenceKey: 'non-commercial-and-evaluation'
})
)
expect(details).toEqual([
{ name: 'serverType', value: 'SASJS' },
{ name: 'adminGroup', value: 'SASAdministrators' },
{ name: 'hotLicenceKey', value: 'non-commercial-and-evaluation' }
])
})
it('flags attributes that carry no value', () => {
expect(getSasjsTagDetails(tagWith({ runAsTask: '' }))).toEqual([
{ name: 'runAsTask', value: '(empty)' }
])
})
})
@@ -3,18 +3,64 @@ import { BehaviorSubject } from 'rxjs'
export type StartupStepStatus = 'pending' | 'in_progress' | 'done' | 'error'
/** A name/value pair shown under a startup step. */
export interface StartupStepDetail {
name: string
value: string
}
export interface StartupStep {
label: string
status: StartupStepStatus
detail?: string
/** Rendered as a grid under the label. */
details?: StartupStepDetail[]
}
/**
* Index of the `<sasjs>` tag dump within the startup steps. It is appended
* after the three startup checks so the indices the startup flow already drives
* (sas.service / app.service) are unchanged.
*/
export const SASJS_TAG_STEP = 3
/**
* Canonical spelling of the `<sasjs>` tag attributes. HTML lower-cases attribute
* names in the DOM, so they are mapped back for display.
*/
const TAG_ATTRIBUTE_NAMES: Record<string, string> = {
serverurl: 'serverUrl',
apploc: 'appLoc',
servertype: 'serverType',
loginmechanism: 'loginMechanism',
admingroup: 'adminGroup',
dcpath: 'dcPath',
debug: 'debug',
usecomputeapi: 'useComputeApi',
runastask: 'runAsTask',
contextname: 'contextName',
hotlicencekey: 'hotLicenceKey'
}
/**
* Reads the attributes of the `<sasjs>` tag for display in the startup checks.
* Every attribute is shown - including ones the parser does not know about, so a
* misspelt one is visible and a wrong value is exactly the misconfiguration this
* dump exists to expose.
*/
export const getSasjsTagDetails = (element: Element): StartupStepDetail[] =>
Array.from(element.attributes).map((attribute) => ({
name: TAG_ATTRIBUTE_NAMES[attribute.name.toLowerCase()] || attribute.name,
value: attribute.value || '(empty)'
}))
@Injectable({ providedIn: 'root' })
export class StartupCheckService {
private steps: StartupStep[] = [
{ label: 'Checking app location', status: 'pending' },
{ label: 'Checking Viya deploy', status: 'pending' },
{ label: 'Loading startup service', status: 'pending' }
{ label: 'Loading startup service', status: 'pending' },
{ label: 'SASjs tag', status: 'pending' }
]
public steps$ = new BehaviorSubject<StartupStep[]>([...this.steps])
@@ -30,6 +76,16 @@ export class StartupCheckService {
}
}
/** Shows the `<sasjs>` tag contents on the boot screen. */
public setTagDetails(details: StartupStepDetail[]) {
this.steps[SASJS_TAG_STEP] = {
...this.steps[SASJS_TAG_STEP],
status: 'done',
details
}
this.steps$.next([...this.steps])
}
public setSteps(steps: StartupStep[]) {
this.steps = steps
this.steps$.next([...this.steps])
@@ -1,27 +1,6 @@
import { VaFilterService } from './va-filter.service'
import { VaMessage } from './va-messaging.service'
/**
* Minimal stand-in for HelperService.convertJsDateToSasDate using the real
* epoch math, so date/datetime assertions use the actual SAS internal values
* without pulling in HelperService's dependency graph (SasService etc.).
*/
class HelperServiceStub {
convertJsDateToSasDate(jsDate: Date, unit = 'days'): number {
const ms = Date.UTC(
jsDate.getFullYear(),
jsDate.getMonth(),
jsDate.getDate(),
jsDate.getHours(),
jsDate.getMinutes(),
jsDate.getSeconds()
)
const sasMs = ms + 315619200000
return unit === 'days'
? Math.floor(Math.abs(sasMs / 86400000))
: sasMs / 1000
}
}
import { HelperService } from './helper.service'
function msg(parameters: any[]): VaMessage {
return {
@@ -63,7 +42,7 @@ describe('VaFilterService', () => {
]
beforeEach(() => {
service = new VaFilterService(new HelperServiceStub() as any)
service = new VaFilterService(new HelperService({} as any))
})
const labelToVar = () =>
@@ -109,28 +88,30 @@ describe('VaFilterService', () => {
expect(build([{ label: 'SOME_NUM', value: 'abc' }])).toEqual([])
})
it('converts temporal values to SAS internal numbers', () => {
it('renders temporal values as SAS literals', () => {
expect(
build([{ label: 'SOME_TIME', value: '0:00:02' }])[0].RAW_VALUE
).toBe('2')
).toBe("'00:00:02't")
expect(
build([{ label: 'SOME_DATE', value: '01JUL1960' }])[0].RAW_VALUE
).toBe('182')
).toBe("'01JUL1960'd")
expect(
build([{ label: 'SOME_DATETIME', value: '01JAN1960:00:06:05' }])[0]
.RAW_VALUE
).toBe('365')
).toBe("'01JAN1960:00:06:05'dt")
})
it('passes an already-internal (bare number) temporal value through raw', () => {
it('renders an already-internal (bare number) temporal value as a literal', () => {
// VA sends the raw SAS internal value when the data item has no format.
expect(build([{ label: 'SOME_DATE', value: '182' }])[0].RAW_VALUE).toBe(
'182'
"'01JUL1960'd"
)
expect(
build([{ label: 'SOME_DATETIME', value: '365' }])[0].RAW_VALUE
).toBe('365')
expect(build([{ label: 'SOME_TIME', value: '2' }])[0].RAW_VALUE).toBe('2')
).toBe("'01JAN1960:00:06:05'dt")
expect(build([{ label: 'SOME_TIME', value: '2' }])[0].RAW_VALUE).toBe(
"'00:00:02't"
)
})
it('parses ISO date shapes identically to DATE9 (VA sends no format)', () => {
@@ -232,9 +213,9 @@ describe('VaFilterService', () => {
expect(clauses.map((c) => [c.VARIABLE_NM, c.RAW_VALUE])).toEqual([
['SOME_CHAR', "'x'"],
['SOME_NUM', '10'],
['SOME_TIME', '2'],
['SOME_DATE', '182'],
['SOME_DATETIME', '365']
['SOME_TIME', "'00:00:02't"],
['SOME_DATE', "'01JUL1960'd"],
['SOME_DATETIME', "'01JAN1960:00:06:05'dt"]
])
})
@@ -247,9 +228,9 @@ describe('VaFilterService', () => {
])
)
expect(clauses.map((c) => [c.VARIABLE_NM, c.RAW_VALUE])).toEqual([
['SOME_DATE', '182'],
['SOME_DATE2', '182'],
['SOME_DTTM', '365']
['SOME_DATE', "'01JUL1960'd"],
['SOME_DATE2', "'01JUL1960'd"],
['SOME_DTTM', "'01JAN1960:00:06:05'dt"]
])
})
})
+33 -21
View File
@@ -223,15 +223,18 @@ export class VaFilterService {
/**
* Formats one VA filter value into a DC RAW_VALUE for the column kind, or null
* when invalid (dropped). Matches DC's native filters, which send the NUMERIC
* INTERNAL value (not SAS literals — those error out in the backend):
* - numeric -> finite number, raw (else null — injection guard)
* - time -> seconds since midnight (VA: "0:00:02" -> 2)
* - date -> days since 1960-01-01 (VA: "01JUL1960" -> 182)
* - datetime -> seconds since 1960-01-01 (VA: "01JAN1960:00:06:05" -> 365)
* when invalid (dropped). Matches DC's native filters, which send a SAS
* literal for a temporal column and the raw value otherwise:
* - numeric -> finite number, raw (else null - injection guard)
* - time -> seconds since midnight, as a SAS time literal
* (VA: "0:00:02" -> '00:00:02't)
* - date -> days since 1960-01-01, as a SAS date literal
* (VA: "01JUL1960" -> '01JUL1960'd)
* - datetime -> seconds since 1960-01-01, as a SAS datetime literal
* (VA: "01JAN1960:00:06:05" -> '01JAN1960:00:06:05'dt)
* - char -> single-quote escaped
* Temporal strings are regex-parsed (digits/letters/colons only), so a value
* either yields a finite number or is dropped — also the injection guard.
* either yields a finite number or is dropped - also the injection guard.
* Date/datetime reuse HelperService.convertJsDateToSasDate so the value is
* byte-identical to what DC's own pickers produce.
*
@@ -239,7 +242,7 @@ export class VaFilterService {
* itself (VA sends it unformatted when the data item carries no format / is
* used as a measure), so it is passed through raw. This is unambiguous because
* the only date formats in use (DATE9, ISO) always contain a letter or a
* separator — a plain integer is never a formatted date.
* separator - a plain integer is never a formatted date.
*/
private formatValueByKind(
value: any,
@@ -254,23 +257,32 @@ export class VaFilterService {
return Number.isFinite(num) ? `${num}` : null
}
case 'time': {
if (this.isBareNumber(s)) return `${Number(s)}`
const secs = this.timeToSeconds(s)
return secs === null ? null : `${secs}`
const secs = this.isBareNumber(s) ? Number(s) : this.timeToSeconds(s)
return secs === null
? null
: this.helperService.sasTemporalLiteral(secs, 'TIME')
}
case 'date': {
if (this.isBareNumber(s)) return `${Number(s)}`
const d = this.parseDate(s, order)
return d
? `${this.helperService.convertJsDateToSasDate(d, 'days')}`
: null
let days: number | null = null
if (this.isBareNumber(s)) days = Number(s)
else {
const d = this.parseDate(s, order)
if (d) days = this.helperService.convertJsDateToSasDate(d, 'days')
}
return days === null
? null
: this.helperService.sasTemporalLiteral(days, 'DATE')
}
case 'datetime': {
if (this.isBareNumber(s)) return `${Number(s)}`
const d = this.parseDatetime(s, order)
return d
? `${this.helperService.convertJsDateToSasDate(d, 'seconds')}`
: null
let secs: number | null = null
if (this.isBareNumber(s)) secs = Number(s)
else {
const d = this.parseDatetime(s, order)
if (d) secs = this.helperService.convertJsDateToSasDate(d, 'seconds')
}
return secs === null
? null
: this.helperService.sasTemporalLiteral(secs, 'DATETIME')
}
default:
return `'${s.replace(/'/g, "''")}'`
@@ -138,13 +138,38 @@ export class VaMessagingService {
this.earlyDrained = true
const captured = (window as unknown as { __vaLastMessage?: any })
.__vaLastMessage
const parsed = this.parseData(captured && captured.data)
// The early listener (va-early.js) captures from any origin, so re-apply
// the live-path trust rule here before acting on it: only replay a message
// that came from our own origin or from the frame that embedded us (whose
// URL is document.referrer). Without this, a same-origin sibling frame
// could inject a crafted DDC message that the live isTrustedSource check
// would have rejected.
if (!captured || typeof captured.origin !== 'string') return
if (!this.isTrustedEarlyOrigin(captured.origin)) return
const parsed = this.parseData(captured.data)
if (!parsed) return
this.resultName = parsed.resultName
if (captured.origin) this.parentOrigin = captured.origin
this.parentOrigin = captured.origin
callback(parsed)
}
/**
* Origin check for the pre-bootstrap replay. Mirrors isTrustedSource: the
* live path trusts a message whose event.source IS the parent frame; for a
* captured message we cannot reference its source Window, so we trust an
* origin that is this window's origin or the embedding frame's origin
* (document.referrer). Unverifiable/absent referrer -> reject.
*/
private isTrustedEarlyOrigin(origin: string): boolean {
if (origin === window.location.origin) return true
if (!document.referrer) return false
try {
return new URL(document.referrer).origin === origin
} catch {
return false
}
}
/**
* Parses a raw window MessageEvent into a VaMessage, or null when it is not a
* recognisable DDC message (e.g. unrelated postMessage traffic).
@@ -28,6 +28,16 @@
}
</div>
<div class="modal-footer">
@if (showServiceLauncher(data.sasService)) {
<button
type="button"
class="btn btn-primary"
(click)="openServiceInNewWindow()"
>
Show log
</button>
}
@if (showConfiguratorButton(data.sasService)) {
<button
type="button"
@@ -0,0 +1,71 @@
import { InfoModalComponent } from './info-modal.component'
describe('InfoModalComponent', () => {
let component: InfoModalComponent
let sasService: any
const buildComponent = (sasServiceConfig: any = {}) => {
sasService = {
getSasjsConfig: () => sasServiceConfig,
openServiceInNewWindow: jasmine.createSpy('openServiceInNewWindow')
}
component = new InfoModalComponent(
{} as any,
{} as any,
sasService,
{} as any
)
component.data = {
modalTitle: 'Error',
message: 'startupservice failed',
sasService: 'public/startupservice',
details: null
}
component.ngOnInit()
}
describe('showServiceLauncher', () => {
beforeEach(() => buildComponent())
it('is shown for the startupservice, on every server type', () => {
expect(component.showServiceLauncher('public/startupservice')).toBeTrue()
expect(
component.showServiceLauncher('services/public/startupservice')
).toBeTrue()
})
it('is not shown for other services or a missing service', () => {
expect(component.showServiceLauncher('public/getdata')).toBeFalse()
expect(component.showServiceLauncher('')).toBeFalse()
expect(component.showServiceLauncher(null)).toBeFalse()
})
})
describe('openServiceInNewWindow', () => {
it('runs the startupservice in a new window', () => {
buildComponent({ serverType: 'SASVIYA' })
component.openServiceInNewWindow()
expect(sasService.openServiceInNewWindow).toHaveBeenCalledWith(
'public/startupservice',
{}
)
})
it('passes the configured Viya context so the log comes from it', () => {
buildComponent({
serverType: 'SASVIYA',
contextName: 'SAS Job Execution compute context'
})
component.openServiceInNewWindow()
expect(sasService.openServiceInNewWindow).toHaveBeenCalledWith(
'public/startupservice',
{ _contextname: 'SAS Job Execution compute context' }
)
})
})
})
@@ -71,6 +71,34 @@ export class InfoModalComponent implements OnInit {
this.onConfirmModalClick.emit()
}
/**
* Whether to show the `Show log` button.
*
* The startupservice failure modal is a dead end otherwise: the adapter
* returned no log, so the only way to see the backend reason is to run the
* service through the JES / STP web app in a browser tab. Offered on every
* server type - SAS 9, Viya and SASjs Server all accept the `_program` URL.
*/
showServiceLauncher(sasService: string | null) {
return !!sasService?.includes('startupservice')
}
/**
* Runs the startupservice in a new browser window so the SAS log is
* available even when the adapter response carried none (e.g. a Viya
* execution task that timed out).
*/
openServiceInNewWindow() {
const sasjsConfig = this.sasService.getSasjsConfig()
const params: { [name: string]: string } = {}
if (sasjsConfig.contextName) {
params['_contextname'] = sasjsConfig.contextName
}
this.sasService.openServiceInNewWindow(this.data.sasService || '', params)
}
/**
* Only on SAS9, opening a backend configurator/deploy page
*/
@@ -61,13 +61,13 @@ export class DcValidator {
// injected separately — see its own doc comment for why.
//
// COLHEADERS is the authoritative grid order and the only safe key to
// build against: it is the variable list of the *output* dataset, where
// getdata.sas hoists the delete column and the PK to the front ("order
// delete var and pk fields at start of table"), whereas cols[].VARNUM
// describes the *source* table and cols[] itself can arrive sorted by
// NAME. Those orders diverge whenever the PK isn't already the source's
// first column, so rules are keyed by name and emitted in COLHEADERS
// order — never paired positionally against cols[] or VARNUM.
// build against: it is the variable list of the *output* dataset, and the
// editor prepends the client-owned delete column to it (see
// editor.component.ts's initSetup) before this constructor runs, whereas
// cols[].VARNUM describes the *source* table and cols[] itself can arrive
// sorted by NAME. Those orders diverge whenever the PK isn't already the
// source's first column, so rules are keyed by name and emitted in
// COLHEADERS order — never paired positionally against cols[] or VARNUM.
//
// A column with no parseable COLTYPE falls back to a plain text rule
// rather than being dropped: getRules() is consumed positionally against
@@ -92,14 +92,49 @@ export class DcValidator {
this.rules.push({ ...EDIT_STATUS_COLUMN_RULE })
this.hiddenColumns.push(this.rules.length - 1)
this.dqrules = dqRules
this.dqrules = [...dqRules]
this.dqdata = dqData
this.primaryKeys = sasparams.PK.split(' ')
// A primary key is NOT NULL by definition, so it must reject a blank and
// a special missing (".A"-".Z", "._") even when the target table carries
// no physical NOT NULL constraint and MPE_VALIDATIONS has no NOTNULL rule
// for it. Synthesised here so every keyed table gets it, and so the grid,
// the edit-record modal and Excel upload validation all see the same rule.
this.addPrimaryKeyNotNullRules()
this.updateDqData()
this.setupValidations()
}
/**
* Adds a NOTNULL rule for each primary key column that does not already
* have one. A primary key identifies the row, so a blank or a special
* missing there is never valid.
*/
private addPrimaryKeyNotNullRules(): void {
for (const pk of this.primaryKeys) {
if (!pk) continue
// A buskey can name a column the table no longer has - do not
// synthesise a rule for a column that is not in the grid.
if (!this.rules.some((rule) => rule.data === pk)) continue
const hasNotNull = this.dqrules.some(
(rule) => rule.BASE_COL === pk && rule.RULE_TYPE === 'NOTNULL'
)
if (!hasNotNull) {
this.dqrules.push({
BASE_COL: pk,
RULE_TYPE: 'NOTNULL',
RULE_VALUE: '',
X: 1
})
}
}
}
registerCustomEditors() {
Handsontable.editors.registerEditor(
'autocomplete.custom',
@@ -283,7 +318,14 @@ export class DcValidator {
* So we will convert it before pushing to array.
*/
if (rule.type && rule.type === 'numeric') {
details.push(Number(data['RULE_DATA']))
// A special missing reaches us as a bare letter ("A", "_"), and
// the regular missing as "." - Number() would turn either into
// NaN, so a strict (HARDSELECT) dropdown could never accept a
// value the column actually holds. Keep them as they are.
const rawValue = data['RULE_DATA']
details.push(
isSpecialMissing(rawValue) ? rawValue : Number(rawValue)
)
} else {
details.push(data['RULE_DATA'])
}
@@ -118,7 +118,12 @@ describe('DC Validator', () => {
expect(dcValidator.getRule('SOME_TIME')).toBeUndefined()
// Test data quality functions
expect(dcValidator.getDqDetails()).toHaveSize(dqRules.length)
// dqRules + 2 synthesised rules: the SOFTSELECT rule updateDqData()
// derives for SOME_DROPDOWN out of dqdata, and the NOTNULL rule
// addPrimaryKeyNotNullRules() gives the primary key column (example_dqRules
// has none for it). Note the constructor copies dqRules rather than
// aliasing it, so this array is no longer mutated by construction.
expect(dcValidator.getDqDetails()).toHaveSize(dqRules.length + 2)
expect(dcValidator.getDqDetails('non_existant')).toHaveSize(0)
expect(dcValidator.getDqDetails('SOME_NUM')).toHaveSize(2)
expect(dcValidator.isDqCol('SOME_NUM')).toBeTrue()
@@ -133,6 +138,91 @@ describe('DC Validator', () => {
])
})
it('treats the primary key column as NOT NULL, even with no NOTNULL rule configured', () => {
const sasparams: SASParam = example_sasparams
const cols: Col[] = example_cols
const dqRules: DQRule[] = example_dqRules // no NOTNULL for PRIMARY_KEY_FIELD
const dqData: DQData[] = example_dqData
const $dataFormats: $DataFormats = example_dataformats
const dcValidator: DcValidator = new DcValidator(
sasparams,
$dataFormats,
cols,
dqRules,
dqData
)
const pkRules = dcValidator.getDqDetails('PRIMARY_KEY_FIELD')
expect(pkRules.some((rule) => rule.RULE_TYPE === 'NOTNULL')).toBeTrue()
const pkRule = dcValidator.getRule('PRIMARY_KEY_FIELD')
// A primary key identifies the row, so neither a blank nor a special
// missing can satisfy it.
dcValidator.executeHotValidator(pkRule!, null, (valid: boolean) => {
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(pkRule!, 'A', (valid: boolean) => {
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(pkRule!, 5, (valid: boolean) => {
expect(valid).toBeTrue()
})
})
it('keeps a special missing in a numeric dropdown source, so a strict rule can match it', () => {
const dqData: DQData[] = [
{
BASE_COL: 'SOME_NUM',
RULE_VALUE: 'SOME_NUM',
RULE_DATA: 1,
SELECTBOX_ORDER: 1
},
{
BASE_COL: 'SOME_NUM',
RULE_VALUE: 'SOME_NUM',
RULE_DATA: 'A',
SELECTBOX_ORDER: 2
},
{
BASE_COL: 'SOME_NUM',
RULE_VALUE: 'SOME_NUM',
RULE_DATA: '_',
SELECTBOX_ORDER: 3
},
{
BASE_COL: 'SOME_NUM',
RULE_VALUE: 'SOME_NUM',
RULE_DATA: '.',
SELECTBOX_ORDER: 4
}
] as DQData[]
const dcValidator: DcValidator = new DcValidator(
example_sasparams,
example_dataformats,
example_cols,
example_dqRules,
dqData
)
// SOME_NUM is numeric and carries a HARDSELECT_HOOK, so its dropdown
// source comes from dqdata. Number() would have NaN'd the special
// missings, leaving the strict membership test unable to match a value
// the column actually holds.
const source = dcValidator.getDqDropdownSource(
dcValidator.getRule('SOME_NUM')!
)
expect(source[0]).toEqual(1)
expect(source[1]).toEqual('A')
expect(source[2]).toEqual('_')
// the regular missing is a dropdown option too, not a NaN
expect(source[3]).toEqual('.')
expect(source.some((value) => Number.isNaN(value as number))).toBeFalse()
})
it('should test hot validator', () => {
const sasparams: SASParam = example_sasparams
const cols: Col[] = example_cols
@@ -163,21 +253,22 @@ describe('DC Validator', () => {
dcValidator.executeHotValidator(someNumRule!, 'ss', (valid: boolean) => {
expect(valid).toBeFalse()
})
//Special missings
// Special missings - a SAS NOT NULL (or primary key) constraint rejects
// these, so the rule must reject them too: they are NULL, not values.
dcValidator.executeHotValidator(someNumRule!, 's', (valid: boolean) => {
expect(valid).toBeTrue()
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(someNumRule!, '.s', (valid: boolean) => {
expect(valid).toBeTrue()
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(someNumRule!, '.', (valid: boolean) => {
expect(valid).toBeTrue()
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(someNumRule!, '..', (valid: boolean) => {
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(someNumRule!, '._', (valid: boolean) => {
expect(valid).toBeTrue()
expect(valid).toBeFalse()
})
// MINVAL, MAXVAL Validation
@@ -193,7 +284,7 @@ describe('DC Validator', () => {
expect(valid).toBeFalse()
})
dcValidator.executeHotValidator(shortNumRule!, 's', (valid: boolean) => {
expect(valid).toBeFalse() // Special missings are lowest numbers, if any MINVAL is set, special missing is always lower
expect(valid).toBeFalse() // Special missings are the lowest numbers, so any MINVAL is above them
})
// CASE validation
@@ -462,11 +553,27 @@ describe('DC Validator', () => {
example_dqData
)
// HOT 18.1 tightened `ColumnSettings['validator']` to the real
// `string | RegExp | function` union (18.0 erased it behind an index
// signature), so narrow it the way the production code does before
// invoking it.
const validatorOf = (rule: ReturnType<DcValidator['getRule']>) => {
const validator = rule?.validator
if (typeof validator !== 'function') {
throw new Error('expected the rule to carry a function validator')
}
return validator as (
this: any,
value: any,
callback: (valid: boolean) => void
) => void
}
it('exempts an invalid non-PK cell on a delete-marked row', () => {
const dcValidator = buildValidator()
const someNumRule = dcValidator.getRule('SOME_NUM')
someNumRule!.validator!.call(
validatorOf(someNumRule).call(
fakeCellProps(true),
'not a number',
(valid: boolean) => {
@@ -479,7 +586,7 @@ describe('DC Validator', () => {
const dcValidator = buildValidator()
const someNumRule = dcValidator.getRule('SOME_NUM')
someNumRule!.validator!.call(
validatorOf(someNumRule).call(
fakeCellProps(true),
null,
(valid: boolean) => {
@@ -492,7 +599,7 @@ describe('DC Validator', () => {
const dcValidator = buildValidator()
const someNumRule = dcValidator.getRule('SOME_NUM')
someNumRule!.validator!.call(
validatorOf(someNumRule).call(
fakeCellProps(false),
'not a number',
(valid: boolean) => {
@@ -505,7 +612,7 @@ describe('DC Validator', () => {
const dcValidator = buildValidator()
const someNumRule = dcValidator.getRule('SOME_NUM')
someNumRule!.validator!.call(
validatorOf(someNumRule).call(
fakeCellProps(false),
2,
(valid: boolean) => {
@@ -518,7 +625,7 @@ describe('DC Validator', () => {
const dcValidator = buildValidator()
const pkRule = dcValidator.getRule('PRIMARY_KEY_FIELD')
pkRule!.validator!.call(
validatorOf(pkRule).call(
fakeCellProps(true),
'not a number',
(valid: boolean) => {
@@ -24,7 +24,44 @@ describe('DC Validator - dq validation', () => {
expect(dqValidate(dqRules, invalidValue)).toBeFalse()
expect(dqValidate(dqRules, invalidStringValue)).toBeFalse()
expect(dqValidate(dqRules, numericStringValue)).toBeTrue()
// A missing sorts below every number, so it is below the floor.
expect(dqValidate(dqRules, numericSpecialMissingValue)).toBeFalse()
expect(dqValidate(dqRules, null)).toBeFalse()
expect(dqValidate(dqRules, undefined)).toBeFalse()
})
it('should order the missing values in a range rule as SAS does', () => {
const missingRange: DQRule[] = [
{ BASE_COL: 'test', RULE_TYPE: 'MINVAL', RULE_VALUE: '.A', X: 0 },
{ BASE_COL: 'test', RULE_TYPE: 'MAXVAL', RULE_VALUE: '.C', X: 0 }
]
// Inside the range of missings
expect(dqValidate(missingRange, '.A')).toBeTrue()
expect(dqValidate(missingRange, '.B')).toBeTrue()
expect(dqValidate(missingRange, '.C')).toBeTrue()
expect(dqValidate(missingRange, 'b')).toBeTrue()
// Outside it - above the ceiling
expect(dqValidate(missingRange, '.D')).toBeFalse()
expect(dqValidate(missingRange, 'z')).toBeFalse()
// Outside it - below the floor. The regular missing sits between ._ and .A
expect(dqValidate(missingRange, '._')).toBeFalse()
expect(dqValidate(missingRange, null)).toBeFalse()
// Every number sorts above every missing, so it is above the ceiling
expect(dqValidate(missingRange, 0)).toBeFalse()
expect(dqValidate(missingRange, 5)).toBeFalse()
// A floor of .A alone still lets the numbers through: they are above it
const missingFloor: DQRule[] = [
{ BASE_COL: 'test', RULE_TYPE: 'MINVAL', RULE_VALUE: '.A', X: 0 }
]
expect(dqValidate(missingFloor, '.A')).toBeTrue()
expect(dqValidate(missingFloor, '.Z')).toBeTrue()
expect(dqValidate(missingFloor, 5)).toBeTrue()
expect(dqValidate(missingFloor, '._')).toBeFalse()
})
it('should validate MAXVAL value', () => {
@@ -49,7 +86,10 @@ describe('DC Validator - dq validation', () => {
expect(dqValidate(dqRules, invalidValue)).toBeFalse()
expect(dqValidate(dqRules, invalidStringValue)).toBeFalse()
expect(dqValidate(dqRules, numericStringValue)).toBeTrue()
// A missing sorts below every number, so it is below the ceiling
expect(dqValidate(dqRules, numericSpecialMissingValue)).toBeTrue()
expect(dqValidate(dqRules, null)).toBeTrue()
expect(dqValidate(dqRules, undefined)).toBeTrue()
})
it('should validate UPCASE value', () => {
@@ -111,6 +151,43 @@ describe('DC Validator - dq validation', () => {
expect(dqValidate(dqRules, invalidValue2)).toBeFalse()
})
it('should reject a special missing on a numeric column (a SAS NOT NULL constraint does)', () => {
const dqRules: DQRule[] = [
{
BASE_COL: 'test',
RULE_TYPE: 'NOTNULL',
RULE_VALUE: ' ',
X: 0
}
]
// The values a real SAS service delivers for a numeric column.
expect(dqValidate(dqRules, 'A', true)).toBeFalse()
expect(dqValidate(dqRules, '_', true)).toBeFalse()
expect(dqValidate(dqRules, '.', true)).toBeFalse()
// Ordinary numbers and numeric strings still pass.
expect(dqValidate(dqRules, 5, true)).toBeTrue()
expect(dqValidate(dqRules, '5', true)).toBeTrue()
})
it('should not reject a single letter on a character column', () => {
const dqRules: DQRule[] = [
{
BASE_COL: 'test',
RULE_TYPE: 'NOTNULL',
RULE_VALUE: ' ',
X: 0
}
]
// There is no special-missing concept on a character column - a lone
// letter is ordinary data.
expect(dqValidate(dqRules, 'A')).toBeTrue()
expect(dqValidate(dqRules, '_')).toBeTrue()
expect(dqValidate(dqRules, '.')).toBeTrue()
expect(dqValidate(dqRules, '', false)).toBeFalse()
})
it('should return true if rule not found', () => {
const validValue = 5
@@ -0,0 +1,75 @@
import {
prepareDeleteRecordColumn,
seedDeleteRecordColumn
} from './deleteRecordColumn'
import { DELETE_RECORD_COLUMN_NAME } from './deleteRecordColumnRule'
const response = (overrides: any = {}) => ({
data: {
sasparams: [{ COLHEADERS: 'PRIMARY_KEY_FIELD,SOME_CHAR' }],
cols: [],
$sasdata: { vars: {} },
...overrides
}
})
describe('prepareDeleteRecordColumn', () => {
it('prepends the delete column to COLHEADERS', () => {
const res = response()
prepareDeleteRecordColumn(res)
expect(res.data.sasparams[0].COLHEADERS).toEqual(
`${DELETE_RECORD_COLUMN_NAME},PRIMARY_KEY_FIELD,SOME_CHAR`
)
})
it('throws when COLHEADERS already carries the delete column', () => {
const res = response({
sasparams: [{ COLHEADERS: `${DELETE_RECORD_COLUMN_NAME},SOME_CHAR` }]
})
expect(() => prepareDeleteRecordColumn(res)).toThrowError(/reserved column/)
})
it('throws when cols carries the delete column', () => {
const res = response({ cols: [{ NAME: DELETE_RECORD_COLUMN_NAME }] })
expect(() => prepareDeleteRecordColumn(res)).toThrowError(/reserved column/)
})
it('throws when $sasdata vars carries the delete column', () => {
const res = response({
$sasdata: { vars: { [DELETE_RECORD_COLUMN_NAME]: {} } }
})
expect(() => prepareDeleteRecordColumn(res)).toThrowError(/reserved column/)
})
it('leaves COLHEADERS untouched when it throws', () => {
const colHeaders = `${DELETE_RECORD_COLUMN_NAME},SOME_CHAR`
const res = response({ sasparams: [{ COLHEADERS: colHeaders }] })
expect(() => prepareDeleteRecordColumn(res)).toThrowError()
expect(res.data.sasparams[0].COLHEADERS).toEqual(colHeaders)
})
})
describe('seedDeleteRecordColumn', () => {
it("sets every row's delete flag to 'No'", () => {
const rows: any[] = [{ PRIMARY_KEY_FIELD: 1 }, { PRIMARY_KEY_FIELD: 2 }]
seedDeleteRecordColumn(rows)
expect(rows[0][DELETE_RECORD_COLUMN_NAME]).toEqual('No')
expect(rows[1][DELETE_RECORD_COLUMN_NAME]).toEqual('No')
})
it('overwrites a flag a row already carried', () => {
const rows: any[] = [{ [DELETE_RECORD_COLUMN_NAME]: 'Yes' }]
seedDeleteRecordColumn(rows)
expect(rows[0][DELETE_RECORD_COLUMN_NAME]).toEqual('No')
})
})
@@ -0,0 +1,64 @@
import { Col } from '../models/col.model'
import { DELETE_RECORD_COLUMN_NAME } from './deleteRecordColumnRule'
/**
* The parts of a getdata response this module touches. Declared structurally
* so the editor and the multi-dataset loader can both use it without either
* owning the other's response type.
*/
interface DeleteColumnResponse {
data: {
sasparams: { COLHEADERS: string }[]
cols?: Col[]
$sasdata?: { vars?: Record<string, unknown> }
}
}
/**
* Asserts that getdata did NOT send the client-owned delete column, then
* prepends it to COLHEADERS so the grid's first column is the delete flag.
*
* `_____DELETE__THIS__RECORD_____` is created by the editor itself (see
* deleteRecordColumnRule.ts) and getdata must never emit it. Its presence in a
* response can only mean a real table column of that name, or a hook that
* re-added it - either way it would shadow the delete flag, so refuse the load
* rather than render a table whose delete column cannot be trusted. Callers
* run this inside a promise chain whose `.catch` surfaces the error (the
* editor sets `getdataError`).
*
* Call it BEFORE constructing a DcValidator or deriving headerArray: rules,
* `columnHeader` and `headerArray` are all keyed off COLHEADERS order, and the
* delete column is always index 0.
*/
export const prepareDeleteRecordColumn = (response: DeleteColumnResponse) => {
const sasparams = response.data.sasparams[0]
const sentByBackend =
sasparams.COLHEADERS.split(',').includes(DELETE_RECORD_COLUMN_NAME) ||
(response.data.cols || []).some(
(col) => col.NAME === DELETE_RECORD_COLUMN_NAME
) ||
Object.prototype.hasOwnProperty.call(
response.data.$sasdata?.vars || {},
DELETE_RECORD_COLUMN_NAME
)
if (sentByBackend) {
throw new Error(
`getdata returned the reserved column ${DELETE_RECORD_COLUMN_NAME}. ` +
'That name is created by the editor itself and must not exist in the target table.'
)
}
sasparams.COLHEADERS = `${DELETE_RECORD_COLUMN_NAME},${sasparams.COLHEADERS}`
}
/**
* Seeds every row's delete flag to 'No' - getdata no longer sends the column,
* so the editor owns the value too (see deleteRecordColumnRule.ts).
*/
export const seedDeleteRecordColumn = (rows: any[]) => {
for (const row of rows) {
row[DELETE_RECORD_COLUMN_NAME] = 'No'
}
}
@@ -1,16 +1,21 @@
import { DcValidation } from '../models/dc-validation.model'
/**
* `_____DELETE__THIS__RECORD_____` is a client-side UI concept (the delete
* checkbox column) that getdata.sas synthesizes into vars3/vars4 for display
* purposes only — it's never a real column of the underlying dataset, so
* `%mp_getcols` (which builds `cols1`, the left side of the join into
* `cols`) never has a row for it, and its rule can no longer travel via
* `cols[].COLTYPE` (see issue #253's vertical-array fix). The rule is fixed
* and data-independent, so it's injected directly here instead.
* `_____DELETE__THIS__RECORD_____` is a purely client-owned column - the
* delete checkbox column. getdata.sas does NOT emit it: the editor adds the
* name to COLHEADERS itself (see editor.component.ts's initSetup) and seeds
* every row to 'No'. A response that carries it is refused, because the name
* can then only come from a real table column of that name (or a hook that
* re-added it), which would silently shadow the delete flag.
*
* Its rule can never travel via `cols[].COLTYPE` - `%mp_getcols` (which
* builds `cols1`, the left side of the join into `cols`) has no row for it -
* so it is injected directly, here and in DcValidator's constructor.
*/
export const DELETE_RECORD_COLUMN_NAME = '_____DELETE__THIS__RECORD_____'
export const DELETE_RECORD_COLUMN_RULE: DcValidation = {
data: '_____DELETE__THIS__RECORD_____',
data: DELETE_RECORD_COLUMN_NAME,
type: 'dropdown',
source: ['No', 'Yes']
}
@@ -1,8 +1,49 @@
import { DQRule } from '../models/dq-rules.model'
import { specialMissingNumericValidator } from './hot-custom-validators'
import { isSpecialMissing } from '@sasjs/utils/input/validators'
import { isRegexRuleExempt } from '../utils/isRegexRuleExempt'
import { parseRegexRule } from '../utils/parseRegexRule'
/**
* A SAS numeric variable's values have a total order, and its missing values sit
* below every non-missing value. The missing values are themselves ordered:
* `._` is the lowest, then the regular missing, then `.A` through `.Z`.
*
* A range rule compares in that order. That is what makes a range of missings
* meaningful - with `MINVAL .A` and `MAXVAL .C`, `.B` is inside the range and `.D`
* is outside it - and it is also why a special missing fails a numeric floor: it
* sorts below every number.
*
* The key is a pair: the class (0 for a missing, 1 for a number, so that every
* number sorts above every missing) and the position within that class. A value
* that is neither a number nor a missing has no place in the order and gets null,
* which no rule accepts.
*/
const sasNumericOrderKey = (value: any): [number, number] | null => {
if (value === undefined || value === null || value === '') return [0, 1] // regular missing
if (typeof value === 'string') {
const upper = value.trim().toUpperCase()
if (upper === '.' || upper === '') return [0, 1] // regular missing
if (upper === '._' || upper === '_') return [0, 0] // the lowest missing
if (/^\.?[A-Z]$/.test(upper))
return [0, 2 + (upper.charCodeAt(upper.length - 1) - 65)] // .A .. .Z
const numValue = parseFloat(upper)
return isNaN(numValue) ? null : [1, numValue]
}
const numValue = Number(value)
return isNaN(numValue) ? null : [1, numValue]
}
const compareSasNumericOrder = (
a: [number, number],
b: [number, number]
): number => (a[0] !== b[0] ? a[0] - b[0] : a[1] - b[1])
const dqValidation: {
[key: string]: (
value: any,
@@ -33,25 +74,39 @@ const dqValidation: {
return true
},
MINVAL: (value: any, ruleValue: string | number): boolean => {
const isValidNumeric = specialMissingNumericValidator(value)
const numValue = parseFloat(value)
const valueKey = sasNumericOrderKey(value)
const ruleKey = sasNumericOrderKey(ruleValue)
// If it's validNumeric and it is NaN it means it is special numeric, and those are always less then any
// min value set
if (isValidNumeric && isNaN(numValue)) return false
// A value that is neither a number nor a missing has no place in the order,
// so nothing satisfies the rule.
if (!valueKey || !ruleKey) return false
return numValue >= Number(ruleValue.toString())
return compareSasNumericOrder(valueKey, ruleKey) >= 0
},
MAXVAL: (value: any, ruleValue: string | number): boolean => {
const isValidNumeric = specialMissingNumericValidator(value)
const numValue = parseFloat(value)
const valueKey = sasNumericOrderKey(value)
const ruleKey = sasNumericOrderKey(ruleValue)
if (isValidNumeric && isNaN(numValue)) return true
if (!valueKey || !ruleKey) return false
return numValue <= Number(ruleValue.toString())
return compareSasNumericOrder(valueKey, ruleKey) <= 0
},
NOTNULL: (value: any, ruleValue: string | number): boolean => {
return value !== undefined && value !== null && value.toString().length > 0
NOTNULL: (
value: any,
ruleValue: string | number,
isNumeric: boolean = false
): boolean => {
if (value === undefined || value === null) return false
// A special missing (.A-.Z, ._) is NULL as far as a SAS NOT NULL (or
// primary key) constraint is concerned - an insert carrying one is
// rejected with an integrity constraint error - so the rule must reject
// it too, or the editor would accept a value the target table refuses.
// Numeric columns only: a lone letter is ordinary data on a character
// column.
if (isNumeric && isSpecialMissing(value)) return false
return value.toString().length > 0
},
// Pattern is used as authored, not auto-anchored — a rule author who
// wants a full-value match must write ^...$ themselves.
@@ -0,0 +1,34 @@
import { SidebarComponent } from './sidebar.component'
describe('SidebarComponent', () => {
// getSubPage is a pure read of the router's current URL, and the only other
// dependencies are the two SasService calls in the constructor - so the
// class can be constructed directly, without a TestBed.
const buildComponent = (routerUrl: string) =>
new SidebarComponent(
{ url: routerUrl } as any,
{} as any,
{
getSasjsConfig: () => ({}),
getServerType: () => 'SASVIYA'
} as any
)
describe('getSubPage', () => {
it('returns the sub-page segment of a plain route', () => {
expect(buildComponent('/home/tables').getSubPage()).toEqual('tables')
})
it('excludes the query string - a VA report embed always adds one', () => {
expect(buildComponent('/home/tables?embed=va').getSubPage()).toEqual(
'tables'
)
})
it('excludes the query string on the viewer route', () => {
expect(buildComponent('/view/data?labels=true').getSubPage()).toEqual(
'data'
)
})
})
})
@@ -67,7 +67,10 @@ export class SidebarComponent implements OnInit {
}
public getSubPage() {
let url = this._router.url.split('/')
// `Router.url` carries the query string, so take the path segment only -
// otherwise any route with a parameter renders it as part of the label
// (a VA report embed always adds one, e.g. `?embed=va`).
let url = this._router.url.split('?')[0].split('/')
return url[2]
}
@@ -149,3 +149,75 @@ describe('buildColInfoHtml', () => {
)
})
})
/**
* DOM-injection reproduction for the column-info dropdown.
* buildColInfoHtml interpolates server/DB-controlled values (column label,
* format, and DQ RULE_VALUE regex/formula strings) into a string that the
* viewer/editor assign to raw DOM `elem.innerHTML` - so a value containing
* markup (e.g. a HARDREGEX RULE_VALUE of `<img src=x onerror=alert(1)>`) is
* parsed and executed in the browser of whoever opens the info dropdown.
* These tests fail on the vulnerable implementation and pass once each field
* is escaped.
*/
describe('buildColInfoHtml escapes rather than injecting raw HTML', () => {
const malicious = '<img src=x onerror=alert(1)>'
const info: DataFormat = {
format: malicious,
label: malicious,
length: '8',
type: 'N'
}
// Parse the returned string the same way the callers do (innerHTML on a
// real element) and assert no scriptable element survived.
const parseInto = (html: string): HTMLElement => {
const host = document.createElement('div')
host.innerHTML = html
return host
}
const assertNoInjectedElement = (html: string) => {
const host = parseInto(html)
expect(host.querySelector('img[onerror]')).toBeNull()
host.remove()
}
it('is inert for a colInfo whose label and format carry markup', () => {
assertNoInjectedElement(buildColInfoHtml('SOMECHAR', info))
})
it('escapes the column NAME', () => {
const html = buildColInfoHtml(malicious, {
format: '$8.',
label: 'safe',
length: '8',
type: 'C'
})
// < and > must not survive as markup in the NAME position
expect(html).not.toContain(malicious)
assertNoInjectedElement(html)
})
it('escapes a HARDREGEX RULE_VALUE', () => {
assertNoInjectedElement(
buildColInfoHtml('SOMECHAR', info, malicious, undefined, undefined)
)
})
it('escapes a SOFTREGEX RULE_VALUE', () => {
assertNoInjectedElement(
buildColInfoHtml('SOMECHAR', info, undefined, malicious, undefined)
)
})
it('escapes a formula RULE_VALUE (with and without a leading =)', () => {
assertNoInjectedElement(
buildColInfoHtml('SOMECHAR', info, undefined, undefined, malicious)
)
assertNoInjectedElement(
buildColInfoHtml('SOMECHAR', info, undefined, undefined, `=${malicious}`)
)
})
})
+30 -4
View File
@@ -1,9 +1,35 @@
import { DataFormat } from '../../models/sas/common/DateFormat'
/**
* Returns string-safe text of any value so it can be concatenated into a
* string that is later assigned to raw DOM innerHTML. The column metadata
* (label/format) and DQ RULE_VALUE strings (regex/formula) are DB-controlled -
* a validation-rule author can store markup such as
* `<img src=x onerror=...>` in a HARDREGEX value or a column label - so they
* must never be parsed as HTML by the browser. Escaping turns any embedded
* markup into inert text.
*/
const escapeHtml = (value: any): string =>
String(value ?? '').replace(/[&<>"']/g, (char) => {
const entities: Record<string, string> = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
}
return entities[char]
})
/**
* Builds the HTML shown in a column-header "info" dropdown item (viewer and
* editor). NAME is listed first so it's visible regardless of whether
* headers are currently displayed as NAME or LABEL.
*
* The returned string is assigned to raw DOM `elem.innerHTML` by both callers
* (viewer.component.ts / editor.component.ts) - every field interpolated below
* is therefore escaped via escapeHtml, since no Angular sanitizer runs on a
* raw innerHTML assignment.
*/
export function buildColInfoHtml(
colName: string,
@@ -14,16 +40,16 @@ export function buildColInfoHtml(
): string {
if (!colInfo) return 'No info found'
let html = `NAME: ${colName}<br>LABEL: ${colInfo.label}<br>TYPE: ${colInfo.type}<br>LENGTH: ${colInfo.length}<br>FORMAT: ${colInfo.format}`
let html = `NAME: ${escapeHtml(colName)}<br>LABEL: ${escapeHtml(colInfo.label)}<br>TYPE: ${escapeHtml(colInfo.type)}<br>LENGTH: ${escapeHtml(colInfo.length)}<br>FORMAT: ${escapeHtml(colInfo.format)}`
// Only ever one REGEX rule is applied per column: when both HARDREGEX
// and SOFTREGEX exist, SOFTREGEX is ignored entirely (same precedence as
// makeRegexWarningRenderer / DcValidator.failsSoftRegex). Show only the
// rule that is applied.
if (hardRegexValue) {
html += `<br>HARDREGEX: ${hardRegexValue}`
html += `<br>HARDREGEX: ${escapeHtml(hardRegexValue)}`
} else if (softRegexValue) {
html += `<br>SOFTREGEX: ${softRegexValue}`
html += `<br>SOFTREGEX: ${escapeHtml(softRegexValue)}`
}
// '√x=' stands in for a text label here - HARDFORMULA vs SOFTFORMULA is
@@ -36,7 +62,7 @@ export function buildColInfoHtml(
const formula = formulaValue.startsWith('=')
? formulaValue.slice(1)
: formulaValue
html += `<br>√x=${formula}`
html += `<br>√x=${escapeHtml(formula)}`
}
return html
@@ -0,0 +1,119 @@
import { parseUserAgent } from './parse-user-agent'
/**
* Table-driven: the point of the parser is the token ORDER, and the only way
* to pin an order is to feed it real user agent strings that carry several
* tokens at once. Every case below is a verbatim UA from the product named
* (the iOS ones are the ones that used to fall through to Safari).
*/
describe('parseUserAgent', () => {
const cases: Array<{
label: string
ua: string
browser: string
version: string
platform: string
}> = [
{
label: 'desktop Edge (Edg)',
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.2592.87',
browser: 'Edge',
version: '126.0.2592.87',
platform: 'Windows'
},
{
label: 'desktop Edge (legacy EdgeHTML)',
ua: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763',
browser: 'Edge',
version: '18.17763',
platform: 'Windows'
},
{
label: 'desktop Opera (OPR)',
ua: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0',
browser: 'Opera',
version: '111.0.0.0',
platform: 'Linux'
},
{
label: 'desktop Firefox',
ua: 'Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0',
browser: 'Firefox',
version: '140.0',
platform: 'Linux'
},
{
label: 'desktop Chrome',
ua: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36',
browser: 'Chrome',
version: '126.0.0.0',
platform: 'Linux'
},
{
label: 'desktop Safari',
ua: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15',
browser: 'Safari',
version: '17.5',
platform: 'macOS'
},
{
label: 'Android Chrome',
ua: 'Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36',
browser: 'Chrome',
version: '126.0.0.0',
platform: 'Android'
},
{
label: 'iOS Chrome (CriOS) - not Safari',
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/126.0.6478.153 Mobile/15E148 Safari/604.1',
browser: 'Chrome',
version: '126.0.6478.153',
platform: 'iOS'
},
{
label: 'iOS Firefox (FxiOS) - not Safari',
ua: 'Mozilla/5.0 (iPad; CPU OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/127.0 Mobile/15E148 Safari/605.1.15',
browser: 'Firefox',
version: '127.0',
platform: 'iOS'
},
{
label: 'iOS Edge (EdgiOS) - not Safari',
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) EdgiOS/126.0.2592.86 Version/17.0 Mobile/15E148 Safari/604.1',
browser: 'Edge',
version: '126.0.2592.86',
platform: 'iOS'
},
{
label: 'iOS Safari',
ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1',
browser: 'Safari',
version: '17.5',
platform: 'iOS'
},
{
label: 'a non-browser client',
ua: 'curl/8.5.0',
browser: 'Unknown',
version: '',
platform: 'Unknown'
},
{
label: 'an empty user agent',
ua: '',
browser: 'Unknown',
version: '',
platform: 'Unknown'
}
]
cases.forEach((c) => {
it(`reports ${c.label} as ${c.browser} ${c.version || '(no version)'} on ${c.platform}`, () => {
expect(parseUserAgent(c.ua)).toEqual({
browser: c.browser,
browserVersion: c.version,
platform: c.platform
})
})
})
})
@@ -0,0 +1,77 @@
/**
* Summarises `navigator.userAgent` into the three things worth logging about a
* browser: its family, its version, and the platform it is running on.
*
* The raw user agent is kept alongside these - it is what a support ticket
* actually needs - but a hook is far more likely to want to branch on a name
* than to write its own user agent parsing.
*
* Order matters: Edge and Opera both claim to be Chrome, and Chrome claims to
* be Safari, so the most specific token has to be tested first. The mobile
* tokens are the sharpest case - an iOS browser carries its own token
* (`CriOS`, `FxiOS`, `EdgiOS`) *and* `Safari/`, so without the mobile token
* being tested first every iPhone and iPad client was reported as Safari with
* an empty version.
*/
export interface UserAgentSummary {
browser: string
browserVersion: string
platform: string
}
/**
* Most specific token first. Each entry carries the version pattern for the
* same token, so the family and its version can never be read from different
* products.
*/
const BROWSER_TOKENS: Array<{ name: string; token: RegExp; version: RegExp }> =
[
{
name: 'Edge',
token: /(?:EdgiOS|Edg[A-Z]?|Edge)\//,
version: /(?:EdgiOS|Edg[A-Z]?|Edge)\/([\d.]+)/
},
{
name: 'Opera',
token: /(?:OPiOS|OPR)\//,
version: /(?:OPiOS|OPR)\/([\d.]+)/
},
{
name: 'Firefox',
token: /(?:FxiOS|Firefox)\//,
version: /(?:FxiOS|Firefox)\/([\d.]+)/
},
{
name: 'Chrome',
token: /(?:CriOS|Chrome)\//,
version: /(?:CriOS|Chrome)\/([\d.]+)/
},
// Safari is the fallback token: everything else that reaches here is
// WebKit wearing another product's name.
{ name: 'Safari', token: /Safari\//, version: /Version\/([\d.]+)/ }
]
export function parseUserAgent(userAgent: string): UserAgentSummary {
const ua = userAgent || ''
const match = (re: RegExp) => (ua.match(re) || [])[1] || ''
let browser = 'Unknown'
let browserVersion = ''
for (const entry of BROWSER_TOKENS) {
if (entry.token.test(ua)) {
browser = entry.name
browserVersion = match(entry.version)
break
}
}
let platform = 'Unknown'
if (/Android/.test(ua)) platform = 'Android'
else if (/iPhone|iPad|iPod/.test(ua)) platform = 'iOS'
else if (/Windows/.test(ua)) platform = 'Windows'
else if (/Mac OS X/.test(ua)) platform = 'macOS'
else if (/Linux/.test(ua)) platform = 'Linux'
return { browser, browserVersion, platform }
}
@@ -0,0 +1,86 @@
import { buildServiceUrl } from './service-url'
describe('buildServiceUrl', () => {
const viyaConfig = {
serverUrl: 'https://sas.example.com',
appLoc: '/Public/app/dc',
executionPath: '/SASJobExecution',
service: 'public/startupservice'
}
it('builds the Viya JES URL for a service, with the log enabled', () => {
expect(buildServiceUrl(viyaConfig)).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_debug=131'
)
})
it('leaves serverUrl empty on SAS 9 so the browser resolves the origin', () => {
expect(
buildServiceUrl({
...viyaConfig,
serverUrl: '',
executionPath: '/SASStoredProcess/do'
})
).toBe(
'/SASStoredProcess/do/?_program=/Public/app/dc/services/public/startupservice&_debug=131'
)
})
it('builds the SASjs Server URL from its execution path', () => {
expect(
buildServiceUrl({
...viyaConfig,
executionPath: '/SASjsApi/stp/execute'
})
).toBe(
'https://sas.example.com/SASjsApi/stp/execute/?_program=/Public/app/dc/services/public/startupservice&_debug=131'
)
})
it('appends encoded parameters before the debug flag', () => {
expect(
buildServiceUrl({
...viyaConfig,
params: { _contextname: 'SAS Job Execution compute context' }
})
).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_contextname=SAS%20Job%20Execution%20compute%20context&_debug=131'
)
})
it('skips parameters with no value', () => {
expect(
buildServiceUrl({
...viyaConfig,
params: { _contextname: undefined, admin: null, dcpath: 'sas' }
})
).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&dcpath=sas&_debug=131'
)
})
it('omits the debug flag when debug is off', () => {
expect(buildServiceUrl({ ...viyaConfig, debug: false })).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice'
)
})
it('accepts a service with a leading slash', () => {
expect(
buildServiceUrl({ ...viyaConfig, service: '/public/startupservice' })
).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_debug=131'
)
})
it('accepts the services/ prefix the request wrapper reports', () => {
expect(
buildServiceUrl({
...viyaConfig,
service: 'services/public/startupservice'
})
).toBe(
'https://sas.example.com/SASJobExecution/?_program=/Public/app/dc/services/public/startupservice&_debug=131'
)
})
})
@@ -0,0 +1,46 @@
/**
* Builds the URL that runs a SAS service directly in a browser window.
*
* The adapter submits requests from JavaScript, and on Viya that can route the
* run through the Compute service (`_executionTasks=true`), where the SAS log
* is not returned to the caller and the request can time out before the
* service finishes. A browser request to the JES / STP web app runs the same
* `_program` without any task involved, and `_debug=131` returns the SAS log
* as the page body - which is what makes it useful when a service fails.
*
* `serverUrl` is left empty on SAS 9 when the app is served from the SAS
* server itself; the browser then resolves the path against the current
* origin.
*/
export interface ServiceUrlOptions {
serverUrl: string
appLoc: string
executionPath: string
service: string
params?: { [name: string]: string | number | null | undefined }
debug?: boolean
}
export const buildServiceUrl = ({
serverUrl,
appLoc,
executionPath,
service,
params = {},
debug = true
}: ServiceUrlOptions): string => {
// Callers pass the service as the app knows it: `public/getdata` in the
// request path, but the request wrapper reports `services/public/getdata`
// on a failed request. Both resolve to the same program.
const servicePath = service.replace(/^\/+/, '').replace(/^services\//, '')
const paramString = Object.entries(params)
.filter(([, value]) => value !== null && value !== undefined)
.map(
([name, value]) =>
`&${encodeURIComponent(name)}=${encodeURIComponent(String(value))}`
)
.join('')
const debugParam = debug ? '&_debug=131' : ''
return `${serverUrl}${executionPath}/?_program=${appLoc}/services/${servicePath}${paramString}${debugParam}`
}
@@ -1404,10 +1404,17 @@ export class ViewboxesComponent implements OnInit, AfterViewInit, OnDestroy {
this.filter = true
this.cdf.detectChanges()
this.sasStoreService.setQueryVariables(
this.filterLibds,
viewboxTable.hotTable.cols
)
// Table columns when we have them (the normal, cheapest source); when the
// view was aborted by the row limit there is no loaded table to read them
// from, so the store falls back to public/getcols.
const cols =
viewboxTable && viewboxTable.hotTable ? viewboxTable.hotTable.cols : []
this.sasStoreService
.setQueryVariablesFromTable(this.filterLibds, cols)
.catch((err: any) =>
this.eventService.catchResponseError('public/getcols', err)
)
}
/**
@@ -286,6 +286,12 @@
UPDATE
</button>
</div>
<div class="admin-action">
Export DC Library DDL
<button (click)="openDdlExport()" class="btn btn-info btn-sm">
EXPORT
</button>
</div>
}
</div>
</div>
@@ -306,3 +312,40 @@
</button>
</div>
</clr-modal>
<clr-modal [(clrModalOpen)]="ddlModal">
<h3 class="modal-title">Export DC Library DDL</h3>
<div class="modal-body">
<clr-select-container>
<label>Flavour</label>
<select [(ngModel)]="ddlFlavour" clrSelect>
<option value="SAS">SAS</option>
<option value="PGSQL">PGSQL</option>
<option value="TSQL">TSQL</option>
</select>
</clr-select-container>
@if (ddlFlavour !== 'SAS') {
<clr-input-container>
<label>Schema (optional)</label>
<input
clrInput
type="text"
[(ngModel)]="ddlSchema"
placeholder="e.g. DC"
/>
</clr-input-container>
}
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-sm btn-outline"
(click)="ddlModal = false"
>
Cancel
</button>
<button type="button" class="btn btn-sm btn-primary" (click)="exportDdl()">
Export
</button>
</div>
</clr-modal>
+29
View File
@@ -42,6 +42,9 @@ export class SystemComponent implements OnInit {
Infinity = Infinity
dcLib: string = globals.dcLib
targetLibref: string = globals.dcLib
ddlModal: boolean = false
ddlFlavour: string = 'SAS'
ddlSchema: string = ''
licenceState = this.licenceService.licenceState
settings: AppSettings
@@ -92,6 +95,32 @@ export class SystemComponent implements OnInit {
window.open(downUrl)
}
openDdlExport() {
this.ddlFlavour = 'SAS'
this.ddlSchema = ''
this.ddlModal = true
}
exportDdl() {
let sasjsConfig = this.sasService.getSasjsConfig()
let storage = sasjsConfig.serverUrl
let metaData = sasjsConfig.appLoc
let path = this.sasService.getExecutionPath()
let downUrl =
storage +
path +
'/?_program=' +
metaData +
'/services/admin/exportdb&flavour=' +
encodeURIComponent(this.ddlFlavour)
let schema = this.ddlSchema.trim()
if (this.ddlFlavour !== 'SAS' && schema) {
downUrl += '&schema=' + encodeURIComponent(schema)
}
window.open(downUrl)
this.ddlModal = false
}
refreshDataCatalog() {
this.refreshingDataCatalog = true
+21 -2
View File
@@ -499,10 +499,29 @@
!['', ' '].includes(queryText) &&
!abortActive
) {
<div class="clr-col-md-12 infoBar">
<span
<div
#infoBar
class="clr-col-md-12 infoBar"
[class.expanded]="filterExpanded"
>
<span class="infoBar-text"
>FILTER : <b>{{ queryText }}</b></span
>
@if (filterOverflows) {
<button
type="button"
class="infoBar-toggle"
[attr.aria-expanded]="filterExpanded"
[attr.aria-label]="
filterExpanded
? 'Collapse the filter clause'
: 'Expand the filter clause'
"
(click)="toggleFilterPanel()"
>
<clr-icon aria-hidden="true" shape="caret down"></clr-icon>
</button>
}
</div>
}
</div>
+58 -1
View File
@@ -3,6 +3,8 @@ import {
AfterContentInit,
ChangeDetectorRef,
AfterViewInit,
AfterViewChecked,
ElementRef,
OnDestroy,
ViewChildren,
QueryList,
@@ -58,7 +60,7 @@ import { buildColInfoHtml } from '../shared/utils/col-info-html'
standalone: false
})
export class ViewerComponent
implements AfterContentInit, AfterViewInit, OnDestroy
implements AfterContentInit, AfterViewInit, AfterViewChecked, OnDestroy
{
@ViewChildren('queryFilter')
queryFilterCompList: QueryList<QueryComponent> = new QueryList()
@@ -96,6 +98,19 @@ export class ViewerComponent
public libTab!: string
public queryText: string = ''
public webQueryText: string = ''
/**
* The applied-filter panel is collapsed to a single line by default. The
* chevron that expands it is only useful when the clause does not fit that
* line, which depends on the rendered width - so it is measured from the DOM
* rather than guessed from the length of the text.
*/
public filterExpanded = false
public filterOverflows = false
@ViewChild('infoBar') infoBar?: ElementRef<HTMLElement>
private filterMeasuredKey = ''
public submitLoading!: boolean
public queryErr: boolean = false
public queryErrMessage!: string
@@ -1445,6 +1460,48 @@ export class ViewerComponent
}
}
ngAfterViewChecked() {
this.scheduleFilterOverflowCheck()
}
/**
* Measures whether the applied-filter clause fits the collapsed single line,
* and shows or hides the chevron accordingly. The measurement is deferred
* because `filterOverflows` and `filterExpanded` are bound in this view -
* setting them inside the change-detection cycle would raise
* ExpressionChangedAfterItHasBeenChecked.
*/
private scheduleFilterOverflowCheck() {
const el = this.infoBar?.nativeElement
if (!el) {
return
}
const text = el.querySelector('.infoBar-text') as HTMLElement | null
if (!text) {
return
}
// re-measure only when the clause, the available width, or the state changes
const key = `${this.queryText}|${text.clientWidth}|${this.filterExpanded}`
if (key === this.filterMeasuredKey) {
return
}
this.filterMeasuredKey = key
setTimeout(() => {
// while expanded the clause wraps, so there is nothing to measure
if (this.filterExpanded) {
return
}
this.filterOverflows = text.scrollWidth > text.clientWidth
})
}
public toggleFilterPanel() {
this.filterExpanded = !this.filterExpanded
}
ngAfterViewInit() {
// Fix ARIA accessibility issues after table initialization
setTimeout(() => {
+3 -4
View File
@@ -42,11 +42,13 @@
* debug: Whether to enable debug on startup
## Viya only settings ##
* adminGroup: This group will have unrestricted access (Viya Only)
* dcPath: The physical location in which to deploy the staging area (Viya only)
* useComputeApi: Connection method (Viya only)
* contextName: Compute Context (Viya only)
The admin group is not configured here - it is a DC setting (DC_ADMIN_GROUP),
shown on the System screen.
-->
<sasjs
@@ -58,9 +60,6 @@
useComputeApi="null"
runAsTask="true"
contextName="SAS Job Execution compute context"
adminGroup="SASAdministrators"
dcPath="/tmp/dc"
hotLicenceKey="non-commercial-and-evaluation"
>
</sasjs>
+137 -38
View File
@@ -120,30 +120,6 @@ app-editor {
.infoBar {
margin-top: 14px;
background: #495967;
color: white;
text-align: center;
padding: 3px;
font-size: 16px;
height: 30px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
span {
width: 80%;
}
&:hover {
height: unset;
white-space: normal;
span {
width: unset;
}
}
}
.pkHeader {
@@ -1228,11 +1204,6 @@ app-viewer {
.infoBar {
margin-top: 10px;
background: #495967;
color: white;
text-align: center;
padding: 3px;
font-size: 16px;
}
.filterSide {
@@ -1693,6 +1664,13 @@ app-requests-modal {
padding: 20px 10px 5px 10px;
}
/* The SAS log pane is `white-space: pre`, so it never wraps. The stock `xl`
width is a fixed 57.6rem, which forced left/right scrolling to read a log
line. */
.requests-modal .modal-dialog {
width: 90vw;
}
.work-tables-dropdown button {
color: var(--clr-nav-link-color, #8c8c8c) !important;
}
@@ -2318,15 +2296,6 @@ app-alerts {
}
// ALERTS.COMPONENT END
// MANUAL-DEPLOY.COMPONENT
app-manual-deploy {
.clear-memory-button {
right: 10px;
top: 2px;
}
}
// MANUAL-DEPLOY.COMPONENT END
// LINEAGE.COMPONENT
app-lineage {
.toggle-switch input[type='checkbox']:checked + label:before {
@@ -4284,6 +4253,30 @@ body[cds-theme='light'] {
color: #c21d00;
}
/* The SASjs tag dump drops onto its own line and reads as a name/value grid. */
&--grid {
flex-wrap: wrap;
align-items: baseline;
}
&__grid {
flex-basis: 100%;
display: grid;
grid-template-columns: auto 1fr;
gap: 1px 12px;
margin-top: 4px;
font-size: 12px;
}
&__grid-name {
color: #999;
}
&__grid-value {
color: #ccc;
word-break: break-word;
}
&__icon--pending {
color: #999;
}
@@ -5026,6 +5019,57 @@ body[cds-theme='dark'] {
border: 1px solid var(--cds-alias-status-warning) !important;
}
/* Derived (computed) columns: read-only, but computed at read time rather than
locked by policy. Tinted and marked with an 'fx' glyph instead of the
read-only dimming, so the two do not read as the same thing. Blue is the
info family - the primary key green and the warning ochre keep their meaning. */
.handsontable th.dc-derived-header {
background: #d3e5f2 !important;
box-shadow: inset 0 -2px 0 #1a6ea3;
}
.handsontable th.dc-derived-header div::after {
content: 'fx';
margin-left: 4px;
font-size: 9px;
font-style: italic;
opacity: 0.7;
}
.handsontable td.dc-derived-cell {
background: #eef5fa !important;
font-style: italic;
}
/* the first derived column starts the computed block */
.handsontable th.dc-derived-first {
border-left: 2px solid #1a6ea3 !important;
}
.handsontable td.dc-derived-cell.dc-derived-first {
box-shadow: inset 2px 0 0 #1a6ea3;
}
body[cds-theme='dark'] {
.handsontable th.dc-derived-header {
background: #2b4a5c !important;
box-shadow: inset 0 -2px 0 #4b9cc9;
}
.handsontable td.dc-derived-cell {
background: #24343d !important;
color: #dbe7ee;
}
.handsontable th.dc-derived-first {
border-left-color: #4b9cc9 !important;
}
.handsontable td.dc-derived-cell.dc-derived-first {
box-shadow: inset 2px 0 0 #4b9cc9;
}
}
.handsontable .numericListbox {
text-align: right;
}
@@ -5448,3 +5492,58 @@ body[cds-theme='dark'] {
cursor: pointer;
text-decoration: underline;
}
/* The applied-filter panel. Collapsed to a single line by default so that a
long filter does not take over the header; the chevron - rendered only when
the clause does not fit that line - expands the panel to show it in full. */
.infoBar {
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
background: #495967;
color: white;
text-align: center;
padding: 3px 8px;
font-size: 16px;
/* the panel shows a query, so set it in the monospace face the app already
uses for code-like content (SAS logs, cell text) */
font-family: 'Lucida Console', Monaco, monospace;
.infoBar-text {
flex: 1;
min-width: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
&.expanded {
align-items: flex-start;
.infoBar-text {
overflow: visible;
white-space: normal;
text-overflow: clip;
overflow-wrap: anywhere;
}
}
.infoBar-toggle {
flex: none;
background: transparent;
border: 0;
color: inherit;
cursor: pointer;
padding: 0 2px;
line-height: 1;
clr-icon {
transition: transform 0.15s ease-in;
}
}
&.expanded .infoBar-toggle clr-icon {
transform: rotate(180deg);
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dcfrontend",
"version": "7.14.1",
"version": "7.19.0",
"description": "Data Controller",
"devDependencies": {
"@nogoo9/gitleaks": "8.30.1-post.2",
+1
View File
@@ -11,5 +11,6 @@
"noNestedMacros": true,
"hasMacroParentheses": true,
"strictMacroDefinition": true,
"ignoredMacros": ["webout", "mpeinit", "mpeterm"],
"ignoreList":["sasjs/scratch"]
}
+10
View File
@@ -0,0 +1,10 @@
{
"fromjs": [
{
"ADMIN": "all-users",
"DCPATH": "/tmp/dcdata",
"OUTFMT": "JSON",
"KEEPME": "Y"
}
]
}
+4
View File
@@ -0,0 +1,4 @@
{
"licenceKey": "G4H/DNTdEMkmCIxOrYkRYTQ1P4sWg0gs8Zk9rakxFNYDZcLyEPMJJo82YJQ/S24P2E/YPxaWsDZXgOrWKfeCDS7NrLcwsoFNa8KRF2WTlRgSMiG4sjBRX8zNEIvszj5DAq4LEgOUUAdfctNfpUcygbxT1dhqy6gU3hBu/xRuXGd36rhxQwfahaKkfaCg/rFplkrvqnjoJ6622BxWP/HG1dxZUE7HNJyT4tNaXzlC9U6u/aaJJ66+V+9511BwjM9ss4nyHuHoogVE1yrzLMlL94P3QoM1hwkGHnEHmFzg3zHbQG1f3pUs9YzK0ytsFKU7AK948gJrGbf37Zqa+Mz7EZf6XzqqXx0zQ4y9zAhLV9s4QG8JdhrByhfG5kefrs4L/BpgKq3ElgYL5EMkrLJUrlqWYI2ouxJuIGCQz41VCWXJ2S7pd39ljifc8Zj+t2Mn5EEkRVsrbdxjCkyoZOQ1ALofa1+auUI26Rm5rwEgrfhEocDmphJpO2F8lZgwDxbepSE6v/vEV/JQWBQTyrX10W+qOEu8OhvZrYJo+eIJMaO7q1pjfdrn3XhoH+BeB3Sy1sevGLXQZC+CzOtcvajetGGCDAabtTLc49ouWPUiUOAWPE3uYymsMoRZgpLIMxaUM86hoK0r9T6wSaP0bddK754sXN1jWwIDAHSGz5WO1ko=",
"activationKey": "MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQD2w8Ge6tMI82vaQ7x5ZdlwnTJycn0UFZoSgRwObaM0NC5wp9Y8lwkVzN8FUhg2oYSTpvyJpix+VGRj0AlNBwFAVcJG9VDPYh2LE3Us9ghRfkzFUiM2PqorHnzL5DwpailRtmFHoDQPGwwSmKncTo2QHql/K6tWe7g3Nv9uqQNks283hvDQ6PVGU4TaFTSRbjGX4j+JAR651J6wI6nY+9kNxOBwnL/yKTnJGmL8oqZ+oC45quZzgRW4dLIeTODcB4IZe2ruxZ9tvXpSuAESiOv5bBZyMJEKdKwsRdt6vk+bezkZBCzPq+ly892Ncq7x5u4/8dGcGxRxxp5TnIIx3hFoiXZ7svXJ7st6uHuKkuwYq+ebWh6bcvQAwH2wCP40twMjQgmU8nHHo6+pulxu1wVZBxtoyM4m3Lu0ZncTi6mF0duiPvpkNNAZzKOF98aUq3hxYp5PP28qrtWuPsgSdTNWJwnV2R288yAPx4WLUAGB9h889d/m67HUiKadmfG4oyUnChCU/mqeJ/5nQkK1n76ezRPGsTcMZIv2mmPLShA/j38lGMjR/3pzM2Ha6UFjJKpurpeDiyt5pUdmRBpQRoBUx/PHnbXBsO9PBXa0mjdq3UFbgb5iBD1Fz2YClZ/h0d4YlYUMSeharDrLfR15g3fGnzxrkR03zYeHkxMUi5vYHQIDAQABAoICAFxUg5pcH8lOF1FMHfXIY5MM5mbHKsC8knERCPfnEvVB/wxc6D60fow/I0Vg4blzNuFuTjiMykIcfpGQMiK1l8TEMdSODoYCHq6+gY3ootUnLj94i79MtCw9FJHPnKkcVUiDNqPvr/rk8l/06j2J0NMXffEc3FeYJCXYuLtlluTzdI4wueNY/wkoz+EvpQMzWXAMkhxHpIEAqr2aIn+TQDQ0MYxBQlqwDTSPYHFJxIVFlvYx2VdnecKSO2E1/76kOowhTzH3FL+hcWcI/TG7tJuXU1C3llV0sUVBgC1NjwjMkuEm3EN5/ffqgj/eJNJTR1r6tqSzxzMJD42WVmqlPhqEmmRE1yeaio6Ulm5EJLREYEY4/1EotdIO6PCXF1Xeo+10VJLcwi19vzMlz7vFB6vSJzJNYOaiwm4rgmF12+nNt18cHoFvegGPAoCJurUhXU+iV6LlKYB8J/+kpITleZwm4dEaa6EWxgFf4nZ4N+qRVqk4JfC+rN3DQgbPcII+z7axAb8xutq5rvzskGAmKcTEagMG+pnk9DI+0m1C2J6+mC/YruVlpSlPB7Ecu/OF++vJoSCLuDXVuxMTQ3tQXoicOG/S8d1aa3nq4fvLIgZTOZoffUvNvjCyy/Dlv6vaDVCjgqt2kFZVSZv3C6ttyrNVBSjhucASGTq/7q82JKVrAoIBAQD7e7SYqDM8SAjOfpRAHCbIVVSaHw1tul16B6JAF67OIs1uD//Y+maL4GHlpFxnib0tg6z3+sG10NMUhK7elB6SkJ8voT+Ztg/+on659vmaqwTlkGjgks+8DmIw1b0ZbXuIqhnkOeSsll2V9NWItIrbzNwvhtMEQsOtFvmrLlKQvx9Bo3lGmbfdU1/9XpwW4wiA5ONcFCl1xllX9nItB+ActPoAeQgnuejWAISQkITDTOFcGu0AjMjJ66HUlY/WDbf7wY/s2aMbOiVx7B6YzQnK+lZdjjNfoaL8nfN8Z8ZzJFAgmTQ9ztZCJ8fLTfZDsYD6XZnVEIG401+6de0Ea4MHAoIBAQD7Mlr++keNDxYy3k6kwTXDOSKMDfXIDverFy/tiNorcVU5nIpuhjowl4HIQVAhzlXhATp938LM/PvJIeu9HtgsY9BFNL52fr7iGEWknqZQVE+8Um35tzV3vtPH9NVXHIYmcRCAQQJ5a6oVQRJKAM3E1+htM2AeZKMaQSCC6VHGBXJG9nEltdMKTet09pd26Z5y/YIfTqbIekyjRomGdInyWBkpJLJ/uROVb9OGnsYWadDktn7y9+oH+VZoJxW5QwXV0OL7wMzymlrKhhBNMziJRBk4rVztclYzUShpwE8Xfjt5WYkOoieXtmkdpF7TMvRYy6cdflh39l8s7THq4U67AoIBAQDPShR+kIZK9gVsUCHbBllhYBSwRVBIVgmfAJPYyKyp9T3nrwBw1VWZjoajR2tzXLG2xobYkLUDLPIQQ53wkZ7xqIvOMte917gvZ7mVh+IOf1E1+Ga6VcktdZ2yKzwHrZrZ93wIB0BakkbpyDoKyOZ8bsw/0J43MOEh14JMe45LCX62GA1rCGHp6UOCEW4P32uu8vwFdgkGr0wNmXJbc9ZjUzmPEjSKqk8ltp+OmdEVOlW4GempPmJzLeri07UP95bjyZTc4jfzxWYAFWTTBo8/5EE0NHZcKVuzZm7A6LlHR3NUq3PITqmFNk0VY1nOSo3J0UVvvn9u3axWgcWwkv4ZAoIBAQD5GaB/RfZ6fcGHxEi8vRTxedE2jglz0NPuCFpw9ctUVVksfn4QyG8gDL6YtZwfShyDutIkTSdCXIXbmRXLP7Ejo/+/AWT24Q2t7F/ztZg8BL/lguCoR/RvwP8HRVXiwtiNeoXgiZdIjWnnFdZrKIzlbS6CS/Y/bZEI0hjJeVKsSm5ezLi7qqmTiF28aWUeeOG2KotFPJvMJuuk5qgue5boilC5KjkQy5oOEQz0bLMHOvv6MreFfi/IpIv5UPkL9NjuhezxtuoGkucB+xxjUi34gV15hQGoPkAZN5wZ8qj8JSQZXJ67sjYNDskCqiOW0Orau2oHp2lX3SvYw4dC4xdNAoIBAQDSXF8OnWu08smGDs4S57yfqe59N0ULIBDOZdEQcLXRaDeAoOwQj8szUf0pycXUZLvXxv29iF61FJg70iGGCp3lW+9Oe0P+dGsKvzphRGsQPZy4h/qZDoQ9dE667ejI4aDb/C1GaOZ8TT1QfpQcVKbgLjdC19IGQPhFljGM1wMQojU5lp4/iKmA3J3ahOuV4dvEUr6xkqzq+PhH405XdURXsVc1J6qYX2wQXRoB0oDsrCbqidZi14DaeE8UhZRA6m9haUOb/3Y+OkCs2QIW4MNZ+zg8XtHjiUhMxAaJ6zdEFltWPoVFsVfgoecquAHb0uDJJRz/+RfR0AiG0XG0NW+C"
}
@@ -14,7 +14,6 @@ function makeRows(n) {
const rows = []
for (let i = 0; i < n; i++) {
rows.push({
_____DELETE__THIS__RECORD_____: "No",
PRIMARY_KEY_FIELD: i,
SOME_CHAR: "dummy data row " + i,
SOME_DROPDOWN: dropdowns[i % dropdowns.length],
@@ -241,7 +240,6 @@ const data = {
{ ODS_TABLE: "ENGINEHOST", NAME: "File Size (bytes)", VALUE: "1048576" }
],
maxvarlengths: [
{ NAME: "_____DELETE__THIS__RECORD_____", MAXLEN: 3 },
{ NAME: "PRIMARY_KEY_FIELD", MAXLEN: 4 },
{ NAME: "some_char", MAXLEN: 591 },
{ NAME: "some_dropdown", MAXLEN: 8 },
@@ -261,7 +259,6 @@ const data = {
sasdata: makeRows(100),
$sasdata: {
vars: {
_____DELETE__THIS__RECORD_____: { format: "$3.", label: "_____DELETE__THIS__RECORD_____", length: "3", type: "char" },
PRIMARY_KEY_FIELD: { format: "best.", label: "PRIMARY_KEY_FIELD", length: "8", type: "num" },
SOME_CHAR: { format: "$32767.", label: "SOME_CHAR", length: "32767", type: "char" },
SOME_DROPDOWN: { format: "$128.", label: "SOME_DROPDOWN", length: "128", type: "char" },
@@ -280,14 +277,14 @@ const data = {
},
sasparams: [
{
COLHEADERS: "_____DELETE__THIS__RECORD_____,PRIMARY_KEY_FIELD,SOME_CHAR,SOME_DROPDOWN,SOME_HARDSELECT,SOME_NUM,SOME_DATE,SOME_DATETIME,SOME_TIME,SOME_SHORTNUM,SOME_BESTNUM,READONLY_COL,HIDDEN_COL,ROUND_COL,NUMFMT_COL",
COLHEADERS: "PRIMARY_KEY_FIELD,SOME_CHAR,SOME_DROPDOWN,SOME_HARDSELECT,SOME_NUM,SOME_DATE,SOME_DATETIME,SOME_TIME,SOME_SHORTNUM,SOME_BESTNUM,READONLY_COL,HIDDEN_COL,ROUND_COL,NUMFMT_COL",
FILTER_TEXT: "",
PKCNT: 1,
PK: "PRIMARY_KEY_FIELD",
DTVARS: " SOME_DATE",
DTTMVARS: " SOME_DATETIME",
TMVARS: " SOME_TIME",
COLTYPE: "{\"data\":\"_____DELETE__THIS__RECORD_____\",\"type\":\"dropdown\",\"source\":[\"No\",\"Yes\"]},{\"data\":\"PRIMARY_KEY_FIELD\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_CHAR\"},{\"data\":\"SOME_DROPDOWN\"},{\"data\":\"SOME_HARDSELECT\"},{\"data\":\"SOME_NUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_DATE\",\"type\":\"date\"},{\"data\":\"SOME_DATETIME\",\"type\":\"datetime\"},{\"data\":\"SOME_TIME\",\"type\":\"time\"},{\"data\":\"SOME_SHORTNUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_BESTNUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"READONLY_COL\"},{\"data\":\"HIDDEN_COL\"},{\"data\":\"ROUND_COL\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"NUMFMT_COL\",\"type\":\"numeric\",\"format\":\"0\"}",
COLTYPE: "{\"data\":\"PRIMARY_KEY_FIELD\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_CHAR\"},{\"data\":\"SOME_DROPDOWN\"},{\"data\":\"SOME_HARDSELECT\"},{\"data\":\"SOME_NUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_DATE\",\"type\":\"date\"},{\"data\":\"SOME_DATETIME\",\"type\":\"datetime\"},{\"data\":\"SOME_TIME\",\"type\":\"time\"},{\"data\":\"SOME_SHORTNUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"SOME_BESTNUM\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"READONLY_COL\"},{\"data\":\"HIDDEN_COL\"},{\"data\":\"ROUND_COL\",\"type\":\"numeric\",\"format\":\"0\"},{\"data\":\"NUMFMT_COL\",\"type\":\"numeric\",\"format\":\"0\"}",
LOADTYPE: "UPDATE",
RK_FLAG: 0,
CLS_FLAG: 0
+2 -2
View File
@@ -1,4 +1,4 @@
{
"licenceKey": "invalid",
"activationKey": "invalid"
"licenceKey": "",
"activationKey": ""
}
+4 -2
View File
@@ -14,9 +14,11 @@
"streamConfig": {
"streamWeb": true,
"streamWebFolder": "web9",
"webSourcePath": "`../../../../client/dist",
"webSourcePath": "../../client/dist",
"assetPaths": [],
"streamServiceName": "clickme"
"streamServiceName": "clickme",
"mockWeb": true,
"mockWebFolder": "sasjsbuild/mock"
}
},
{
+160
View File
@@ -0,0 +1,160 @@
const nodePath = require('path')
let appLoc = nodePath.join(..._program.split('services')[0].split('/'))
const sasjsRoot = nodePath.resolve(weboutPath, '..', '..', '..')
const driveRoot = nodePath.resolve(sasjsRoot, 'drive')
eval(fs.readFileSync(nodePath.resolve(driveRoot, 'files', appLoc, 'services', 'dcMockUtils.js'), 'utf8'))
/**
* Mock of services/admin/exportdb.sas - exports the DC library as DDL.
*
* The real service streams mp_ds2ddl output for every table in &DC_LIBREF, in
* the requested flavour, and mp_lib2inserts appends the rows for the SAS and
* PGSQL flavours. This mock emits the DDL only - a basic, readable rendering
* per flavour, enough to exercise the System screen's Export DC Library DDL
* action end to end (the download headers, the filename, the flavour and the
* optional schema). It deliberately does not append INSERTs: the real service
* does, but for a mock that would mean serialising the whole library's rows
* (MPE_X_WIDE alone is 200,000 cells) for no extra test value.
*
* Params arrive from the URL the client opens:
* <serverUrl>/SASjsApi/stp/execute/?_program=<appLoc>/services/admin/exportdb
* &flavour=SAS|PGSQL|TSQL[&schema=<name>]
* The schema box only applies to the DB flavours, and the client omits the
* param entirely when it is blank, so both must be read defensively - an
* unset URL param is an undeclared const here, not an empty string.
*/
const ddlFlavour = (typeof flavour === 'undefined' || !flavour)
? 'SAS'
: String(flavour).toUpperCase()
const dcConf = loadDcSettings(driveRoot, appLoc)
const libref = dcConf.dcLibref
const dataDir = dcConf.dataDir
// if no schema param, the DC libref is used (as in exportdb.sas)
const ddlSchema = (typeof schema === 'undefined' || !schema)
? libref
: String(schema)
// ─── Column types, per flavour ───────────────────────────────────────────────
function colType(col, flavour) {
const isChar = String(col.type).toUpperCase() === 'C'
const fmt = String(col.format || '').toUpperCase()
const len = Number(col.length) || (isChar ? 1 : 8)
if (flavour === 'SAS') {
return isChar ? `char(${len})` : 'num'
}
// PGSQL and TSQL share the mapping; only the quoting differs. The one type
// that must not be shared is the datetime: T-SQL's TIMESTAMP is a deprecated
// synonym for rowversion - a binary row version, not a datetime - so it maps
// to DATETIME2 there. DOUBLE PRECISION is a T-SQL synonym for float, so it
// stays valid on both.
if (isChar) return `VARCHAR(${len})`
if (fmt.startsWith('DATETIME'))
return flavour === 'TSQL' ? 'DATETIME2' : 'TIMESTAMP'
if (fmt.startsWith('DATE')) return 'DATE'
if (fmt.startsWith('TIME')) return 'TIME'
return 'DOUBLE PRECISION'
}
function colRef(name, flavour) {
if (flavour === 'PGSQL') return `"${name}"`
if (flavour === 'TSQL') return `[${name}]`
return name
}
function tableRef(table, flavour) {
if (flavour === 'TSQL') return `[${ddlSchema}].[${table}]`
return `${ddlSchema}.${table}`
}
// ─── Buskeys (for the unique index), from MPE_TABLES ─────────────────────────
const buskeys = {}
try {
const reg = makeTableLoader(dataDir)('MPE_TABLES')
for (const row of ((reg && reg.rows) || [])) {
const dsn = String(colVal(row, 'DSN') || '').trim().toUpperCase()
const buskey = String(colVal(row, 'BUSKEY') || '').trim()
if (dsn && buskey) buskeys[dsn] = buskey
}
} catch(err) { /* no MPE_TABLES - the DDL is still emitted, without indexes */ }
// ─── Build the DDL ───────────────────────────────────────────────────────────
const lines = []
const stamp = new Date().toISOString().replace('T', ':').substring(0, 19)
lines.push(`/* DDL generated by the Data Controller mock on ${stamp} */`)
if (ddlFlavour === 'PGSQL') {
lines.push(`CREATE SCHEMA ${ddlSchema};`)
}
let tables = []
try {
tables = fs.readdirSync(dataDir)
.filter(f => f.endsWith('.json'))
.map(f => {
try {
return JSON.parse(fs.readFileSync(nodePath.resolve(dataDir, f), {encoding:'utf8'}).toString())
} catch(e) { return null }
})
.filter(t => t && t.name && Array.isArray(t.columns))
.sort((a, b) => String(a.name).localeCompare(String(b.name)))
} catch(err) { /* nothing to export */ }
for (const table of tables) {
const tableName = String(table.name).toUpperCase()
const cols = table.columns.filter(c => String(c.name || '').trim() !== '')
if (cols.length === 0) continue
if (ddlFlavour === 'SAS') {
lines.push(`/* SAS flavour DDL for ${libref}.${tableName} */`)
lines.push(`create table ${tableRef(tableName, ddlFlavour)}(`)
} else if (ddlFlavour === 'PGSQL') {
lines.push(`/* Postgres Flavour DDL for ${libref}.${tableName} */`)
lines.push(`CREATE TABLE ${tableRef(tableName, ddlFlavour)} (`)
} else {
lines.push(`/* TSQL Flavour DDL for ${libref}.${tableName} */`)
lines.push(`create table ${tableRef(tableName, ddlFlavour)}(`)
}
cols.forEach((col, idx) => {
const name = colRef(String(col.name).toUpperCase(), ddlFlavour)
const prefix = idx === 0 ? ' ' : ' ,'
lines.push(`${prefix}${name} ${colType(col, ddlFlavour)}`)
})
lines.push(');')
// a unique index on the buskey, where MPE_TABLES declares one - SAS has no
// equivalent in mp_ds2ddl output, so it is skipped for that flavour
const buskey = buskeys[tableName]
if (buskey && ddlFlavour !== 'SAS') {
const keys = buskey.split(/[\s,]+/).filter(Boolean)
.map(k => colRef(k.toUpperCase(), ddlFlavour))
lines.push(
`CREATE UNIQUE INDEX ${colRef(tableName + '_pk', ddlFlavour)} ON ` +
`${tableRef(tableName, ddlFlavour)}(\n ${keys.join('\n ,')}\n);`
)
}
lines.push('')
}
// ─── Stream it back as a download, as mp_streamfile does ─────────────────────
const filename = `${libref}.ddl`
fs.writeFile(
_SASJS_WEBOUT_HEADERS,
`Content-type: text/plain \n Content-Disposition: attachment;filename="${filename}"`,
function (err) {
if (err) throw err
}
)
_webout = lines.join('\n') + '\n'
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,104 @@
const nodePath = require('path')
let appLoc = nodePath.join(..._program.split('services')[0].split('/'))
const sasjsRoot = nodePath.resolve(weboutPath, '..', '..', '..')
const driveRoot = nodePath.resolve(sasjsRoot, 'drive')
// Load shared DC mock utilities
eval(
fs.readFileSync(
nodePath.resolve(driveRoot, 'files', appLoc, 'services', 'dcMockUtils.js'),
'utf8'
)
)
const dcConf = loadDcSettings(driveRoot, appLoc)
const mpeDataDir = dcConf.dataDir
const stagingDir = nodePath.resolve(mpeDataDir, 'staging')
const mpeLoadTableData = makeTableLoader(mpeDataDir)
// ─── Parse input ──────────────────────────────────────────────────────────────
// The submission id arrives as the `table` URL param, as in getauditfile.sas.
let tableId = ''
if (typeof table !== 'undefined' && table) tableId = String(table).trim()
// libds comes from MPE_SUBMIT, the same lookup the SAS service makes before it
// decides the request is valid.
let libds = ''
if (tableId) {
const submit = mpeLoadTableData('MPE_SUBMIT')
const row =
submit && submit.rows
? submit.rows.find((r) => r.TABLE_ID === tableId)
: null
if (row) {
libds = (String(row.BASE_LIB || '') + '.' + String(row.BASE_DS || '')).toUpperCase()
}
}
// ─── Respond ──────────────────────────────────────────────────────────────────
if (!tableId || !libds) {
// getauditfile.sas aborts with the same message when either is missing.
webOutOpen()
webOutObj([{ MSG: 'Missing: libds table', MAC: 'getauditfile' }], 'sasjsAbort')
webOutObj([{ STATUS: 'ERROR', DSID: '' }], 'sasparams')
webOutClose()
} else {
// The SAS service also checks EDIT or APPROVE access (mpe_accesscheck). The
// mock seeds MPE_SECURITY but no mock service enforces it, so access is not
// emulated here.
// The approval folder is zipped as it stands. getauditfile.sas lists it with
// mp_dirlist and adds each file to the package under contents/.
const stageFolder = nodePath.resolve(stagingDir, tableId)
const names = []
if (fs.existsSync(stageFolder)) {
for (const name of fs.readdirSync(stageFolder)) {
const absolute = nodePath.resolve(stageFolder, name)
let stat
try {
stat = fs.statSync(absolute)
} catch (err) {
continue
}
if (stat.isFile()) names.push(name)
}
}
names.sort()
const entries = names.map((name) => ({
name: 'contents/' + name,
content: fs
.readFileSync(nodePath.resolve(stageFolder, name), { encoding: 'utf8' })
.toString()
}))
const archive = mpZipPackage(entries)
const streamed = mpStreamfile({
filename: tableId + '.zip',
contentType: 'application/zip',
bytes: archive
})
if (!streamed) {
// The browser host returns a text body and ignores the streamed headers, so
// the archive cannot reach the browser as a download. The pack is described
// instead, which is what a reviewer opening the tab gets there.
_webout = JSON.stringify(
{
table: tableId,
libds: libds,
archive: tableId + '.zip',
note: 'The browser mock host streams text only, so this lists the archive contents.',
contents: entries.map((entry) => ({
name: entry.name,
bytes: entry.content.length
}))
},
null,
2
)
}
}
+10 -1
View File
@@ -152,10 +152,19 @@ for (const col of diffCols) colDdtypes[col.name] = getDdType(col)
// Staged values arrive from CSV as strings ("42"), base values are native JSON
// (42). Compare numerics by value and strings case-sensitively.
// A SAS special missing (._ , .A-.Z) reaches us as a string. Special missings
// are numeric-only, and real DC writes the DIFF with `missing=STRING` - whose
// format maps ._ and .a-.z to a string but leaves a bare `.` as null (see the
// `bart` format in mp_jsonout.sas). Coercing a special missing with Number()
// would yield NaN and blank the cell out of the DIFF.
const SPECIAL_MISSING_RE = /^\.(_|[a-z])$/i
function normVal(value, colName) {
const col = diffCols.find((c) => c.name === colName)
if (col && col.type === 'N') {
if (value === null || value === undefined || value === '') return null
const str = String(value).trim()
if (SPECIAL_MISSING_RE.test(str)) return str
const num = Number(value)
return isNaN(num) ? null : num
}
@@ -543,7 +552,7 @@ if (action === 'SHOW_DIFFS') {
const stageFolder = getStageFolder(loadRef)
// check: has this user already approved? (mirrors prev_upload_check in postdata.sas)
const reviewData = loadTableData('MPE_REVIEW') || { rows: [] }
const reviewData = mpeLoadTableData('MPE_REVIEW') || { rows: [] }
const alreadyApproved = reviewData.rows.some(
(r) =>
r.TABLE_ID === loadRef &&
+735 -6
View File
@@ -5,6 +5,7 @@
* Provides:
* - fetchTable / fetchRaw / parseCsv : emulate SAS %webout(FETCH)
* - webOutOpen / webOutObj / webOutClose : emulate SAS %webout(OPEN/OBJ/CLOSE)
* - mpeinit : emulate the %mpeinit debug dump
* - formatSasValue : apply a SAS format to a numeric value
* - parseFormattedToSas : convert an ISO string back to a SAS numeric
* - getDdType : derive DATE/DATETIME/TIME/N/C from a column format
@@ -147,14 +148,63 @@ function _parseCsvLine(line) {
// ─── SAS format <-> ISO conversions ──────────────────────────────────────────
/**
* Derives a DDTYPE (DATE, DATETIME, TIME, N, C) from a SAS column format string.
* Column metadata, mirroring %mp_getcols.sas.
*
* The SAS macro runs proc contents and derives, per column: NAME (upcased),
* TYPE (C/N), LENGTH, LABEL (defaulting to the name), VARNUM, FMTNAME, FORMAT
* and DDTYPE - CHARACTER, NUMERIC, DATETIME, DATE or TIME. The date list is
* the macro's (YYMMDD, MMDDYY, DDMMYY, MONYY, E8601DA, B8601DA, E8601DT,
* NLDATM, NLDATE), so a column types the same way here as it does in the
* service that shares this code.
*
* @param {Array} schemaCols the table's columns as the mock data stores them
* ({name, type, length, format, label}), the equivalent of the proc contents
* output the macro reads
* @returns {Array} one entry per column, in the macro's shape and order
*/
function mpGetcols(schemaCols) {
return (schemaCols || []).map((col, index) => {
const name = String(col.name || '').toUpperCase()
const isChar = String(col.type || '').toUpperCase() === 'C'
const fmtname = String(col.format || '')
.replace(/[\d.]+$/, '')
.toUpperCase()
let ddtype
if (isChar) ddtype = 'CHARACTER'
else if (fmtname.startsWith('DATETIME') || fmtname.startsWith('E8601DT')
|| fmtname.startsWith('NLDATM')) ddtype = 'DATETIME'
else if (fmtname.startsWith('DATE') || fmtname.startsWith('DDMMYY')
|| fmtname.startsWith('MMDDYY') || fmtname.startsWith('YYMMDD')
|| fmtname.startsWith('E8601DA') || fmtname.startsWith('B8601DA')
|| fmtname.startsWith('MONYY') || fmtname.startsWith('NLDATE')) ddtype = 'DATE'
else if (fmtname.startsWith('TIME')) ddtype = 'TIME'
else ddtype = 'NUMERIC'
return {
NAME: name,
TYPE: isChar ? 'C' : 'N',
LENGTH: Number(col.length) || 0,
LABEL: col.label || col.name,
VARNUM: index + 1,
FORMAT: String(col.format || ''),
FMTNAME: fmtname,
DDTYPE: ddtype
}
})
}
/**
* Derives a DDTYPE (DATE, DATETIME, TIME, N, C) from a SAS column format
* string, in the shape the client expects. Delegates to mpGetcols so the
* inference is the macro's, rather than a second format list that can drift
* away from the service's.
*/
function getDdType(col) {
const fmt = (col.format || '').toLowerCase()
if (fmt.startsWith('datetime') || fmt.startsWith('e8601dt')) return 'DATETIME'
if (fmt.startsWith('date') || fmt.startsWith('yymmdd') || fmt.startsWith('ddmmyy') || fmt.startsWith('mmddyy')) return 'DATE'
if (fmt.startsWith('time')) return 'TIME'
return col.type === 'N' ? 'N' : 'C'
const ddtype = mpGetcols([col])[0].DDTYPE
if (ddtype === 'CHARACTER') return 'C'
if (ddtype === 'NUMERIC') return 'N'
return ddtype
}
/**
@@ -336,6 +386,44 @@ function loadTableSchema(dataDir, tableName) {
return (data && data.columns) ? data.columns : []
}
/**
* Resolves a hook program name to the source of its mock implementation.
*
* MPE_TABLES.pre_edit_hook / post_edit_hook (and the SOFTSELECT_HOOK /
* HARDSELECT_HOOK rule_value in MPE_VALIDATIONS) hold a hook program: either a
* physical .sas path, or a path relative to the appLoc (e.g.
* 'services/hooks/mytable_postedit'). The real backend %includes the program
* into the running service, so the hook shares the service's macro variables
* and work datasets and can modify them.
*
* The mock mirrors that: this returns the source of the hook's .js counterpart,
* which the calling service eval()s in its OWN scope so the hook can read and
* modify the service's variables. Returns null when the hook has no mock
* implementation, so callers can fall back to an inline emulation or ignore it.
*
* Requires nodePath, driveRoot and appLoc in the caller's scope.
*/
function mockHookSource(hookValue) {
if (!hookValue) return null
let hook = String(hookValue).trim()
if (!hook) return null
// Reduce to the services-relative form, dropping any drive path or appLoc
// prefix the config may carry.
const idx = hook.indexOf('services/')
if (idx > -1) hook = hook.slice(idx)
// A physical hook is a .sas program on the server; its mock is a .js file
// sitting in the same place on the Drive.
hook = hook.replace(/\.sas$/i, '')
const hookFile = nodePath.resolve(driveRoot, 'files', appLoc, hook + '.js')
// The hook value is hand-edited mock config, and a value carrying '..'
// segments would otherwise resolve outside the Drive and be eval()'d
// in-service. Keep it inside the Drive's files tree.
const filesRoot = nodePath.resolve(driveRoot, 'files')
if (!hookFile.startsWith(filesRoot + nodePath.sep)) return null
if (!fs.existsSync(hookFile)) return null
return fs.readFileSync(hookFile, 'utf8')
}
/**
* Synthesises NOTNULL dqrules from the table schema, mirroring the
* dictionary.columns union in getdata.sas:
@@ -372,6 +460,60 @@ function sasVarsEntry(col) {
return { format: fmt, label: col.label || col.name, length: String(col.length), type: col.type === 'N' ? 'num' : 'char' }
}
/**
* Assigns the retained key (RK) to staged rows for a table registered with
* rk_underlying, mirroring %mp_retainedkey as %mpe_loader invokes it: any RK
* column in the input is dropped, and every row's RK is derived from its
* business key - the value that key already holds on the base table, or the
* next key value for a new one. Business keys are matched the way SAS compares
* them: case-sensitive, trailing blanks ignored.
*
* @param {Object} opts - { rows, tableReg, baseData }
* tableReg - the table's MPE_TABLES row (needs rk_underlying and buskey)
* baseData - { columns, rows } of the base table, for the key lookup
* @returns {String} the RK column name when the assignment ran, else ''
*/
function mpeAssignRetainedKey(opts) {
const { rows, tableReg, baseData } = opts
const rkUnderlying = tableReg && tableReg.rk_underlying
? String(tableReg.rk_underlying).trim()
: ''
const rkCol = tableReg && tableReg.buskey ? String(tableReg.buskey).trim() : ''
if (!rkUnderlying || !rkCol || !rows || rows.length === 0) return ''
const base = baseData || { columns: [], rows: [] }
const submitted = Object.keys(rows[0] || {}).find(
(k) => k.toUpperCase() === rkCol.toUpperCase()
)
const rkName = submitted ||
(base.columns.find((c) => c.name.toUpperCase() === rkCol.toUpperCase()) || {}).name ||
rkCol
const keys = rkUnderlying.split(/\s+/)
const keyValue = (value) => {
if (value === null || value === undefined) return ''
return typeof value === 'number' ? String(value) : String(value).replace(/\s+$/, '')
}
const businessKey = (row) => keys.map((k) => keyValue(colVal(row, k))).join('|')
const baseByKey = new Map()
let nextRk = 0
for (const row of base.rows) {
const rk = colVal(row, rkCol)
baseByKey.set(businessKey(row), rk)
const num = Number(rk)
if (isFinite(num) && num > nextRk) nextRk = num
}
for (const row of rows) {
Object.keys(row).forEach((k) => {
if (k.toUpperCase() === rkCol.toUpperCase()) delete row[k]
})
const existing = baseByKey.get(businessKey(row))
row[rkName] = existing === undefined || existing === null ? ++nextRk : existing
}
return rkName
}
/**
* Stages a submission: writes staged.json under staging/<tableId>/, copies the
* session audit items, and inserts the MPE_SUBMIT row. Shared by the
@@ -405,6 +547,12 @@ function stageSubmission(opts) {
// keep audit items from this Stored Program run alongside the staged data
copySessionAuditItems(stageFolder, 'submit')
// Files the SAS loader leaves in the approval folder, so the audit pack
// holds the same artefacts: the cleaned CSV and the uploaded file itself.
for (const file of opts.auditFiles || []) {
fs.writeFileSync(nodePath.resolve(stageFolder, file.name), file.content)
}
// Insert a record into MPE_SUBMIT (always in the control library /
// mpelib, regardless of which library the base table lives in)
const mpeDataDir = libDataDir('DC_JSLIB')
@@ -461,6 +609,146 @@ function copySessionAuditItems(stageFolder, prefix) {
}
}
// ─── %mp_streamfile + ODS package (zip) ───────────────────────────────────────
const ZIP_CRC_TABLE = (() => {
const table = new Array(256)
for (let i = 0; i < 256; i++) {
let c = i
for (let k = 0; k < 8; k++) c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1)
table[i] = c >>> 0
}
return table
})()
function zipCrc32(bytes) {
let crc = -1
for (let i = 0; i < bytes.length; i++)
crc = (crc >>> 8) ^ ZIP_CRC_TABLE[(crc ^ bytes[i]) & 0xff]
return (crc ^ -1) >>> 0
}
function zipUtf8(value) {
const text = String(value)
if (typeof TextEncoder !== 'undefined') return new TextEncoder().encode(text)
const out = []
for (let i = 0; i < text.length; i++) {
const code = text.charCodeAt(i)
if (code < 0x80) out.push(code)
else if (code < 0x800) out.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f))
else out.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f))
}
return Uint8Array.from(out)
}
/**
* Renders rows as CSV, the counterpart of %mp_ds2csv: the header row, then one
* line per row, with values quoted only when they carry a delimiter, quote or
* line break.
*
* @param {string[]} headers column names, in order
* @param {Array<Object>} rows objects keyed by column name
* @returns {string} CSV text with a trailing newline
*/
function toCsv(headers, rows) {
const cell = (value) => {
const text = value === undefined || value === null ? '' : String(value)
return /[",\n\r]/.test(text) ? '"' + text.replace(/"/g, '""') + '"' : text
}
const lines = [headers.map(cell).join(',')]
for (const row of rows) {
lines.push(headers.map((header) => cell(row[header])).join(','))
}
return lines.join('\n') + '\n'
}
/**
* Builds a zip archive in memory, entries stored rather than deflated - the JS
* counterpart of the ODS package getauditfile.sas publishes. The zip format
* leaves compression to the writer, so a stored archive opens anywhere.
*
* @param {Array<{name: string, content: string}>} entries archive entries
* @returns {Uint8Array} the archive
*/
function mpZipPackage(entries) {
const u16 = (n) => [n & 0xff, (n >>> 8) & 0xff]
const u32 = (n) => [n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, (n >>> 24) & 0xff]
const local = []
const central = []
let offset = 0
for (const entry of entries) {
const name = zipUtf8(entry.name)
const data = zipUtf8(entry.content)
const crc = zipCrc32(data)
// Bit 11 marks the name as UTF-8. Without it an extractor decodes a
// non-ASCII name as CP437, so the entry cannot be read back by name.
const flags = name.some((byte) => byte >= 0x80) ? 0x0800 : 0
// 1980-01-01 00:00, the earliest DOS timestamp: a stable value keeps
// the archive byte-identical for identical inputs.
const header = [].concat(
u32(0x04034b50), u16(20), u16(flags), u16(0), u16(0), u16(0x21),
u32(crc), u32(data.length), u32(data.length), u16(name.length), u16(0)
)
local.push(Uint8Array.from(header), name, data)
central.push({ name, crc, size: data.length, offset, flags })
offset += header.length + name.length + data.length
}
const directory = []
let directorySize = 0
for (const entry of central) {
const header = [].concat(
u32(0x02014b50), u16(20), u16(20), u16(entry.flags), u16(0), u16(0), u16(0x21),
u32(entry.crc), u32(entry.size), u32(entry.size),
u16(entry.name.length), u16(0), u16(0), u16(0), u16(0), u32(0),
u32(entry.offset)
)
directory.push(Uint8Array.from(header), entry.name)
directorySize += header.length + entry.name.length
}
const end = Uint8Array.from([].concat(
u32(0x06054b50), u16(0), u16(0),
u16(central.length), u16(central.length),
u32(directorySize), u32(offset), u16(0)
))
const chunks = local.concat(directory, [end])
const total = chunks.reduce((sum, chunk) => sum + chunk.length, 0)
const archive = new Uint8Array(total)
let at = 0
for (const chunk of chunks) {
archive.set(chunk, at)
at += chunk.length
}
return archive
}
/**
* Streams a file back as an attachment, the JS counterpart of %mp_streamfile on
* the SASJS platform: the headers name the content type and the body is the file
* itself. Returns false where that is not possible - the browser mock host has
* a text-only webout - so the caller can fall back to something textual.
*
* @param {{filename: string, contentType: string, bytes: Uint8Array}} opts
* @returns {boolean} whether the file was streamed
*/
function mpStreamfile(opts) {
if (typeof Buffer === 'undefined') return false
// A content-type header is what tells the SASjs Server to send webout.txt as
// binary rather than a string (api/src/controllers/internal/Execution.ts).
fs.writeFileSync(
_SASJS_WEBOUT_HEADERS,
`Content-type: ${opts.contentType} \n Content-Disposition: attachment;filename="${opts.filename}"`
)
fs.writeFileSync(weboutPath, Buffer.from(opts.bytes))
return true
}
/**
* Generates a DC table_id in the same format as the real backend
* (DC<yyyymmdd-hhmmss.sss>_<rand6>_<pid4>).
@@ -492,6 +780,7 @@ function makeTableId() {
* ('A','B') -> ["A","B"] (IN list)
* (1,2,3) -> [1,2,3] (IN list, numeric)
* 1 AND 5 -> [1, 5] (BETWEEN)
* '20DEC2053'd-> 34322 (date / datetime / time literal)
*/
function parseFilterRawValue(raw, operator) {
if (raw === undefined || raw === null || raw === '') return null
@@ -510,8 +799,40 @@ function parseFilterRawValue(raw, operator) {
return parseFilterScalar(s)
}
/**
* SAS date / datetime / time literal -> the SAS internal value, or null.
* 34322 <- '20DEC2053'd
* 42 <- '01JAN1960:00:00:42'dt
* 42 <- '00:00:42't
* The client builds these in canonical ddMMMyyyy form (HelperService
* .sasTemporalLiteral), so only that shape needs parsing here.
*/
const TEMPORAL_LITERAL_RE = /^'(\d{2})([A-Z]{3})(\d{4})(?::(\d{2}):(\d{2}):(\d{2})(\.\d+)?)?'(dt|d|t)$/i
/* A time literal carries no date part, so it is matched separately */
const TIME_LITERAL_RE = /^'(\d{2}):(\d{2}):(\d{2})(\.\d+)?'t$/i
function parseTemporalLiteral(s) {
const t = TIME_LITERAL_RE.exec(s)
if (t) {
return Number(t[1]) * 3600 + Number(t[2]) * 60 + Number(t[3]) +
(t[4] ? Number(t[4]) : 0)
}
const m = TEMPORAL_LITERAL_RE.exec(s)
if (!m) return null
const month = MONTHS_ABBR.indexOf(m[2].toUpperCase())
if (month < 0) return null
const days = (Date.UTC(Number(m[3]), month, Number(m[1])) - SAS_EPOCH_MS) / 86400000
const suffix = m[8].toLowerCase()
if (suffix === 'd') return days
const secs = Number(m[4]) * 3600 + Number(m[5]) * 60 + Number(m[6]) +
(m[7] ? Number(m[7]) : 0)
return suffix === 'dt' ? days * 86400 + secs : secs
}
function parseFilterScalar(s) {
s = s.trim()
const temporal = parseTemporalLiteral(s)
if (temporal !== null) return temporal
if (s.startsWith("'") && s.endsWith("'")) {
return s.slice(1, -1).replace(/''/g, "'")
}
@@ -1033,6 +1354,289 @@ function mpFilterStore(opts) {
}
}
// ─── mpe_derived.sas ────────────────────────────────────────────────────────
/**
* Compiles a SAS expression into a JS function - for the mock only.
*
* The real evaluation is done by SAS. This covers the subset used by the mock
* and demo configs, so the EDIT screen can be exercised (display, filtering,
* submission) without a SAS server:
*
* - column names, numbers, quoted strings
* - + - * / and comparisons (= ne < > <= >=)
* - AND OR, and `X IN (a, b, c)`
* - ifc(), cats(), catx(), upcase(), lowcase(), strip(), trim(), length(),
* substr(), index()
*
* Anything outside that subset throws when a row is derived, and the column is
* left missing for that row - the same way a failing SAS expression would.
*/
function compileSasExpression(expr, columnNames) {
// Tokenise first, so operators are only rewritten outside quoted strings
// (a literal such as 'OR' must never be read as an operator).
const tokens = []
const s = String(expr)
let i = 0
while (i < s.length) {
const c = s[i]
if (/\s/.test(c)) { i++; continue }
if (c === "'" || c === '"') {
const q = c
let j = i + 1
let val = ''
while (j < s.length) {
if (s[j] === q) {
if (s[j + 1] === q) { val += q; j += 2; continue }
break
}
val += s[j]
j++
}
tokens.push({ type: 'str', value: val })
i = j + 1
continue
}
if (/[0-9]/.test(c)) {
let j = i
while (j < s.length && /[0-9.]/.test(s[j])) j++
tokens.push({ type: 'num', value: s.slice(i, j) })
i = j
continue
}
if (/[A-Za-z_]/.test(c)) {
let j = i
while (j < s.length && /[A-Za-z0-9_]/.test(s[j])) j++
tokens.push({ type: 'word', value: s.slice(i, j) })
i = j
continue
}
const two = s.slice(i, i + 2)
if (['<=', '>=', '!=', '<>'].includes(two)) {
tokens.push({ type: 'punct', value: two })
i += 2
continue
}
// only the operators in the documented subset may reach the generated
// function - anything else is rejected rather than executed
if (!'+-*/(),<>='.includes(c)) {
throw new Error('Unsupported character in derived expression: ' + c)
}
tokens.push({ type: 'punct', value: c })
i++
}
// X IN (a, b, c) -> __in([a, b, c], X)
const out = []
for (let t = 0; t < tokens.length; t++) {
const tok = tokens[t]
if (
tok.type === 'word' &&
tok.value.toLowerCase() === 'in' &&
out.length > 0 &&
tokens[t + 1] &&
tokens[t + 1].value === '('
) {
let depth = 0
let j = t + 1
for (; j < tokens.length; j++) {
if (tokens[j].value === '(') depth++
else if (tokens[j].value === ')') {
depth--
if (depth === 0) break
}
}
if (j < tokens.length) {
const left = out.pop()
const inner = tokens.slice(t + 2, j)
out.push(
{ type: 'word', value: '__in' },
{ type: 'punct', value: '(' },
{ type: 'punct', value: '[' },
...inner,
{ type: 'punct', value: ']' },
{ type: 'punct', value: ',' },
left,
{ type: 'punct', value: ')' }
)
t = j
continue
}
}
out.push(tok)
}
const OPS = {
and: '&&', or: '||',
eq: '==', ne: '!=', lt: '<', gt: '>', le: '<=', ge: '>='
}
const js = out
.map(tok => {
if (tok.type === 'str') return JSON.stringify(tok.value)
if (tok.type === 'num') return tok.value
if (tok.type === 'word') return OPS[tok.value.toLowerCase()] || tok.value
if (tok.value === '=') return '=='
if (tok.value === '<>') return '!='
return tok.value
})
.join(' ')
const sasTrue = v => {
if (typeof v === 'boolean') return v
if (typeof v === 'number') return v !== 0 && !isNaN(v)
if (v === null || v === undefined) return false
const str = String(v).trim()
return str !== '' && str !== '0'
}
const toStr = v => {
if (v === null || v === undefined) return ''
if (typeof v === 'number') return isNaN(v) ? '' : String(v)
return String(v).trim()
}
const fns = {
ifc: (c, a, b) => (sasTrue(c) ? a : b),
cats: (...args) => args.map(toStr).join(''),
catx: (sep, ...args) => args.map(toStr).filter(v => v !== '').join(toStr(sep)),
upcase: v => toStr(v).toUpperCase(),
lowcase: v => toStr(v).toLowerCase(),
strip: v => toStr(v),
trim: v => toStr(v),
length: v => toStr(v).length,
substr: (v, p, n) => {
const str = toStr(v)
const start = Number(p) - 1
return n === undefined
? str.substring(start)
: str.substring(start, start + Number(n))
},
index: (v, sub) => toStr(v).indexOf(toStr(sub)) + 1,
__in: (list, v) => list.some(item => String(item) === String(v) || Number(item) === Number(v))
}
const names = Object.keys(fns)
const fn = new Function(...columnNames, ...names, 'return (' + js + ');')
return row => fn(...columnNames.map(n => row[n]), ...names.map(n => fns[n]))
}
/**
* Reads MPE_DERIVED for a table, mirroring %mpe_derived. Returns the active
* variables with a compiled row function, in dependency order (ties by name),
* the same sequence the real macro emits.
*
* @param {Object} opts
* @param {string} opts.libref - target libref
* @param {string} opts.table - target dataset
* @param {string} opts.dataDir - data directory of the DC control library
* @param {Array<Object>} opts.columns - physical columns of the target table
*/
function mpeDerived(opts) {
const { libref, table, dataDir, columns } = opts
const loadTableData = makeTableLoader(dataDir)
const cfg = loadTableData('MPE_DERIVED')
if (!cfg || !Array.isArray(cfg.rows) || cfg.rows.length === 0) return []
const now = Date.now() / 1000
const lib = String(libref || '').toUpperCase()
const dsn = String(table || '').toUpperCase()
const columnNames = (columns || []).map(c => c.name)
const vars = cfg.rows
.filter(r =>
String(colVal(r, 'LIBREF') || '').toUpperCase() === lib &&
String(colVal(r, 'DSN') || '').toUpperCase() === dsn &&
Number(colVal(r, 'ACTIVE')) === 1 &&
(!Number(colVal(r, 'TX_TO')) || Number(colVal(r, 'TX_TO')) > now)
)
.map(r => {
const logic = String(colVal(r, 'VAR_LOGIC') || '').trim()
const nm = String(colVal(r, 'VAR_NM') || '').toUpperCase()
return {
name: nm,
// every input the expression uses - columns and derived vars
deps: String(colVal(r, 'VAR_DEPS') || '')
.toUpperCase()
.split(/\s+/)
.filter(Boolean),
type: String(colVal(r, 'VAR_TYPE') || '').toUpperCase(),
length: Number(colVal(r, 'VAR_LEN')) || 8,
format: String(colVal(r, 'VAR_FMT') || ''),
logic,
label: String(colVal(r, 'VAR_LABEL') || '').trim() || nm + '=' + logic
}
})
.filter(d => d.name && (d.type === 'C' || d.type === 'N') && d.logic)
// dependency order: repeatedly take the variables whose derived inputs are
// already placed, alphabetically within a round
const byName = new Map(vars.map(v => [v.name, v]))
const placed = []
const done = new Set()
while (placed.length < vars.length) {
const ready = vars
.filter(v => !done.has(v.name))
.filter(v => v.deps.every(d => !byName.has(d) || done.has(d)))
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
if (ready.length === 0) {
console.log('derived variables for ' + lib + '.' + dsn + ' contain a cycle')
return []
}
for (const v of ready) {
placed.push(v)
done.add(v.name)
}
}
vars.length = 0
vars.push.apply(vars, placed)
// compile each against the physical columns plus the variables defined
// earlier, so a derived variable can build on another one
const compileCols = columnNames.slice()
for (const d of vars) {
try {
// slice(): the compiled function captures the column list it was
// built with, not the array as it grows
d.fn = compileSasExpression(d.logic, compileCols.slice())
} catch (err) {
console.log('derived variable ' + d.name + ' could not be compiled: ' + err.message)
d.fn = () => (d.type === 'N' ? null : '')
}
compileCols.push(d.name)
}
return vars
}
/**
* Adds the derived variables to every row and to the column list, so that the
* filter (which runs afterwards) and the grid both see them.
*/
function mpeDeriveRows(tableData, derived) {
if (!derived || derived.length === 0) return tableData
const rows = tableData.rows.map(row => {
const copy = Object.assign({}, row)
for (const d of derived) {
try {
copy[d.name] = d.fn(copy)
} catch (err) {
copy[d.name] = d.type === 'N' ? null : ''
}
}
return copy
})
const derivedCols = derived.map(d => ({
name: d.name,
type: d.type,
length: d.length,
format: d.format,
label: d.label,
notnull: false
}))
return {
name: tableData.name,
columns: (tableData.columns || []).concat(derivedCols),
rows
}
}
// ─── DC settings (services/settings.js) ──────────────────────────────────────
/**
@@ -1063,6 +1667,61 @@ function loadDcSettings(driveRoot, appLoc) {
return result
}
/**
* Reads the DC-scope options out of MPE_CONFIG, mirroring the loop in the real
* backend's generated settings.sas: only rows that are active (var_active=1)
* and current (now < tx_to) count, and the latest tx_from wins. Returns a map
* of var_name -> trimmed var_value.
*
* An option that is absent, or switched off, is simply missing from the map so
* the caller's own default applies - which is what the real service's
* %symexist fallback does (a switched-off option means "use the code default",
* not "no limit").
*
* Requires nodePath, fs and the caller's driveRoot/appLoc/dataDir.
*/
function loadDcConfig(driveRoot, appLoc, dataDir) {
const out = {}
try {
const configFile = nodePath.resolve(
dataDir || nodePath.resolve(driveRoot, 'files', appLoc, 'data', 'DC_JSLIB'),
'mpe_config.json'
)
const config = JSON.parse(fs.readFileSync(configFile, {encoding:'utf8'}).toString())
const now = Math.floor(Date.now() / 1000)
const latest = {}
for (const row of (config.rows || [])) {
// colVal, not row.var_name: a row that has been through the app's
// own edit and approve flow comes back from the adapter with
// upper-case keys, and a direct property read would skip it - which
// silently drops the option back to its default.
if (colVal(row, 'VAR_SCOPE') !== 'DC') continue
if (Number(colVal(row, 'VAR_ACTIVE')) !== 1) continue
if (Number(colVal(row, 'TX_TO')) <= now) continue
const name = String(colVal(row, 'VAR_NAME') || '').trim()
if (!name) continue
const from = Number(colVal(row, 'TX_FROM')) || 0
if (latest[name] === undefined || from > latest[name]) {
const val = colVal(row, 'VAR_VALUE')
latest[name] = from
out[name] = String(val == null ? '' : val).trim()
}
}
} catch(err) { /* no MPE_CONFIG - every option falls back to its default */ }
return out
}
/**
* A numeric DC option out of a loadDcConfig() map, or the service's own default
* when the option is absent, blank, or not a number.
*/
function dcConfigNumber(cfg, name, fallback) {
const raw = cfg ? cfg[name] : undefined
if (raw === undefined || raw === '') return fallback
const num = Number(raw)
return isNaN(num) ? fallback : num
}
// ─── %webout(OPEN/OBJ/CLOSE) emulation ───────────────────────────────────────
/**
@@ -1176,3 +1835,73 @@ function webOutSend(tables) {
}
webOutClose()
}
// ─── %mpeinit() emulation ────────────────────────────────────────────────────
/**
* The `_debug` values that mean "debug on", mirroring the test in mpeinit.sas.
*
* 131 is what the adapter sends - SASjsApiClient.executeJob() puts it on every
* server-mode request, and on the multipart form when the payload goes out as
* FormData. 128 is what arrives on the Viya WEB JES path when runAsTask is
* enabled, and 2477 / 'fields,log,trace' are the SASjs debug values.
*/
const MPEINIT_DEBUG_VALUES = ['2477', 'fields,log,trace', '131', '128']
/* Mirrors the &mpeinit=1 guard in the SAS macro: dump once per execution. */
let _mpeinitDone = false
/**
* Dumps the browser_url_vars and browser_info input tables, mirroring the
* debug block of %mpeinit (sas/sasjs/macros/mpeinit.sas).
*
* The SAS macro reads work.browser_url_vars (name/value pairs taken from the
* query string) and work.browser_info (the browser fingerprint). Both arrive
* here as input tables - see fetchRaw() - and are dumped with console.log,
* which SASjs Server returns in the request's log (after its
* SASJS_LOGS_SEPARATOR marker), so the dump shows up in Data Controller's
* SAS Log tab exactly as the SAS version does.
*
* Called at the bottom of this file, so the services that eval() it dump the
* tables at startup - the same place %mpeinit() runs in the SAS services.
* That covers every diagnostics-carrying service (startup, editors, auditors);
* the mocks that do not load this file (lineage, metanav, usernav, a few
* public ones) have no equivalent startup step in the SAS app either.
*
* Difference from the SAS version: the header line is printed once per table,
* where SAS repeats it for every row (its PUTLOG sits inside the SET loop).
*/
function mpeinit() {
if (_mpeinitDone) return
const debugValue = typeof _debug === 'undefined' ? '' : _debug
if (MPEINIT_DEBUG_VALUES.indexOf(String(debugValue)) < 0) return
_mpeinitDone = true
const urlVars = fetchRaw('browser_url_vars')
if (urlVars === null) {
console.log('NOTE: mpeinit: no work.browser_url_vars on this request')
} else {
console.log('NOTE: mpeinit: work.browser_url_vars:')
parseCsv(urlVars).forEach(row => {
console.log(
'name=' + colVal(row, 'name') + ' value=' + colVal(row, 'value')
)
})
}
const browserInfo = fetchRaw('browser_info')
if (browserInfo === null) {
console.log('NOTE: mpeinit: no work.browser_info on this request')
} else {
console.log('NOTE: mpeinit: work.browser_info:')
parseCsv(browserInfo).forEach(row => {
console.log(Object.keys(row).map(col => col + '=' + row[col]).join(' '))
})
}
}
/* Every service that eval()s this file runs %mpeinit() at startup, the same
place the SAS services call it. */
mpeinit()
+194 -31
View File
@@ -8,6 +8,28 @@ const dcLibref = 'DC_JSLIB'
// Load shared DC mock utilities
eval(fs.readFileSync(nodePath.resolve(driveRoot, 'files', appLoc, 'services', 'dcMockUtils.js'), 'utf8'))
// Mirrors SAS cats() for the values a dropdown source can hold: a special
// missing stored in its period form (".a") becomes the bare uppercase letter
// ("A") that cats() returns, so the mock's dropdown list matches the real one.
function cats(value) {
if (typeof value === 'string') {
const m = /^\.(_|[a-z])$/i.exec(value.trim())
if (m) return m[1].toUpperCase()
return value.trim()
}
return String(value)
}
/**
* SAS sort position of a special missing, or null when the value is ordinary.
* `._` sorts first, then `.a` to `.z` - all of them below every number.
*/
function missingRank(value) {
const m = /^\.(_|[a-z])$/i.exec(String(value).trim())
if (!m) return null
return m[1] === '_' ? 0 : m[1].toUpperCase().charCodeAt(0) - 64
}
// ─── Parse input ──────────────────────────────────────────────────────────────
const _sctRow = fetchTable('SASControlTable')[0] || {}
@@ -55,6 +77,42 @@ if (mpeTablesData && mpeTablesData.rows) {
tableReg = mpeTablesData.rows.find(r => r.libref === requestedLibref && r.dsn === requestedTable)
}
// The variables exposed to the editor as the primary key, matching getdata.sas:
// pk = coalesce(rk_underlying, buskey). A table registered with rk_underlying
// is keyed on its business key in the editor - the RK itself is assigned by the
// backend loader, so it is neither shown nor sent by the user.
const rkUnderlying = tableReg && tableReg.rk_underlying ? tableReg.rk_underlying.trim() : ''
const buskey = tableReg && tableReg.buskey ? tableReg.buskey.trim() : ''
const pkFields = rkUnderlying || buskey
const pkColumns = pkFields ? pkFields.split(/\s+/) : []
// Order columns with the PK variables first, in PK order, then the remaining
// columns in schema order. getdata.sas does the same ("order delete var and pk
// fields at start of table") and the client reads the first PKCNT columns
// positionally when it detects duplicate keys.
function pkFirst(columns, keys) {
const rank = new Map(keys.map((name, i) => [name.toUpperCase(), i]))
const keyColumns = columns
.filter(col => rank.has(col.name.toUpperCase()))
.sort((a, b) => rank.get(a.name.toUpperCase()) - rank.get(b.name.toUpperCase()))
return keyColumns.concat(columns.filter(col => !rank.has(col.name.toUpperCase())))
}
// ─── Derived (computed) variables (mpe_derived.sas) ─────────────────────────
// Applied before the filter, so a filter can reference them. The derived
// columns are added to the schema too, which is what puts them in COLS and in
// the grid; they are held read-only by a READONLY rule below.
const derived = mpeDerived({
libref: requestedLibref,
table: requestedTable,
dataDir: mpeDataDir,
columns: tableData ? tableData.columns : []
})
if (tableData && derived.length > 0) {
tableData = mpeDeriveRows(tableData, derived)
}
// ─── DQ rules (from MPE_VALIDATIONS + NOTNULL from schema) ──────────────────
// Mirrors getdata.sas: dqrules = MPE_VALIDATIONS rows UNION dictionary.columns
// NOTNULL constraints. MPE_VALIDATIONS lives in the control library.
@@ -63,10 +121,7 @@ const validationsData = mpeLoadTableData('MPE_VALIDATIONS')
let dqrules = []
let dqdata = []
if (validationsData && validationsData.rows) {
const pkCols = new Set()
if (tableReg && tableReg.buskey) {
tableReg.buskey.trim().split(/\s+/).forEach(c => pkCols.add(c.toUpperCase()))
}
const pkCols = new Set(pkColumns.map(c => c.toUpperCase()))
dqrules = validationsData.rows
.filter(r => r.base_lib === requestedLibref && r.base_ds === requestedTable)
.map(r => ({
@@ -105,6 +160,16 @@ if (tableData && tableData.columns) {
}
}
// A derived variable is computed at read time, so the grid must not accept a
// value for it. COLS carries READ for the same reason (a derived column has no
// CLS rule row), but the client only applies COLS.CLS_RULE when CLS_FLAG is
// set, which column-level security drives - so the rule is declared here too,
// as getdata.sas does. dqrules is the request-local array the filter/map above
// built, so appending to it leaves the loaded MPE_VALIDATIONS rows untouched.
for (const v of derived) {
dqrules.push({ BASE_COL: v.name, RULE_TYPE: 'READONLY', RULE_VALUE: '' })
}
// ─── DQ dropdown data (from MPE_SELECTBOX + SOFTSELECT from table data) ──────
// MPE_SELECTBOX lives in the control library.
@@ -130,7 +195,7 @@ if (tableData && tableData.rows && tableData.columns) {
const colName = parts[parts.length - 1]
const lcName = colName.toLowerCase()
const seen = new Set()
let order = 1
const values = []
for (const row of tableData.rows) {
let val = row[colName]
if (val === undefined) val = row[lcName]
@@ -139,19 +204,38 @@ if (tableData && tableData.rows && tableData.columns) {
if (key) val = row[key]
}
if (val !== undefined && val !== null) {
const strVal = String(val)
const strVal = cats(val)
if (!seen.has(strVal)) {
seen.add(strVal)
dqdata.push({ BASE_COL: rule.BASE_COL, RULE_VALUE: rule.RULE_VALUE, RULE_DATA: strVal, SELECTBOX_ORDER: order++ })
values.push({ raw: val, str: strVal })
}
}
}
// getdata.sas orders the source by the column itself, and a special
// missing sorts below every number - so the list reads `._`, `.a`-`.z`,
// then the numbers ascending.
values.sort((a, b) => {
const ra = missingRank(a.raw)
const rb = missingRank(b.raw)
if (ra !== null && rb !== null) return ra - rb
if (ra !== null) return -1
if (rb !== null) return 1
const na = Number(a.str)
const nb = Number(b.str)
if (!isNaN(na) && !isNaN(nb)) return na - nb
return a.str < b.str ? -1 : a.str > b.str ? 1 : 0
})
values.forEach((v, i) => {
dqdata.push({ BASE_COL: rule.BASE_COL, RULE_VALUE: rule.RULE_VALUE, RULE_DATA: v.str, SELECTBOX_ORDER: i + 1 })
})
}
}
// ─── Build response ──────────────────────────────────────────────────────────
let response
// Set when the row or cell limit cut the selection down - mirrors the
// TRUNCATED / TRUNC_MSG in sasparams in getdata.sas.
if (tableData && tableData.columns && tableData.rows) {
// Exclude temporal columns (TX_FROM/TX_TO etc.) from the editor view
@@ -164,9 +248,18 @@ if (tableData && tableData.columns && tableData.rows) {
if (tableReg.var_busfrom) excludeCols.add(tableReg.var_busfrom.toUpperCase())
if (tableReg.var_busto) excludeCols.add(tableReg.var_busto.toUpperCase())
}
// getdata.sas drops the RK field from the editor view when the table is
// registered with rk_underlying (drop_rk=&buskey), and exposes the business
// key instead.
if (rkUnderlying && buskey) {
buskey.split(/\s+/).forEach(c => excludeCols.add(c.toUpperCase()))
}
const visibleColumns = tableData.columns.filter(c => !excludeCols.has(c.name.toUpperCase()))
const visibleRows = tableData.rows
let visibleColumns = pkFirst(
tableData.columns.filter(c => !excludeCols.has(c.name.toUpperCase())),
pkColumns
)
let visibleRows = tableData.rows
.filter(r => filterPredicate(r))
.map(r => {
const copy = {}
@@ -176,6 +269,68 @@ if (tableData && tableData.columns && tableData.rows) {
return copy
})
// ─── PRE_EDIT_HOOK ───────────────────────────────────────────────────────
// Mirrors getdata.sas: %mpe_runhook(PRE_EDIT_HOOK) runs after the filter has
// been applied and the rows sorted, with the data in work.OUT, and may
// replace it. The mock eval()s the hook's .js counterpart in this scope, so
// the hook may reassign visibleRows / visibleColumns - e.g. to show the live
// rows of another table behind an empty mirror.
if (tableReg && tableReg.pre_edit_hook) {
const hookSrc = mockHookSource(tableReg.pre_edit_hook)
if (hookSrc) {
try {
eval(hookSrc)
} catch (err) {
console.log('Error running pre_edit_hook ' + tableReg.pre_edit_hook + ': ' + err.message)
}
}
}
// ─── Row and cell limits ─────────────────────────────────────────────────
// Mirrors getdata.sas: DC_MAXOBS_WEBEDIT rows or DC_MAXCELLS_WEBEDIT
// cells (rows x columns), whichever is reached first - the selection is
// cut to min(rows, cells/columns) and flagged in sasparams.
// Both options are read from MPE_CONFIG, the way the real service picks
// them up from the settings program it generates - so editing the option
// in DC changes what the mock serves, and an option that is absent (or
// switched off, var_active=0) falls back to the shipped default. The
// check runs after the PRE_EDIT_HOOK, as the single check in getdata.sas
// does - a hook may replace the data with a larger table.
// MPE_CONFIG lives in the control library, not in the table's own library,
// so this reads mpeDataDir - the same directory the MPE_TABLES lookup above
// uses. Passing the requested table's dataDir made the read fail for every
// non-control libref, and the catch then fell back to the shipped defaults.
const dcCfg = loadDcConfig(driveRoot, appLoc, mpeDataDir)
const maxObsWebEdit = dcConfigNumber(dcCfg, 'DC_MAXOBS_WEBEDIT', 250)
const maxCellsWebEdit = dcConfigNumber(dcCfg, 'DC_MAXCELLS_WEBEDIT', 200000)
// getdata.sas counts the columns of work.out, i.e. the table's own
// columns - the delete column is client-owned and not part of it.
const editColCount = visibleColumns.length
let maxRows = maxObsWebEdit
let limitVar = 'DC_MAXOBS_WEBEDIT'
if (editColCount > 0) {
const cellRows = Math.floor(maxCellsWebEdit / editColCount)
if (cellRows < maxRows) {
maxRows = cellRows
limitVar = 'DC_MAXCELLS_WEBEDIT'
}
}
if (maxRows < 1) maxRows = 1
let truncated = 0
let truncMsg = ''
if (visibleRows.length > maxRows) {
truncated = 1
// Same wording as the macro getdata.sas sets, so the spec can assert
// on the text the real service would send.
truncMsg =
'Only the first ' +
maxRows +
' rows are loaded - the ' +
limitVar +
' limit has been reached. Filter the table to work with the rest.'
visibleRows = visibleRows.slice(0, maxRows)
}
// Augment rows: add delete flag, normalise keys, convert temporal values to ISO
const colLookup = {}
for (const col of visibleColumns) {
@@ -188,16 +343,16 @@ if (tableData && tableData.columns && tableData.rows) {
const targetKey = info ? info.name : key
normalised[targetKey] = info ? formatCellValue(r[key], info.ddtype) : r[key]
}
return { _____DELETE__THIS__RECORD_____: 'No', ...normalised }
return { ...normalised }
})
// $sasdata vars: temporal columns are char ($200.), others keep their SAS type
const vars = { _____DELETE__THIS__RECORD_____: { format: '$3.', label: '_____DELETE__THIS__RECORD_____', length: '3', type: 'char' } }
const vars = {}
for (const col of visibleColumns) {
vars[col.name] = sasVarsEntry(col)
}
const colHeaders = ['_____DELETE__THIS__RECORD_____', ...visibleColumns.map(c => c.name)]
const colHeaders = visibleColumns.map(c => c.name)
// Determine DTVARS, DTTMVARS, TMVARS from column formats
let dtVars = [], dttmVars = [], tmVars = []
@@ -208,22 +363,25 @@ if (tableData && tableData.columns && tableData.rows) {
else if (ddtype === 'TIME') tmVars.push(col.name)
}
// Build cols array
const cols = visibleColumns.map(col => {
const ddtype = getDdType(col)
const fmtname = col.format
? col.format.replace(/[\d.]+$/, '').replace('datetime', 'DATETIME').replace('date', 'DATE').replace('time', 'TIME').replace('best', 'BEST').replace('E8601DT', 'DATETIME')
: ' '
// Build cols array. Every column of the table, as getdata.sas emits them:
// the temporal columns are dropped from the data (the rows below) but not
// from the cols payload, so a filter can still be built on them. mpGetcols
// is the JS counterpart of %mp_getcols.sas - the macro getdata.sas itself
// calls to type these columns - so the editor sees the same DDTYPE the
// service would give it.
const cols = mpGetcols(tableData.columns).map((c, i) => {
const raw = tableData.columns[i]
const ddtype = c.DDTYPE === 'CHARACTER' ? 'C' : c.DDTYPE === 'NUMERIC' ? 'N' : c.DDTYPE
let coltype
if (ddtype === 'DATE') coltype = `{"data":"${col.name}","type":"date"}`
else if (ddtype === 'DATETIME') coltype = `{"data":"${col.name}","type":"datetime"}`
else if (ddtype === 'TIME') coltype = `{"data":"${col.name}","type":"time"}`
else if (ddtype === 'N') coltype = `{"data":"${col.name}","type":"numeric","format":"0"}`
else coltype = `{"data":"${col.name}"}`
if (ddtype === 'DATE') coltype = `{"data":"${raw.name}","type":"date"}`
else if (ddtype === 'DATETIME') coltype = `{"data":"${raw.name}","type":"datetime"}`
else if (ddtype === 'TIME') coltype = `{"data":"${raw.name}","type":"time"}`
else if (ddtype === 'N') coltype = `{"data":"${raw.name}","type":"numeric","format":"0"}`
else coltype = `{"data":"${raw.name}"}`
return {
NAME: col.name,
LABEL: col.label || col.name,
FMTNAME: fmtname || ' ',
NAME: c.NAME,
LABEL: c.LABEL,
FMTNAME: c.FMTNAME || ' ',
DDTYPE: ddtype,
CLS_RULE: 'READ',
MEMLABEL: ' ',
@@ -235,7 +393,6 @@ if (tableData && tableData.columns && tableData.rows) {
// Build maxvarlengths
const maxvarlengths = [
{ NAME: '_____DELETE__THIS__RECORD_____', MAXLEN: 3 },
...visibleColumns.map(col => {
let maxLen = 0
const lcName = col.name.toLowerCase()
@@ -269,15 +426,21 @@ if (tableData && tableData.columns && tableData.rows) {
sasparams: [{
COLHEADERS: colHeaders.join(','),
FILTER_TEXT: filterText === '' ? ' ' : filterText,
PKCNT: tableReg && tableReg.buskey ? tableReg.buskey.trim().split(/\s+/).length : 0,
PK: tableReg ? tableReg.buskey || '' : '',
PKCNT: pkColumns.length,
PK: pkFields,
DTVARS: dtVars.length ? ' ' + dtVars.join(' ') : '',
DTTMVARS: dttmVars.length ? ' ' + dttmVars.join(' ') : '',
TMVARS: tmVars.length ? ' ' + tmVars.join(' ') : '',
LOADTYPE: tableReg ? tableReg.loadtype || 'UPDATE' : 'UPDATE',
RK_FLAG: tableReg && tableReg.rk_underlying ? 1 : 0,
CLS_FLAG: 0,
ISMAP: 0
ISMAP: 0,
TRUNCATED: truncated,
TRUNC_MSG: truncMsg,
// names the derived columns for the grid, as getdata.sas does - the
// READONLY rule above is why they cannot be edited, this is how the
// EDIT screen knows they are computed rather than locked
DERIVEDVARS: derived.map(d => d.name).join(' ')
}],
versions: [],
xl_rules: []
@@ -292,7 +455,7 @@ if (tableData && tableData.columns && tableData.rows) {
],
maxvarlengths: [], query: [], sasdata: [],
$sasdata: { vars: {} },
sasparams: [{ COLHEADERS: '', FILTER_TEXT: ' ', PKCNT: 0, PK: '', DTVARS: '', DTTMVARS: '', TMVARS: '', LOADTYPE: 'UPDATE', RK_FLAG: 0, CLS_FLAG: 0, ISMAP: 0 }],
sasparams: [{ COLHEADERS: '', FILTER_TEXT: ' ', PKCNT: 0, PK: '', DTVARS: '', DTTMVARS: '', TMVARS: '', LOADTYPE: 'UPDATE', RK_FLAG: 0, CLS_FLAG: 0, ISMAP: 0, TRUNCATED: 0, TRUNC_MSG: '', DERIVEDVARS: '' }],
versions: [], xl_rules: []
}
}
+66 -4
View File
@@ -59,8 +59,11 @@ for (let i = 1; i <= 10; i++) {
let libds = ''
if (typeof table !== 'undefined' && table) libds = String(table).toUpperCase()
const libref = libds.split('.')[0] || dcLibref
const dsn = libds.split('.')[1] || ''
// captured before any hook can re-point the submission: the cleaned CSV is
// named after the original table, as loadfile.sas names it
const origLibds = libds
let libref = libds.split('.')[0] || dcLibref
let dsn = libds.split('.')[1] || ''
// ─── Validate (mirrors the mp_abort checks in loadfile.sas) ─────────────────
@@ -147,6 +150,12 @@ if (!msg) {
if (tableEntry.var_txfrom) computedCols.push(tableEntry.var_txfrom.toUpperCase())
if (tableEntry.var_txto) computedCols.push(tableEntry.var_txto.toUpperCase())
if (tableEntry.var_processed) computedCols.push(tableEntry.var_processed.toUpperCase())
// loadfile.sas drops the RK from the comparison for a table
// with rk_underlying (the loader derives it), so an upload
// for one legitimately omits it.
if (tableEntry.rk_underlying && tableEntry.buskey) {
computedCols.push(String(tableEntry.buskey).toUpperCase())
}
}
}
const baseCols = schema.map((c) => c.name.toUpperCase())
@@ -167,8 +176,56 @@ if (!msg) {
}
if (!msg) {
// ─── POST_EDIT_HOOK ──────────────────────────────────────────────────
// Mirrors mpe_loader.sas: the hook runs before the MPE_SUBMIT record is
// written, while LIBREF / DS are still ordinary macro variables, so it
// can re-point the changeset at a different table. The mock eval()s the
// hook's .js counterpart in this scope so it can reassign libref / dsn.
// A validating hook rejects the submission by setting hookErrmsg (see
// hooks/mpe_derived_postedit.js), which stops the staging below.
let hookErrmsg = ''
const hookTables = mpeLoadTableData('MPE_TABLES')
const hookReg = (hookTables && hookTables.rows)
? hookTables.rows.find(r => r.libref === libref && r.dsn === dsn)
: null
if (hookReg && hookReg.post_edit_hook) {
const hookSrc = mockHookSource(hookReg.post_edit_hook)
if (hookSrc) {
// a hook reads and normalises the submitted rows as jsDataRows
// (stagedata.js names them that); here they are `rows`
const jsDataRows = rows
try {
eval(hookSrc)
} catch (err) {
// a hook that throws has not validated anything, so the
// submission is refused rather than staged unchecked
hookErrmsg =
'post_edit_hook ' + hookReg.post_edit_hook + ' failed: ' + err.message
}
libds = libref + '.' + dsn
}
}
if (hookErrmsg) msg = hookErrmsg
tableId = makeTableId()
stageSubmission({
// ─── RK assignment (mpe_loader) ──────────────────────────────────────
// The uploaded file carries the business key and no RK (see the
// expected-columns check above), so the loader derives it before the
// rows are staged.
const finalTables = mpeLoadTableData('MPE_TABLES')
const finalReg =
finalTables && finalTables.rows
? finalTables.rows.find((r) => r.libref === libref && r.dsn === dsn)
: null
const rkName = mpeAssignRetainedKey({
rows,
tableReg: finalReg,
baseData: makeTableLoader(libDataDir(libref))(dsn)
})
if (rkName && !headers.some((h) => h.toUpperCase() === rkName.toUpperCase())) {
headers.push(rkName)
}
if (!msg) stageSubmission({
dataDir: libDataDir(libref),
stagingDir,
tableId,
@@ -177,7 +234,12 @@ if (!msg) {
dsn,
message: 'File upload: ' + csvName,
headers,
rows
rows,
// loadfile.sas leaves the cleaned CSV (%mp_cleancsv) in the approval
// folder, named after the table as the request found it. It copies
// the upload as BKP_<name> only when a second, non-CSV fileref came
// with the request, which the mock does not accept - so no BKP here.
auditFiles: [{ name: origLibds + '.csv', content: csvText }]
})
}
}
+89 -5
View File
@@ -20,8 +20,11 @@ const _sctRow = fetchTable('SASControlTable')[0] || {}
let action = _sctRow.ACTION || 'LOAD'
let message = _sctRow.MESSAGE || ''
let libds = _sctRow.LIBDS || ''
const libref = libds.split('.')[0] || dcLibref
const dsn = libds.split('.')[1] || ''
let libref = libds.split('.')[0] || dcLibref
let dsn = libds.split('.')[1] || ''
// stagedata.sas names the CSV it stages after the table as the request found
// it, before a hook can re-point the submission
const origLibds = libds
// The base table lives in its own library (DC_JSLIB for control tables,
// TESTDATA for demo user tables); the staging dir stays in the control lib.
@@ -56,6 +59,79 @@ if (schema.length > 0) {
})
}
// ─── POST_EDIT_HOOK ──────────────────────────────────────────────────────────
// Mirrors mpe_loader.sas: %mpe_runhook(POST_EDIT_HOOK) runs before the MPE_SUBMIT
// record is written, while LIBREF / DS are still ordinary macro variables - which
// is what lets a hook re-point a changeset at a different table. The mock
// eval()s the hook's .js counterpart in this scope so it can reassign
// libref / dsn / libds; the submit record then names the new base table, exactly
// as the SAS hook does via call symputx.
// A validating hook rejects the submission by setting hookErrmsg (see
// hooks/mpe_derived_postedit.js); the response below turns it into an abort,
// and nothing is staged.
let hookErrmsg = ''
const hookTables = makeTableLoader(mpeDataDir)('MPE_TABLES')
const hookReg = (hookTables && hookTables.rows)
? hookTables.rows.find(r => r.libref === libref && r.dsn === dsn)
: null
if (hookReg && hookReg.post_edit_hook) {
const hookSrc = mockHookSource(hookReg.post_edit_hook)
if (hookSrc) {
try {
eval(hookSrc)
} catch (err) {
// a hook that throws has not validated anything, so the submission
// is refused rather than staged unchecked
hookErrmsg =
'post_edit_hook ' + hookReg.post_edit_hook + ' failed: ' + err.message
}
libds = libref + '.' + dsn
}
}
// ─── RK assignment (mpe_loader) ──────────────────────────────────────────────
// A table registered with rk_underlying is edited on its business key and the
// RK column is withheld from the editor (see getdata.js), so the submitted rows
// carry no RK. The loader derives it, and MPE_SUBMIT records the staged width
// - which includes the derived column.
const finalTables = makeTableLoader(mpeDataDir)('MPE_TABLES')
const finalReg =
finalTables && finalTables.rows
? finalTables.rows.find((r) => r.libref === libref && r.dsn === dsn)
: null
const rkName = mpeAssignRetainedKey({
rows: jsDataRows,
tableReg: finalReg,
baseData: loadTableData(dsn)
})
if (rkName && !jsDataHeaders.some((h) => h.toUpperCase() === rkName.toUpperCase())) {
jsDataHeaders.push(rkName)
}
// ─── Derived variables ───────────────────────────────────────────────────────
// stagedata.sas drops the MPE_DERIVED droplist from the submitted data before
// anything is staged (they are display-only), and the approval CSV is written
// from that stripped dataset - so neither the staged rows nor the pack may
// carry them.
const derivedVars = mpeDerived({
libref,
table: dsn,
dataDir: mpeDataDir,
columns: schema
})
if (derivedVars.length > 0) {
const derivedNames = new Set(derivedVars.map((d) => d.name.toUpperCase()))
const keep = (key) => !derivedNames.has(key.toUpperCase())
jsDataHeaders = jsDataHeaders.filter(keep)
jsDataRows = jsDataRows.map((row) => {
const copy = {}
for (const key of Object.keys(row)) if (keep(key)) copy[key] = row[key]
return copy
})
}
// ─── Stage the data ──────────────────────────────────────────────────────────
// One subfolder per submission (DSID) under the staging directory, so that the
// staged data can sit alongside related artifacts (submit/approval logs,
@@ -63,7 +139,7 @@ if (schema.length > 0) {
const tableId = makeTableId()
stageSubmission({
if (!hookErrmsg) stageSubmission({
dataDir,
stagingDir,
tableId,
@@ -72,9 +148,17 @@ stageSubmission({
dsn,
message,
headers: jsDataHeaders,
rows: jsDataRows
rows: jsDataRows,
// stagedata.sas writes the staged rows as <orig_libds>.csv alongside them
// (%mp_ds2csv into the approval folder), so the audit pack carries it
auditFiles: [{ name: origLibds + '.csv', content: toCsv(jsDataHeaders, jsDataRows) }]
})
webOutOpen()
webOutObj([{ STATUS: 'SUCCESS', DSID: tableId, URL: '' }], 'sasparams')
if (hookErrmsg) {
webOutObj([{ MSG: hookErrmsg, MAC: 'stagedata' }], 'sasjsAbort')
webOutObj([{ STATUS: 'ERROR', DSID: '' }], 'sasparams')
} else {
webOutObj([{ STATUS: 'SUCCESS', DSID: tableId, URL: '' }], 'sasparams')
}
webOutClose()
Loaded 100 of 171 files, more files were not shown because too many files have changed in this diff. Show more