@ng-org/orm 0.1.2-alpha.12 → 0.1.2-alpha.14

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/README.md CHANGED
@@ -13,7 +13,7 @@ For a walk-through you can see the the expense-tracker example apps for [discret
13
13
  Different CRDTs have different APIs. We want to make it as easy as possible to use them in the same way:\
14
14
  **You modify a plain old TypeScript object and that updates the CRDT.**\
15
15
  Vice versa, the CRDT is modified and that is reflected in your TS object.\
16
- We offer this for **React, Vue, and Svelte**.
16
+ We offer this for **React, Vue, and Svelte (5 and 4)**.
17
17
 
18
18
  Note that we support discrete (**JSON**) CRDT and graph (**RDF**) CRDT ORMs.
19
19
 
@@ -22,16 +22,19 @@ Note that we support discrete (**JSON**) CRDT and graph (**RDF**) CRDT ORMs.
22
22
 
23
23
  ## Table of Contents
24
24
 
25
+ - [Reference documentation](#reference-documentation)
26
+ - [Why?](#why)
25
27
  - [Installation](#installation)
26
28
  - [Start](#start)
27
- - [Graph ORM: Defining Schemas](#graph-orm-defining-schemas)
29
+ - [RDF (graph) ORM: Defining Schemas](#rdf-graph-orm-defining-schemas)
28
30
  - [Frontend Framework Usage](#frontend-framework-usage)
29
31
  - [Working with Data](#working-with-data)
30
- - [Creating a Document](#creating-a-document)
31
- - [Using and Modifying ORM Objects](#using-and-modifying-orm-objects)
32
- - [The (Discrete)OrmSubscription Class](#the-discreteormsubscription-class)
33
- - [The DeepSignal\<\> type](#the-deepsignal-type)
34
- - [Graph ORM: Relationships](#graph-orm-relationships)
32
+ - [Creating a Document](#creating-a-document)
33
+ - [Using and Modifying ORM Objects](#using-and-modifying-orm-objects)
34
+ - [The (Discrete)OrmSubscription Class](#the-discreteormsubscription-class)
35
+ - [Transactions](#transactions)
36
+ - [The DeepSignal\<\> type](#the-deepsignal-type)
37
+ - [Graph ORM: Relationships](#graph-orm-relationships)
35
38
 
36
39
  ---
37
40
 
@@ -53,16 +56,14 @@ pnpm add -D @ng-org/shex-orm
53
56
 
54
57
  Before writing your own app, you are strongly advised to look at the example apps below, where you can find framework and crdt-specific walkthroughs.
55
58
 
56
- - Discrete CRDTs
57
- - [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-discrete)
58
- - [Svelte 5 Runes](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte)
59
- - [Svelte 3/4](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte4)
59
+ - Discrete CRDTs [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-discrete)
60
+ - [Svelte 5](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte)
61
+ - [Svelte 4](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte4) (no support for Svelte 3)
60
62
  - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-vue)
61
63
  - [React](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-react)
62
- - RDF/Graph CRDT
63
- - [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-graph)
64
- - [Svelte 5 Runes](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte)
65
- - [Svelte 3/4](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte4)
64
+ - RDF CRDTs for [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-graph)
65
+ - [Svelte 5](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte)
66
+ - [Svelte 4](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte4) (no support for Svelte 3)
66
67
  - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-graph-vue)
67
68
  - [React](https://git.nextgraph.org/NextGraph/expense-tracker-graph-react)
68
69
 
@@ -99,7 +100,7 @@ See [@ng-org/shex-orm](../shex-orm/README.md) for details.
99
100
  **`shapes/shex/dogShape.shex`**:
100
101
 
101
102
  ```shex
102
- PREFIX ex: <http://example.org/>
103
+ PREFIX ex: <did:ng:z:>
103
104
  PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
104
105
 
105
106
  ex:Dog {
@@ -125,12 +126,12 @@ The SDK offers hooks for discrete and graph-based CRDTs for Svelte, Vue and Reac
125
126
 
126
127
  - discrete CRDTs for
127
128
  - Svelte 5: [useDiscrete](#svelteusediscrete)
128
- - Svelte 3/4: [useDiscrete](#svelte4usediscrete)
129
+ - Svelte 4: [useDiscrete](#svelte4usediscrete)
129
130
  - Vue: [useDiscrete](#vueusediscrete)
130
131
  - React: [useDiscrete](#reactusediscrete)
131
132
  - graph CRDTs for:
132
133
  - Svelte 5: [useShape](#svelteuseshape)
133
- - Svelte 3/4: [useShape](#svelte4useshape)
134
+ - Svelte 4: [useShape](#svelte4useshape)
134
135
  - Vue: [useShape](#vueuseshape)
135
136
  - React: [useShape](#reactuseshape)
136
137
 
@@ -24,7 +24,7 @@ import { DeepSignalSet } from "@ng-org/alien-deepsignals";
24
24
  * () => {
25
25
  * expenses.add({
26
26
  * "@graph": `<graph NURI>`,
27
- * "@type": "http://example.org/Expense",
27
+ * "@type": "did:ng:z:Expense",
28
28
  * "@id": "", // Assigns ID automatically, if set to "".
29
29
  * title: "New expense",
30
30
  * dateOfPurchase: obj.dateOfPurchase ?? new Date().toISOString(),
@@ -1 +1 @@
1
- {"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/react/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,OAAO,KAAK,GAAG,MAAM,GAAG,SAAS,KAgCjB,aAAa,CAAC,CAAC,CAClC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/react/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,OAAO,KAAK,GAAG,MAAM,GAAG,SAAS,KAmCjB,aAAa,CAAC,CAAC,CAClC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -34,7 +34,7 @@ import { readOnlySet } from "../utils.js";
34
34
  * () => {
35
35
  * expenses.add({
36
36
  * "@graph": `<graph NURI>`,
37
- * "@type": "http://example.org/Expense",
37
+ * "@type": "did:ng:z:Expense",
38
38
  * "@id": "", // Assigns ID automatically, if set to "".
39
39
  * title: "New expense",
40
40
  * dateOfPurchase: obj.dateOfPurchase ?? new Date().toISOString(),
@@ -79,7 +79,7 @@ import { readOnlySet } from "../utils.js";
79
79
  * ```
80
80
  */
81
81
  const useShape = (shape, scope) => {
82
- const parsedScope = !scope ? undefined : normalizeScope(scope);
82
+ const parsedScope = useMemo(() => (!scope ? undefined : normalizeScope(scope)), [scope, scope?.graphs, scope?.subjects]);
83
83
  const prevOrmSubscription = useRef(undefined);
84
84
  const ormSubscription = useMemo(() => {
85
85
  if (parsedScope === undefined)
@@ -89,7 +89,7 @@ const useShape = (shape, scope) => {
89
89
  const newOrmSubscription = OrmSubscription.getOrCreate(shape, parsedScope);
90
90
  prevOrmSubscription.current = newOrmSubscription;
91
91
  return newOrmSubscription;
92
- }, [shape, scope, parsedScope?.graphs, parsedScope?.subjects]);
92
+ }, [shape, parsedScope, parsedScope?.graphs, parsedScope?.subjects]);
93
93
  useEffect(() => {
94
94
  if (!ormSubscription)
95
95
  return;
@@ -29,7 +29,7 @@ import { DeepSignalSet } from "@ng-org/alien-deepsignals";
29
29
  * const createExpense = () => {
30
30
  * expenses.add({
31
31
  * "@graph": `<graph NURI>`,
32
- * "@type": "http://example.org/Expense",
32
+ * "@type": "did:ng:z:Expense",
33
33
  * "@id": "", // Assigns ID automatically, if set to "".
34
34
  * title: "New expense",
35
35
  * dateOfPurchase: obj.dateOfPurchase ?? new Date().toISOString(),
@@ -40,7 +40,7 @@ import { readOnlySet } from "../utils.js";
40
40
  * const createExpense = () => {
41
41
  * expenses.add({
42
42
  * "@graph": `<graph NURI>`,
43
- * "@type": "http://example.org/Expense",
43
+ * "@type": "did:ng:z:Expense",
44
44
  * "@id": "", // Assigns ID automatically, if set to "".
45
45
  * title: "New expense",
46
46
  * dateOfPurchase: obj.dateOfPurchase ?? new Date().toISOString(),
@@ -1,7 +1,7 @@
1
1
  import { UseDeepSignalResult } from "@ng-org/alien-deepsignals/svelte4";
2
2
  import { DiscreteRoot } from "../../types.ts";
3
3
  /**
4
- * Svelte 3/4 hook to subscribe to discrete (JSON) CRDT documents.
4
+ * Svelte 4 hook to subscribe to discrete (JSON) CRDT documents.
5
5
  * You can modify the returned object like any other JSON object. Changes are immediately
6
6
  * reflected in the CRDT.
7
7
  *
@@ -11,7 +11,7 @@ import { onDestroy } from "svelte";
11
11
  import { useDeepSignal, } from "@ng-org/alien-deepsignals/svelte4";
12
12
  import { DiscreteOrmSubscription } from "../../connector/discrete/discreteOrmSubscriptionHandler.js";
13
13
  /**
14
- * Svelte 3/4 hook to subscribe to discrete (JSON) CRDT documents.
14
+ * Svelte 4 hook to subscribe to discrete (JSON) CRDT documents.
15
15
  * You can modify the returned object like any other JSON object. Changes are immediately
16
16
  * reflected in the CRDT.
17
17
  *
@@ -6,7 +6,7 @@ export interface UseShapeStoreResult<T = object> extends UseDeepSignalResult<T>
6
6
  root: any;
7
7
  }
8
8
  /**
9
- * Svelte 3/4 hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
9
+ * Svelte 4 hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
10
10
  *
11
11
  * Returns a {@link DeepSignalSet} store containing the objects matching the shape and that are within the scope.
12
12
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
@@ -13,7 +13,7 @@ import { useDeepSignal, } from "@ng-org/alien-deepsignals/svelte4";
13
13
  import { OrmSubscription } from "../../connector/ormSubscriptionHandler.js";
14
14
  import { readOnlySet } from "../utils.js";
15
15
  /**
16
- * Svelte 3/4 hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
16
+ * Svelte 4 hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
17
17
  *
18
18
  * Returns a {@link DeepSignalSet} store containing the objects matching the shape and that are within the scope.
19
19
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-org/orm",
3
- "version": "0.1.2-alpha.12",
3
+ "version": "0.1.2-alpha.14",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "authors": [
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "react": "^19.0.0 || ^18.0.0",
42
- "svelte": "^5.0.0 || ^4.0.0 || ^3.0.0",
42
+ "svelte": "^5.0.0 || ^4.0.0",
43
43
  "vue": "^3.0.0"
44
44
  },
45
45
  "peerDependenciesMeta": {
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "dependencies": {
57
- "@ng-org/alien-deepsignals": "0.1.2-alpha.9"
57
+ "@ng-org/alien-deepsignals": "0.1.2-alpha.10"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/react": "^19.1.10",
@@ -66,8 +66,8 @@
66
66
  "react-dom": "^19.1.1",
67
67
  "svelte": "^5.39.12",
68
68
  "vue": "^3.5.19",
69
- "@ng-org/shex-orm": "0.1.2-alpha.6",
70
- "@ng-org/web": "0.1.2-alpha.9"
69
+ "@ng-org/shex-orm": "0.1.2-alpha.7",
70
+ "@ng-org/web": "0.1.2-alpha.10"
71
71
  },
72
72
  "files": [
73
73
  "dist"