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

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
@@ -29,6 +29,8 @@ Note that we support discrete (**JSON**) CRDT and graph (**RDF**) CRDT ORMs.
29
29
  - [Working with Data](#working-with-data)
30
30
  - [Creating a Document](#creating-a-document)
31
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)
32
34
  - [Graph ORM: Relationships](#graph-orm-relationships)
33
35
 
34
36
  ---
@@ -49,7 +51,24 @@ pnpm add -D @ng-org/shex-orm
49
51
 
50
52
  ## Start
51
53
 
52
- You are strongly advised to look at the example apps for [discrete JSON documents](https://git.nextgraph.org/NextGraph/expense-tracker-discrete) and [typed graph documents](https://git.nextgraph.org/NextGraph/expense-tracker-graph).
54
+ 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
+
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)
60
+ - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-vue)
61
+ - [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)
66
+ - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-graph-vue)
67
+ - [React](https://git.nextgraph.org/NextGraph/expense-tracker-graph-react)
68
+
69
+ The app looks the same in all implementations. You can see that the `useShape()` and `useDiscrete()` frontend hooks that interact with the data, share the same syntax across all frameworks.
70
+
71
+ ---
53
72
 
54
73
  Before using the ORM, initialize NextGraph in your app entry point:
55
74
 
@@ -57,9 +76,14 @@ Before using the ORM, initialize NextGraph in your app entry point:
57
76
  import { ng, init } from "@ng-org/web";
58
77
  import { initNg } from "@ng-org/orm";
59
78
 
79
+ // Call init as early as possible when your app loads.
80
+ // At the first call, it will redirect the user to login with their wallet.
81
+ // In that case, there is no need to render the rest of the app.
82
+ // Then your app will reload, and this time, this call back will be called:
60
83
  await init(
61
84
  async (event) => {
62
- // The ORM needs to have access to ng, the interface to the engine running in WASM.
85
+ // The ORM needs to have access to ng,
86
+ // the interface to the engine running in WASM.
63
87
  initNg(ng, event.session);
64
88
  },
65
89
  true,
@@ -67,19 +91,7 @@ await init(
67
91
  );
68
92
  ```
69
93
 
70
- Then use `useShape()` for graphs, or `useDiscrete()` for discrete documents.
71
-
72
- In some cases, you may want to use advanced features managing subscriptions with the engine.
73
- With an OrmSubscription, you can manage things like transactions manually.
74
- This is useful for example when you want to manage a state across components.
75
- See [`OrmSubscription.getOrCreate(ShapeType, scope)`](#getorcreate-1) for graphs
76
- and [`DiscreteOrmSubscription.getOrCreate(documentId)`](#getorcreate) for discrete documents.
77
-
78
- Internally, the OrmSubscription keeps a signalObject, a proxied, reactive object. When modifications are made, this makes the frontend components rerender and sends the update to the engine to be persisted.
79
-
80
- In all cases, you have to create a document first with `ng.doc_create()`.
81
-
82
- ## Graph ORM: Defining Schemas
94
+ ## RDF (graph) ORM: Defining Schemas
83
95
 
84
96
  Define your data model using [SHEX (Shape Expressions)](https://shex.io/):
85
97
  See [@ng-org/shex-orm](../shex-orm/README.md) for details.
@@ -95,15 +107,18 @@ ex:Dog {
95
107
  ex:name xsd:string ;
96
108
  ex:age xsd:integer ? ;
97
109
  ex:toys xsd:string * ;
110
+ ex:owner IRI ? ;
98
111
  }
99
112
  ```
100
113
 
101
- Generate TypeScript types. Add the following to your `package.json` scripts and run `build:orm`:
114
+ Add the following to your `package.json` scripts and run `build:orm` (assuming you installed `@ng-org/shex-orm` as dev dependency):
102
115
 
103
116
  ```json
104
117
  "build:orm": "rdf-orm build --input ./src/shapes/shex --output ./src/shapes/orm"
105
118
  ```
106
119
 
120
+ This will generate three files: one for TypeScript type definitions, one with generated schemas, and one that exports objects with the schema, type definition and shape name: The so called _shape types_. When you request data from the engine, you will pass a shape type in your request that defines what your object looks like.
121
+
107
122
  ## Frontend Framework Usage
108
123
 
109
124
  The SDK offers hooks for discrete and graph-based CRDTs for Svelte, Vue and React:
@@ -119,21 +134,25 @@ The SDK offers hooks for discrete and graph-based CRDTs for Svelte, Vue and Reac
119
134
  - Vue: [useShape](#vueuseshape)
120
135
  - React: [useShape](#reactuseshape)
121
136
 
122
- All of them have the same logic. They create a 2-way binding to the engine.
137
+ All of them share the same logic. They create a 2-way binding to the engine.
123
138
  You can modify the returned object like any other JSON object. Changes are immediately
124
- reflected in the CRDT and the components rerender.
139
+ reflected in the CRDT and the components refresh.
125
140
  When the component unmounts, the subscription is closed.
126
141
 
127
142
  ```ts
128
143
  // Queries the graphs with NURI did:ng:o:g1 and did:ng:o:g2 and with subject s1 or s2.
129
- const expenses: DeepSignal<Set<Expense>> = useShape(ExpenseShapeType, {
144
+ const expenses = useShape(ExpenseShapeType, {
130
145
  graphs: ["did:ng:o:g1", "did:ng:o:g2"],
131
146
  subjects: ["<s1 IRI>", "<s2 IRI>"],
132
147
  });
148
+ // Note: While the returned `expenses` object has type `DeepSignal<Set<Expense>>`, you can treat and type it as `Set<Expense>` as well, for convenience.
149
+
150
+ // Now you can use expenses in your component
151
+ // and modify them to trigger a refresh and persist them.
133
152
 
134
- // Use expenses in your component
135
- // and modify them to trigger a rerender and persist them.
136
- // ...
153
+ // In analogy:
154
+ const expense: DeepSignal<Expense[]> = useDiscrete(expenseDocumentNuri);
155
+ // Note: While the returned `expenses` object has type `DeepSignal<Expense[]>`, you can treat and type it as `Expense[]` as well, for convenience.
137
156
  ```
138
157
 
139
158
  ---
@@ -143,7 +162,7 @@ const expenses: DeepSignal<Set<Expense>> = useShape(ExpenseShapeType, {
143
162
  The ORM is designed to make working with data as normal as possible.
144
163
  You get an object as you are used to it and when you change properties,
145
164
  they are automatically persisted and synced with other devices. Conversely,
146
- modifications arrive at the ORM objects immediately and your components rerender.
165
+ modifications coming from other devices update the ORM objects too and your components refresh.
147
166
 
148
167
  ### Creating a Document
149
168
 
@@ -168,7 +187,7 @@ await ng.sparql_update(
168
187
  );
169
188
  ```
170
189
 
171
- To find your document, you can make a sparql query as well:
190
+ To find your document NURI, you make a sparql query:
172
191
 
173
192
  ```ts
174
193
  const ret = await ng.sparql_query(
@@ -184,9 +203,31 @@ let documentId = ret?.results.bindings?.[0]?.storeId?.value;
184
203
 
185
204
  There are multiple ways to get and modify data:
186
205
 
187
- - Get and modify the data returned by a `useShape()` or `useDiscrete()` hook inside a component.
188
- - Get and modify the signalObject of the subscription returned by `Orm(Discrete)Subscription.getOrCreate()`.
189
- - For graph ORMs: Call [`insertObject()`](#insertobject) or [`getObjects`](#getobjects) (no 2-way binding).
206
+ - Get and modify the signalObject of the subscription returned by [`Orm(Discrete)Subscription.getOrCreate()`](#the-discreteormsubscription-class).
207
+ - Get and modify the data returned by a `useShape()` or `useDiscrete()` hook inside of a component.
208
+ - For graph ORMs (no 2-way binding):
209
+ - [`getObjects(shapeType, scope)`](#getobjects) Gets all object with the given shape type within the `scope`. The returned objects are _not_ `DeepSignal` objects - modifications to them do not trigger updates and changes from other sources do not update the returned object.
210
+ - [`insertObject(shapeType, object)`](#insertobject): A convenience function to add objects of a given shape to the database. While with `useShape()` and `OrmSubscription`, you can just add objects to the returned set or `subscription.signalObject`, respectively.
211
+ This function spares you of creating an `OrmSubscription` and can be used outside of components, where you can't call `useShape`.
212
+
213
+ ### The (Discrete)OrmSubscription Class
214
+
215
+ You can establish subscriptions outside of frontend components using the (Discrete)OrmSubscription class. DiscreteOrmSubscriptions are scoped to one document, (RDF-based) OrmSubscriptions can have a `Scope` of more than one document and require a shape type. Once a subscription is established, its `.readyPromise` resolves and the `.signalObject` contains the 2-way bound data.
216
+
217
+ You can create a new subscription using `(Discrete)OrmSubscription.getOrCreate()`. If a subscription with the same document or scope exists already, a reference to that object is returned. Otherwise, a new one is created.
218
+ The pooling is especially useful when more than one frontend component subscribes to the same data and scope by calling `useShape()` or `useDiscrete()`. This reduces load and the data is available instantly.
219
+
220
+ Subscriptions are open until `.close()` is called on all references of this object. The `useShape` and `useDiscrete` hooks call `.close()` on their reference when their component unmounts.
221
+
222
+ ### Transactions
223
+
224
+ To improve performance, you can start transactions with subscriptions using `.beginTransaction()` and `.commitTransaction()`. This will delay the persistence until `.commitTransaction()` is called. Transactions do not affect updates to the frontend and incoming updates from the engine / other devices. When more than one reference to a subscription exists, the transaction affects all of them.
225
+
226
+ Note that even in non-transaction mode, changes are batched and only committed after the current task finished. The changes are sent to the engine in a [microtask](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide). You can end the current task and flush, for example, by awaiting a promise: `await Promise.resolve()`.
227
+
228
+ Note that you can use the signal object of an orm subscription (e.g. `myOrmSubscription.signalObject`) in components too. For that, you need to use `useDeepSignal(signalObject)` from the package `@ng-org/alien-deepsignals/svelte|vue|react`. This can be useful to keep a connection open over the lifetime of a component and to avoid the loading time when creating new subscriptions.
229
+
230
+ Example of using an OrmSubscription:
190
231
 
191
232
  ```typescript
192
233
  const dogSubscription = OrmSubscription.getOrCreate(DogShape, {
@@ -194,7 +235,7 @@ const dogSubscription = OrmSubscription.getOrCreate(DogShape, {
194
235
  });
195
236
  await dogSubscription.readyPromise;
196
237
 
197
- // If we used OrmDiscreteSubscription, the signalObject type would be array or object.
238
+ // If we used OrmDiscreteSubscription, the signalObject type would be an array or object.
198
239
  const dogSet: DeepSignal<Set<Dog>> = dogSubscription.signalObject;
199
240
 
200
241
  dogs.add({
@@ -214,12 +255,26 @@ aDog.toy.add("bone");
214
255
 
215
256
  // Utility to find objects in sets:
216
257
  const sameDog = dogs.getBy(aDog["@graph"], aDog["@id"]);
217
- // sameSog === aDog.
258
+ // sameDog === aDog.
218
259
 
219
260
  dogs.delete(aDog);
220
261
  ```
221
262
 
222
- Note that the graph CRDT supports sets only, the discrete CRDTs arrays only.
263
+ Note that the RDF CRDT supports sets only, the discrete CRDTs arrays only.
264
+
265
+ #### The DeepSignal<> type
266
+
267
+ Data returned by the ORM is of type `DeepSignal<T>`. It behaves like plain objects of type `T` but with some extras. Under the hood, the object is proxied. The proxy tracks modifications and will immediately update the frontend and propagate to the engine.
268
+
269
+ In your code however, you _do not have to to wrap your type definitions in `DeepSignal<>`_. Nevertheless, it can be instructive for TypeScript to show you the additional utilities that DeepSignal objects expose. Also, it might keep you aware that modifications you make to those objects are persisted and that they update the frontend.
270
+ The utilities that DeepSignal objects include are:
271
+
272
+ - For sets (with the RDF ORM):
273
+ - iterator helper methods (e.g. `map()`, `filter()`, `reduce()`, `any()`, ...)
274
+ - `first()` to get one element from the set -- useful if you know that there is only one.
275
+ - `getBy(graphNuri: string, subjectIri: string)`, to find objects by their graph NURI and subject IRI.
276
+ - **NOTE**: When assigning a set to `DeepSignal<Set>`, TypeScript will warn you. You can safely ignore this by writing (`parent.children = new Set() as DeepSignal<Set<any>>`). Internally, the set is automatically converted but this is not expressible in TypeScript.
277
+ - For all objects: `__raw__` which gives you the non-proxied object without tracking value access and without triggering updates upon modifications. Tracking value access is used in the frontend so it knows on what changes to refresh. If you use `__raw__`, that won't work anymore.
223
278
 
224
279
  #### Graph ORM: Relationships
225
280
 
@@ -231,9 +286,10 @@ casey.friends.add(jackNuri);
231
286
  // When the child object is a nested object that you do not have in memory,
232
287
  // you can establish the link by adding an object that contains the `@id` property only.
233
288
  shoppingExpense.category.add({ "@id": "<Subject IRI of expense category>" });
234
- // Link objects by storing the target's `@id` NURI/IRI:
235
289
 
290
+ // Link objects by storing the target's `@id` NURI/IRI:
236
291
  dog.owner = jackNuri;
292
+
237
293
  // Resolve the relationship
238
294
  const jack = people.find((p) => p["@id"] === dog.owner);
239
295
  ```
@@ -25,12 +25,12 @@ export declare class DiscreteOrmSubscription {
25
25
  private refCount;
26
26
  /** When true, modifications from the signalObject are not processed. */
27
27
  private suspendDeepWatcher;
28
- /** @readonly True, if a transaction is running. */
29
- inTransaction: boolean;
30
- /** Aggregation of patches to be sent when in transaction. */
31
- pendingPatches: Patch[] | undefined;
28
+ /** True, if a transaction is running. */
29
+ private inTransaction_;
30
+ /** Aggregation of patches to be sent when in transaction. @ignore */
31
+ private pendingPatches;
32
32
  /** **Await to ensure that the subscription is established and the data arrived.** */
33
- readyPromise: Promise<void>;
33
+ private readyPromise_;
34
34
  private closeOrmSubscription;
35
35
  /** Function to call once initial data has been applied. */
36
36
  private resolveReady;
@@ -124,6 +124,10 @@ export declare class DiscreteOrmSubscription {
124
124
  * ```
125
125
  */
126
126
  static getOrCreate: <T extends BaseType>(documentId: string) => DiscreteOrmSubscription;
127
+ /** True, if a transaction is running. */
128
+ get inTransaction(): boolean;
129
+ /** **Await to ensure that the subscription is established and the data arrived.** */
130
+ get readyPromise(): Promise<void>;
127
131
  /**
128
132
  * Stop the subscription.
129
133
  *
@@ -1 +1 @@
1
- {"version":3,"file":"discreteOrmSubscriptionHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/discrete/discreteOrmSubscriptionHandler.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAA4B,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQrE,OAAO,KAAK,EACR,SAAS,EACT,UAAU,EAEb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AASjD;;;;;;;;;GASG;AACH,qBAAa,uBAAuB;IAChC,kEAA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;;OASG;IACI,KAAK,aASV;IAEF,wEAAwE;IACxE,OAAO,CAAC,oBAAoB,CAsB1B;IAEF,wEAAwE;IACxE,OAAO,CAAC,gBAAgB,CAStB;IAEF,OAAO,CAAC,qBAAqB,CAiB3B;IAEF,8CAA8C;IAC9C,OAAO,CAAC,eAAe,CAUrB;IAEF;;;;;;OAMG;IACI,gBAAgB,aAerB;IAEF;;;;OAIG;IACI,iBAAiB,sBAiCtB;CACL;AAED;;;;;;GAMG;AAEH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,CAO/D"}
@@ -39,12 +39,12 @@ export class DiscreteOrmSubscription {
39
39
  refCount;
40
40
  /** When true, modifications from the signalObject are not processed. */
41
41
  suspendDeepWatcher;
42
- /** @readonly True, if a transaction is running. */
43
- inTransaction = false;
44
- /** Aggregation of patches to be sent when in transaction. */
42
+ /** True, if a transaction is running. */
43
+ inTransaction_ = false;
44
+ /** Aggregation of patches to be sent when in transaction. @ignore */
45
45
  pendingPatches;
46
46
  /** **Await to ensure that the subscription is established and the data arrived.** */
47
- readyPromise;
47
+ readyPromise_;
48
48
  closeOrmSubscription;
49
49
  /** Function to call once initial data has been applied. */
50
50
  resolveReady;
@@ -60,7 +60,7 @@ export class DiscreteOrmSubscription {
60
60
  this.closeOrmSubscription = () => { };
61
61
  this.suspendDeepWatcher = false;
62
62
  // Initialize per-entry readiness promise that resolves in setUpConnection
63
- this.readyPromise = new Promise((resolve) => {
63
+ this.readyPromise_ = new Promise((resolve) => {
64
64
  this.resolveReady = resolve;
65
65
  });
66
66
  ngSession.then(async ({ ng, session }) => {
@@ -177,6 +177,14 @@ export class DiscreteOrmSubscription {
177
177
  return newConnection;
178
178
  }
179
179
  };
180
+ /** True, if a transaction is running. */
181
+ get inTransaction() {
182
+ return this.inTransaction_;
183
+ }
184
+ /** **Await to ensure that the subscription is established and the data arrived.** */
185
+ get readyPromise() {
186
+ return this.readyPromise_;
187
+ }
180
188
  /**
181
189
  * Stop the subscription.
182
190
  *
@@ -203,13 +211,13 @@ export class DiscreteOrmSubscription {
203
211
  return;
204
212
  const ormPatches = deepPatchesToWasm(patches);
205
213
  // If in transaction, collect patches immediately (no await before).
206
- if (this.inTransaction) {
214
+ if (this.inTransaction_) {
207
215
  this.pendingPatches?.push(...ormPatches);
208
216
  return;
209
217
  }
210
218
  // Wait for session and subscription to be initialized.
211
219
  const { ng, session } = await ngSession;
212
- await this.readyPromise;
220
+ await this.readyPromise_;
213
221
  ng.discrete_orm_update(this.subscriptionId, ormPatches, session.session_id);
214
222
  };
215
223
  /** Handle messages coming from the engine (initial data or patches). */
@@ -255,9 +263,9 @@ export class DiscreteOrmSubscription {
255
263
  * Modifications keep being rendered instantly.
256
264
  */
257
265
  beginTransaction = () => {
258
- this.inTransaction = true;
266
+ this.inTransaction_ = true;
259
267
  this.pendingPatches = [];
260
- this.readyPromise.then(() => {
268
+ this.readyPromise_.then(() => {
261
269
  // Use a listener that immediately triggers on object modifications.
262
270
  // We don't need the deep-signal's batching (through microtasks) here.
263
271
  this.stopSignalListening?.();
@@ -271,12 +279,12 @@ export class DiscreteOrmSubscription {
271
279
  * @throws if no transaction is open.
272
280
  */
273
281
  commitTransaction = async () => {
274
- if (!this.inTransaction) {
282
+ if (!this.inTransaction_) {
275
283
  throw new Error("No transaction is open. Call `beginTransaction` first.");
276
284
  }
277
285
  const { ng, session } = await ngSession;
278
- await this.readyPromise;
279
- this.inTransaction = false;
286
+ await this.readyPromise_;
287
+ this.inTransaction_ = false;
280
288
  if (this.pendingPatches?.length == 0) {
281
289
  // Nothing to send to the backend.
282
290
  }
@@ -4,8 +4,8 @@ import { Scope } from "../types.ts";
4
4
  * Utility for retrieving objects once without establishing a two-way subscription.
5
5
  *
6
6
  * @param shapeType The shape type of the objects to be retrieved.
7
- * @param scope The scope of the objects to be retrieved.
7
+ * @param scope The scope of the objects to be retrieved as Scope object or as graph NURI string.
8
8
  * @returns A set of all objects matching the shape and scope
9
9
  */
10
- export declare function getObjects<T extends BaseType>(shapeType: ShapeType<T>, scope?: Scope): Promise<import("@ng-org/alien-deepsignals").DeepSignalSet<T>>;
10
+ export declare function getObjects<T extends BaseType>(shapeType: ShapeType<T>, scope: Scope | string): Promise<import("@ng-org/alien-deepsignals").DeepSignalSet<T>>;
11
11
  //# sourceMappingURL=getObjects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getObjects.d.ts","sourceRoot":"","sources":["../../src/connector/getObjects.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAC/C,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,KAAK,GAAE,KAAU,iEAUpB"}
1
+ {"version":3,"file":"getObjects.d.ts","sourceRoot":"","sources":["../../src/connector/getObjects.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAkB,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,QAAQ,EAC/C,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,KAAK,EAAE,KAAK,GAAG,MAAM,iEAaxB"}
@@ -8,16 +8,17 @@
8
8
  // according to those terms.
9
9
  // SPDX-License-Identifier: Apache-2.0 OR MIT
10
10
  import { OrmSubscription } from "./ormSubscriptionHandler.js";
11
+ import { normalizeScope } from "../types.js";
11
12
  import { deepClone } from "./utils.js";
12
13
  /**
13
14
  * Utility for retrieving objects once without establishing a two-way subscription.
14
15
  *
15
16
  * @param shapeType The shape type of the objects to be retrieved.
16
- * @param scope The scope of the objects to be retrieved.
17
+ * @param scope The scope of the objects to be retrieved as Scope object or as graph NURI string.
17
18
  * @returns A set of all objects matching the shape and scope
18
19
  */
19
- export async function getObjects(shapeType, scope = {}) {
20
- const connection = OrmSubscription.getOrCreate(shapeType, scope);
20
+ export async function getObjects(shapeType, scope) {
21
+ const connection = OrmSubscription.getOrCreate(shapeType, normalizeScope(scope));
21
22
  await connection.readyPromise;
22
23
  setTimeout(() => {
23
24
  connection.close();
@@ -1,22 +1,13 @@
1
- import * as NG from "@ng-org/lib-wasm";
2
- /** A NextGraph session with an engine. */
3
- export type Session = {
4
- session_id: string | number;
5
- protected_store_id: string;
6
- private_store_id: string;
7
- public_store_id: string;
8
- ng: typeof NG;
9
- [key: string]: unknown;
10
- };
1
+ import type { Session, NG } from "@ng-org/web";
11
2
  /** Resolves to the NG session and the ng implementation. */
12
3
  export declare const ngSession: Promise<{
13
- ng: typeof NG;
4
+ ng: NG;
14
5
  session: Session;
15
6
  }>;
16
7
  /**
17
8
  * Initialize the ORM by passing the ng implementation and session.
18
9
  *
19
- * **This is the first thing you need to to before using the ORM.**
10
+ * **This is the first thing you need to do before using the ORM.**
20
11
  *
21
12
  * @param ngImpl The NextGraph API, e.g. exported from `@ng-org/web`.
22
13
  * @param session The established NextGraph session.
@@ -42,5 +33,5 @@ export declare const ngSession: Promise<{
42
33
  * ```
43
34
  *
44
35
  */
45
- export declare function initNgSignals(ngImpl: typeof NG, session: Session): void;
36
+ export declare function initNgSignals(ngImpl: NG, session: Session): void;
46
37
  //# sourceMappingURL=initNg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initNg.d.ts","sourceRoot":"","sources":["../../src/connector/initNg.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEvC,0CAA0C;AAC1C,MAAM,MAAM,OAAO,GAAG;IAClB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,EAAE,EAAE,OAAO,EAAE,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B,CAAC;AAIF,4DAA4D;AAC5D,eAAO,MAAM,SAAS;QAAqB,OAAO,EAAE;aAAW,OAAO;EAIrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,QAEhE"}
1
+ {"version":3,"file":"initNg.d.ts","sourceRoot":"","sources":["../../src/connector/initNg.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAI/C,4DAA4D;AAC5D,eAAO,MAAM,SAAS;QAAqB,EAAE;aAAW,OAAO;EAI9D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,QAEzD"}
@@ -15,7 +15,7 @@ export const ngSession = new Promise((resolve) => {
15
15
  /**
16
16
  * Initialize the ORM by passing the ng implementation and session.
17
17
  *
18
- * **This is the first thing you need to to before using the ORM.**
18
+ * **This is the first thing you need to do before using the ORM.**
19
19
  *
20
20
  * @param ngImpl The NextGraph API, e.g. exported from `@ng-org/web`.
21
21
  * @param session The established NextGraph session.
@@ -1,6 +1,7 @@
1
1
  import { BaseType, ShapeType } from "@ng-org/shex-orm";
2
2
  /**
3
- * Utility for adding ORM-typed objects to the database without the need for subscribing to documents.
3
+ * Utility for adding ORM-typed objects to the database without
4
+ * the need for subscribing to documents using an {@link OrmSubscription}.
4
5
  *
5
6
  * @param shapeType The shape type of the objects to be inserted.
6
7
  * @param object The object to be inserted.
@@ -1 +1 @@
1
- {"version":3,"file":"insertObject.d.ts","sourceRoot":"","sources":["../../src/connector/insertObject.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,CAAC,SAAS,QAAQ,EACjD,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,MAAM,EAAE,CAAC,iBASZ"}
1
+ {"version":3,"file":"insertObject.d.ts","sourceRoot":"","sources":["../../src/connector/insertObject.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,CAAC,SAAS,QAAQ,EACjD,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,MAAM,EAAE,CAAC,iBASZ"}
@@ -9,7 +9,8 @@
9
9
  // SPDX-License-Identifier: Apache-2.0 OR MIT
10
10
  import { OrmSubscription } from "./ormSubscriptionHandler.js";
11
11
  /**
12
- * Utility for adding ORM-typed objects to the database without the need for subscribing to documents.
12
+ * Utility for adding ORM-typed objects to the database without
13
+ * the need for subscribing to documents using an {@link OrmSubscription}.
13
14
  *
14
15
  * @param shapeType The shape type of the objects to be inserted.
15
16
  * @param object The object to be inserted.
@@ -1,5 +1,4 @@
1
1
  import { type Scope } from "../types.ts";
2
- import { Patch } from "./applyPatches.ts";
3
2
  import type { DeepSignalSet } from "@ng-org/alien-deepsignals";
4
3
  import type { ShapeType, BaseType } from "@ng-org/shex-orm";
5
4
  /**
@@ -41,13 +40,13 @@ export declare class OrmSubscription<T extends BaseType> {
41
40
  /** Identifier as a combination of shape type and scope. Prevents duplications. */
42
41
  private identifier;
43
42
  /** When true, modifications from the signalObject are not processed. */
44
- suspendDeepWatcher: boolean;
43
+ private suspendDeepWatcher;
45
44
  /** True, if a transaction is running. */
46
- inTransaction: boolean;
47
- /** Aggregation of patches to be sent when in transaction. */
48
- pendingPatches: Patch[] | undefined;
45
+ private inTransaction_;
46
+ /** Aggregation of patches to be sent when in transaction. @ignore */
47
+ private pendingPatches;
49
48
  /** **Await to ensure that the subscription is established and the data arrived.** */
50
- readyPromise: Promise<void>;
49
+ private readyPromise_;
51
50
  private closeOrmSubscription;
52
51
  /** Function to call once initial data has been applied. */
53
52
  private resolveReady;
@@ -130,6 +129,10 @@ export declare class OrmSubscription<T extends BaseType> {
130
129
  * ```
131
130
  */
132
131
  static getOrCreate: <T_1 extends BaseType>(shapeType: ShapeType<T_1>, scope: Scope) => OrmSubscription<T_1>;
132
+ /** True, if a transaction is running. */
133
+ get inTransaction(): boolean;
134
+ /** **Await to ensure that the subscription is established and the data arrived.** */
135
+ get readyPromise(): Promise<void>;
133
136
  /**
134
137
  * Stop the subscription.
135
138
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ormSubscriptionHandler.d.ts","sourceRoot":"","sources":["../../src/connector/ormSubscriptionHandler.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAA4B,KAAK,EAAE,MAAM,mBAAmB,CAAC;AASpE,OAAO,KAAK,EAER,aAAa,EAEhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAU5D;;;;;;;;;GASG;AACH,qBAAa,eAAe,CAAC,CAAC,SAAS,QAAQ;IAC3C,kEAAkE;IAClE,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2C;IAEnE,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,CAAC,mBAAmB,CAAa;IACxC,qFAAqF;IACrF,OAAO,CAAC,cAAc,CAAqB;IAC3C,kFAAkF;IAClF,OAAO,CAAC,QAAQ,CAAS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,wEAAwE;IACxE,OAAO,CAAC,oBAAoB,CAoB1B;IAEF,wEAAwE;IACxE,OAAO,CAAC,gBAAgB,CAStB;IAEF,OAAO,CAAC,qBAAqB,CAuB3B;IAEF,8CAA8C;IAC9C,OAAO,CAAC,eAAe,CAOrB;IAEF,gFAAgF;IAChF,OAAO,CAAC,yBAAyB,CAgD/B;IAEF;;;;;;OAMG;IACI,gBAAgB,aAarB;IAEF;;;OAGG;IACI,iBAAiB,sBAkCtB;CACL"}
@@ -59,11 +59,11 @@ export class OrmSubscription {
59
59
  /** When true, modifications from the signalObject are not processed. */
60
60
  suspendDeepWatcher;
61
61
  /** True, if a transaction is running. */
62
- inTransaction = false;
63
- /** Aggregation of patches to be sent when in transaction. */
62
+ inTransaction_ = false;
63
+ /** Aggregation of patches to be sent when in transaction. @ignore */
64
64
  pendingPatches;
65
65
  /** **Await to ensure that the subscription is established and the data arrived.** */
66
- readyPromise;
66
+ readyPromise_;
67
67
  closeOrmSubscription;
68
68
  /** Function to call once initial data has been applied. */
69
69
  resolveReady;
@@ -102,7 +102,7 @@ export class OrmSubscription {
102
102
  const { stopListening } = watchDeepSignal(this.signalObject, this.onSignalObjectUpdate);
103
103
  this.stopSignalListening = stopListening;
104
104
  // Set promise to be resolved when data arrived from engine.
105
- this.readyPromise = new Promise((resolve) => {
105
+ this.readyPromise_ = new Promise((resolve) => {
106
106
  this.resolveReady = resolve;
107
107
  });
108
108
  ngSession.then(async ({ ng, session }) => {
@@ -208,6 +208,14 @@ export class OrmSubscription {
208
208
  return newConnection;
209
209
  }
210
210
  };
211
+ /** True, if a transaction is running. */
212
+ get inTransaction() {
213
+ return this.inTransaction_;
214
+ }
215
+ /** **Await to ensure that the subscription is established and the data arrived.** */
216
+ get readyPromise() {
217
+ return this.readyPromise_;
218
+ }
211
219
  /**
212
220
  * Stop the subscription.
213
221
  *
@@ -235,13 +243,13 @@ export class OrmSubscription {
235
243
  return;
236
244
  const ormPatches = deepPatchesToWasm(patches);
237
245
  // If in transaction, collect patches immediately (no await before).
238
- if (this.inTransaction) {
246
+ if (this.inTransaction_) {
239
247
  this.pendingPatches?.push(...ormPatches);
240
248
  return;
241
249
  }
242
250
  // Wait for session and subscription to be initialized.
243
251
  const { ng, session } = await ngSession;
244
- await this.readyPromise;
252
+ await this.readyPromise_;
245
253
  ng.graph_orm_update(this.subscriptionId, ormPatches, session.session_id);
246
254
  };
247
255
  /** Handle messages coming from the engine (initial data or patches). */
@@ -335,7 +343,7 @@ export class OrmSubscription {
335
343
  * Modifications keep being rendered.
336
344
  */
337
345
  beginTransaction = () => {
338
- this.inTransaction = true;
346
+ this.inTransaction_ = true;
339
347
  this.pendingPatches = [];
340
348
  // Use a listener that immediately triggers on object modifications.
341
349
  // We don't need the deep-signal's batching (through microtasks) here.
@@ -348,12 +356,12 @@ export class OrmSubscription {
348
356
  * (started with `beginTransaction`) to the database.
349
357
  */
350
358
  commitTransaction = async () => {
351
- if (!this.inTransaction) {
359
+ if (!this.inTransaction_) {
352
360
  throw new Error("No transaction is open. Call `beginTransaction` first.");
353
361
  }
354
362
  const { ng, session } = await ngSession;
355
- await this.readyPromise;
356
- this.inTransaction = false;
363
+ await this.readyPromise_;
364
+ this.inTransaction_ = false;
357
365
  if (this.pendingPatches?.length == 0) {
358
366
  // Nothing to send to the engine.
359
367
  }
package/dist/core.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { OrmSubscription } from "./connector/ormSubscriptionHandler.ts";
2
+ import { DiscreteOrmSubscription } from "./connector/discrete/discreteOrmSubscriptionHandler.ts";
3
+ import { initNgSignals, ngSession } from "./connector/initNg.ts";
4
+ import { insertObject } from "./connector/insertObject.ts";
5
+ import { getObjects } from "./connector/getObjects.ts";
6
+ export * from "./types.ts";
7
+ export type { DeepSignal, DeepSignalObject, DeepSignalSet, } from "@ng-org/alien-deepsignals";
8
+ export { getRaw, watch, effect } from "@ng-org/alien-deepsignals";
9
+ export { initNgSignals as initNg, ngSession, OrmSubscription, DiscreteOrmSubscription, insertObject, getObjects, };
10
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AACjG,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;AAEvD,cAAc,YAAY,CAAC;AAE3B,YAAY,EACR,UAAU,EACV,gBAAgB,EAChB,aAAa,GAChB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EACH,aAAa,IAAI,MAAM,EACvB,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,UAAU,GACb,CAAC"}
package/dist/core.js ADDED
@@ -0,0 +1,17 @@
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 { OrmSubscription } from "./connector/ormSubscriptionHandler.js";
11
+ import { DiscreteOrmSubscription } from "./connector/discrete/discreteOrmSubscriptionHandler.js";
12
+ import { initNgSignals, ngSession } from "./connector/initNg.js";
13
+ import { insertObject } from "./connector/insertObject.js";
14
+ import { getObjects } from "./connector/getObjects.js";
15
+ export * from "./types.js";
16
+ export { getRaw, watch, effect } from "@ng-org/alien-deepsignals";
17
+ export { initNgSignals as initNg, ngSession, OrmSubscription, DiscreteOrmSubscription, insertObject, getObjects, };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,7 @@
1
- import { OrmSubscription } from "./connector/ormSubscriptionHandler.ts";
2
- import { DiscreteOrmSubscription } from "./connector/discrete/discreteOrmSubscriptionHandler.ts";
3
1
  import { useShape as svelteUseShape, useDiscrete as svelteUseDiscrete } from "./frontendAdapters/svelte/index.ts";
4
2
  import { useShape as svelte4UseShape, useDiscrete as svelte4UseDiscrete, type UseShapeStoreResult as Svelte4UseShapeStoreResult } from "./frontendAdapters/svelte4/index.ts";
5
3
  import { useShape as reactUseShape, useDiscrete as reactUseDiscrete } from "./frontendAdapters/react/index.ts";
6
4
  import { useShape as vueUseShape, useDiscrete as vueUseDiscrete } from "./frontendAdapters/vue/index.ts";
7
- import { initNgSignals, ngSession, type Session } from "./connector/initNg.ts";
8
- import { insertObject } from "./connector/insertObject.ts";
9
- import { getObjects } from "./connector/getObjects.ts";
10
- export * from "./connector/applyPatches.ts";
11
- export * from "./types.ts";
12
- export type { DeepSignal, DeepSignalObject, DeepSignalSet, } from "@ng-org/alien-deepsignals";
13
- export { getRaw, watch, effect } from "@ng-org/alien-deepsignals";
14
- export { initNgSignals as initNg, ngSession, type Session, OrmSubscription as OrmSubscription, DiscreteOrmSubscription, svelteUseShape, svelteUseDiscrete, svelte4UseShape, svelte4UseDiscrete, Svelte4UseShapeStoreResult, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, insertObject, getObjects, };
5
+ export * from "./core.ts";
6
+ export { svelteUseShape, svelteUseDiscrete, svelte4UseShape, svelte4UseDiscrete, Svelte4UseShapeStoreResult, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, };
15
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAA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C1B,WAAW,IAAI,iBAAiB,EACnC,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,QAAQ,IAAI,eAAe,EAC3B,WAAW,IAAI,kBAAkB,EACjC,KAAK,mBAAmB,IAAI,0BAA0B,EACzD,MAAM,qCAAqC,CAAC;AAC7C,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;AAEzC,cAAc,WAAW,CAAC;AAE1B,OAAO,EACH,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,cAAc,GACjB,CAAC"}
package/dist/index.js CHANGED
@@ -7,16 +7,9 @@
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 { OrmSubscription } from "./connector/ormSubscriptionHandler.js";
11
- import { DiscreteOrmSubscription } from "./connector/discrete/discreteOrmSubscriptionHandler.js";
12
10
  import { useShape as svelteUseShape, useDiscrete as svelteUseDiscrete, } from "./frontendAdapters/svelte/index.js";
13
11
  import { useShape as svelte4UseShape, useDiscrete as svelte4UseDiscrete, } from "./frontendAdapters/svelte4/index.js";
14
12
  import { useShape as reactUseShape, useDiscrete as reactUseDiscrete, } from "./frontendAdapters/react/index.js";
15
13
  import { useShape as vueUseShape, useDiscrete as vueUseDiscrete, } from "./frontendAdapters/vue/index.js";
16
- import { initNgSignals, ngSession } from "./connector/initNg.js";
17
- import { insertObject } from "./connector/insertObject.js";
18
- import { getObjects } from "./connector/getObjects.js";
19
- export * from "./connector/applyPatches.js";
20
- export * from "./types.js";
21
- export { getRaw, watch, effect } from "@ng-org/alien-deepsignals";
22
- export { initNgSignals as initNg, ngSession, OrmSubscription as OrmSubscription, DiscreteOrmSubscription, svelteUseShape, svelteUseDiscrete, svelte4UseShape, svelte4UseDiscrete, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, insertObject, getObjects, };
14
+ export * from "./core.js";
15
+ export { svelteUseShape, svelteUseDiscrete, svelte4UseShape, svelte4UseDiscrete, reactUseShape, reactUseDiscrete, vueUseShape, vueUseDiscrete, };
package/dist/types.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare const normalizeScope: (scope?: Scope | string | undefined) => {
33
33
  graphs: string[];
34
34
  subjects: string[];
35
35
  };
36
- /** An allowed array in the CRDT. */
36
+ /** An allowed array in the CRDT. @ignore */
37
37
  export interface DiscreteArray extends Array<DiscreteType> {
38
38
  }
39
39
  /** An allowed object in the CRDT. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,KAAK,GAAG;IAChB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,QAAO,KAAK,GAAG,MAAM,GAAG,SAAc;;;CASpE,CAAC;AAEF,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,EA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,GACN,MAAM,GACN,OAAO,GACP,iBAAiB,CAAC;CAC3B;AAED,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,kBAAkB,CAAC;AAElE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@ng-org/orm",
3
- "version": "0.1.2-alpha.11",
3
+ "version": "0.1.2-alpha.12",
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": "./dist/index.js",
10
+ "main": "./dist/core.js",
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/core.d.ts",
14
+ "default": "./dist/core.js"
15
+ },
16
+ "./all": {
13
17
  "types": "./dist/index.d.ts",
14
18
  "default": "./dist/index.js"
15
19
  },
@@ -33,47 +37,44 @@
33
37
  "publishConfig": {
34
38
  "access": "public"
35
39
  },
36
- "optionalDependencies": {
40
+ "peerDependencies": {
37
41
  "react": "^19.0.0 || ^18.0.0",
38
- "svelte": "^5.0.0",
42
+ "svelte": "^5.0.0 || ^4.0.0 || ^3.0.0",
39
43
  "vue": "^3.0.0"
40
44
  },
45
+ "peerDependenciesMeta": {
46
+ "react": {
47
+ "optional": true
48
+ },
49
+ "svelte": {
50
+ "optional": true
51
+ },
52
+ "vue": {
53
+ "optional": true
54
+ }
55
+ },
41
56
  "dependencies": {
42
- "@gn8/alien-signals-react": "^0.1.1",
43
- "@gn8/alien-signals-solid": "^0.1.1",
44
- "@gn8/alien-signals-svelte": "^0.1.1",
45
- "@gn8/alien-signals-vue": "^0.1.1",
46
- "@types/react": "19.1.10",
47
- "@types/react-dom": "19.1.7",
48
- "@types/shexj": "^2.1.7",
49
- "alien-signals": "^2.0.7",
50
- "install": "^0.13.0",
51
- "npm": "^11.5.2",
52
- "prettier-eslint": "^16.4.2",
53
- "@ng-org/shex-orm": "0.1.2-alpha.5",
54
- "@ng-org/alien-deepsignals": "0.1.2-alpha.8"
57
+ "@ng-org/alien-deepsignals": "0.1.2-alpha.9"
55
58
  },
56
59
  "devDependencies": {
57
- "@playwright/test": "^1.55.0",
58
- "@types/node": "24.3.0",
59
- "@types/react": "19.1.10",
60
- "@types/react-dom": "19.1.7",
61
- "vite": "7.1.3",
60
+ "@types/react": "^19.1.10",
61
+ "@types/react-dom": "^19.1.7",
62
+ "vite": "7.3.1",
62
63
  "vitest": "^3.2.4",
63
64
  "typescript": "^5.3.0",
64
- "react": "19.1.1",
65
- "react-dom": "19.1.1",
66
- "svelte": "5.39.12",
67
- "vue": "3.5.19",
68
- "@ng-org/lib-wasm": "0.1.2-alpha.2"
65
+ "react": "^19.1.1",
66
+ "react-dom": "^19.1.1",
67
+ "svelte": "^5.39.12",
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
71
  },
70
72
  "files": [
71
73
  "dist"
72
74
  ],
73
75
  "scripts": {
74
76
  "test": "vitest",
75
- "test:e2e": "playwright test",
76
77
  "build:ts": "rm -rf dist && tsc"
77
78
  },
78
- "types": "./dist/index.d.ts"
79
+ "types": "./dist/core.d.ts"
79
80
  }