KETTLE-46: Isolate kettle.dataSource.URL for ease of reuse on the client-side....

Metadata

Source
KETTLE-46
Type
Improvement
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Antranig Basman
Reporter
Tony Atkins [RtF]
Created
2016-07-05T05:31:39.346-0400
Updated
2016-08-30T10:06:52.110-0400
Versions
N/A
Fixed Versions
N/A
Component
N/A

Description

Currently, the node-unique dataSource components live in one file, with the browser-safe components in another file.

To make it possible to use kettle.dataSource.URL with browserify (see GPII-1587), we should further compartmentalize the pieces that can only ever run on node (such as the dataSources that use the "fs" module) from things like kettle.dataSource.URL, which can conceivably be run in the browser using browserify.

This spike would not add client-side tests, it would only confirm that all tests pass once the code is reorganized. To preserve support for references to the old structure used in calls like fluid.require("%kettle/lib/dataSource-node.js");}, I plan to require the new file from within {{dataSource-node.js.

cc: @@Antranig Basman

Comments

  • Tony Atkins [RtF] commented 2016-07-05T05:48:05.842-0400

    https://github.com/fluid-project/kettle/pull/24

  • Tony Atkins [RtF] commented 2016-07-05T05:51:08.223-0400

    I have made the minimum changes to enable proof-of-concept work in using kettle.dataSource.URL in-browser. All tests pass and the change does not affect the level of code coverage.

    We need to have a larger discussion around where data sources should live, for now I will write the initial browser tests for kettle.dataSource.URL in the UL API repo.

  • Tony Atkins [RtF] commented 2016-07-05T08:30:28.573-0400

    I have discovered that jsonlint has a different structure when called from node, basically it wires itself in as the parser when it's used from CommonJS. Kettle expects to find jsonlint.parser, which doesn't exist on the browser side. The workaround (which we should review) is simply to set jsonlint.parser = jsonlint

    I also discovered that the implementation of kettle.dataSource.URL relies on the node-side kettle.wrapCallback function:

    https://github.com/fluid-project/kettle/blob/9fdef26a796eaab5dd1f531a940f08f3d7761912/lib/KettleRequest.js#L91
    https://github.com/fluid-project/kettle/blob/9fdef26a796eaab5dd1f531a940f08f3d7761912/lib/dataSource-node.js#L313

    I will create a workaround for that as well until we can discuss further.

  • Tony Atkins [RtF] commented 2016-08-30T10:06:52.079-0400

    Happy to see this one closed, as we agreed, we need a parallel implementation backed by jQuery.