-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change versioning structure * Updated readme and release notes * Fixing integration tests * Add dataset and schema services * Version and readme update * Tyypo fix
- Loading branch information
1 parent
9df79a2
commit 8861413
Showing
58 changed files
with
1,347 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
...require('./query') | ||
...require('./query'), | ||
...require('./schema') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports.OsduSchemaQueryBuilder = require('./osduSchemaQueryBuilder'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/** | ||
* Class to build OSDU schema query bodies with friendly names for each available option | ||
* - Note that querys built with this builder must at minimum specify the [kind]{@link OsduQueryBuilder#kind} | ||
* | ||
* @class | ||
* @category Models | ||
* @subcategory Schema | ||
*/ | ||
class OsduSchemaQueryBuilder { | ||
/** @constructor */ | ||
constructor() { | ||
} | ||
|
||
// Setters | ||
/** | ||
* Pass an optional string to search for a specific authority | ||
* - Accepts wildcards `*` | ||
* @param {string} authority - The OSDU authority with which to filter the search | ||
*/ | ||
authority(authority) { | ||
this._authority = authority; | ||
return this; | ||
} | ||
|
||
/** | ||
* Pass an optional string to search for a specific source | ||
* - Accepts wildcards `*` | ||
* @param {string} source - The OSDU source with which to filter the search | ||
*/ | ||
source(source) { | ||
this._source = source; | ||
return this; | ||
} | ||
|
||
/** | ||
* Pass an optional string to search for a specific entityType | ||
* - Accepts wildcards `*` | ||
* @param {string} entityType - The OSDU entityType with which to filter the search | ||
*/ | ||
entityType(entityType) { | ||
this._entityType = entityType; | ||
return this; | ||
} | ||
|
||
/** | ||
* Pass an optional string to search for a specific schemaVersionMajor | ||
* - Accepts wildcards `*` | ||
* @param {string|number} schemaVersionMajor - The OSDU schemaVersionMajor with which to filter the search | ||
*/ | ||
schemaVersionMajor(schemaVersionMajor) { | ||
this._schemaVersionMajor = schemaVersionMajor; | ||
return this; | ||
} | ||
|
||
/** | ||
* Pass an optional string to search for a specific schemaVersionMinor | ||
* - Accepts wildcards `*` | ||
* @param {string|number} schemaVersionMinor - The OSDU schemaVersionMinor with which to filter the search | ||
*/ | ||
schemaVersionMinor(schemaVersionMinor) { | ||
this._schemaVersionMinor = schemaVersionMinor; | ||
return this; | ||
} | ||
|
||
/** | ||
* The schema status specification | ||
* - Accepts only valid status `PUBLISHED`, `DEVELOPMENT`, or `OBSOLETE` | ||
* @param {('PUBLISHED'|'DEVELOPMENT'|'OBSOLETE')} status - The OSDU status with which to filter the search | ||
*/ | ||
status(status) { | ||
if (![ | ||
"PUBLISHED", | ||
"DEVELOPMENT", | ||
"OBSOLETE" | ||
].contains(status)) { | ||
throw new Error(`Invalid status type ${status} in Osdu Schema Query Builder`); | ||
} | ||
this._status = status; | ||
return this; | ||
} | ||
|
||
/** | ||
* The scope or schema visibility specification | ||
* - Accepts only valid status `INTERNAL` or `SHARED` | ||
* @param {('INTERNAL'|'SHARED')} status - The OSDU scope with which to filter the search | ||
*/ | ||
scope(scope) { | ||
if (![ | ||
"SHARED", | ||
"INTERNAL" | ||
].contains(scope)) { | ||
throw new Error(`Invalid scope type ${scope} in Osdu Schema Query Builder`); | ||
} | ||
this._scope = scope; | ||
return this; | ||
} | ||
|
||
/** | ||
* If True, only return the latest version | ||
* @param {boolean} latestVersion - Whether to retrieve only the latest version | ||
*/ | ||
latestVersion(latestVersion) { | ||
this._latestVersion = !!latestVersion ? "True" : "False"; | ||
return this; | ||
} | ||
|
||
/** | ||
* Maximum number of schema records to return | ||
* @param {number} limit - The integer number of records to return | ||
*/ | ||
limit(limit) { | ||
this._limit = limit; | ||
return this; | ||
} | ||
|
||
/** | ||
* Number of records to skip for pagination | ||
* @param {number} offset - The integer number of records to skip | ||
*/ | ||
offset(offset) { | ||
this._offset = offset; | ||
return this; | ||
} | ||
|
||
// Build | ||
/** | ||
* Construct the query request query string based on the attributes set | ||
* @returns {string} The query string that is passed to the schema query request | ||
*/ | ||
build() { | ||
var queryString = "?"; | ||
|
||
if (this._authority) { | ||
queryString += `&authority=${this._authority}`; | ||
} | ||
if (this._source) { | ||
queryString += `&source=${this._source}`; | ||
} | ||
if (this._entityType) { | ||
queryString += `&entityType=${this._entityType}`; | ||
} | ||
if (this._schemaVersionMajor) { | ||
queryString += `&schemaVersionMajor=${this._schemaVersionMajor}`; | ||
} | ||
if (this._schemaVersionMinor) { | ||
queryString += `&schemaVersionMinor=${this._schemaVersionMinor}`; | ||
} | ||
if (this._status) { | ||
queryString += `&status=${this._status}`; | ||
} | ||
if (this._scope) { | ||
queryString += `&scope=${this._scope}`; | ||
} | ||
if (this._latestVersion) { | ||
queryString += `&latestVersion=${this._latestVersion}`; | ||
} | ||
if (this._limit) { | ||
queryString += `&limit=${this._limit}`; | ||
} | ||
if (this._offset) { | ||
queryString += `&offset=${this._offset}`; | ||
} | ||
|
||
queryString = queryString.substr(0, queryString.count-1); | ||
|
||
return queryString; | ||
} | ||
} | ||
|
||
module.exports = OsduSchemaQueryBuilder; |
Oops, something went wrong.