Skip to content

Za/data access webapi#643

Draft
amrc-za wants to merge 65 commits into
mainfrom
za/data-access-webapi
Draft

Za/data access webapi#643
amrc-za wants to merge 65 commits into
mainfrom
za/data-access-webapi

Conversation

@amrc-za
Copy link
Copy Markdown
Contributor

@amrc-za amrc-za commented Apr 30, 2026

Implemented web api feature. Includes:

  • dataflow
  • api-v1
  • lib/js-service-client/lib/data-access.js client interface for data access service

@amrc-za amrc-za requested a review from amrc-benmorrow April 30, 2026 08:01
Copy link
Copy Markdown
Contributor

@amrc-benmorrow amrc-benmorrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I've requested a few changes. Some of them are larger-scale refactors and may not be worth pursuing at the moment.

Comment thread acs-data-access/lib/api-v1.js Outdated
Comment thread acs-data-access/lib/api-v1.js Outdated
Comment thread acs-data-access/lib/api-v1.js Outdated
Comment thread acs-data-access/lib/api-v1.js Outdated
Comment thread acs-data-access/lib/api-v1.js Outdated
Comment thread acs-data-access/lib/dataflow.js Outdated
Comment thread acs-data-access/lib/dataflow.js Outdated


async get_allowed_dataset_uuids(principal, permission, dataset_validity) {
const dataset_def_obs = this.get_dataset_definitions(dataset_validity);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you convert this function to an Rx operator you can avoid the dataset_validity parameter everywhere.

An Rx operator is not a complicated thing, it's just something you can call from within .pipe; in RxJS it's implemented as a function that returns a function which modifies the source sequence. (I like JS, you can do things like that…)

So in this case you would want something like

filter_allowed_uuids (principal, permission) {
    const acls = this.auth.watch_acl_with_perm(principal, permission);
    return datasets => datasets.pipe(
        rx.combineLatestWith(acls),
        rx.map(([datasets, targets]) => { /* as before */ }),
    );
}

Then when you use it you start with the appropriate datasets sequence (all datasets or valid-only) and apply the ACL operator, i.e. still in Dataflow you define

metadata_list (principal) {
    return rxu.rx(
        this.valid_definitions,
        this.filter_allowed_uuids(principal, Constants.Perm.ReadDataset),
    );
}

where data.valid_definitions is defined in the constructor as

    this.valid_definitions = this.dataset_definitions.pipe(
        rx.filter(def => def.structure != StructurallyInvalidDataset));

(This assumes the change above to avoid keeping invalid definitions). Then for the API function metadata_list you just call

    const uuids = rx.firstValueFrom(this.data.metadata_list(req.auth));

and for the notify interface you can make a similar call, without the firstValueFrom, using the principal from the notify session. By pushing the firstValueFrom as late as possible you make the notify interface easier to implement.

Comment thread acs-data-access/lib/influx-reader.js Outdated
Comment thread acs-data-access/lib/utils.js Outdated
Comment thread lib/js-service-client/lib/service/data-access.js Outdated
@amrc-za amrc-za force-pushed the za/data-access-webapi branch from 3cd2891 to 9580fcd Compare May 6, 2026 12:46
@amrc-za amrc-za force-pushed the za/data-access-webapi branch from 4a36494 to 789267d Compare May 7, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants