@genesislcap/mock-server 15.73.0 → 15.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +296 -58
- package/dist/db/schema.d.ts +9 -1
- package/dist/db/schema.js +40 -11
- package/dist/db/store.d.ts +1 -0
- package/dist/db/store.js +4 -0
- package/dist/handlers/auth.d.ts +15 -6
- package/dist/handlers/auth.js +152 -33
- package/dist/handlers/commitEvent.js +43 -20
- package/dist/handlers/crudEvents.d.ts +3 -1
- package/dist/handlers/crudEvents.js +3 -2
- package/dist/handlers/eventValidation.js +6 -3
- package/dist/handlers/http.d.ts +2 -2
- package/dist/handlers/http.js +66 -43
- package/dist/handlers/jsonSchema.d.ts +1 -0
- package/dist/handlers/jsonSchema.js +72 -21
- package/dist/handlers/meta.d.ts +1 -1
- package/dist/handlers/meta.js +59 -10
- package/dist/handlers/requestReply.js +36 -9
- package/dist/index.d.ts +1 -1
- package/dist/presets/auth.d.ts +25 -0
- package/dist/presets/auth.js +855 -0
- package/dist/presets/cronExpression.d.ts +1 -0
- package/dist/presets/cronExpression.js +429 -0
- package/dist/presets/fileServer.d.ts +13 -0
- package/dist/presets/fileServer.js +399 -0
- package/dist/presets/gsf.d.ts +24 -0
- package/dist/presets/gsf.js +450 -0
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +1 -0
- package/dist/presets/javaTime.d.ts +7 -0
- package/dist/presets/javaTime.js +322 -0
- package/dist/presets/multipart.d.ts +14 -0
- package/dist/presets/multipart.js +91 -0
- package/dist/presets/notify.d.ts +27 -0
- package/dist/presets/notify.js +250 -0
- package/dist/presets/notifyDispatch.d.ts +28 -0
- package/dist/presets/notifyDispatch.js +570 -0
- package/dist/presets/notifyRules.d.ts +9 -0
- package/dist/presets/notifyRules.js +754 -0
- package/dist/presets/platform/backing.json +8058 -217
- package/dist/presets/platform/criteria-model.json +362 -0
- package/dist/presets/platform/time-zones.json +608 -0
- package/dist/presets/platform.d.ts +7 -0
- package/dist/presets/platform.js +145 -103
- package/dist/presets/products.d.ts +9 -7
- package/dist/presets/products.js +89 -21
- package/dist/presets/reconciliation.d.ts +18 -0
- package/dist/presets/reconciliation.js +721 -0
- package/dist/presets/reporting.d.ts +14 -0
- package/dist/presets/reporting.js +862 -0
- package/dist/protocol/connection.d.ts +2 -0
- package/dist/protocol/connection.js +4 -0
- package/dist/protocol/dtoTypes.d.ts +30 -0
- package/dist/protocol/dtoTypes.js +250 -0
- package/dist/protocol/errors.d.ts +3 -1
- package/dist/protocol/errors.js +2 -0
- package/dist/protocol/fieldTypes.js +5 -0
- package/dist/protocol/router.d.ts +1 -0
- package/dist/protocol/router.js +3 -3
- package/dist/protocol/schemaValidation.d.ts +1 -1
- package/dist/protocol/schemaValidation.js +53 -8
- package/dist/server.js +34 -2
- package/dist/types.d.ts +50 -2
- package/package.json +1 -1
- package/src/db/schema.ts +56 -13
- package/src/db/store.ts +5 -0
- package/src/handlers/auth.ts +211 -37
- package/src/handlers/commitEvent.ts +44 -19
- package/src/handlers/crudEvents.ts +9 -2
- package/src/handlers/eventValidation.ts +6 -3
- package/src/handlers/http.ts +83 -42
- package/src/handlers/jsonSchema.ts +86 -23
- package/src/handlers/meta.ts +77 -9
- package/src/handlers/requestReply.ts +42 -6
- package/src/index.ts +7 -0
- package/src/presets/auth.ts +961 -0
- package/src/presets/cronExpression.ts +445 -0
- package/src/presets/fileServer.ts +475 -0
- package/src/presets/gsf.ts +475 -0
- package/src/presets/index.ts +5 -0
- package/src/presets/javaTime.ts +354 -0
- package/src/presets/multipart.ts +110 -0
- package/src/presets/notify.ts +312 -0
- package/src/presets/notifyDispatch.ts +685 -0
- package/src/presets/notifyRules.ts +866 -0
- package/src/presets/platform/backing.json +8058 -217
- package/src/presets/platform/criteria-model.json +362 -0
- package/src/presets/platform/time-zones.json +608 -0
- package/src/presets/platform.ts +204 -115
- package/src/presets/products.ts +125 -19
- package/src/presets/reconciliation.ts +824 -0
- package/src/presets/reporting.ts +953 -0
- package/src/protocol/connection.ts +4 -0
- package/src/protocol/dtoTypes.ts +310 -0
- package/src/protocol/errors.ts +13 -1
- package/src/protocol/fieldTypes.ts +5 -0
- package/src/protocol/router.ts +3 -3
- package/src/protocol/schemaValidation.ts +61 -8
- package/src/server.ts +38 -2
- package/src/types.ts +147 -3
package/README.md
CHANGED
|
@@ -87,9 +87,10 @@ covers the server-side behaviors real projects lean on:
|
|
|
87
87
|
- **Computed request-replies** — for request servers that calculate rather
|
|
88
88
|
than read (date calculations, holiday validate/roll, premium schedules,
|
|
89
89
|
keyed composite lookups), give the `RequestReplyDef` a `resolver` instead
|
|
90
|
-
of a `source`. It receives `{ request, message, user, store }` (the
|
|
91
|
-
`REQUEST` fields, the raw message, the requesting user, the live store
|
|
92
|
-
returns the `REPLY` rows verbatim;
|
|
90
|
+
of a `source`. It receives `{ request, message, user, store, config }` (the
|
|
91
|
+
keyed `REQUEST` fields, the raw message, the requesting user, the live store,
|
|
92
|
+
the server's config as it is then) and returns the `REPLY` rows verbatim;
|
|
93
|
+
throw `NackError` for a
|
|
93
94
|
protocol-correct error (a `MSG_NACK`; see
|
|
94
95
|
[Request servers](#request-servers-req_)). Set `metadataRows` (a
|
|
95
96
|
representative sample reply) so `META_REQUEST` can still derive
|
|
@@ -408,6 +409,10 @@ should run its checks and return before writing when `ctx.validate` is set
|
|
|
408
409
|
rolls back anything it writes anyway (see
|
|
409
410
|
[Commit semantics](#commit-semantics-validate-warnings-and-ignore_warnings)).
|
|
410
411
|
|
|
412
|
+
**`ctx.config`** is the server's whole config as the event finds it (the audit
|
|
413
|
+
tables it derives included), for a handler that depends on what else the
|
|
414
|
+
server holds: a table's unique indexes, the request servers it reads.
|
|
415
|
+
|
|
411
416
|
**An `eventHandlers` entry of the same name wins**, so a table can list all
|
|
412
417
|
three verbs and still write out the one with business rules.
|
|
413
418
|
`getEventHandler(name)` returns the generic handler when there is no entry, so
|
|
@@ -498,6 +503,19 @@ warns): `test/commitSemantics.test.ts` follows the Kotlin.
|
|
|
498
503
|
writes stay whatever it replies), warnings always NACK (in `ERROR`), and
|
|
499
504
|
`ctx.ignoreWarnings` is always `false`.
|
|
500
505
|
|
|
506
|
+
State a handler keeps outside the store, which a rollback can't undo, changes
|
|
507
|
+
through `ctx.afterCommit(callback)`: the callback runs once the event has
|
|
508
|
+
committed, before its `EVENT_ACK` goes out, and never when the event NACKs or
|
|
509
|
+
only validates (at once under `fidelity: 'legacy'`). A failing one is logged.
|
|
510
|
+
The platform preset keeps its users' passwords this way.
|
|
511
|
+
|
|
512
|
+
A typed GSF handler whose reply isn't an `EventReply` (`eventHandler<In, Out>`,
|
|
513
|
+
e.g. auth's `CreateMfaSecretAck`) answers with its own message: return
|
|
514
|
+
`{ reply: { MESSAGE_TYPE: 'CREATE_MFA_SECRET_ACK', ... } }`, sent as it is in
|
|
515
|
+
place of the `EVENT_ACK` (under `VALIDATE` too, so return the validate reply
|
|
516
|
+
then), and throw `new NackError(errors, { messageType: '..._NACK' })` for its
|
|
517
|
+
NACK.
|
|
518
|
+
|
|
501
519
|
## Audit tables (`TableDef.audit`)
|
|
502
520
|
|
|
503
521
|
A table declared with `audit = details(id = …, sequence = "TA")` in the
|
|
@@ -618,8 +636,8 @@ What it provides:
|
|
|
618
636
|
|
|
619
637
|
| Piece | From |
|
|
620
638
|
| --- | --- |
|
|
621
|
-
| `auth.
|
|
622
|
-
| Tables `USER
|
|
639
|
+
| Logins over the store (`auth.directory`): each user's `PROFILE` from `PROFILE_USER`, `PERMISSION` from `RIGHT_SUMMARY`, seeded with their profiles' `PROFILE_RIGHT` codes (`permission` overrides), so what auth's events change, the next login has; see [auth](#product-events) | the PBCs' seed CSVs, auth 8.15.5's bytecode |
|
|
640
|
+
| Tables `USER` (`STATUS` defaulting to `ENABLED`), `USER_ATTRIBUTES`, `PROFILE`, `PROFILE_USER`, `RIGHT`, `PROFILE_RIGHT`, `RIGHT_SUMMARY`, `KEY_VALUE`, `NOTIFY_ALERT`, as the dictionaries declare them, audits included | GSF 8.15.29, auth 8.15.5, genesis-notify 8.15.16 dictionaries |
|
|
623
641
|
| Dataservers `ALL_USERS` (`USER_VIEW`), `ALL_PROFILES`, `ALL_RIGHTS`, `ALL_PROFILE_RIGHTS`, `ALL_PROFILE_USERS`, `ALL_NOTIFY_ALERT_RECORDS` (the user's own alerts) | `auth-dataserver.kts`, `genesis-notify-rules-dataserver.kts` |
|
|
624
642
|
| Request servers `RIGHT`, `PROFILE`, `KEY_VALUE_LIST`, `KEY_VALUE_READ` (`VALUE` in base64, as a RAW column goes out) | `auth-reqrep.kts` |
|
|
625
643
|
| Events `EVENT_KEY_VALUE_PUT` / `_DELETE`, `EVENT_DISMISS_NOTIFY_ALERT` / `_DISMISS_ALL_NOTIFY_ALERT`, with the real handlers' NACK texts | `auth-key-value-eventhandler.kts`, `genesis-notify-eventhandler.kts` |
|
|
@@ -661,8 +679,9 @@ definition, the script and line it comes from, and the tables it reads:
|
|
|
661
679
|
|
|
662
680
|
- Tables and views come from GSF's own compilation of the product's
|
|
663
681
|
dictionaries (its `<product>-dictionary-cache` jar), not from re-parsing
|
|
664
|
-
Kotlin. A column keeps its type, ENUM values
|
|
665
|
-
|
|
682
|
+
Kotlin. A column keeps its type, ENUM values (an ALIASED_ENUM's labels, as GSF
|
|
683
|
+
sends, reads and describes them: `GENERATED_REPORT.STATUS` is `'Generated'`),
|
|
684
|
+
default (an inline enum's first value when it names none), size (but GSF's default 64 and `dbMaxSize`) and
|
|
666
685
|
not-null (key, index, `not null` and dictionary not-null fields, as
|
|
667
686
|
`VerifiedTable.getNotNullFields` makes them). A view keeps its joins (type,
|
|
668
687
|
`backwardsJoin`), renamed columns and derived fields' types.
|
|
@@ -673,59 +692,223 @@ definition, the script and line it comes from, and the tables it reads:
|
|
|
673
692
|
`NOTIFY_DESTINATIONS` asks for `ID`. A view has its base table's key even when
|
|
674
693
|
it doesn't list it, as GSF adds it (the dictionary's `PRIMARY-KEY` imports).
|
|
675
694
|
A typed `requestReply<Unit, SomeView>` serves that view's rows with no request
|
|
676
|
-
(`GENERATED_REPORTS`, whose Kotlin reply
|
|
695
|
+
(`GENERATED_REPORTS`, whose Kotlin reply reads them newest first).
|
|
696
|
+
- Every table of an included product is there, read or not: its event handlers write them.
|
|
697
|
+
An audited one (`audit = details(..., sequence = "XA")`) carries `audit` with that sequence,
|
|
698
|
+
so the engine derives its `<TABLE>_AUDIT` table (see [Audit tables](#audit-tables-tabledefaudit)),
|
|
699
|
+
which a script may read: notify's `NOTIFY_ALERT` request server does.
|
|
677
700
|
- Rows: none, but a product's own seed data (notify's `NOTIFY_ROUTE.csv` and
|
|
678
701
|
`SCREEN_NOTIFY_ROUTE_EXT.csv`), the columns a row leaves out taking their
|
|
679
702
|
defaults as GSF's data load does.
|
|
680
|
-
-
|
|
681
|
-
|
|
682
|
-
and `PROFILE_RIGHT`. The pieces `platform.ts` writes out (`ALL_USERS`, the
|
|
683
|
-
key-value store, the alerts) replace generated ones of the same name.
|
|
703
|
+
- The pieces `platform.ts` writes out (`ALL_PROFILES`, the key-value store,
|
|
704
|
+
the alerts) replace generated ones of the same name.
|
|
684
705
|
|
|
685
706
|
What each product's screens read, and so what is now served (zero rows unless
|
|
686
707
|
said):
|
|
687
708
|
|
|
688
709
|
| Product | Dataservers | Request servers |
|
|
689
710
|
| --- | --- | --- |
|
|
690
|
-
| auth | `ALL_USERS`, `ALL_PROFILES` (rows: the users, profiles) | `USER`, `RIGHT`, `PROFILE_RIGHT`, `PROFILE_USER` (rows: the users, rights); also `USER_DETAILS`, `PROFILE_USERS` |
|
|
691
|
-
| genesis-notify | `ALL_DYNAMIC_NOTIFY_RULES`, `ALL_RULE_TEMPLATES`, `ALL_SCREEN_ROUTES` (2 rows), `ALL_EMAIL_DISTRIBUTION_ROUTES`, `ALL_EMAIL_USER_ROUTES`, `ALL_LOG_ROUTES`, `ALL_MS_TEAMS_ROUTES`, `ALL_SLACK_ROUTES`, `ALL_NOTIFY_ALERT_RECORDS`; also `ALL_NOTIFY_RECORDS`, `ALL_TOAST_NOTIFICATIONS` | `NOTIFICATION_RULE`, `NOTIFICATION_RULE_TEMPLATE` |
|
|
711
|
+
| auth | `ALL_USERS`, `ALL_PROFILES` (rows: the users, profiles); also `ALL_USER_RIGHTS`, `ALL_USER_AUDITS`, `ALL_USER_LOGIN_AUDITS`, `ALL_CRON_RULES` (reporting's schedules), `ALL_APPROVAL_ALERTS`, `ALL_APPROVAL_ALERTS_AUDITS` | `USER`, `RIGHT`, `PROFILE_RIGHT`, `PROFILE_USER` (rows: the users, rights); also `USER_DETAILS`, `PROFILE_USERS`, `USER_PROFILES`, `USER_LOGIN_AUDIT`, `USER_ATTRIBUTES_AUDIT`, `TAG` |
|
|
712
|
+
| genesis-notify | `ALL_DYNAMIC_NOTIFY_RULES`, `ALL_RULE_TEMPLATES`, `ALL_SCREEN_ROUTES` (2 rows), `ALL_EMAIL_DISTRIBUTION_ROUTES`, `ALL_EMAIL_USER_ROUTES`, `ALL_LOG_ROUTES`, `ALL_MS_TEAMS_ROUTES`, `ALL_SLACK_ROUTES`, `ALL_NOTIFY_ALERT_RECORDS`; also `ALL_NOTIFY_RECORDS`, `ALL_TOAST_NOTIFICATIONS` | `NOTIFICATION_RULE`, `NOTIFICATION_RULE_TEMPLATE`, `NOTIFY_ALERT` (the user's alerts' audit) |
|
|
692
713
|
| reporting | `ALL_REPORT_CONFIGS`, `ALL_SAVED_REPORTS` | `GENERATED_REPORTS`, `NOTIFY_DESTINATIONS`; also `SAVED_REPORTS`, `REPORT_CONFIGS`, `SFTP_DESTINATIONS` |
|
|
693
714
|
| file-server | `ALL_FILE_STORAGES` | `FILE_STORAGE`, `FILE_STORAGE_TEMPLATES`, `FILE_STORAGE_ASSETS` |
|
|
694
715
|
| reconciliation | `ALL_RECONCILIATION_VIEWS`, `ALL_RECONCILIATION_RECORD_RESULTS_VIEW`, `ALL_RECONCILIATION_RULE_RESULTS`, `RECONCILIATION_SUMMARY` | `RECONCILIATION_CONFIG`, `RECONCILIATION_RULE`, `DATASOURCE_CONFIG`, `DATA_DICTIONARY`, `DATA_DICTIONARY_FIELD`, `RECONCILIATION_RULE_RESULT` |
|
|
695
716
|
|
|
717
|
+
#### Product events
|
|
718
|
+
|
|
719
|
+
The preset runs the products' event handlers it models as their scripts do (one
|
|
720
|
+
module per product, `src/presets/<product>.ts`), DTO schemas included, so the
|
|
721
|
+
products' forms build and their saves land. What happens outside the database
|
|
722
|
+
(email, Teams, Slack, report files, reconciliation matching) isn't modelled: the
|
|
723
|
+
event validates, writes its rows (audited, as every event write is) and acks.
|
|
724
|
+
|
|
725
|
+
- **Auth** (`auth.ts`): its 15 user, profile, password and MFA events as
|
|
726
|
+
`auth-user-eventhandler.kts`, `auth-profile-eventhandler.kts`,
|
|
727
|
+
`auth-password-eventhandler.kts` and `auth-mfa-eventhandler.kts` run them,
|
|
728
|
+
with their NACKs (a script's `StandardError("CODE", ...)` is 500 whatever its
|
|
729
|
+
code). A user, a profile and their links keep `RIGHT_SUMMARY` inside the event,
|
|
730
|
+
as auth's consolidation does, quirks included: `EVENT_USER_PROFILE_AMEND`
|
|
731
|
+
keeps a removed profile's rights, and `EVENT_DELETE_PROFILE` leaves its users'
|
|
732
|
+
(it re-reads a profile's users after deleting them). A new user starts
|
|
733
|
+
`PASSWORD_EXPIRED`, auth's default: their first login answers
|
|
734
|
+
`PASSWORD_EXPIRED`, and foundation-auth's change of password
|
|
735
|
+
(`POST gwf/event-change-user-password`, logged in or out, as GSF's router
|
|
736
|
+
takes it) enables them. An amend writes the user whole, as the script's
|
|
737
|
+
entity modify does: a column it leaves out is cleared. Logins read the same
|
|
738
|
+
tables and write what auth's do: the checks in its order (an unknown or
|
|
739
|
+
`DISABLED` user and a wrong password alike `INCORRECT_CREDENTIALS`, an
|
|
740
|
+
expired password `PASSWORD_EXPIRED` whatever the password, another status but
|
|
741
|
+
`ENABLED` `LOCKED_ACCOUNT`, no `PASSWORD` `NO_COMPATIBLE_PROVIDERS`), the
|
|
742
|
+
lockout (three failures lock a name out for five minutes, `MAX_TRIES_REACHED`,
|
|
743
|
+
in `USER_LOGIN_ATTEMPT`), a `USER_LOGIN_AUDIT` row per login, failed login and
|
|
744
|
+
logout (`IP_ADDRESS` as the router gives it: the `HOSTNAME` header, else
|
|
745
|
+
`/<address>`), and `USER`'s `ONLINE` and `LAST_LOGIN`. Passwords are kept
|
|
746
|
+
hashed beside the store, never in `USER`, and change when their event
|
|
747
|
+
commits. `USER_PROFILES` and `USER_ATTRIBUTES_AUDIT` answer as the reply
|
|
748
|
+
blocks say. `ALL_APPROVAL_ALERTS` stays empty (the engine doesn't hold
|
|
749
|
+
events for approval), as do `TAG` and, until reporting schedules one,
|
|
750
|
+
`ALL_CRON_RULES`. MFA's events answer with their own replies, a secret
|
|
751
|
+
waiting in memory for its confirmation (any code confirms it); no login asks
|
|
752
|
+
for one.
|
|
753
|
+
- **genesis-notify's routes** (`notify.ts`): the 18 create, update and delete
|
|
754
|
+
events of the six route families (screen, email distribution, email user,
|
|
755
|
+
MS Teams, Slack, log) write `NOTIFY_ROUTE` and the family's ext table as
|
|
756
|
+
`genesis-notify-eventhandler.kts` does, with its NACKs (`NOTIFY_ROUTE <id> not
|
|
757
|
+
found`, a missing ext row's `RECORD_NOT_FOUND`). An email distribution route's
|
|
758
|
+
`Set<String>` fields are arrays in the schema, stored comma-joined; the routes
|
|
759
|
+
screen sends the stored string back on an update, which GSF's schema check
|
|
760
|
+
refuses too.
|
|
761
|
+
- **genesis-notify's rules and templates** (`notifyRules.ts`): the 10 rule and
|
|
762
|
+
template events (create, update, delete, subscribe, unsubscribe, enable,
|
|
763
|
+
disable) write `DYNAMIC_RULE`, the template's params, its subscribers' links
|
|
764
|
+
and their alert sounds as `genesis-notify-rules-eventhandler.kts` does, with
|
|
765
|
+
its owner-or-`NotificationAdminAction` checks and alert-sound limits.
|
|
766
|
+
`RULE_EXPRESSION` and `RESULT_EXPRESSION` are stored as GSF's
|
|
767
|
+
`EvaluatorExpressionWriter` writes them, and a subscription fills the
|
|
768
|
+
template's placeholders as Mustache does (each value HTML-escaped, then
|
|
769
|
+
`"` back to `"`). `NOTIFICATION_RULE_DETAILS` and
|
|
770
|
+
`NOTIFICATION_RULE_TEMPLATE_DETAILS` answer with the expression model the
|
|
771
|
+
event sent, where GSF parses the stored string back; a rule the mock didn't
|
|
772
|
+
write answers its stored string as the raw expression. `NOTIFY_ALERT_SOUND`
|
|
773
|
+
plays a sound to whoever the script lets hear it. The rule and template reads
|
|
774
|
+
(`ALL_DYNAMIC_NOTIFY_RULES`, `ALL_RULE_TEMPLATES`, `NOTIFICATION_RULE`,
|
|
775
|
+
`NOTIFICATION_RULE_TEMPLATE`) apply their `where` / `filter`, and
|
|
776
|
+
`NOTIFICATION_RULE` its user filter. Rules never fire: GSF's rules engine,
|
|
777
|
+
which raises `EVENT_NOTIFY_INSERT` when a matching record changes, isn't
|
|
778
|
+
modelled. The expressions' schema is any object, as their class tree can't
|
|
779
|
+
be described here.
|
|
780
|
+
- **genesis-notify's notifications** (`notifyDispatch.ts`): `NOTIFY_INSERT`
|
|
781
|
+
(with its sender check), `NOTIFY_SCREEN_DIRECT` and `NOTIFY_EMAIL_DIRECT`
|
|
782
|
+
write `NOTIFY` and its attachments as the scripts do. Then, after the ack and
|
|
783
|
+
outside the event's transaction, the dispatcher routes the row as GSF's
|
|
784
|
+
does: by topic (an enabled route whose `TOPIC_MATCH` is `*` or a prefix of
|
|
785
|
+
the topic), direct, or basic (`MY_SCREEN`, `ALL_SCREENS`), the route's users
|
|
786
|
+
resolved by `ENTITY_ID_TYPE` and filtered by `EXCLUDE_SENDER` and
|
|
787
|
+
`RIGHT_CODE`. A screen gateway gives each user one unaudited `NOTIFY_ALERT`
|
|
788
|
+
(the inbox and the toasts), with the routes' expiry, after which the alert
|
|
789
|
+
turns `EXPIRED`, audited as `ScreenAlertExpiryManager`'s. A route naming an
|
|
790
|
+
auth cache reaches nobody, as the mock has none; email, Teams, Slack and log
|
|
791
|
+
deliveries aren't made. The gateways are the `notifyGateways` option
|
|
792
|
+
(default the product's: screen `Screen`, email `Email`), which
|
|
793
|
+
`CONFIGURED_NOTIFY_ROUTES` lists. `NOTIFY_ROUTE_TOPICS` lists the routes'
|
|
794
|
+
topics and the broadcast ones; `NOTIFY_SYSTEM_ENTITY` the app's tables
|
|
795
|
+
(audit tables included) and views, or the `notifyEntities` option's (the
|
|
796
|
+
sysdef's `NOTIFY_ENTITY_LIST`).
|
|
797
|
+
- **Reporting** (`reporting.ts`): its 15 events write report configurations
|
|
798
|
+
(with their datasources, parameters, destination maps and schedules, a
|
|
799
|
+
schedule a `CRON_RULE` firing `EVENT_GENERATE_REPORT`, which the mock has no
|
|
800
|
+
scheduler to run), destinations and saved reports as
|
|
801
|
+
`reporting-eventhandler.kts` does, with its NACKs; the fields the events take
|
|
802
|
+
from the DAO classes they unwrap are described and checked with the DAO's
|
|
803
|
+
annotations (`FILE_NAME` at most 256 characters). A schedule is refused as
|
|
804
|
+
the product refuses it, with log4j's `CronExpression` and Java's `ZoneId.of`
|
|
805
|
+
messages, ported (`cronExpression.ts`, `javaTime.ts`). `EVENT_GENERATE_REPORT`
|
|
806
|
+
writes the run's `GENERATED_REPORT` row as `ReportingManager` does: its file
|
|
807
|
+
name with `$(timestamp:<Joda pattern>)` (in the `reportingTimeZone` option's
|
|
808
|
+
zone, the sysdef's `REPORTING_DEFAULT_TIMEZONE`, else, or when it can't be
|
|
809
|
+
resolved, the host's) and `$(parameter:<key>)` filled in (a bare
|
|
810
|
+
`$(parameter)` fails the run, as the product's `!!` does), a file id, and a
|
|
811
|
+
status: `Generated`, or
|
|
812
|
+
`Delivered` once dispatched to its destinations, a notify destination
|
|
813
|
+
raising the "New Report Generated" notification genesis-notify routes, an
|
|
814
|
+
SFTP one failing as the product's `TODO()` does. A run that fails past its
|
|
815
|
+
first checks NACKs and keeps its row `Failed`, as the non-transactional
|
|
816
|
+
handler does. No file is made: the datasources aren't run. The request
|
|
817
|
+
servers answer as the product's Kotlin does: `REPORT_CONFIG_DETAILS` (the
|
|
818
|
+
stored transformer configuration read back whole), `REPORT_PARAMETER_DETAILS`
|
|
819
|
+
(a JSON schema from the datasources' own), `ALL_REPORT_DATASOURCES` (every
|
|
820
|
+
request server, or the `reportingDatasources` option's, the sysdef's
|
|
821
|
+
`REPORTING_DATASOURCE_LIST`), `VALID_TIME_ZONE` (JDK 17.0.12's 603 zone
|
|
822
|
+
ids), `REPORTING_DATA_PIPELINES` (none), and `GENERATED_REPORTS` every run,
|
|
823
|
+
newest first.
|
|
824
|
+
- **Reconciliation** (`reconciliation.ts`): its 9 events write data
|
|
825
|
+
dictionaries and configurations (rules, datasources) as
|
|
826
|
+
`reconciliation-eventhandler.kts` does, with `ReconStrategyUtils`' and
|
|
827
|
+
`FieldToleranceUtils`' checks (a strategy's datasource count, a tolerance
|
|
828
|
+
type and value a field type allows) and its other NACKs. A run is the
|
|
829
|
+
product's lifecycle without its matching: checked as `ReconciliationManager`
|
|
830
|
+
checks it, started `IN_PROGRESS` (its input parameters pretty-printed as
|
|
831
|
+
Jackson does), then `COMPLETED` after the `reconciliationRunMs` option (default
|
|
832
|
+
1000 ms) with no record results, as the mock reads no data to match. A
|
|
833
|
+
datasource that can't start fails the run as the product does: the run's
|
|
834
|
+
row stays `FAILED` though the event NACKs (the handler isn't
|
|
835
|
+
transactional); a FILE one needs its input parameters and a `.csv` file
|
|
836
|
+
file-server has, a DATABASE one isn't implemented, a PIPELINE one with no name
|
|
837
|
+
fails once running. A live run can be cancelled; a comment is kept per
|
|
838
|
+
record result. The request servers pair the datasources as the strategy says
|
|
839
|
+
(`RECONCILIATION_DATA_SOURCE_PAIRS`), list the live configurations, a field
|
|
840
|
+
type's tolerance types, a record pair's values, and the
|
|
841
|
+
`reconciliationPipelines` option's pipelines. The configuration editor
|
|
842
|
+
resends its rules and datasources with keys their classes don't have
|
|
843
|
+
(`RECORD_ID`, `IS_EDITING`): GSF's schema leaves nested classes open and its
|
|
844
|
+
decoder drops those keys, and so does the mock.
|
|
845
|
+
- **File-server** (`fileServer.ts`): the router's `file-server/` endpoints
|
|
846
|
+
(`upload`, `replace`, `download`, `all-files`, `delete`) as
|
|
847
|
+
`file-server-web-handler.kts` serves them, for a logged-in user (401
|
|
848
|
+
otherwise), with the content validator's refusals (an empty file, an
|
|
849
|
+
extension off `ALLOWED_FILE_EXTENSIONS`, case-sensitive, a long name or a
|
|
850
|
+
special character; not its content sniffing). Files are saved one after
|
|
851
|
+
another, so those before a refused one are kept. An upload is a
|
|
852
|
+
`FILE_STORAGE` row with a uuid-strategy id (`<uuid>FFLO1`), kept under
|
|
853
|
+
`SUB_DIR` with `(1)`, `(2)` before the extension when the name's taken; its
|
|
854
|
+
bytes are kept in memory for `download`, so a body over 100 MiB is refused
|
|
855
|
+
as the router refuses one over its 1 GiB `maxFileSize` (400, `File exceeds
|
|
856
|
+
max size of ...`). A download's name above U+00FF goes out as `?`, as Netty
|
|
857
|
+
writes the header. `EVENT_FILE_STORAGE_DELETE`,
|
|
858
|
+
`EVENT_LINK_TEMPLATE_ASSETS` and `ASSETS_FOR_TEMPLATE` work over them. A
|
|
859
|
+
report run doesn't make a file, so its `REPORT_FILE_STORAGE_ID` downloads
|
|
860
|
+
nothing.
|
|
861
|
+
|
|
862
|
+
- **GSF** (`gsf.ts`): `SYSTEM_ENTITY` and `SYSTEM_ENTITY_FIELDS` as
|
|
863
|
+
`system-info-reqrep.kts` answers them, typed request servers over the
|
|
864
|
+
server's dictionary. The entities are the tables, each audit table right
|
|
865
|
+
after its own, then the views (every product's, not the ones the preset
|
|
866
|
+
declares only to serve a renamed column), in the config's order where GSF
|
|
867
|
+
lists the tables by product in its dictionary files' HashMap order. A
|
|
868
|
+
pattern matches a name whole (`*` any run for `SYSTEM_ENTITY`; as given, the
|
|
869
|
+
first match, for `_FIELDS`), and one Java refuses fails with its message
|
|
870
|
+
(`Dangling meta character '*' near index 0`). Java's spellings JavaScript
|
|
871
|
+
lacks (`\Q...\E`, `\A`, `\z`, a leading `(?i)`) are translated; an inline
|
|
872
|
+
flag later in the pattern fails with JavaScript's message. Matching stops
|
|
873
|
+
after a second (`GENERIC_ERROR`): a pattern that backtracks that long ties
|
|
874
|
+
up one request thread on GSF, but would stall every socket here. A field is described as GSF's
|
|
875
|
+
generated config classes give it: `MAX_SIZE` and `FILE_NAME` always null,
|
|
876
|
+
an ALIASED_ENUM by its keys, an ENUM defaulting to its first value, not
|
|
877
|
+
nullable when it's in any index, generated or defaulted, then `RECORD_ID`
|
|
878
|
+
and `TIMESTAMP`; a view's fields by their names in it, a joined or derived
|
|
879
|
+
one nullable, none with a default. A platform table is described as its
|
|
880
|
+
product declares it (`USER` with `PASSWORD`, which the preset keeps out of
|
|
881
|
+
its own). `ALL_PROCESSES_STATUS` and `ALL_SYSTEM_STATUS` are
|
|
882
|
+
`StatusDataserver`'s, on GSF's older engine, their fields in its order: no
|
|
883
|
+
rows, as only GSF's Resource Daemon fills them and Genesis Start and Create's
|
|
884
|
+
preview don't run it. `NOTIFY_SYSTEM_ENTITY` lists the same entities.
|
|
885
|
+
- **Typed request servers.** The products' 17 `requestReply<In, Out>` servers
|
|
886
|
+
(`VALID_TIME_ZONE`, `REPORT_CONFIG_DETAILS`, `NOTIFICATION_RULE_DETAILS`,
|
|
887
|
+
`RECONCILIATION_DATA_SOURCE_PAIRS`, ...) answer META as GSF 8.15.29 builds it
|
|
888
|
+
from the pinned jars (`scripts/platform-preset/seeds/typed-request-servers.json`,
|
|
889
|
+
sent as it is: their classes' sealed subtypes and DAO annotations), and their
|
|
890
|
+
replies carry `PARAMETRIC_TYPE` and stop at `MAX_ROWS`.
|
|
891
|
+
|
|
696
892
|
#### What isn't backed
|
|
697
893
|
|
|
698
|
-
Listed, and answered with the router's 404:
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
a dictionary: notify's `NOTIFY_ALERT` request server, auth's
|
|
717
|
-
`ALL_APPROVAL_ALERTS_AUDITS`, `ALL_USER_AUDITS`, `USER_ATTRIBUTES_AUDIT`.
|
|
718
|
-
- **GSF's and auth's over tables platform processes fill at runtime**, where an
|
|
719
|
-
empty table would be a wrong answer: `ALL_USER_RIGHTS` (`RIGHT_SUMMARY`),
|
|
720
|
-
`ALL_USER_LOGIN_AUDITS` and `USER_LOGIN_AUDIT`, `ALL_APPROVAL_ALERTS`,
|
|
721
|
-
`ALL_CRON_RULES`, `TAG`; GSF's `ALL_PROCESSES_STATUS` and `ALL_SYSTEM_STATUS`.
|
|
722
|
-
Auth's `USER_PROFILES` renames a column in its reply block.
|
|
723
|
-
|
|
724
|
-
Not modelled in what is served: `where` / `filter` clauses (their tables start
|
|
725
|
-
empty, and generation refuses one over a seeded table), permissioning
|
|
726
|
-
(permission codes, auth maps, as elsewhere in the preset), derived view fields
|
|
727
|
-
(declared and typed, always null), `GENERATED_REPORTS`'s Kotlin reply, and
|
|
728
|
-
UUID keys (`FILE_STORAGE_ID`), which only an insert would need.
|
|
894
|
+
Listed, and answered with the router's 404: **GSF's own events**, cron rules,
|
|
895
|
+
dynamic rules, pending approvals and the default `EVENT_INSERT` / `_MODIFY` /
|
|
896
|
+
`_DELETE`.
|
|
897
|
+
|
|
898
|
+
Not modelled in what is served: `where` / `filter` clauses but the rule and
|
|
899
|
+
template reads' (their tables start empty, and generation refuses one over a
|
|
900
|
+
seeded table), permissioning (permission codes, auth maps, as elsewhere in
|
|
901
|
+
the preset: auth's `MFA_ENABLE` and `MFA_DISABLE`, which no platform profile
|
|
902
|
+
holds, don't refuse anyone here), and the audit rows GSF's data load writes
|
|
903
|
+
for seeded rows. Rights are checked only where a product's own code checks
|
|
904
|
+
them (`CHANGE_PWD`, `EXPIRE_PWD`, genesis-notify's sender rights): any user
|
|
905
|
+
can still change a profile's users, so these checks guard nothing here.
|
|
906
|
+
|
|
907
|
+
Derived view fields are computed as the products' view dictionaries define
|
|
908
|
+
them: `DYNAMIC_RULE_VIEW.DATETIME`, `GENERATED_REPORT_VIEW.LAST_UPDATED_AT` and
|
|
909
|
+
`FILE_NAME`, `RECONCILIATION_VIEW.DATETIME` (the run's start, else its
|
|
910
|
+
timestamp) and `RECONCILIATION_RECORD_RESULT_VIEW.DATETIME`. GSF's
|
|
911
|
+
`TIMESTAMP shr 22` is the mock's TIMESTAMP, which is already epoch millis.
|
|
729
912
|
|
|
730
913
|
**Composing.** `mergeConfigs(...configs)` merges later configs over earlier
|
|
731
914
|
ones: tables, views, queries, request servers, event handlers and event
|
|
@@ -733,7 +916,9 @@ schemas by name (a later one replaces the earlier whole), `auth.users` by
|
|
|
733
916
|
username, `additionalResources` without repeats, `httpRoutes` (later first) and
|
|
734
917
|
`onMessage` hooks (in order) both kept, anything else the later config's. So an
|
|
735
918
|
app overrides a platform piece by naming it, e.g. its own
|
|
736
|
-
`eventHandlers.EVENT_KEY_VALUE_PUT`.
|
|
919
|
+
`eventHandlers.EVENT_KEY_VALUE_PUT`. Logins find the preset's users in its
|
|
920
|
+
`USER` table (`auth.directory`), so a user another config adds to
|
|
921
|
+
`auth.users` can't log in: add them with `platformPreset({ users })`.
|
|
737
922
|
|
|
738
923
|
**Resources.** `config.additionalResources` is listed after the resources the
|
|
739
924
|
engine derives from the config, skipping any already there (same name and
|
|
@@ -762,6 +947,11 @@ versions the showcase server pins (GSF itself is `genesis@8.15.29`):
|
|
|
762
947
|
- `scripts/*.kts`: the product's dataserver, request-server and event-handler
|
|
763
948
|
scripts, verbatim from its config jar (GSF's `system-info-reqrep.kts` from
|
|
764
949
|
genesis-server's `genesis-console`).
|
|
950
|
+
- `typed-request-servers.json` (beside the product directories): the typed
|
|
951
|
+
request servers' META DETAILS, built by running GSF's own
|
|
952
|
+
`CustomReqRep` metadata, `MetadataWrapper` and `FeatureAck` code against the
|
|
953
|
+
8.15.29 and pinned product jars (checked against a recorded 8.15.29 event
|
|
954
|
+
META, byte for byte).
|
|
765
955
|
|
|
766
956
|
It then formats the output with oxfmt. Re-record, re-copy, rerun.
|
|
767
957
|
|
|
@@ -774,7 +964,11 @@ having to monkey-patch the engine:
|
|
|
774
964
|
`http.Server` (e.g. a project's `GET pbi/configs`). Tried before the
|
|
775
965
|
built-in login/SSO handlers, so they can also override those. A string
|
|
776
966
|
`path` matches `pathname.endsWith(path)` (tolerating any gateway prefix);
|
|
777
|
-
a RegExp is tested against the full pathname
|
|
967
|
+
a RegExp is tested against the full pathname. The handler's `ctx` has the
|
|
968
|
+
store, the live pushes, the session's `userName` (none without one) and
|
|
969
|
+
`commitEvent(message, userName)`, which runs an event as that user through
|
|
970
|
+
the socket's commit path and gives back its reply, as GSF's router answers
|
|
971
|
+
an event POSTed over HTTP (the platform preset's change of password):
|
|
778
972
|
|
|
779
973
|
```ts
|
|
780
974
|
httpRoutes: [{
|
|
@@ -836,10 +1030,17 @@ Both transports answer as auth 8.15.5 does (recorded in
|
|
|
836
1030
|
and genesis 8.15.29). Top level: `UPDATE_QUEUE_DETAILS` (a stock ZeroMQ install's),
|
|
837
1031
|
`USER` (`AuthUser.loginAck`, else null) and `USER_DETAILS` (`FIRST_NAME`/`LAST_NAME` of
|
|
838
1032
|
`AuthUser.user`). HTTP replies carry a `SOURCE_REF` (the request's, or `AUTO_<uuid>`).
|
|
839
|
-
- **Failed login:** `EVENT_LOGIN_AUTH_NACK` with one `LoginError`
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
1033
|
+
- **Failed login:** `EVENT_LOGIN_AUTH_NACK` with one `LoginError` ("Problem logging in")
|
|
1034
|
+
and null `REFRESH_AUTH_TOKEN` / `REFRESH_TOKEN_EXPIRATION_MINS`; over HTTP it is a
|
|
1035
|
+
**200**, as on GSF, so foundation-auth takes its NACK path rather than its fetch-error
|
|
1036
|
+
path. Its `CODE` is auth's `AuthFailure`, checked in auth's order: an unknown user, a
|
|
1037
|
+
`DISABLED` one (`AuthUser.status`) and a wrong password `INCORRECT_CREDENTIALS` (401);
|
|
1038
|
+
`PASSWORD_EXPIRED` or `PASSWORD_RESET`, whatever the password, `PASSWORD_EXPIRED` (403),
|
|
1039
|
+
which sends foundation-auth to its change of password; a right password with another
|
|
1040
|
+
status but `ENABLED`, `LOCKED_ACCOUNT` (403); no `PASSWORD`, `NO_COMPATIBLE_PROVIDERS`
|
|
1041
|
+
(400); a refresh token no session holds, `UNKNOWN_ACCOUNT` (401). A
|
|
1042
|
+
`config.auth.directory` (the platform preset's) finds the users and decides instead,
|
|
1043
|
+
over the store.
|
|
843
1044
|
- **Logout:** `LOGOUT_ACK {OIDC_LOGOUT_URL: null}`, ending that session.
|
|
844
1045
|
- **`HEARTBEAT_PING` with `VERBOSE: true`:** the pong adds `USER_NAME`, `CREATED_AT`,
|
|
845
1046
|
`LAST_RECEIVED` and `LAST_SENT` (heartbeats don't count) and `RESOURCES`, the live
|
|
@@ -869,8 +1070,8 @@ load and the login screen never appears, which is usually what you want for
|
|
|
869
1070
|
CI/local dev. A request without a live session gets a new one, and with
|
|
870
1071
|
`cookieAuthentication` its login cookies too, so the socket can open. Leave it
|
|
871
1072
|
unset to require an explicit `EVENT_LOGIN_AUTH` POST (validated against
|
|
872
|
-
`config.auth.users`, same as the WS flow) before
|
|
873
|
-
succeed on a later reload.
|
|
1073
|
+
`config.auth.users`, or its directory, same as the WS flow) before
|
|
1074
|
+
`event-login-details` will succeed on a later reload.
|
|
874
1075
|
|
|
875
1076
|
An **opt-in** auth gate (`config.auth.requireAuth: true`) rejects WS data
|
|
876
1077
|
traffic (`DATA_LOGON`, `REQ_*`, `META_REQUEST`, `JSON_SCHEMA_REQUEST`, commit
|
|
@@ -1063,7 +1264,7 @@ ignoring only `SOURCE_REF`):
|
|
|
1063
1264
|
|
|
1064
1265
|
| Resource | `META_REQUEST` `DETAILS` | `JSON_SCHEMA_REQUEST` |
|
|
1065
1266
|
|---|---|---|
|
|
1066
|
-
| Dataserver | `{TYPE: 'DATASERVER', NAME, FIELD: [{NAME, TYPE, VALID_VALUES?}], INDEXES: [{NAME, FIELDS: 'A B'}]}`. `VALID_VALUES` on ENUMs only; no indexes → `[{NAME: null, FIELDS: 'RECORD_ID'}]` | INBOUND: the `DATA_LOGON` message. OUTBOUND: the `DataLogonReply` `oneOf`, the fields in `$defs['global.genesis.message.core.dataserver.QueryRow']` (all `oneOf [null, type]`, `genesisType`) |
|
|
1267
|
+
| Dataserver | `{TYPE: 'DATASERVER', NAME, FIELD: [{NAME, TYPE, VALID_VALUES?}], INDEXES: [{NAME, FIELDS: 'A B'}]}`. `VALID_VALUES` on ENUMs only; no indexes → `[{NAME: null, FIELDS: 'RECORD_ID'}]`; none at all for a query on GSF's older engine (`legacyEngine`, as `ALL_PROCESSES_STATUS` is) | INBOUND: the `DATA_LOGON` message. OUTBOUND: the `DataLogonReply` `oneOf`, the fields in `$defs['global.genesis.message.core.dataserver.QueryRow']` (all `oneOf [null, type]`, `genesisType`) |
|
|
1067
1268
|
| Request server | Plain: `{REQUEST_FIELD, INDICES: [], CRITERIA_ONLY_REQUEST: false, REPLY_FIELD}`; `REQUEST_FIELD` is `requestFields`, else the key. `criteriaOnly`: `{REQUEST_FIELD: [], CRITERIA_ONLY_REQUEST: true, SORTABLE_FIELDS, CRITERIA_FIELDS, REPLY_FIELD}`, the sortable and criteria fields being the source's fields then `RECORD_ID` and `TIMESTAMP`. `REPLY_FIELD` is the reply block (`fields`), else the source's fields then `RECORD_ID: LONG` and `TIMESTAMP: NANO_TIMESTAMP`, for either kind | INBOUND: top-level `REQUEST` (object or array of the request fields) required, `DETAILS {VIEW_NUMBER, MAX_ROWS, CRITERIA_MATCH}`. OUTBOUND: `properties.REPLY.items` (as `REPLY_FIELD`; nullable fields as `oneOf [null, type]`) |
|
|
1068
1269
|
| Event | `{NAME, TITLE?, DESCRIPTION, FIELD, DEFINITIONS: {}, REPLY, REQUIRES_APPROVAL: false, SCHEDULABLE: false, TYPE: 'EVENT_HANDLER'}`. FIELD items: `NAME, TITLE?, DESCRIPTION (JVM class), NULLABLE, TYPE, JSON_TYPE, OPTIONAL, READ_ONLY, GENESIS_TYPE` plus `MIN/MAX`, `MIN_LENGTH/MAX_LENGTH`, `VALID_VALUES`, `DEFAULT_VALUE`, `ENUM_CLASS`, `DEFAULT` where they apply. `REPLY` describes EventAck/EventApprovableAck/EventNack, copied from the recording | INBOUND: the event envelope, `DETAILS` with `additionalProperties: false` and `required` = the fields that aren't `OPTIONAL`. Nullable fields are `oneOf [schema, null]`; dates are `integer`; BigDecimal is a `string` with a pattern and no `genesisType`. OUTBOUND: the `EventReply` `oneOf` |
|
|
1069
1270
|
|
|
@@ -1082,7 +1283,26 @@ reports its first value as `DEFAULT`. Three classes, as the real server reports
|
|
|
1082
1283
|
- **Deletes** (`.../_DELETE`, or `pkOnly`): `<Table>.ById`, the key fields only, all mandatory,
|
|
1083
1284
|
no annotations (`GENESIS_TYPE: null`).
|
|
1084
1285
|
- **Custom DTOs** (`eventSchemas[name].fields`): the declared fields, no annotations,
|
|
1085
|
-
`className` as DESCRIPTION
|
|
1286
|
+
`className` as DESCRIPTION; a field with `dao: true` comes from a generated DAO class the DTO
|
|
1287
|
+
unwraps (`@JsonUnwrapped`) and has its annotations, as a table event's do (`maxSize` is then
|
|
1288
|
+
checked). A DTO field can hold more than one value, as GSF describes and
|
|
1289
|
+
checks it (`src/protocol/dtoTypes.ts`):
|
|
1290
|
+
|
|
1291
|
+
```ts
|
|
1292
|
+
{ name: 'EMAIL_TO', type: 'ARRAY', unique: true, items: { type: 'STRING' } }, // Set<String>
|
|
1293
|
+
{ name: 'RULES', type: 'ARRAY', items: { type: 'OBJECT', className: 'com.acme.Rule',
|
|
1294
|
+
fields: [/* FieldDef */] } }, // List<Rule>
|
|
1295
|
+
{ name: 'PARAMS', type: 'MAP', items: { type: 'STRING' } }, // Map<String, String>; no items: Any
|
|
1296
|
+
{ name: 'ENTITY', type: 'ANY' }, // Any?
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
META gives the type in the field's entry (`VALUE_TYPE`, `KEY_TYPE`, `UNIQUE`, `REFERENCE`) and
|
|
1300
|
+
each nested class in `DEFINITIONS`; the JSON schema gives arrays `items` and `uniqueItems` and
|
|
1301
|
+
each nested class in `$defs`. An INBOUND schema writes a nested class as GSF writes it for its
|
|
1302
|
+
validator, open to other properties, and the handler never sees those keys (GSF's decoder
|
|
1303
|
+
drops them); a reply's `$defs` are closed. DETAILS are checked against the INBOUND schema, item
|
|
1304
|
+
by item (`$.DETAILS.RULES[0]: ...`). Items are not null unless they say so; an ENUM that isn't a
|
|
1305
|
+
generated one names its class in `enumClass`.
|
|
1086
1306
|
|
|
1087
1307
|
The AI assistant (`ai-assistant/src/genesis/event-fields.ts`) builds its write tools from event
|
|
1088
1308
|
META: `NAME`, `GENESIS_TYPE`/`TYPE`, `JSON_TYPE`, `OPTIONAL`, `READ_ONLY`, `TITLE`,
|
|
@@ -1328,7 +1548,7 @@ requestReplies: {
|
|
|
1328
1548
|
| `CRITERIA_MATCH` | Filters the rows. Malformed — refused by the Groovy check, or unparseable and not known to be valid Groovy ([Strict criteria](#strict-criteria)): `MSG_NACK INTERNAL_ERROR` (recorded). An unknown field: `REPLY: []` (recorded), and `REQUEST_FAILED` "Paging not supported on lazy criteria evaluation" with an `OFFSET` past 0 | Filters the rows. Malformed (as for criteria-only): `MSG_NACK REQUEST_FAILED` with the parse error. An unknown field matches nothing |
|
|
1329
1549
|
| `MAX_ROWS` | The page size: `DETAILS.MAX_ROWS`, else `rowLimit`, else 10000. Below 1: `REQUEST_FAILED` "maxRows should be greater than 0" | The most rows each `REQUEST` object returns, same defaults. No signal that more exist |
|
|
1330
1550
|
| `OFFSET` / `VIEW_NUMBER` | `OFFSET` skips that many rows. `VIEW_NUMBER` n (from 1) is the page at `MAX_ROWS × (n − 1)`, with `NEXT_VIEW: n + 1` while the page has rows. Both, or either negative: `REQUEST_FAILED` with GSF's text | Ignored |
|
|
1331
|
-
| `ORDER_BY` | `'FIELD [ASC\|DESC], …'` (grid-pro sends `'NAME DESC'`, `'RECORD_ID ASC'`); an index name or `PK` stands for its fields; ties go by `RECORD_ID` ascending, nulls sort low. Malformed, or a field the source doesn't have: `REQUEST_FAILED` with GSF's text (`Order fields [Asc(field=X)] not found on table T`). Without it, a first page comes in the table's order (oldest first, recorded) and a later page by primary key | Ignored: rows come in primary-key order (recorded: `RIGHT` in `CODE` order) |
|
|
1551
|
+
| `ORDER_BY` | `'FIELD [ASC\|DESC], …'` (grid-pro sends `'NAME DESC'`, `'RECORD_ID ASC'`); an index name or `PK` stands for its fields; ties go by `RECORD_ID` ascending, nulls sort low. Malformed, or a field the source doesn't have: `REQUEST_FAILED` with GSF's text (`Order fields [Asc(field=X)] not found on table T`). Without it, a first page comes in the table's order (oldest first, recorded) and a later page by primary key | Ignored: rows come in primary-key order (recorded: `RIGHT` in `CODE` order), or the server's `order` (a comparator, for a Kotlin reply that reads an index or reads it backwards) |
|
|
1332
1552
|
| Reply | `{REPLY, PARAMETRIC_TYPE, MESSAGE_TYPE, NEXT_VIEW?, NEXT_OFFSET?, MORE_ROWS}`: `MORE_ROWS` always, `NEXT_OFFSET` only while it is `true`; past the end `REPLY: []` (recorded: `reqrep-paging`, `reqrep-max-rows`) | `{MESSAGE_TYPE, SOURCE_REF, PARAMETRIC_TYPE, REPLY}` |
|
|
1333
1553
|
|
|
1334
1554
|
- **Wildcards** (`WildcardFilter.kt`): any string value containing `*`. With `*`
|
|
@@ -1354,6 +1574,24 @@ requestReplies: {
|
|
|
1354
1574
|
which foundation-comms rejects the request's promise with. A `resolver`'s
|
|
1355
1575
|
`NackError` keeps its items; anything else it throws is `GENERIC_ERROR`
|
|
1356
1576
|
with the message (`AbstractCustomReqRep.kt`).
|
|
1577
|
+
- **Typed request servers.** A GPAL `requestReply<In, Out>` whose Kotlin
|
|
1578
|
+
builds the reply (GSF's `CustomReqRep`) is a `resolver` with
|
|
1579
|
+
`typed: { request: { className, fields }, reply: { className, fields } }`,
|
|
1580
|
+
the classes' fields declared as an event DTO's are, in the order GSF lists
|
|
1581
|
+
them (by name, but for an unwrapped class's). Its META is GPAL's shape:
|
|
1582
|
+
`{NAME, DESCRIPTION, FIELD, DEFINITIONS, REPLY: {NAME: 'REP_<NAME>',
|
|
1583
|
+
DESCRIPTION, FIELD, DEFINITIONS}, CRITERIA_ONLY_REQUEST: false,
|
|
1584
|
+
SORTABLE_FIELDS: null, CRITERIA_FIELDS: null, TYPE}`, the request class in
|
|
1585
|
+
`FIELD`, the reply class in `REPLY`, each field described as an event's is,
|
|
1586
|
+
not `REQUEST_FIELD` / `REPLY_FIELD`. `typed.meta` is the META a real server
|
|
1587
|
+
sends, sent as it is, for classes the fields can't describe whole (a sealed
|
|
1588
|
+
class's subtypes, a DAO's annotations); the fields then describe only the
|
|
1589
|
+
JSON schema. Its `REP_` is `{REPLY, MESSAGE_TYPE,
|
|
1590
|
+
PARAMETRIC_TYPE}` with the reply class as `PARAMETRIC_TYPE`;
|
|
1591
|
+
`CRITERIA_MATCH` filters the reply rows (a malformed one fails open), then
|
|
1592
|
+
at most `MAX_ROWS` go out (`rowLimit`, else 10000), with no paging
|
|
1593
|
+
(`AbstractCustomReqRep.kt`). The JSON schema takes the classes' fields
|
|
1594
|
+
(not recorded).
|
|
1357
1595
|
- A `CRITERIA_MATCH` this engine's grammar doesn't model but that GSF's
|
|
1358
1596
|
validator passes (`-QTY < -5`, `QTY == 5L`) still fails open, logged, as on
|
|
1359
1597
|
the dataserver. What the validator refuses (`NAME in ['A']`, `QTY * 2 > 1`,
|
|
@@ -1378,8 +1616,8 @@ Deviations: `VIEW_NUMBER` and `OFFSET` are as GSF's SQL engine answers them
|
|
|
1378
1616
|
(non-SQL engines send no `MORE_ROWS` or `NEXT_OFFSET`); request field aliases,
|
|
1379
1617
|
`criteriaTemplate` and timeouts are not modelled; the plain kind always reads
|
|
1380
1618
|
by primary key, where GSF reads through the index a `REQUEST` names (the same
|
|
1381
|
-
rows, possibly in that index's order);
|
|
1382
|
-
`CRITERIA_MATCH` or capped by `MAX_ROWS
|
|
1619
|
+
rows, possibly in that index's order); an untyped resolver's rows are not
|
|
1620
|
+
filtered by `CRITERIA_MATCH` or capped by `MAX_ROWS`.
|
|
1383
1621
|
|
|
1384
1622
|
## Entity-management (`@genesislcap/foundation-entity-management`) support
|
|
1385
1623
|
|
package/dist/db/schema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CrudEventVerb, FieldDef, IndexDef, MockServerConfig, QueryDef, RequestReplyDef, Row, TableDef } from '../types.ts';
|
|
1
|
+
import type { CrudEventVerb, FieldDef, FieldTypeDef, IndexDef, MockServerConfig, QueryDef, RequestReplyDef, Row, TableDef } from '../types.ts';
|
|
2
2
|
import type { Store } from './store.ts';
|
|
3
3
|
export interface ResolvedField {
|
|
4
4
|
name: string;
|
|
@@ -16,6 +16,12 @@ export interface ResolvedField {
|
|
|
16
16
|
title?: string;
|
|
17
17
|
optional?: boolean;
|
|
18
18
|
table?: string;
|
|
19
|
+
items?: FieldTypeDef;
|
|
20
|
+
unique?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
fields?: FieldDef[];
|
|
23
|
+
enumClass?: string;
|
|
24
|
+
dao?: boolean;
|
|
19
25
|
}
|
|
20
26
|
export interface ResolvedSchema {
|
|
21
27
|
fields: ResolvedField[];
|
|
@@ -63,4 +69,6 @@ export interface EventTarget {
|
|
|
63
69
|
export declare function resolveEventTarget(name: string | undefined, config: MockServerConfig, { bareTable }?: {
|
|
64
70
|
bareTable?: boolean;
|
|
65
71
|
}): EventTarget | undefined;
|
|
72
|
+
export declare function typedFields(fields: FieldDef[]): ResolvedField[];
|
|
73
|
+
export declare function dtoFields(fields: FieldDef[], table?: string, fieldTypes?: Record<string, string>): ResolvedField[];
|
|
66
74
|
export declare function eventFields(target: EventTarget, config: MockServerConfig, store: Store): ResolvedField[];
|
package/dist/db/schema.js
CHANGED
|
@@ -48,6 +48,12 @@ function fromFieldDef(field, table, notNullByDefault, generated) {
|
|
|
48
48
|
...(field.title !== undefined ? { title: field.title } : {}),
|
|
49
49
|
...(field.optional !== undefined ? { optional: field.optional } : {}),
|
|
50
50
|
...(table ? { table } : {}),
|
|
51
|
+
...(field.items !== undefined ? { items: field.items } : {}),
|
|
52
|
+
...(field.unique !== undefined ? { unique: field.unique } : {}),
|
|
53
|
+
...(field.className !== undefined ? { className: field.className } : {}),
|
|
54
|
+
...(field.fields !== undefined ? { fields: field.fields } : {}),
|
|
55
|
+
...(field.enumClass !== undefined ? { enumClass: field.enumClass } : {}),
|
|
56
|
+
...(field.dao ? { dao: true } : {}),
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
function declaredTableFields(tableName, def) {
|
|
@@ -234,12 +240,23 @@ export function queryCriteriaTypes(query, config, store) {
|
|
|
234
240
|
export function requestReplySchema(requestReply, config, store) {
|
|
235
241
|
const schema = requestReply.source
|
|
236
242
|
? resolveSourceSchema(requestReply.source, config, store)
|
|
237
|
-
: {
|
|
238
|
-
fields: inferredFields(requestReply.metadataRows ?? [], [], new Set(), undefined),
|
|
239
|
-
declared: false,
|
|
240
|
-
};
|
|
243
|
+
: { fields: resolverFields(requestReply, isLegacyFidelity(config)), declared: false };
|
|
241
244
|
return withTypeOverrides(schema, requestReply.fieldTypes);
|
|
242
245
|
}
|
|
246
|
+
// A resolver's fields: its metadataRows', then any fieldTypes name they
|
|
247
|
+
// don't have (typed by withTypeOverrides). fidelity: 'legacy' lists the
|
|
248
|
+
// metadataRows' alone, as 15.47 did.
|
|
249
|
+
function resolverFields(requestReply, legacy) {
|
|
250
|
+
const fields = inferredFields(requestReply.metadataRows ?? [], [], new Set(), undefined);
|
|
251
|
+
if (legacy)
|
|
252
|
+
return fields;
|
|
253
|
+
const named = new Set(fields.map((field) => field.name));
|
|
254
|
+
const declared = Object.keys(requestReply.fieldTypes ?? {}).filter((name) => !named.has(name));
|
|
255
|
+
return [
|
|
256
|
+
...fields,
|
|
257
|
+
...declared.map((name) => ({ name, type: 'STRING', nullable: true, generated: false })),
|
|
258
|
+
];
|
|
259
|
+
}
|
|
243
260
|
// The record identity every table entity carries after its own columns: what
|
|
244
261
|
// a request server with no reply block sends in each row and lists in
|
|
245
262
|
// REPLY_FIELD, and what a criteria-only one can sort and filter by.
|
|
@@ -497,6 +514,24 @@ const byName = (a, b) => {
|
|
|
497
514
|
const [left, right] = [propertyName(a), propertyName(b)];
|
|
498
515
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
499
516
|
};
|
|
517
|
+
// A custom class's fields, as a DTO event's DETAILS or a class nested in one:
|
|
518
|
+
// sorted by name, each optional only when it declares a default or
|
|
519
|
+
// `optional: true` (a DTO's Kotlin defaults are invisible).
|
|
520
|
+
// A typed request server's class fields (TypedRequestReply), in the order
|
|
521
|
+
// they're listed rather than by name.
|
|
522
|
+
export function typedFields(fields) {
|
|
523
|
+
const resolved = new Map(dtoFields(fields).map((field) => [field.name, field]));
|
|
524
|
+
return fields.map(({ name }) => resolved.get(name));
|
|
525
|
+
}
|
|
526
|
+
export function dtoFields(fields, table, fieldTypes) {
|
|
527
|
+
const resolved = fields.map((field) => fromFieldDef(field, table, false, false));
|
|
528
|
+
return withTypeOverrides({ fields: resolved, declared: true }, fieldTypes)
|
|
529
|
+
.fields.map((field) => ({
|
|
530
|
+
...field,
|
|
531
|
+
optional: field.optional ?? field.default !== undefined,
|
|
532
|
+
}))
|
|
533
|
+
.sort(byName);
|
|
534
|
+
}
|
|
500
535
|
// The fields an event's DETAILS take, sorted by name as the real server
|
|
501
536
|
// lists a class's properties — except a delete's, which are the key fields
|
|
502
537
|
// in key order, all mandatory. A key field the schema doesn't know (an
|
|
@@ -508,13 +543,7 @@ const byName = (a, b) => {
|
|
|
508
543
|
// DTO field is optional only when it declares a default or `optional: true`.
|
|
509
544
|
export function eventFields(target, config, store) {
|
|
510
545
|
if (target.kind === 'dto') {
|
|
511
|
-
|
|
512
|
-
return withTypeOverrides({ fields: resolved, declared: true }, target.fieldTypes)
|
|
513
|
-
.fields.map((field) => ({
|
|
514
|
-
...field,
|
|
515
|
-
optional: field.optional ?? field.default !== undefined,
|
|
516
|
-
}))
|
|
517
|
-
.sort(byName);
|
|
546
|
+
return dtoFields(target.fields ?? [], target.table, target.fieldTypes);
|
|
518
547
|
}
|
|
519
548
|
const table = target.table;
|
|
520
549
|
const { fields } = withTypeOverrides(resolveSourceSchema(table, config, store), target.fieldTypes);
|
package/dist/db/store.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export declare class Store {
|
|
|
70
70
|
private viewOf;
|
|
71
71
|
getResourceRows(resourceName: string): Row[];
|
|
72
72
|
getMetadataRows(resourceName: string): Row[];
|
|
73
|
+
hasTable(tableName: string): boolean;
|
|
73
74
|
getPkFields(resourceName: string): string[];
|
|
74
75
|
getRowRef(resourceName: string, row: Row): unknown;
|
|
75
76
|
getRecordRef(resourceName: string, row: Row): unknown;
|
package/dist/db/store.js
CHANGED
|
@@ -638,6 +638,10 @@ export class Store {
|
|
|
638
638
|
: seedOf(resourceName);
|
|
639
639
|
return seed.map(withoutRecordFields);
|
|
640
640
|
}
|
|
641
|
+
// Whether tableName is a table (not a view).
|
|
642
|
+
hasTable(tableName) {
|
|
643
|
+
return this.tableConfig.has(tableName);
|
|
644
|
+
}
|
|
641
645
|
// Row-identity fields for a table or view; empty when unknown.
|
|
642
646
|
getPkFields(resourceName) {
|
|
643
647
|
const view = this.views.get(resourceName);
|