1.16.6 • Published 8 months ago

@ezs/lodex v1.16.6

Weekly downloads
301
License
MIT
Repository
github
Last release
8 months ago

lodex

Ce plugin propose une série d'instructions spécifiques à l’usage de lodex

installation

npm install @ezs/core

usage

Table of Contents

convertJsonLdToNQuads

Take a JSON-LD object and transform it into NQuads triples.

Returns String

convertToAtom

Generate an atom XML feed from a resources feed, the LODEX configuration and model.

Parameters

  • fields Object LODEX model (optional, default {})
  • atomFeed Feed A feed of resources, see feed (optional, default {})
  • config Object LODEX configuration (with perPage) (optional, default {})

Returns String

convertToExtendedJsonLd

Convert the result of an ISTEX query to an extended JSON-LD.

Every hit must contain the URI of original lodex resource, linked to the query.

Parameters

  • schemeForIstexQuery string URI to put between document and resource

extractIstexQuery

Extract an ISTEX API query.

Parameters

  • fields Array<Field> list of LODEX fields (optional, default [])

Examples

Output:

{
   content: 'fake query',
   lodex: {
      uri: 'http://resource.uri',
  },
}

Field

Type: Object<string, any>

Properties

  • name string The identifier of the field.
  • scheme string The semantic property of the field.

flattenPatch

Take Object and transform all key ending byu number on array.

Parameters

Returns Object

getLastCharacteristic

Get last characteristic (list of all dataset covering fields).

Examples

Input:

[
  {
    "_id" : ObjectId("5ca32c64019f45001d2b602d"),
    "publicationDate" : ISODate("2019-04-02T09:33:24.463Z")
  },
  {
    "_id" : ObjectId("5cee50bb019f45001d2b602f"),
    "publicationDate" : ISODate("2019-05-29T09:28:27.773Z")
  },
  {
    "_id" : ObjectId("5cee5119019f45001d2b6031"),
    "publicationDate" : ISODate("2019-05-29T09:30:01.319Z")
  },
  {
    "_id" : ObjectId("5cee5153019f45001d2b6032"),
    "publicationDate" : ISODate("2019-05-29T09:30:59.770Z")
  },
  {
    "_id" : ObjectId("5cee5160019f45001d2b6033"),
    "publicationDate" : ISODate("2019-05-29T09:31:12.503Z")
  },
  {
    "_id" : ObjectId("5cee530e3e9676001909ba24"),
    "publicationDate" : ISODate("2019-05-29T09:38:22.569Z")
  }
]

Output:

{
  "_id" : ObjectId("5cee530e3e9676001909ba24"),
  "publicationDate" : ISODate("2019-05-29T09:38:22.569Z")
}

Returns any

getParam

injectDatasetFields

Inject in each item the last characteristics (the dataset covering fields) of a LODEX.

Parameters

  • connectionStringURI string MongoDB connection string

Examples

Output:

[
  {
    "characteristics": {
      "_id": "5d289071340bb500201b5146",
      "qW6w": "Catégories WOS",
      "ImiI": "Cette table correspond aux catégories Web Of Science.",
      "alRS": "/api/run/syndication",
      "aDLT": "Dans le cadre de l'enrichissement des documents du...",
      "SFvt": "https://enrichment-process.data.istex.fr/ark:/67375/R0H-PWBRNFQ8-H",
      "RzXW": "https://docs.google.com/drawings/d/1LzjO-oD6snh0MYfqxfPB7q-LU6Dev1SRmJstXFGzgvg/pub?w=960&h=720",
      "E4jH": "https://www.etalab.gouv.fr/licence-ouverte-open-licence",
      "MvkG": "Plateforme ISTEX",
      "m7G5": "Inist-CNRS",
      "1TvM": "2016-05-12",
      "WcNl": "2019-01-16",
      "publicationDate": "2019-07-12T13:51:45.129Z"
    }
  }
]

keyMapping

Take an object and map its keys to the one in mapping parameters. Keep keys absent in from parameter.

[{
  "dFgH": "Value",
  "AaAa": "Value 2"
}]
[keyMapping]
from = dFgH
to = Title
from = AaAa
to = Description
[{
  "Title": "Value",
  "Description": "Value 2"
}]

Parameters

Returns any Same object with modified keys

labelizeFieldID

Inject in each item the last characteristics (the dataset covering fields) of a LODEX.

Parameters

  • connectionStringURI string MongoDB connection string
  • suffix boolean Add ID field as a suffix

Examples

Input:

[
  {
      "xderc": "Catégories WOS",
      "34Ddd": "Cette table correspond aux catégories Web Of Science.",
      "SD2Fs": "/api/run/syndication",
    }
  }
]

Output:

[
  {
      "Titre": "Catégories WOS",
      "Description": "Cette table correspond aux catégories Web Of Science.",
      "URL": "/api/run/syndication",
    }
  }
]

LodexAggregateQuery

Take Object containing a MongoDB aggregate query and throw the result

The input object must contain a connectionStringURI property, containing the connection string to MongoDB.

Parameters

  • collection String collection to use (optional, default "publishedDataset")
  • referer Object? data injected into every result object
  • filter Object? MongoDB filter
  • limit Object? limit the result
  • skip Object? limit the result

Returns Object

LodexBuildContext

Take Object containing a URL query and throw a Context Object compatible with runQuery or reduceQuery

Parameters

  • connectionStringURI String to connect to MongoDB (optional, default "mongodb://ezmaster_db:27017")
  • host String? to set host (usefull to build some links)

Returns Object

LodexGetCharacteristics

Return the last characteristics (the dataset covering fields) of a LODEX.

Parameters

  • connectionStringURI string MongoDB connection string

Examples

Output:

[
  {
    "characteristics": {
      "_id": "5d289071340bb500201b5146",
      "qW6w": "Catégories WOS",
      "ImiI": "Cette table correspond aux catégories Web Of Science.",
      "alRS": "/api/run/syndication",
      "aDLT": "Dans le cadre de l'enrichissement des documents du...",
      "SFvt": "https://enrichment-process.data.istex.fr/ark:/67375/R0H-PWBRNFQ8-H",
      "RzXW": "https://docs.google.com/drawings/d/1LzjO-oD6snh0MYfqxfPB7q-LU6Dev1SRmJstXFGzgvg/pub?w=960&h=720",
      "E4jH": "https://www.etalab.gouv.fr/licence-ouverte-open-licence",
      "MvkG": "Plateforme ISTEX",
      "m7G5": "Inist-CNRS",
      "1TvM": "2016-05-12",
      "WcNl": "2019-01-16",
      "publicationDate": "2019-07-12T13:51:45.129Z"
    }
  }
]

LodexGetFields

Return the fields (the model) of a LODEX.

Parameters

  • connectionStringURI string MongoDB connection string

LodexInjectCountFrom

Inject in each item the last characteristics (the dataset covering fields) of a LODEX.

[
          { "id": 0, "value":2000  },
          { "id": 1, "value":2001  },
          { "id": 2, "value":2003  },
          { "id": 3, "value":2005  },
          { "id": 4, "value":2007  },
          { "id": 2, "value":2003  },
          { "id": 6, "value":2011  },
          { "id": 7, "value":2013  }
]
[injectCountFrom]
path = value
field = publicationDate
[
          { "id": 0, "value":2003, "value_count":3  },
          { "id": 1, "value":2001, "value_count":1  },
          { "id": 2, "value":2003, "value_count":3  },
          { "id": 3, "value":2005, "value_count":1  },
          { "id": 4, "value":2007, "value_count":1  },
          { "id": 2, "value":2003, "value_count":3  },
          { "id": 6, "value":2011, "value_count":2  },
          { "id": 7, "value":2011, "value_count":2  }
]

Parameters

  • connectionStringURI string MongoDB connection string
  • path string to get value to find
  • field string name contains the value to find (generaly equals to path) (optional, default auto)

LodexInjectSyndicationFrom

Inject title & description (syndicationà from field what conatsin the uri of one resource

Parameters

  • path string Field path contains URI
  • connectionStringURI string MongoDB connection string

Examples

Output:

[
  {
{
      "id": "uri:/ZD44DSQ",
      "id-title": "Titre de la ressource uri:/ZD44DSQ",
      "id-description": "Description de la ressource uri:/ZD44DSQ",
      "value": 10
    }
  }
]

LodexJoinQuery

Take 3 parameters and create a join query (one to many, on sub-ressource)

The input object must contain a connectionStringURI property, valued with the connection string to MongoDB.

Parameters

  • collection String collection to use (optional, default "publishedDataset")
  • referer Object? data injected into every result object
  • filter Object MongoDB filter (optional, default {})
  • sortOn String? Field to sort on
  • sortOrder String? Oder to sort
  • matchField String? Lodex field, containing matchable element
  • matchValue String? Value used with the match field to get items
  • joinField String? Lodex field used for the join request
  • limit Object? limit the result
  • skip Object? limit the result

Returns Object

LodexOutput

Format the output in compliance with LODEX routines format.

Parameters

  • keyName string name of the data property (optional, default "data")
  • indent boolean indent or not (optional, default false)
  • extract Array<string>? fields to put at the root of the output object

Examples

Input

[
     { _id: 1, value: 2, total: 2 },
     { _id: 2, value: 4, total: 2 }
]

Script

.pipe(ezs('LodexOutput', { extract: 'total' }))

Output

{
    data [
        { _id: 1, value: 2 },
        { _id: 2, value: 4 }
    ],
    total: 2
}

Returns string

LodexReduceQuery

Take an Object containing a MongoDB query, and a reducer, then throw the result.

The input object must contain a connectionStringURI property, containing the connection string to MongoDB.

Parameters

  • reducer String The name of the reducer to use
  • referer Object? data injected into every result object
  • filter Object MongoDB filter (optional, default {})
  • field Array<string> limit the result to some fields (optional, default "uri")
  • minValue Object? limit the result
  • maxValue Object? limit the result
  • maxSize Object limit the result (optional, default 1000000)
  • orderBy Object? sort the result

Returns Object

LodexRunQuery

Take Object containing a MongoDB query and throw the result

The input object must contain a connectionStringURI property, containing the connection string to MongoDB.

Parameters

  • collection String collection to use (optional, default "publishedDataset")
  • referer Object? data injected into every result object
  • filter Object? MongoDB filter
  • sortOn String? Field to sort on
  • sortOrder String? Oder to sort
  • field Object limit the result to some fields (optional, default "uri")
  • limit Object? limit the result
  • skip Object? limit the result

Returns Object

objects2columns

Take an Object and flatten it to get only one level of keys.

[{
  "foo": {
    "hello": "world"
  },
  "bar": "anything else",
  "baz": 1
}]
[{
  "foo": "{\"hello\":\"world\"}",
  "bar": "anything else",
  "baz": 1
}]

Parameters

Returns Object

parseNQuads

Take N-Quads string and transform it to Objects.

Returns Object

writeTurtle

Take quad or prefixes object and return turtle string.

[{
   quad: {
     subject: { id: 'http://uri/janedoe' },
     predicate: { id: 'http://schema.org/jobTitle' },
     object: { id: '"Professor"' }
   }
 }, {
     quad: {
     subject: { id: 'http://uri/janedoe' },
     predicate: { id: 'http://schema.org/name' },
     object: { id: '"Jane Doe"' }
   }
 }, {
     quad: {
     subject: { id: 'http://uri/janedoe' },
     predicate: { id: 'http://schema.org/telephone' },
     object: { id: '"(425) 123-4567"' }
     }
 }, {
     quad: {
     subject: { id: 'http://uri/janedoe' },
     predicate: { id: 'http://schema.org/url' },
     object: { id: 'http://www.janedoe.com' }
     }
 }, {
     quad: {
     subject: { id: 'http://uri/janedoe' },
     predicate: { id: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' },
     object: { id: 'http://schema.org/Person' }
     }
 }, { prefixes: {} }
]
\@prefix schema: <http://schema.org/>.
\@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.

<http://uri/janedoe> schema:jobTitle "Professor";
    schema:name "Jane Doe";
    schema:telephone "(425) 123-4567";
    schema:url <http://www.janedoe.com>;
    a schema:Person.

Returns String turtle

1.16.6

8 months ago

1.16.5

9 months ago

1.16.3

1 year ago

1.16.4

1 year ago

1.16.2

1 year ago

1.16.1

1 year ago

1.16.0

1 year ago

1.15.2

2 years ago

1.15.1

2 years ago

1.15.0

2 years ago

1.14.10

2 years ago

1.14.11

2 years ago

1.14.9

2 years ago

1.14.8

2 years ago

1.14.7

2 years ago

1.14.6

2 years ago

1.14.5

2 years ago

1.14.4

3 years ago

1.14.3

3 years ago

1.14.2

3 years ago

1.14.1

3 years ago

1.14.0

3 years ago

1.13.0

3 years ago

1.12.0

3 years ago

1.11.0

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.9.5

3 years ago

1.9.4

3 years ago

1.9.2

3 years ago

1.10.0

3 years ago

1.8.3

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.0

3 years ago

1.6.2

3 years ago

1.6.1

3 years ago

1.6.0

3 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.12

4 years ago

1.3.11

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.6

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

5 years ago

1.0.1

5 years ago