### Run TriplyETL Generator with npx Source: https://docs.triply.cc/triply-etl/generic/getting-started Use this command to start the TriplyETL Generator. On first use, it downloads and installs the latest version; on subsequent uses, it updates to the latest version if available. ```bash npx @triply/etl-generator ``` -------------------------------- ### Install TriplyDB.js with npm Source: https://docs.triply.cc/triplydb-js Install the @triply/triplydb package. Requires Node.js 20 or newer; an API token is needed for non-public data access and writes. ```bash npm install @triply/triplydb ``` -------------------------------- ### Complex example with dots in keys Source: https://docs.triply.cc/triply-etl/extract/xml An extensive JSON example showing how complex sequences of keys with dots can be used. ```json { "a": { "$text": "1" }, "b": { "c": { "$text": "2" } }, "b.c": { "$text": "3" }, "d.d": { "e": { "$text": "4" }, "f": { "$text": "5" } }, "g.g": [ { "h.h": { "$text": "6" } }, { "h.h": { "$text": "7" } } ] } ``` -------------------------------- ### list() example: children linked lists Source: https://docs.triply.cc/triply-etl/assert/ratt/terms Example usage of list() to create linked lists for the children of every parent. ```text fromJson([{ parent: 'John', children: ['Joe', 'Jane'] }]), triple(iri(prefix.person, 'parent'), sdo.children, list(prefix.skolem, iris(prefix.person, 'children'))), ``` -------------------------------- ### list() example: resulting linked data for children Source: https://docs.triply.cc/triply-etl/assert/ratt/terms The linked data produced by the children example, showing the RDF list structure. ```text person:John sdo:children _:list1. _:list1 rdf:first person:Joe; rdf:rest _:list2. _:list2 rdf:first person:Jane; rdf:rest rdf:nil. ``` -------------------------------- ### Trace output example Source: https://docs.triply.cc/triply-etl/generic/debug Example output of the trace middleware showing record trace information and quads trace information. The output includes a command to rerun the traced middlewares for the record. ```text ┌─────────────────────────────────────┐ │ Record trace information │ │ { │ │ "a": 101, │ │ "b": 1 │ │ "b": 101 │ │ } │ │ │ └─────────────────────────────────────┘ ┌─────────────────────────────────────┐ │ Quads trace information (unchanged) │ │ empty │ │ │ └─────────────────────────────────────┘ To rerun the traced middlewares for this record use the following command: > npx etl lib/{script-name} --trace .trace-1650542307095 ``` -------------------------------- ### Example records from XLSX Source: https://docs.triply.cc/triply-etl/extract/xlsx Shows two example records emitted by fromXlsx() for a table with ID, Name, and Age columns. Includes special keys $recordId, $environment, $sheetName, and $fileName. ```json { "$recordId": 1, "$environment": "Development", "$sheetName": "Sheet1", "$fileName": "static/Untitled 1.xlsx", "ID": "1", "Name": "Doe, John", "Age": 32 } { "$recordId": 2, "$environment": "Development", "$sheetName": "Sheet1", "$fileName": "static/Untitled 1.xlsx", "ID": "2", "Name": "D., Jane", } ``` -------------------------------- ### Trace middleware example pipeline Source: https://docs.triply.cc/triply-etl/generic/debug Example pipeline using traceStart() and traceEnd() to trace changes to a record. The pipeline changes key 'a' by +100, then traces, then changes key 'b' by +100, and ends tracing. ```javascript fromJson([ { a: 1, b: 1 }, // first dummy record { a: 2, b: 2 }, // second dummy record ]), change({key:'a', type:'number', change: (val) => val +100}), // change the 'a' key traceStart(), change({key:'b', type:'number', change: (val) => val +100}), // change the 'b' key traceEnd(), ``` -------------------------------- ### list() example: resulting linked data (collection notation) Source: https://docs.triply.cc/triply-etl/assert/ratt/terms The linked data produced by the list() example using collection notation. ```text basket:123 def:contains ( 'apple'@en 'pear'@en 'banana'@en ). ``` -------------------------------- ### list() example: fruit basket Source: https://docs.triply.cc/triply-etl/assert/ratt/terms Example usage of list() to create linked lists for the contents of a basket. ```text fromJson([{ id: 123, contents: ['apple', 'pear', 'banana'] }]), triple(iri(prefix.basket, 'id'), def.contains, list(prefix.basket, literals('contents', lang.en))), ``` -------------------------------- ### Import debug functions from @triplyetl/etl/debug Source: https://docs.triply.cc/triply-etl/generic/changelog Example of importing logRecord, traceEnd, and traceStart from the debug module. ```javascript import { logRecord, traceEnd, traceStart } from '@triplyetl/etl/debug' ``` -------------------------------- ### Example run of TriplyETL Generator Source: https://docs.triply.cc/triply-etl/generic/getting-started Shows a possible interactive session with the generator, including hidden inputs and the final success message. ```text ? TriplyETL License Key: [hidden] ? Project name: my-etl ? Target folder: my-etl ? Dataset name: my-etl ? Create a new TriplyDB API Token? Yes ? Your TriplyDB URL: my-org.triply.cc ? Your TriplyDB email: my-account@my-organization.com ? Your TriplyDB password: [hidden] 🏁 Your project my-etl is ready for use in my-etl. ``` -------------------------------- ### Linked data output for geometry example Source: https://docs.triply.cc/triply-etl/assert/ratt/statements The linked data assertions generated by the geometry example. ```turtle feature:1 geo:hasGeometry geometry:1. geometry:1 a geo:Geometry; geo:asWKT 'Point(1.1 2.2)'^^geo:wktLiteral. ``` -------------------------------- ### Check current TriplyETL version with npm list Source: https://docs.triply.cc/triply-etl/generic/maintenance Prints the currently installed TriplyETL version. ```bash npm list @triplyetl/etl ``` -------------------------------- ### wkt.addPoint() example: resulting record of key '_point' Source: https://docs.triply.cc/triply-etl/transform/ratt The record of the key '_point' produced by the wkt.addPoint() example. It shows the WKT literal with its datatype and validation status. ```json { "_point": { "termType": "Literal", "value": "Point (52.37308 4.89245)", "language": "", "datatype": { "termType": "NamedNode", "value": "http://www.opengis.net/ont/geosparql#wktLiteral", "validationStatus": "canonical" }, "validationStatus": "canonical" } } ``` -------------------------------- ### iris() example: assert IRIs for children Source: https://docs.triply.cc/triply-etl/assert/ratt/terms Example usage of iris() to assert one IRI for each entry in the 'children' key. ```text fromJson([{ parent: 'John', children: ['Joe', 'Jane'] }]), triple(iri(prefix.person, 'parent'), sdo.children, iris(prefix.person, 'children')), ``` -------------------------------- ### list() example: resulting linked data (without collection notation) Source: https://docs.triply.cc/triply-etl/assert/ratt/terms The linked data produced by the list() example when not using collection notation, showing the explicit RDF list structure. ```text basket:123 def:contains _:list1. _:list1 rdf:first 'apple'@en; rdf:rest _:list2. _:list2 rdf:first 'pear'@en; rdf:rest _:list3. _:list3 rdf:first 'banana'@en; rdf:rest rdf:nil. ``` -------------------------------- ### triples() example with metadata and data graphs Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Example usage of triples() to make multiple metadata assertions in the metadata graph and multiple data assertions in the data graph. ```text triples(graph.metadata, [iri(prefix.dataset, str('flowers')), a, dcat.Dataset], ... ), triples(graph.data, [iri(prefix.flower, '_id'), a, def.Flower], ... ), ``` -------------------------------- ### Example: dynamic IRI prefix Source: https://docs.triply.cc/triply-etl/transform/ratt Shows how to use a dynamic IRI prefix from the data source record with addHashedIri(). ```turtle fromJson([ { prefix: Iri('https://triplydb.com/my-account/my-dataset/id/person/'), name: 'John Doe', }, { prefix: Iri('https://triplydb.com/my-account/my-dataset/id/product/'), name: '123', }, ]), addHashedIri({ prefix: 'prefix', content: ['name'], key: '_subject', }), triple('_subject', a, owl.NamedIndividual), ``` ```turtle prefix person: prefix product: person:76f294ac311b99e65ec99f947f30e a owl:NamedIndividual. product:9154deaa364b289c6b012e99f947f30e a owl:NamedIndividual. ``` -------------------------------- ### quads() example: data and metadata Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Example usage of quads() to make assertions in a metadata graph and a data graph, using arrays for each quad. ```text quads( [iri(prefix.dataset, 'flowers'), a, dcat.Dataset, graph.metadata], ..., ), quads( [iri(prefix.flower, '_id'), a, def.Flower, graph.data], ..., ), ``` -------------------------------- ### quad() example: data and metadata Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Example usage of quad() to make one statement in a metadata graph and one in a data graph, distinguishing data from metadata. ```text quad(iri(prefix.dataset, 'flowers'), a, dcat.Dataset, graph.metadata), quad(iri(prefix.flower, '_id'), a, def.Flower, graph.data), ``` -------------------------------- ### iris() example: resulting linked data Source: https://docs.triply.cc/triply-etl/assert/ratt/terms The linked data assertions produced by the iris() example. ```text person:John sdo:children person:Joe, person:Jane. ``` -------------------------------- ### addValue() with ifElse: adding a start date or 'unknown' Source: https://docs.triply.cc/triply-etl/transform/ratt Adds a '_startDate' key that either contains the start date from the source record or the value 'unknown' when the 'start' key is absent. Uses ifElse and addLiteral. ```triply fromJson([ { id: '123', start: '2022-02-12' }, { id: '456' }, ]), ifElse({ if: 'start', then: addLiteral({ content: 'start', datatype: xsd.date, key: '_start', }), }, { else: addValue({ content: 'unknown', key: '_start', }), }), triple(iri(prefix.event, 'id'), sdo.startDate, '_start'), ``` -------------------------------- ### Linked data output for unit of measure example Source: https://docs.triply.cc/triply-etl/assert/ratt/statements The linked data assertions generated by the unit of measure example. ```turtle product:1 sdo:height [ qudt:unit unit:CentiM; rdf:value 15 ]. ``` -------------------------------- ### Install dependencies with npm i Source: https://docs.triply.cc/triply-etl/generic/cli Run this command after pulling changes that include updates to `package.json` to effectuate dependency changes in your local copy. ```bash npm i ``` -------------------------------- ### XML source file example.xml Source: https://docs.triply.cc/triply-etl/generic/record The contents of the local XML file used as the source in the following example. ```XML 123 John 456 Jane ``` -------------------------------- ### Example record from Shapefile Source: https://docs.triply.cc/triply-etl/extract/shapefile Shows the structure of a record extracted from a Shapefile, including properties and geometry. ```json { '$recordId': 1, '$environment': 'Development', '$fileName': 'nl_1km.shp', type: 'Feature', properties: { CELLCODE: '1kmE3793N3217', EOFORIGIN: 3793000, NOFORIGIN: 3217000 }, geometry: { type: 'Polygon', coordinates: [ [ [ 3793000, 3217000 ], [ 3793000, 3218000 ], [ 3794000, 3218000 ], [ 3794000, 3217000 ], [ 3793000, 3217000 ] ] ] } } ``` -------------------------------- ### Example JSON data with nested keys Source: https://docs.triply.cc/triply-etl/extract/json Example JSON data used to illustrate nested keys and path selectors. Contains nested metadata and data objects with arrays. ```json { "metadata": { "title": { "name": "Data about countries." } }, "data": { "countries": [ { "country.id": "nl", "name": "The Netherlands" }, { "country.id": "de", "name": "Germany" } ] } } ``` -------------------------------- ### wkt.addPoint() example: fromJson, wkt.addPoint, triple Source: https://docs.triply.cc/triply-etl/transform/ratt Shows how to use wkt.addPoint() to create a WKT literal from latitude and longitude keys. The example uses fromJson to create data, wkt.addPoint to generate the WKT string, and triple to assert linked data. ```javascript fromJson({ place: 'Amsterdam', lat: 52.37308, long: 4.89245 }), wkt.addPoint({ latitude: 'lat', longitude: 'long', key: '_point' }), triple(iri(prefix.city, 'place'), geo.asWKT, '_point'), ``` -------------------------------- ### Example: Alternative labels using objects() Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Asserts multiple alternative labels for a city using fromJson and objects(). The example uses a JSON input with name and alt1-alt4 fields, and asserts skos:altLabel for each alt value. ```javascript fromJson([{ name: 'Ney York', alt1: 'The Big Apple', alt2: 'The Capital of the World', alt3: 'The City of Dreams', alt4: 'The City That Never Sleeps', }]), objects(iri(prefix.city, 'name'), skos.altLabel, 'alt1', 'alt2', 'alt3', 'alt4', ), ``` -------------------------------- ### padStart() example: Create year literals Source: https://docs.triply.cc/triply-etl/transform/ratt Pads the year component to at least 4 digits to create standards-conforming temporal literals. The transformation uses padStart() on the 'Year' key and then creates a triple with the padded value. The output shows the resulting linked data assertions. ```triply padStart({ content: 'Year', padString: '0', targetLength: 4, key: '_lexicalForm', }), triple( iri(prefix.id, 'Artifact'), dct.created, literal('_lexicalForm', xsd.gYear), ), ``` ```turtle id:0001 dct:created '0612'^^xsd:gYear. id:0002 dct:created '1702'^^xsd:gYear. ``` -------------------------------- ### padStart() example: Fixed-length identifiers Source: https://docs.triply.cc/triply-etl/transform/ratt Processes identifiers of varying length and pads them with '0' to a target length of 6. The input is a JSON array with two records. The output shows the resulting records with the padded '_id' field. ```triply fromJson([ { id: '16784' }, { id: '129' }, ]), padStart({ content: 'id', padString: '0', targetLength: 6, key: '_id', }), ``` ```json [ { "id": "16784", "_id": "016784" }, { "id": "129", "_id": "000129" } ] ``` -------------------------------- ### XML example with nested keys and indexed arrays Source: https://docs.triply.cc/triply-etl/extract/xml Shows an XML document with nested keys and indexed arrays, used to illustrate path expressions. ```xml <name>Data about countries.</name> The Netherlands Germany ``` -------------------------------- ### Using fromXml() with XSLT stylesheet Source: https://docs.triply.cc/triply-etl/transform/xslt Example of using fromXml() middleware in TriplyETL to load and transform XML to XML with a different structure, specifying the stylesheet parameter. ```javascript fromXml(Source.file(xml), { selectors: 'rdf:RDF.sdo:Person', stylesheet: Source.file(stylesheet), }) ``` -------------------------------- ### Input XML file (books.xml) Source: https://docs.triply.cc/triply-etl/transform/xslt Example XML file containing a library with two books, used as input for the XSLT transformation. ```xml The Great Gatsby F. Scott Fitzgerald 1984 George Orwell ``` -------------------------------- ### uppercase() example: fromJson, uppercase, triple Source: https://docs.triply.cc/triply-etl/transform/ratt Shows how to use uppercase() to convert the value of 'countryCode' to uppercase and store it in '_countryCode'. The example uses fromJson to create data, uppercase to transform, and triple to assert linked data. ```javascript fromJson({ place: 'Amsterdam', countryCode: 'nl' }), uppercase({ content: 'countryCode', key: '_countryCode' }), triple(iri(prefix.id, 'place'), iri(prefix.geonames, str('countryCode')), '_countryCode') ``` -------------------------------- ### Markdown headings example Source: https://docs.triply.cc/triply-db-getting-started/reference Demonstrates Markdown headings from level 1 to level 6 using hash characters. Used to divide text into sections. ```markdown # Heading 1 ## Heading 2 ### Heading 3 #### Heading 4 ##### Heading 5 ###### Heading 6 ``` -------------------------------- ### Use multiple TriplyDB instances with different tokens and URLs Source: https://docs.triply.cc/triply-etl/publish Configure two TriplyDB sources in one Etl pipeline, each with its own token and URL. The example uses a production instance for the data model and an acceptance instance for instance data, reading tokens from environment variables. ```javascript const etl = new Etl({ sources: { data_model: Source.TriplyDb.rdf( 'my-account', 'my-dataset', { triplyDb: { token: process.env['PRODUCTION_INSTANCE_TOKEN'], url: 'https://api.production.example.com' } } ), instance_data: Source.TriplyDb.rdf( 'my-account', 'my-dataset', { triplyDb: { token: process.env['ACCEPTANCE_INSTANCE_TOKEN'], url: 'https://api.acceptance.example.com' } } ), }, }) ``` -------------------------------- ### Import logRecord from @triplyetl/etl/debug Source: https://docs.triply.cc/triply-etl/generic/changelog Example of ESM import syntax for the logRecord function from the debug module. ```javascript import { logRecord } from '@triplyetl/etl/debug' ``` -------------------------------- ### Example JSON file for TriplyDB upload Source: https://docs.triply.cc/triply-db-getting-started/uploading-data A sample JSON document with nested objects and arrays, used to illustrate how TriplyDB converts JSON to RDF using the Facade-X model. ```json { "name": "Friends", "genres": ["Comedy", "Romance"], "cast": [ { "actor": "Jennifer Aniston", "role": "Rachel" }, { "actor": "Matt LeBlanc", "role": "Joey" } ] } ``` -------------------------------- ### when() with shorthand for zipcode presence Source: https://docs.triply.cc/triply-etl/generic/control-structures Equivalent to the previous example but uses a shorthand string 'zipcode' to check for presence. This is common for single key checks. ```text when('zipcode', triple(iri(prefix.id, 'id'), def.zipcode, 'zipcode'), ), ``` -------------------------------- ### Typical ETL structure with executeRules Source: https://docs.triply.cc/triply-etl/enrich/shacl Shows the typical ETL structure: assert linked data, execute SHACL rules, and then do something with the enriched data. The example uses Source.file('static/model.trig') to load the model and executeRules to run the rules. ```typescript import { Etl, Source } from '@triplyetl/etl/generic' import { executeRules } from '@triplyetl/etl/shacl' export default async function (): Promise { const etl = new Etl() etl.use( // Step 1. Assert some linked data into the internal store. executeRules(Source.file('static/model.trig')), // Step 2 // Step 3. Do something with the linked data, e.g. publish it to TriplyDB. ) return etl } ``` -------------------------------- ### wkt.addPoint() example: resulting linked data assertion Source: https://docs.triply.cc/triply-etl/transform/ratt The linked data assertion produced by the wkt.addPoint() example. It shows the WKT literal as the object of the geo:asWKT property. ```turtle city:Amstedam geo:asWKT "Point (52.37308 4.89245)"^^geo:wktLiteral ``` -------------------------------- ### addValue() example: resulting linked data assertion Source: https://docs.triply.cc/triply-etl/transform/ratt The linked data assertion produced by the previous addValue() example, showing the person:johndoe foaf:age 22 triple. ```turtle person:johndoe foaf:age 22. ``` -------------------------------- ### Example desired tree structure Source: https://docs.triply.cc/generics/JSON-LD-frames Shows the desired tree-shaped JSON structure with cities as keys and inhabitants as arrays, illustrating the framing goal. ```json { "amsterdam": { "inhabitants": [ "john" ] }, "berlin": { "inhabitants": [ "jane", "tim" ] } } ``` -------------------------------- ### Example CSV file values Source: https://docs.triply.cc/triply-db-getting-started/uploading-data A sample CSV file content that can be uploaded to TriplyDB. It is used to illustrate the simple representation for tabular data. ```csv product_id,name,category,price,in_stock P001,Laptop Stand,Office Equipment,49.99,true P002,Ergonomic Keyboard,Peripherals,89.50,true ``` -------------------------------- ### Markdown inline code example Source: https://docs.triply.cc/triply-db-getting-started/reference Shows how to use inline code with single backticks inside a sentence. ```markdown Use `code` inside a sentence. ``` -------------------------------- ### loadRdf() base IRI fix example Source: https://docs.triply.cc/triply-etl/generic/changelog Example showing the previous incorrect base IRI behavior when using `loadRdf()` with a string source. The snippet uses `Source.string('

.')` and `logQuads()` to display the resulting quads. ```typescript import { logQuads } from '@triplyetl/etl/debug' import { Etl, loadRdf, Source } from '@triplyetl/etl/generic' export default async function (): Promise { const etl = new Etl() etl.use( loadRdf(Source.string('

.')), logQuads(), ) return etl } ``` ```turtle { } ``` ```turtle { } ``` -------------------------------- ### Publish to TriplyDB with toTriplyDb() Source: https://docs.triply.cc/triply-etl/publish Uploads pipeline output to a TriplyDB dataset. If no account is given, the user account tied to the current API Token is used. The second and third examples specify an account and optionally set the overwrite option. ```javascript toTriplyDb({dataset: 'my-dataset'}) toTriplyDb({account: 'my-account', dataset: 'my-dataset'}) toTriplyDb({account: 'my-account', dataset: 'my-dataset', opts:{ overwrite: true }}) ``` -------------------------------- ### Sample data with nested countries and labels Source: https://docs.triply.cc/triply-etl/generic/control-structures Example data used to illustrate nested forEach() calls. Contains an outer list of countries and an inner list of labels. ```json { "data": { "countries": [ { "id": "NL", "labels": [ { "name": "The Netherlands", "locale": "en-us" }, { "name": "Nederland", "locale": "nl-nl" } ] }, { "id": "EN", "labels": [ { "name": "England", "locale": "en-gb" } ] } ] } } ``` -------------------------------- ### Example: statement reification Source: https://docs.triply.cc/triply-etl/transform/ratt Uses addHashedIri() to create a unique identifier for each reified statement, along with the resulting linked data. ```turtle fromJson([{ id: '1', name: 'John Doe' }]), // Step 1. Create the subject, predicate, and object terms. addIri({ prefix: prefix.person, content: 'id', key: 'subject' }), addIri({ prefix: prefix.def, content: str('name'), key: 'predicate' }), addLiteral({ content: 'name', key: 'object' }), // Step 2. Create the triple statement. triple('subject', 'predicate', 'object'), // Step 3. Create the reified statement. addHashedIri({ prefix: prefix.statement, content: ['subject', 'predicate', 'object'], key: 'statement', }), pairs('statement', [a, rdf.Statement], [rdf.subject, 'subject'], [rdf.predicate, 'predicate'], [rdf.object, 'object'], ), ``` ```turtle person:1 def:name 'John Doe'. statement:549decc4c44204a907aa32b4cc9bfaba a rdf:Statement; rdf:subject person:1; rdf:predicate def:name; rdf:object 'John Doe'. ``` -------------------------------- ### Using loadRdf() with XSLT stylesheet Source: https://docs.triply.cc/triply-etl/transform/xslt Example of using loadRdf() middleware in TriplyETL to load and transform XML to RDF, specifying the stylesheet parameter and content type. ```javascript loadRdf(Source.file(xml), { contentType: 'application/rdf+xml', stylesheet: Source.file(xsl), }), ``` -------------------------------- ### Example JSON-LD graph data Source: https://docs.triply.cc/generics/JSON-LD-frames Shows a JSON-LD array representing a graph with three persons and their cities. This is the input to be framed. ```json [ { "@id": "john", "livesIn": { "@id": "amsterdam" } }, { "@id": "jane", "livesIn": { "@id": "berlin" } }, { "@id": "tim", "livesIn": { "@id": "berlin" } } ] ``` -------------------------------- ### Validate usage example Source: https://docs.triply.cc/triply-etl/transform/ratt Asserts a triple with an email address validated in the object position. Throws an error for invalid email addresses. ```triply-etl fromJson([{ name: "John", email: 'john.appleseed@example.com' }, {name: 'NA', email: 'notAnEmail' } ]), addLiteral({ content: 'email', validate: isEmail(), key: '_email', }), triple(iri(prefix.person, 'name'), foaf.mbox, '_email'), ``` ```text ERROR (Record #2) String "notAnEmail" is not an email address. ``` ```triply-etl fromJson([{ name: "John", email: 'john.appleseed@example.com' }, { name: "Lisa", email: 'lisa.appleseed@example.com' } ]), addLiteral({ content: 'email', validate: isEmail(), key: '_email', }), triple(iri(prefix.person, 'name'), foaf.mbox, '_email'), ``` ```turtle person:John foaf:mbox "john.appleseed@example.com" person:Lisa foaf:mbox "lisa.appleseed@example.com" ``` -------------------------------- ### addValue() example: adding an array to a record Source: https://docs.triply.cc/triply-etl/transform/ratt Starts with an empty source record and adds a 'data' key containing an array with a string and a number. The triple assertion extracts elements using 'data[0]' and 'data[1]'. ```triply fromJson([{}]), addValue({ content: ['johndoe', 22], key: 'data', }), triple(iri(prefix.person, 'data[0]'), foaf.age, 'data[1]'), ``` -------------------------------- ### addTag() example: creating a Dutch language tag Source: https://docs.triply.cc/triply-etl/transform/ratt Creates a language tag for Dutch as spoken in the Netherlands and uses it in a triple assertion. The content 'nl-nl' must follow the IANA language subtag registry format. ```triply fromJson([{ label: 'Amsterdam' }]), addTag({ content: 'nl-nl', key: 'lang', }), triple(iri(prefix.city, 'label'), rdfs.label, literal('label', 'lang')), ``` -------------------------------- ### Linked data assertions output Source: https://docs.triply.cc/triply-etl/generic/changelog The resulting linked data assertions from the nestedPairs() example, showing the generated triples. ```turtle product:1 sdo:height [ qudt:unit unit:CentiM; rdf:value 15 ]. ``` -------------------------------- ### Run SHACL SPARQL rule using external files Source: https://docs.triply.cc/triply-etl/enrich/shacl/sparql-rules Same TriplyETL script as Step 1C but loads instance data and information model from separate files (`static/instances.trig` and `static/model.trig`) instead of inline strings, keeping the script concise. ```typescript import { logQuads } from '@triplyetl/etl/debug' import { Etl, Source, loadRdf } from '@triplyetl/etl/generic' import { executeRules } from '@triplyetl/etl/shacl' export default async function (): Promise { const etl = new Etl() etl.use( loadRdf(Source.file('static/instances.trig')), executeRules(Source.file('static/model.trig')), logQuads(), ) return etl } ``` -------------------------------- ### nestedPairs() with fromJson() and addSkolemIri() Source: https://docs.triply.cc/triply-etl/generic/changelog Example of nestedPairs() used with fromJson() and addSkolemIri() to create linked data assertions with a Skolem IRI for the subject. ```typescript fromJson([{ id: '1', height: 15 }]), addSkolemIri({ prefix: prefix.skolem, key: '_height', }), nestedPairs(iri(prefix.product, 'id'), sdo.height, [qudt.unit, unit.CentiM], [rdf.value, 'height'], ), ``` -------------------------------- ### Navigate to target folder Source: https://docs.triply.cc/triply-etl/generic/getting-started Change into the target folder you specified during project creation. ```bash cd my-etl ``` -------------------------------- ### Alternative to nestedPairs() using triple() and pairs() Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Shows how the geometry example can be rewritten without nestedPairs(), requiring the nested node to be specified twice, which is a maintenance burden. ```typescript fromJson([{ id: '1', geometry: 'Point(1.1 2.2)' }]), triple(iri(prefix.feature, 'id'), geo.hasGeometry, iri(prefix.geometry, 'id')), pairs(iri(prefix.geometry, 'id'), [a, geo.Geometry], [geo.asWKT, literal('geometry', geo.wktLiteral)], ), ``` -------------------------------- ### IRI prefix tree example with base IRI and prefix object Source: https://docs.triply.cc/triply-etl/generic/declarations Declares a base IRI, internal prefix nodes, and leaf prefixes in an object. This consolidates the IRI strategy for a dataset in one place. ```typescript import { Iri } from '@triplyetl/etl/generic' const baseIri = Iri('https://triplydb.com/my-account/my-dataset/') const prefix_id = baseIri.concat('id/') const prefix_model = baseIri.concat('model/') const prefix = { city: prefix_id.concat('city/'), def: prefix_model.concat('def/'), person: prefix_id.concat('person/'), } ``` -------------------------------- ### Resulting linked data assertions Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Shows the 4 linked data assertions produced by the example above, with city:New%20York as subject and skos:altLabel predicates. ```turtle city:New%20York skos:altLabel 'The Big Apple'@en. 'The Capital of the World'@en, 'The City of Dreams'@en, 'The City That Never Sleeps'@en. ``` -------------------------------- ### TriG graph notation equivalent Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Shows the TriG notation that is structurally similar to the triples() example. It uses graph:metadata and graph:data blocks to assert the same statements. ```text graph:metadata { dataset:flowers a dcat:Dataset. ... } graph:data { flower:123 a def:Flower. ... } ``` -------------------------------- ### Insert Data example with logQuads Source: https://docs.triply.cc/triply-etl/enrich/sparql/update Adds one triple to the Internal Store using SPARQL Update. The `logQuads()` function prints the store content to standard output. ```typescript import { logQuads } from '@triplyetl/etl/debug' import { Etl } from '@triplyetl/etl/generic' import { update } from '@triplyetl/etl/sparql' export default async function (): Promise { const etl = new Etl() etl.use( update(` base insert data { . }`), logQuads(), ) return etl } ``` ```text base . ``` -------------------------------- ### CSV example with quoted fields and empty values Source: https://docs.triply.cc/triply-etl/extract/csv Example CSV snippet showing quoted fields with commas and an empty trailing cell. ```CSV ID,Name,Age 1,"Doe, John",32 2,"D., Jane ", ``` -------------------------------- ### Run ETL with TriplyETL Runner Source: https://docs.triply.cc/triply-etl/generic/getting-started Use this command to run the ETL project with the TriplyETL Runner. ```bash npx etl ``` -------------------------------- ### uppercase() example: resulting linked data assertion Source: https://docs.triply.cc/triply-etl/transform/ratt The linked data assertion produced by the uppercase() example. It shows the transformed value 'NL' as the object of the triple. ```turtle city:Amsterdam geonames:countryCode "NL" ``` -------------------------------- ### Import external vocabularies (FOAF, OWL, PREMIS) Source: https://docs.triply.cc/triply-etl/generic/declarations Imports the FOAF, OWL, and PREMIS vocabularies from the TriplyETL vocabulary library. Required before using terms like foaf.Person or premis.File. ```typescript import { foaf, owl, premis } from '@triplyetl/vocabularies' ``` -------------------------------- ### Example JSON-LD from Wikipedia page of Ada Lovelace Source: https://docs.triply.cc/triply-etl/extract/rdf Example of JSON-LD linked data found on the Wikipedia page of Ada Lovelace. It includes schema.org context, type Article, and properties such as name, url, sameAs, author, publisher, and dates. ```json { "@context": "https://schema.org", "@type": "Article", "name": "Ada Lovelace", "url": "https://en.wikipedia.org/wiki/Ada_Lovelace", "sameAs": "http://www.wikidata.org/entity/Q7259", "mainEntity": "http://www.wikidata.org/entity/Q7259", "author": { "@type": "Organization", "name": "Contributors to Wikimedia projects" }, "publisher": { "@type": "Organization", "name": "Wikimedia Foundation, Inc.", "logo": { "@type": "ImageObject", "url": "https://www.wikimedia.org/static/images/wmf-hor-googpub.png" } }, "datePublished": "2001-05-20T14:57:05Z", "dateModified": "2023-03-17T21:28:23Z", "image": "https://upload.wikimedia.org/wikipedia/commons/0/0b/Ada_Byron_daguerreotype_by_Antoine_Claudet_1843_or_1850.jpg", "headline": "1815-1852 British mathematician, considered the first computer programmer" } ``` -------------------------------- ### Destination.TriplyDb.rdf() with 'me' account Source: https://docs.triply.cc/triply-etl/generic/changelog Uses Destination.TriplyDb.rdf() with the 'me' account name. ```typescript Destination.TriplyDb.rdf("me", datasetName) ``` -------------------------------- ### Source data inline JSON Source: https://docs.triply.cc/triply-etl/validate/shacl The source data used in the example, recording the age of a person as a string. ```json { "age": "twelve", "id": "id" } ``` -------------------------------- ### Key with dot Source: https://docs.triply.cc/triply-etl/extract/json Example key containing a dot. This key requires escaping when used in path expressions. ```json "country.id" ``` -------------------------------- ### Check for new TriplyETL versions with npm outdated Source: https://docs.triply.cc/triply-etl/generic/maintenance Prints the latest available TriplyETL version and other outdated dependencies. ```bash npm outdated ``` -------------------------------- ### Extract and log records from local XML file using fromXml() Source: https://docs.triply.cc/triply-etl/generic/record Uses the fromXml() extractor with Source.file('example.xml') to read the XML file and logRecord() to print each record. The output records are identical to those from the JSON source, demonstrating the generic Record format. ```TypeScript import { Etl, fromXml, logRecord } from '@triplyetl/etl/generic' export default async function (): Promise { const etl = new Etl() etl.use( fromXml(Source.file('example.xml')), logRecord(), ) return etl } ``` ```JSON { "id": "123", "name": "John", "$recordId": 1, "$environment": "Development" } { "id": "456", "name": "Jane", "$recordId": 2, "$environment": "Development" } ``` -------------------------------- ### when() with condition and multiple statements Source: https://docs.triply.cc/triply-etl/generic/control-structures Shows the general syntax of when() with a condition and multiple statements. The condition determines whether the remaining parameters are called. ```text when('{condition}', '{statement-1}', '{statement-2}', '{statement-3}', // etc ), ``` -------------------------------- ### Language-tagged string example Source: https://docs.triply.cc/triply-etl/transform/ratt Asserts a triple with a language-tagged string in the object position. The literal is created with a language tag and used in the triple. ```triply-etl fromJson([{ name: 'London' }]), addLiteral({ content: 'name', language: language.en, key: '_name', }), triple(iri(prefix.city, 'name'), skos.prefLabel, '_name'), ``` ```turtle city:London skos:prefLabel 'London'@en. ``` ```triply-etl fromJson([{ name: 'London' }]), triple(iri(prefix.city, 'name'), skos.prefLabel, literal('name', lang['en'])), ``` -------------------------------- ### Invalid literal with xsd:nonNegativeInteger Source: https://docs.triply.cc/triply-etl/validate/shacl An example of an invalid literal that TriplyETL will not allow to be asserted, as it would create incorrect linked data. ```turtle 'twelve'^^xsd:nonNegativeInteger ``` -------------------------------- ### Validate with Source.string() Source: https://docs.triply.cc/triply-etl/validate/shacl Uses validate() with an in-line SHACL model via Source.string(). The model is the same as the previous example but embedded in a template literal. ```typescript validate(Source.string(` prefix foaf: prefix rdf: prefix sh: prefix shp: prefix xsd: shp:Person a sh:NodeShape; sh:closed true; sh:ignoredProperties ( rdf:type ); sh:property shp:Person_age; sh:targetClass foaf:Person. shp:Person_age a sh:PropertyShape; sh:datatype xsd:nonNegativeInteger; sh:maxCount 1; sh:minCount 1; sh:path foaf:age.` )), ``` -------------------------------- ### Publish to local file with Destination.file() Source: https://docs.triply.cc/triply-etl/publish Use Destination.file() to write RDF output to a local file. This is useful when you lack an active Internet connection, though local files do not support browsing, querying, metadata, or prefix declarations like TriplyDB destinations do. ```javascript toRdf(Destination.file('my-file.trig')), ``` -------------------------------- ### Target data (informal) in Turtle Source: https://docs.triply.cc/triply-etl/validate/shacl The intended linked data output for the example, showing a foaf:Person with foaf:age 'twelve'. ```turtle id:123 a foaf:Person; foaf:age 'twelve'. ``` -------------------------------- ### Publish to TriplyDB with toRdf() Source: https://docs.triply.cc/triply-etl/publish Legacy way to upload to TriplyDB using toRdf() with Destination.TriplyDb.rdf(). Still supported but simplified by toTriplyDb(). ```javascript toRdf(Destination.TriplyDb.rdf('my-account', 'my-dataset', {triplyDb: etl.triplyDb})) ``` -------------------------------- ### nestedPairs() example: Geometry Source: https://docs.triply.cc/triply-etl/assert/ratt/statements Asserts a GeoSPARQL geometry using nestedPairs() with an explicit nested node. The geometry is created as a separate node. ```typescript fromJson([{ id: '1', geometry: 'Point(1.1 2.2)' }]), nestedPairs(iri(prefix.feature, 'id'), geo.hasGeometry, iri(prefix.geometry, 'id'), [a, geo.Geometry], [geo.asWKT, literal('geometry', geo.wktLiteral)], ), ``` -------------------------------- ### forEach with logRecord() to observe $parent Source: https://docs.triply.cc/triply-etl/generic/control-structures Prints the iterated elements to the terminal using logRecord(). The output shows the $parent key containing the parent record. ```triply-etl forEach('data.countries', logRecord(), ), ``` -------------------------------- ### Configure Comunica engine for construct() Source: https://docs.triply.cc/triply-etl/generic/changelog Explicitly configures the Comunica SPARQL engine for the construct() function. Use this to restore the previous default engine if the new Speedy engine causes issues in your ETL pipeline. ```TypeScript import { construct } from '@triplyetl/etl/sparql' construct(Source.TriplyDb.query('my-query'), { sparqlEngine: 'comunica' }), ``` -------------------------------- ### String literal example Source: https://docs.triply.cc/triply-etl/transform/ratt Asserts a triple with a string literal in the object position. The literal is created from a record field and used directly in the triple. ```triply-etl fromJson([{name: 'London'}]), addLiteral({ content: 'name', key: '_name', }), triple(iri(prefix.city, '_name'), skos.prefLabel, '_name') ``` ```turtle city:London sdo:name 'London'. ``` ```triply-etl fromJson([{ name: 'London' }]), triple(iri(prefix.city, 'name'), skos.prefLabel, 'name'), ``` -------------------------------- ### Records with $recordId special key Source: https://docs.triply.cc/triply-etl/generic/record Example records from a source table with no unique properties, showing the automatically added $recordId special key. ```json { "First name": "John", "Last name": "Doe", "$recordId": 1 } { "First name": "Jane", "Last name": "Doe", "$recordId": 2 } { "First name": "John", "Last name": "Doe", "$recordId": 3 } ``` -------------------------------- ### Import fromXlsx and Source Source: https://docs.triply.cc/triply-etl/extract/xlsx Imports the fromXlsx extractor and Source class from the TriplyETL generic module. ```typescript import { fromXlsx, Source } from '@triplyetl/etl/generic' ```