@ng-org/orm 0.1.2-alpha.5 → 0.1.2-alpha.6
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 +1 -1
- package/dist/connector/applyPatches.d.ts +6 -11
- package/dist/connector/applyPatches.d.ts.map +1 -1
- package/dist/connector/applyPatches.js +48 -19
- package/dist/connector/discrete/discreteOrmConnectionHandler.d.ts +45 -0
- package/dist/connector/discrete/discreteOrmConnectionHandler.d.ts.map +1 -0
- package/dist/connector/discrete/discreteOrmConnectionHandler.js +186 -0
- package/dist/connector/getObjects.d.ts +10 -0
- package/dist/connector/getObjects.d.ts.map +1 -0
- package/dist/connector/getObjects.js +25 -0
- package/dist/connector/insertObject.d.ts +8 -0
- package/dist/connector/insertObject.d.ts.map +1 -0
- package/dist/connector/{createSignalObjectForShape.js → insertObject.js} +10 -11
- package/dist/connector/ormConnectionHandler.d.ts +14 -13
- package/dist/connector/ormConnectionHandler.d.ts.map +1 -1
- package/dist/connector/ormConnectionHandler.js +74 -40
- package/dist/connector/utils.d.ts +14 -0
- package/dist/connector/utils.d.ts.map +1 -0
- package/dist/connector/utils.js +65 -0
- package/dist/frontendAdapters/react/index.d.ts +2 -1
- package/dist/frontendAdapters/react/index.d.ts.map +1 -1
- package/dist/frontendAdapters/react/index.js +2 -1
- package/dist/frontendAdapters/react/useDiscrete.d.ts +84 -0
- package/dist/frontendAdapters/react/useDiscrete.d.ts.map +1 -0
- package/dist/frontendAdapters/react/useDiscrete.js +127 -0
- package/dist/frontendAdapters/react/useShape.d.ts +64 -5
- package/dist/frontendAdapters/react/useShape.d.ts.map +1 -1
- package/dist/frontendAdapters/react/useShape.js +84 -14
- package/dist/frontendAdapters/svelte/index.d.ts +2 -1
- package/dist/frontendAdapters/svelte/index.d.ts.map +1 -1
- package/dist/frontendAdapters/svelte/index.js +2 -1
- package/dist/frontendAdapters/svelte/useDiscrete.svelte.d.ts +85 -0
- package/dist/frontendAdapters/svelte/useDiscrete.svelte.d.ts.map +1 -0
- package/dist/frontendAdapters/svelte/useDiscrete.svelte.js +124 -0
- package/dist/frontendAdapters/svelte/useShape.svelte.d.ts +65 -3
- package/dist/frontendAdapters/svelte/useShape.svelte.d.ts.map +1 -1
- package/dist/frontendAdapters/svelte/useShape.svelte.js +68 -6
- package/dist/frontendAdapters/vue/index.d.ts +2 -1
- package/dist/frontendAdapters/vue/index.d.ts.map +1 -1
- package/dist/frontendAdapters/vue/index.js +2 -1
- package/dist/frontendAdapters/vue/useDiscrete.d.ts +92 -0
- package/dist/frontendAdapters/vue/useDiscrete.d.ts.map +1 -0
- package/dist/frontendAdapters/vue/useDiscrete.js +111 -0
- package/dist/frontendAdapters/vue/useShape.d.ts +76 -1
- package/dist/frontendAdapters/vue/useShape.d.ts.map +1 -1
- package/dist/frontendAdapters/vue/useShape.js +79 -5
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/types.d.ts +48 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +40 -24
- package/dist/connector/applyPatches.test.d.ts +0 -2
- package/dist/connector/applyPatches.test.d.ts.map +0 -1
- package/dist/connector/applyPatches.test.js +0 -772
- package/dist/connector/createSignalObjectForShape.d.ts +0 -14
- package/dist/connector/createSignalObjectForShape.d.ts.map +0 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright (c) 2026 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
// Licensed under the Apache License, Version 2.0
|
|
4
|
+
// <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
|
|
5
|
+
// or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
|
|
6
|
+
// at your option. All files in the project carrying such
|
|
7
|
+
// notice may not be copied, modified, or distributed except
|
|
8
|
+
// according to those terms.
|
|
9
|
+
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
10
|
+
import { computed, onBeforeUnmount, toValue } from "vue";
|
|
11
|
+
import { useDeepSignal } from "@ng-org/alien-deepsignals/vue";
|
|
12
|
+
import { DiscreteOrmConnection } from "../../connector/discrete/discreteOrmConnectionHandler.js";
|
|
13
|
+
const EMPTY_OBJECT = {};
|
|
14
|
+
/**
|
|
15
|
+
* Hook to subscribe to discrete (JSON) CRDT documents.
|
|
16
|
+
* You can modify the returned object like any other JSON object. Changes are immediately
|
|
17
|
+
* reflected in the CRDT.
|
|
18
|
+
*
|
|
19
|
+
* Establishes a 2-way binding: Modifications to the object are immediately committed,
|
|
20
|
+
* changes coming from the backend (or other components) cause an immediate rerender.
|
|
21
|
+
*
|
|
22
|
+
* In comparison to `useShape`, discrete CRDTs are untyped.
|
|
23
|
+
* You can put any JSON data inside and need to validate the schema yourself.
|
|
24
|
+
*
|
|
25
|
+
* @param documentId The IRI of the crdt document.
|
|
26
|
+
* @returns An object that contains as `data` the reactive DeepSignal object.
|
|
27
|
+
*
|
|
28
|
+
*@example
|
|
29
|
+
```html
|
|
30
|
+
<script lang="ts">
|
|
31
|
+
// We assume you have created a CRDT document already, as below.
|
|
32
|
+
// const documentId = await ng.doc_create(
|
|
33
|
+
// session_id,
|
|
34
|
+
// crdt, // "Automerge" | "YMap" | "YArray"
|
|
35
|
+
// crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
|
|
36
|
+
// "store",
|
|
37
|
+
// undefined
|
|
38
|
+
// );
|
|
39
|
+
const { data } = useDiscrete(documentId);
|
|
40
|
+
|
|
41
|
+
// If document is new, we need to set up the basic structure.
|
|
42
|
+
if (data && !data.expenses) {
|
|
43
|
+
data.expenses = [];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Note that we use expense["@id"] as a key in the expense list.
|
|
47
|
+
// Every object added to a CRDT array gets a stable `@id` property assigned
|
|
48
|
+
// which you can use for referencing objects in arrays even as
|
|
49
|
+
// objects are removed from the array. The ID is an IRI with the schema `<documentId>:d:<object-specific id>`.
|
|
50
|
+
// Since the `@id` is generated in the backend, the object is preliminarily
|
|
51
|
+
// given a mock id which will be replaced immediately
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<div v-if="!data">
|
|
56
|
+
Loading...
|
|
57
|
+
</div>
|
|
58
|
+
<div v-else>
|
|
59
|
+
<p v-if="expensesSorted.length === 0">
|
|
60
|
+
No expenses yet.
|
|
61
|
+
</p>
|
|
62
|
+
<template v-else>
|
|
63
|
+
<ExpenseCard
|
|
64
|
+
v-for="expense in expenses"
|
|
65
|
+
:key="expense['@id']"
|
|
66
|
+
:expense="expense"
|
|
67
|
+
/>
|
|
68
|
+
</template>
|
|
69
|
+
</div>
|
|
70
|
+
</template>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
In the `ExpenseCard` component:
|
|
74
|
+
```html
|
|
75
|
+
<script lang="ts">
|
|
76
|
+
const props = defineProps<{
|
|
77
|
+
expense: DeepSignal<Expense>;
|
|
78
|
+
}>();
|
|
79
|
+
|
|
80
|
+
// Important!
|
|
81
|
+
// In vue, you need to wrap children into useDeepSignal hooks,
|
|
82
|
+
// to ensure the component re-renders on changes coming from
|
|
83
|
+
// other components or the backend.
|
|
84
|
+
const expense = useDeepSignal(props.expense);
|
|
85
|
+
|
|
86
|
+
// If you modify expense in the component,
|
|
87
|
+
// the changes are immediately propagated to the other components
|
|
88
|
+
// And persisted in the database.
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<template>
|
|
92
|
+
<input
|
|
93
|
+
v-model="expense.title"
|
|
94
|
+
placeholder="Expense title"
|
|
95
|
+
/>
|
|
96
|
+
</template>
|
|
97
|
+
```
|
|
98
|
+
*/
|
|
99
|
+
export function useDiscrete(documentId) {
|
|
100
|
+
const ormConnection = computed(() => {
|
|
101
|
+
const id = toValue(documentId);
|
|
102
|
+
return id ? DiscreteOrmConnection.getOrCreate(id) : undefined;
|
|
103
|
+
});
|
|
104
|
+
onBeforeUnmount(() => {
|
|
105
|
+
ormConnection?.value?.close();
|
|
106
|
+
});
|
|
107
|
+
const signalSource = computed(() => ormConnection.value?.signalObject ?? EMPTY_OBJECT);
|
|
108
|
+
const state = useDeepSignal(signalSource);
|
|
109
|
+
const data = computed(() => ormConnection.value?.signalObject ? state : undefined);
|
|
110
|
+
return { data };
|
|
111
|
+
}
|
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
import type { Scope } from "../../types.ts";
|
|
2
2
|
import type { BaseType, ShapeType } from "@ng-org/shex-orm";
|
|
3
|
-
|
|
3
|
+
import { DeepSignalSet } from "@ng-org/alien-deepsignals";
|
|
4
|
+
/**
|
|
5
|
+
* Hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
|
|
6
|
+
* The returned objects are as easy to use as other TypeScript objects.
|
|
7
|
+
*
|
|
8
|
+
* Returns a {@link DeepSignalSet} of objects matching the shape and that are within the scope.
|
|
9
|
+
* Establishes a 2-way binding: Modifications to the object are immediately committed,
|
|
10
|
+
* changes coming from the backend (or other components) cause an immediate rerender.
|
|
11
|
+
*
|
|
12
|
+
* @param shape The {@link ShapeType} the objects should have (generated by the shex-orm tool).
|
|
13
|
+
* @param scope The scope in which the objects should be.
|
|
14
|
+
* @returns A {@link DeepSignalSet} containing the objects matching the shape type and scope.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
```html
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
// Contains all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
|
|
20
|
+
const expenses: DeepSignalSet<Expense> = useShape(ExpenseShape,
|
|
21
|
+
{graphs: ["<g1 IRI>", "<g2 IRI>"],
|
|
22
|
+
subjects: ["<s1 IRI>", "<s2 IRI>"]});
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const expensesSorted = computed(() => [...expenses].sort((a, b) =>
|
|
26
|
+
a.dateOfPurchase.localeCompare(b.dateOfPurchase)
|
|
27
|
+
));
|
|
28
|
+
|
|
29
|
+
// Call expenses.add({"@graph": "<g1 or g2 IRI>", "@id": "", title: "Example title"}), to add new elements.
|
|
30
|
+
// Leave `@id` an empty string to auto-generate a subject IRI (adjust your scope accordingly).
|
|
31
|
+
|
|
32
|
+
// Not that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
|
|
33
|
+
// If it is not, use the combination of `@graph` and `@id`.
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<div>
|
|
38
|
+
<p v-if="expensesSorted.length === 0">
|
|
39
|
+
No expenses yet.
|
|
40
|
+
</p>
|
|
41
|
+
<template v-else>
|
|
42
|
+
<ExpenseCard
|
|
43
|
+
v-for="expense in expensesSorted"
|
|
44
|
+
:key="expense['@id'])"
|
|
45
|
+
:expense="expense"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
In the `ExpenseCard` component:
|
|
53
|
+
```html
|
|
54
|
+
<script lang="ts">
|
|
55
|
+
const props = defineProps<{
|
|
56
|
+
expense: DeepSignal<Expense>;
|
|
57
|
+
}>();
|
|
58
|
+
|
|
59
|
+
// Important!
|
|
60
|
+
// In vue, you need to wrap children into useDeepSignal hooks,
|
|
61
|
+
// to ensure the component re-renders on changes coming from
|
|
62
|
+
// other components or the backend.
|
|
63
|
+
const expense = useDeepSignal(props.expense);
|
|
64
|
+
|
|
65
|
+
// If you modify expense in the component,
|
|
66
|
+
// the changes are immediately propagated to the other components
|
|
67
|
+
// And persisted in the database.
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<input
|
|
72
|
+
v-model="expense.title"
|
|
73
|
+
placeholder="Expense title"
|
|
74
|
+
/>
|
|
75
|
+
</template>
|
|
76
|
+
```
|
|
77
|
+
*/
|
|
78
|
+
export declare function useShape<T extends BaseType>(shape: ShapeType<T>, scope?: Scope): DeepSignalSet<T>;
|
|
4
79
|
export default useShape;
|
|
5
80
|
//# sourceMappingURL=useShape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useShape.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACvC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,GAAE,KAAU,oBAYpB;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -7,16 +7,90 @@
|
|
|
7
7
|
// notice may not be copied, modified, or distributed except
|
|
8
8
|
// according to those terms.
|
|
9
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
10
|
-
import { createSignalObjectForShape } from "../../connector/createSignalObjectForShape.js";
|
|
11
10
|
import { useDeepSignal } from "@ng-org/alien-deepsignals/vue";
|
|
12
11
|
import { onBeforeUnmount } from "vue";
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import { OrmConnection } from "../../connector/ormConnectionHandler.js";
|
|
13
|
+
/**
|
|
14
|
+
* Hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
|
|
15
|
+
* The returned objects are as easy to use as other TypeScript objects.
|
|
16
|
+
*
|
|
17
|
+
* Returns a {@link DeepSignalSet} of objects matching the shape and that are within the scope.
|
|
18
|
+
* Establishes a 2-way binding: Modifications to the object are immediately committed,
|
|
19
|
+
* changes coming from the backend (or other components) cause an immediate rerender.
|
|
20
|
+
*
|
|
21
|
+
* @param shape The {@link ShapeType} the objects should have (generated by the shex-orm tool).
|
|
22
|
+
* @param scope The scope in which the objects should be.
|
|
23
|
+
* @returns A {@link DeepSignalSet} containing the objects matching the shape type and scope.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
```html
|
|
27
|
+
<script lang="ts">
|
|
28
|
+
// Contains all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
|
|
29
|
+
const expenses: DeepSignalSet<Expense> = useShape(ExpenseShape,
|
|
30
|
+
{graphs: ["<g1 IRI>", "<g2 IRI>"],
|
|
31
|
+
subjects: ["<s1 IRI>", "<s2 IRI>"]});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const expensesSorted = computed(() => [...expenses].sort((a, b) =>
|
|
35
|
+
a.dateOfPurchase.localeCompare(b.dateOfPurchase)
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
// Call expenses.add({"@graph": "<g1 or g2 IRI>", "@id": "", title: "Example title"}), to add new elements.
|
|
39
|
+
// Leave `@id` an empty string to auto-generate a subject IRI (adjust your scope accordingly).
|
|
40
|
+
|
|
41
|
+
// Not that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
|
|
42
|
+
// If it is not, use the combination of `@graph` and `@id`.
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div>
|
|
47
|
+
<p v-if="expensesSorted.length === 0">
|
|
48
|
+
No expenses yet.
|
|
49
|
+
</p>
|
|
50
|
+
<template v-else>
|
|
51
|
+
<ExpenseCard
|
|
52
|
+
v-for="expense in expensesSorted"
|
|
53
|
+
:key="expense['@id'])"
|
|
54
|
+
:expense="expense"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
</div>
|
|
58
|
+
</template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
In the `ExpenseCard` component:
|
|
62
|
+
```html
|
|
63
|
+
<script lang="ts">
|
|
64
|
+
const props = defineProps<{
|
|
65
|
+
expense: DeepSignal<Expense>;
|
|
66
|
+
}>();
|
|
67
|
+
|
|
68
|
+
// Important!
|
|
69
|
+
// In vue, you need to wrap children into useDeepSignal hooks,
|
|
70
|
+
// to ensure the component re-renders on changes coming from
|
|
71
|
+
// other components or the backend.
|
|
72
|
+
const expense = useDeepSignal(props.expense);
|
|
73
|
+
|
|
74
|
+
// If you modify expense in the component,
|
|
75
|
+
// the changes are immediately propagated to the other components
|
|
76
|
+
// And persisted in the database.
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<input
|
|
81
|
+
v-model="expense.title"
|
|
82
|
+
placeholder="Expense title"
|
|
83
|
+
/>
|
|
84
|
+
</template>
|
|
85
|
+
```
|
|
86
|
+
*/
|
|
87
|
+
export function useShape(shape, scope = {}) {
|
|
88
|
+
const connection = OrmConnection.getOrCreate(shape, scope);
|
|
15
89
|
// Cleanup
|
|
16
90
|
onBeforeUnmount(() => {
|
|
17
|
-
|
|
91
|
+
connection.close();
|
|
18
92
|
});
|
|
19
|
-
const ref = useDeepSignal(
|
|
93
|
+
const ref = useDeepSignal(connection.signalObject);
|
|
20
94
|
return ref;
|
|
21
95
|
}
|
|
22
96
|
export default useShape;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useShape as
|
|
4
|
-
import { useShape as
|
|
5
|
-
import {
|
|
1
|
+
import { OrmConnection } from "./connector/ormConnectionHandler.ts";
|
|
2
|
+
import { DiscreteOrmConnection } from "./connector/discrete/discreteOrmConnectionHandler.ts";
|
|
3
|
+
import { useShape as svelteUseShape, useDiscrete as svelteUseDiscrete } from "./frontendAdapters/svelte/index.ts";
|
|
4
|
+
import { useShape as reactUseShape, useDiscrete as reactUseDiscrete } from "./frontendAdapters/react/index.ts";
|
|
5
|
+
import { useShape as vueUseShape, useDiscrete as vueUseDiscrete } from "./frontendAdapters/vue/index.ts";
|
|
6
|
+
import { initNgSignals, ngSession } from "./connector/initNg.ts";
|
|
7
|
+
import { insertObject } from "./connector/insertObject.ts";
|
|
8
|
+
import { getObjects } from "./connector/getObjects.ts";
|
|
6
9
|
export * from "./connector/applyPatches.ts";
|
|
7
|
-
export { initNgSignals as initNg,
|
|
10
|
+
export { initNgSignals as initNg, ngSession, OrmConnection, DiscreteOrmConnection, svelteUseShape, svelteUseDiscrete, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, insertObject, getObjects, };
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sDAAsD,CAAC;AAC7F,OAAO,EACH,QAAQ,IAAI,cAAc,EAC1B,WAAW,IAAI,iBAAiB,EACnC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,QAAQ,IAAI,aAAa,EACzB,WAAW,IAAI,gBAAgB,EAClC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,QAAQ,IAAI,WAAW,EACvB,WAAW,IAAI,cAAc,EAChC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EACH,aAAa,IAAI,MAAM,EACvB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,YAAY,EACZ,UAAU,GACb,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useShape as
|
|
4
|
-
import { useShape as
|
|
5
|
-
import {
|
|
1
|
+
import { OrmConnection } from "./connector/ormConnectionHandler.js";
|
|
2
|
+
import { DiscreteOrmConnection } from "./connector/discrete/discreteOrmConnectionHandler.js";
|
|
3
|
+
import { useShape as svelteUseShape, useDiscrete as svelteUseDiscrete, } from "./frontendAdapters/svelte/index.js";
|
|
4
|
+
import { useShape as reactUseShape, useDiscrete as reactUseDiscrete, } from "./frontendAdapters/react/index.js";
|
|
5
|
+
import { useShape as vueUseShape, useDiscrete as vueUseDiscrete, } from "./frontendAdapters/vue/index.js";
|
|
6
|
+
import { initNgSignals, ngSession } from "./connector/initNg.js";
|
|
7
|
+
import { insertObject } from "./connector/insertObject.js";
|
|
8
|
+
import { getObjects } from "./connector/getObjects.js";
|
|
6
9
|
export * from "./connector/applyPatches.js";
|
|
7
|
-
export { initNgSignals as initNg,
|
|
10
|
+
export { initNgSignals as initNg, ngSession, OrmConnection, DiscreteOrmConnection, svelteUseShape, svelteUseDiscrete, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, insertObject, getObjects, };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,13 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* When dealing with shapes (RDF graph ORMs):
|
|
3
|
+
* The scope of a shape request.
|
|
4
|
+
* In most cases, it is recommended to use a narrow scope for performance.
|
|
5
|
+
* You can filter results by `subjects` and `graphs`. Only objects in that scope will be returned.
|
|
6
|
+
*
|
|
7
|
+
* @param subjects array of subject IRIs to filter by. For no filtering, set to `undefined` set to `[]`.
|
|
8
|
+
* @param graphs array of graph IRIs to filter by. For no filtering, set to `undefined`.
|
|
9
|
+
* If you set to `[]`, *no objects are returned*. This is useful only for inserting objects in the database only
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Contains all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
|
|
14
|
+
* const expenses: DeepSignalSet<Expense = useShape(ExpenseShape,
|
|
15
|
+
* {graphs: ["<g1 IRI>", "<g2 IRI>"],
|
|
16
|
+
* subjects: ["<s1 IRI>", "<s2 IRI>"]});
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type Scope = {
|
|
20
|
+
graphs?: string[];
|
|
21
|
+
subjects?: string[];
|
|
12
22
|
};
|
|
23
|
+
/** An allowed array in the CRDT. */
|
|
24
|
+
export interface DiscreteArray extends Array<DiscreteType> {
|
|
25
|
+
}
|
|
26
|
+
/** An allowed object in the CRDT. */
|
|
27
|
+
export interface DiscreteObject {
|
|
28
|
+
[key: string]: DiscreteType;
|
|
29
|
+
}
|
|
30
|
+
/** An allowed type in the CRDT. */
|
|
31
|
+
export type DiscreteType = DiscreteArray | DiscreteObject | string | number | boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The root root array for reading and modifying the CRDT as a plain object.
|
|
34
|
+
*/
|
|
35
|
+
export type DiscreteRootArray = (DiscreteArray | string | number | boolean | (DiscreteObject & {
|
|
36
|
+
readonly "@id": string;
|
|
37
|
+
}))[];
|
|
38
|
+
/**
|
|
39
|
+
* The root object for reading and modifying the CRDT as a plain object.
|
|
40
|
+
*/
|
|
41
|
+
export interface DiscreteRootObject {
|
|
42
|
+
[key: string]: DiscreteObject | string | number | boolean | DiscreteRootArray;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The supported discrete (JSON) CRDTs.
|
|
46
|
+
* Automerge and YMap require objects as roots.
|
|
47
|
+
* YArray requires an array as root.
|
|
48
|
+
*/
|
|
49
|
+
export type DiscreteCrdt = "YMap" | "YArray" | "Automerge";
|
|
13
50
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,KAAK,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/D,oCAAoC;AACpC,MAAM,WAAW,aAAc,SAAQ,KAAK,CAAC,YAAY,CAAC;CAAG;AAE7D,qCAAqC;AACrC,MAAM,WAAW,cAAc;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAC;CAC/B;AACD,mCAAmC;AACnC,MAAM,MAAM,YAAY,GAClB,aAAa,GACb,cAAc,GACd,MAAM,GACN,MAAM,GACN,OAAO,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC1B,aAAa,GACb,MAAM,GACN,MAAM,GACN,OAAO,GACP,CAAC,cAAc,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAClD,EAAE,CAAC;AAEJ;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,CAAC,GAAG,EAAE,MAAM,GACN,cAAc,GACd,MAAM,GACN,MAAM,GACN,OAAO,GACP,iBAAiB,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright (c)
|
|
1
|
+
// Copyright (c) 2026 Laurin Weger, Par le Peuple, NextGraph.org developers
|
|
2
2
|
// All rights reserved.
|
|
3
3
|
// Licensed under the Apache License, Version 2.0
|
|
4
4
|
// <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
|
package/package.json
CHANGED
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-org/orm",
|
|
3
|
-
"version": "0.1.2-alpha.
|
|
3
|
+
"version": "0.1.2-alpha.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"authors": [
|
|
7
7
|
"Laurin Weger"
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT/Apache-2.0",
|
|
10
|
-
"main": "./
|
|
10
|
+
"main": "./src/index.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"test:e2e": "playwright test",
|
|
14
|
+
"build:ts": "rm -rf dist && tsc",
|
|
15
|
+
"prepublishOnly": "pnpm build:ts"
|
|
16
|
+
},
|
|
11
17
|
"exports": {
|
|
12
18
|
".": {
|
|
13
|
-
"
|
|
14
|
-
"default": "./dist/index.js"
|
|
19
|
+
"default": "./src/index.ts"
|
|
15
20
|
},
|
|
16
21
|
"./react": {
|
|
17
|
-
"
|
|
18
|
-
"default": "./dist/frontendAdapters/react/index.js"
|
|
22
|
+
"default": "./src/frontendAdapters/react/index.ts"
|
|
19
23
|
},
|
|
20
24
|
"./svelte": {
|
|
21
|
-
"
|
|
22
|
-
"default": "./dist/frontendAdapters/svelte/index.js"
|
|
25
|
+
"default": "./src/frontendAdapters/svelte/index.ts"
|
|
23
26
|
},
|
|
24
27
|
"./vue": {
|
|
25
|
-
"
|
|
26
|
-
"default": "./dist/frontendAdapters/vue/index.js"
|
|
28
|
+
"default": "./src/frontendAdapters/vue/index.ts"
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
31
|
"publishConfig": {
|
|
30
|
-
"
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"access": "public",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./react": {
|
|
41
|
+
"types": "./dist/frontendAdapters/react/index.d.ts",
|
|
42
|
+
"default": "./dist/frontendAdapters/react/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./svelte": {
|
|
45
|
+
"types": "./dist/frontendAdapters/svelte/index.d.ts",
|
|
46
|
+
"default": "./dist/frontendAdapters/svelte/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./vue": {
|
|
49
|
+
"types": "./dist/frontendAdapters/vue/index.d.ts",
|
|
50
|
+
"default": "./dist/frontendAdapters/vue/index.js"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
31
53
|
},
|
|
32
54
|
"optionalDependencies": {
|
|
33
55
|
"react": "^19.0.0 || ^18.0.0",
|
|
@@ -39,17 +61,18 @@
|
|
|
39
61
|
"@gn8/alien-signals-solid": "^0.1.1",
|
|
40
62
|
"@gn8/alien-signals-svelte": "^0.1.1",
|
|
41
63
|
"@gn8/alien-signals-vue": "^0.1.1",
|
|
64
|
+
"@ng-org/shex-orm": "workspace:*",
|
|
65
|
+
"@ng-org/alien-deepsignals": "workspace:*",
|
|
42
66
|
"@types/react": "19.1.10",
|
|
43
67
|
"@types/react-dom": "19.1.7",
|
|
44
68
|
"@types/shexj": "^2.1.7",
|
|
45
69
|
"alien-signals": "^2.0.7",
|
|
46
70
|
"install": "^0.13.0",
|
|
47
71
|
"npm": "^11.5.2",
|
|
48
|
-
"prettier-eslint": "^16.4.2"
|
|
49
|
-
"@ng-org/shex-orm": "0.1.2-alpha.2",
|
|
50
|
-
"@ng-org/alien-deepsignals": "0.1.2-alpha.3"
|
|
72
|
+
"prettier-eslint": "^16.4.2"
|
|
51
73
|
},
|
|
52
74
|
"devDependencies": {
|
|
75
|
+
"@ng-org/lib-wasm": "workspace:*",
|
|
53
76
|
"@playwright/test": "^1.55.0",
|
|
54
77
|
"@types/node": "24.3.0",
|
|
55
78
|
"@types/react": "19.1.10",
|
|
@@ -60,16 +83,9 @@
|
|
|
60
83
|
"react": "19.1.1",
|
|
61
84
|
"react-dom": "19.1.1",
|
|
62
85
|
"svelte": "5.39.12",
|
|
63
|
-
"vue": "3.5.19"
|
|
64
|
-
"@ng-org/lib-wasm": "0.1.2-alpha.1"
|
|
86
|
+
"vue": "3.5.19"
|
|
65
87
|
},
|
|
66
88
|
"files": [
|
|
67
89
|
"dist"
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
"test": "vitest",
|
|
71
|
-
"test:e2e": "playwright test",
|
|
72
|
-
"build:ts": "rm -rf dist && tsc"
|
|
73
|
-
},
|
|
74
|
-
"types": "./dist/index.d.ts"
|
|
75
|
-
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"applyPatches.test.d.ts","sourceRoot":"","sources":["../../src/connector/applyPatches.test.ts"],"names":[],"mappings":""}
|