ldkit 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Karel Klima
3
+ Copyright (c) 2021-present Karel Klima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,7 +1,117 @@
1
- # LDkit
1
+ # LDkit - Linked Data for TypeScript developers.
2
2
 
3
- Linked Data query toolkit for TypeScript developers.
3
+ **LDkit** is **Linked Data** query toolkit for **TypeScript** developers. It
4
+ provides ORM-like abstraction over [RDF](https://www.w3.org/RDF/) datasources.
5
+ You define the data model and then you can retrieve or update data without any
6
+ extra hustle. LDkit will generate SPARQL queries, retrieves RDF data and
7
+ converts them to TypeScript native types.
4
8
 
5
- RDF and SPARQL abstraction for browser, Deno and Node.
9
+ ## 💣 Key Features
6
10
 
11
+ - Next-generation ORM-like [RDF](https://www.w3.org/RDF/) abstraction.
12
+ - Retrieve and update data using reusable data models.
13
+ - Compatible with [Comunica](https://comunica.dev) query engine (you can even
14
+ write your own!).
15
+ - 10+ popular ontologies included.
16
+ - First class TypeScript support, best in class developer experience.
17
+ - Runs in browser, [Deno](https://deno.land) and [Node](nodejs.org).
18
+ - ...and more!
19
+
20
+ ## 📖 Documentation
21
+
22
+ The [documentation](https://ldkit.io/docs) and examples are available on
7
23
  [ldkit.io](https://ldkit.io).
24
+
25
+ ## 🚀 Getting Started
26
+
27
+ If you are using Node, then you can install LDkit using your favourite package
28
+ manager.
29
+
30
+ ```bash
31
+ npm i ldkit
32
+ ```
33
+
34
+ For Deno environment, you can import LDkit like this:
35
+
36
+ ```ts
37
+ import * as ldkit from "https://deno.land/x/ldkit/mod.ts";
38
+ ```
39
+
40
+ ### Set up RDF source and create data schema
41
+
42
+ ```ts
43
+ import { type Context, createResource } from "ldkit";
44
+ import { dbo, rdfs, xsd } from "ldkit/namespaces";
45
+
46
+ // Create a context for query engine
47
+ const context: Context = {
48
+ sources: ["https://dbpedia.org/sparql"], // SPARQL endpoint
49
+ language: "en", // Preferred language
50
+ };
51
+
52
+ // Create a schema
53
+ const PersonSchema = {
54
+ "@type": dbo.Person,
55
+ name: rdfs.label,
56
+ abstract: dbo.abstract,
57
+ birthDate: {
58
+ "@id": dbo.birthDate,
59
+ "@type": xsd.date,
60
+ },
61
+ } as const;
62
+
63
+ // Create a resource using the data schema and context above
64
+ const Person = createResource(PersonSchema, context);
65
+ ```
66
+
67
+ ### List all available data
68
+
69
+ ```ts
70
+ // List all persons
71
+ const persons = await Person.find();
72
+ for (const person of persons) {
73
+ console.log(person.name); // string
74
+ console.log(person.birthDate); // Date
75
+ }
76
+
77
+ // Get total count of all persons
78
+ const count = await Person.count();
79
+ console.log(count); // number
80
+ ```
81
+
82
+ ### Get a particular entity
83
+
84
+ ```ts
85
+ // Get a particular person identified by IRI
86
+ const ada = await Person.findByIri("http://dbpedia.org/resource/Ada_Lovelace");
87
+ console.log(ada?.name); // string "Ada Lovelace"
88
+ console.log(ada?.birthDate); // Date object of 1815-12-10
89
+ ```
90
+
91
+ ### Data manipulation - insert, update and delete
92
+
93
+ ```ts
94
+ // Insert a new person
95
+ Person.insert({
96
+ $id: "http://dbpedia.org/resource/Alan_Turing",
97
+ name: "Alan Turing",
98
+ birthDate: new Date("1912-06-23"),
99
+ });
100
+
101
+ // Modify a person's name
102
+ Person.update({
103
+ $id: "http://dbpedia.org/resource/Alan_Turing",
104
+ name: "Not Alan Turing",
105
+ });
106
+
107
+ // Delete a person
108
+ Person.delete("http://dbpedia.org/resource/Alan_Turing");
109
+ ```
110
+
111
+ More complex examples can be found in [documentation](https://ldkit.io/docs).
112
+
113
+ ## License
114
+
115
+ [MIT License](./LICENSE.md)
116
+
117
+ Copyright © 2021-present [Karel Klima](https://karelklima.com)