
Security News
Socket Security Analysis Is Now One Click Away on npm
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.
@map-colonies/csw-client
Advanced tools
This package provides client-side API for OGC CSW service(s) written in TypeScript.
Suits for Node.JS and React/Angular applications
Package boilerplate based on ts-npm-package-boilerplate
This Client library is based on Jsonix and ogc-schemas libraries.
Code samples are provided by TypeScript.
npm install @map-colonies/csw-client --save
yarn add @map-colonies/csw-client --save
Add following script to your package.json
"scripts": {
.
.
.
"patch:deps": "cd ./node_modules/@map-colonies/csw-client && patch-package --patch-dir ./dist/patches"
}
You can add patch:deps script to one of the npm hooks or run it manually.
For example add it to postinstall hook:
"scripts": {
"postinstall": "yarn run patch:deps && <your_own_postinstall>",
.
.
.
"patch:deps": "cd ./node_modules/@map-colonies/csw-client && patch-package --patch-dir ./dist/patches"
}
// import CswClient class
import { CswClient, ICapabilities } from from '@map-colonies/csw-client';
// later in code
const csw = new CswClient('<YOUR_OGC_CSW_SRV_URL>', <YOUR_REQUEST_EXECUTOR_FUNC>, <CONFIG>);
// trigger one of the exposed methods
csw.GetDomain('<propertyName>').then((data: ICapabilities) => {
// your code
});
// import CswClient class
import { CswClient } from from '@map-colonies/csw-client';
import Axios, { Method } from 'axios';
// import desired ADDITIONAL schemas
const ISO19139_GCO_20060504 = require('ogc-schemas').ISO19139_GCO_20060504;
const ISO19139_GMD_20060504 = require('ogc-schemas').ISO19139_GMD_20060504;
const GML_3_2_0 = require('ogc-schemas').GML_3_2_0;
// define your own requestExecutor
const myRequest = async (url: string, method: string, params: Record<string, unknown>): Promise<any> => {
const errorMsg = 'CLIENT HTTP ERROR BY AXIOS';
return Axios.request({
url,
method: method as Method,
...params,
})
.then((res) => res)
.catch((error) => {
console.error(errorMsg);
throw error;
});
};
// later in code
const cswConfig = {
schemas: [
GML_3_2_0,
ISO19139_GCO_20060504,
ISO19139_GMD_20060504,
],
nameSpaces: {
namespacePrefixes: { // define ADDITIONAL namespace prefixes
'http://schema.mapcolonies.com': 'mc',
'http://www.isotc211.org/2005/gmd': 'gmd',
'http://www.isotc211.org/2005/gco': 'gco',
},
},
credentials: {},
};
const csw = new CswClient('http://127.0.0.1:56477/?version=2.0.2&service=CSW', myRequest, cswConfig);
GetCapabilities(): Promise
Allow clients to retrieve information describing the service instance
csw.GetCapabilities().then((data: ICapabilities) => {
... // your code
});
DescribeRecord(): Promise
Allows a client to discover elements of the information model supported by the target catalog service
csw.DescribeRecord().then((data) => {
... // your code
});
GetDomain(propertyName: string): Promise
Obtain runtime information about the range of values of a metadata record element or request parameter.
csw.GetDomain('title').then((data) => {
... // your code
});
GetRecords(start: number, max: number, opts: { filter?: IFilterField[]; sort?: ISortField[] }, outputSchema: string): Promise
Get metadata records according to defined filter and sort order
const options = {
filter: [
{
field: 'mcgc:geojson',
bbox: {
llat: 31.90,
llon: 36.80,
ulat: 31.91,
ulon: 36.81,
},
},
{
field: 'mcgc:name',
like: 'magic_place',
},
],
sort: [
{
field: 'mcgc:name',
desc: false,
},
{
field: 'mcgc:creation_date',
desc: true,
},
]
};
csw.GetRecords(1, 10, options, 'http://schema.myschema.com').then((data) => {
... // your code
});
GetRecordsById(id_list: string[]): Promise
Get metadata records by ID list
csw.GetRecordsById(['1', '2', '5']).then((data) => {
... // your code
});
InsertRecords(records: any[]): Promise
Create catalog records
csw.InsertRecords(records).then((data) => {
... // your code
});
UpdateRecord(record: any): Promise
Modify catalog record
csw.UpdateRecord(records).then((data) => {
... // your code
});
DeleteRecords(filters: IFilterField[]): Promise
Delete catalog records according to defined filter
csw.DeleteRecords(filters).then((data) => {
... // your code
});
xmlStringToJson(xmlString: string): any
Converts XML-like string to JSON object according to defined schemas
const obj = csw.xmlStringToJson(xmlString);
jsonToXml(json: any): XMLDocument
Converts JSON object to XMLDocument according to defined schemas
const xmlDoc: XMLDocument = csw.jsonToXml(json);
xmlToJson(xml: XMLDocument): any
Converts XMLDocument to JSON object according to defined schemas
const obj = csw.xmlToJson(xml);
xmlToString(xml: XMLDocument): string
Converts XMLDocument to XML-like string according to defined schemas
const str = csw.xmlToString(xml);
Operators:
let filter: any = new FilterBuilder().PropertyName('dc:title').isLike('%water%');
filter = filter.and(new FilterBuilder().PropertyName('dc:subject').isLike('%polution%'));
let filter: any = new FilterBuilder().PropertyName('dc:title').isLike('%water%');
filter = filter.or(new FilterBuilder().PropertyName('dc:title').isLike('%oil%'));
Spatial Operatos:
let filter: any = new FilterBuilder().PropertyName('dc:title').isLike('%water%');
filter = filter.and(new FilterBuilder().BBOX(-80, 150, 80, -150));
Comparison
const sort: SortBuilder = new SortBuilder().Sort('dc:title');
sort.Sort('dc:dummy', true);
FAQs
TypeScript and JavaScript classes for osm elements
The npm package @map-colonies/csw-client receives a total of 9 weekly downloads. As such, @map-colonies/csw-client popularity was classified as not popular.
We found that @map-colonies/csw-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.

Security News
A compromised npm publish token was used to push a malicious postinstall script in cline@2.3.0, affecting the popular AI coding agent CLI with 90k weekly downloads.

Product
Socket is now scanning AI agent skills across multiple languages and ecosystems, detecting malicious behavior before developers install, starting with skills.sh's 60,000+ skills.