Take into account new ordering and filtering options

This commit is contained in:
srosset81
2026-08-07 15:56:33 +02:00
parent 3d3a69d3f6
commit 0fc977fcca
5 changed files with 136 additions and 24 deletions
+8 -8
View File
@@ -95,16 +95,16 @@
},
"peerDependencies": {
"@refinedev/core": "^5.0.12",
"@ng-org/alien-deepsignals": "0.1.2-alpha.12",
"@ng-org/orm": "0.1.2-alpha.19",
"@ng-org/shex-orm": "0.1.2-alpha.8",
"@ng-org/web": "0.1.2-alpha.13"
"@ng-org/alien-deepsignals": "0.1.2-alpha.13",
"@ng-org/orm": "0.1.2-alpha.20",
"@ng-org/shex-orm": "0.1.2-alpha.9",
"@ng-org/web": "0.1.2-alpha.14"
},
"devDependencies": {
"@ng-org/alien-deepsignals": "0.1.2-alpha.12",
"@ng-org/orm": "0.1.2-alpha.19",
"@ng-org/shex-orm": "0.1.2-alpha.8",
"@ng-org/web": "0.1.2-alpha.13",
"@ng-org/alien-deepsignals": "0.1.2-alpha.13",
"@ng-org/orm": "0.1.2-alpha.20",
"@ng-org/shex-orm": "0.1.2-alpha.9",
"@ng-org/web": "0.1.2-alpha.14",
"@refinedev/core": "^5.0.12",
"concurrently": "^10.0.3",
"parcel": "^2.16.4",
+79 -10
View File
@@ -9,17 +9,17 @@ importers:
.:
devDependencies:
'@ng-org/alien-deepsignals':
specifier: 0.1.2-alpha.12
version: 0.1.2-alpha.12(react@19.2.7)
'@ng-org/orm':
specifier: 0.1.2-alpha.19
version: 0.1.2-alpha.19(react@19.2.7)
'@ng-org/shex-orm':
specifier: 0.1.2-alpha.8
version: 0.1.2-alpha.8(typescript@5.9.3)
'@ng-org/web':
specifier: 0.1.2-alpha.13
version: 0.1.2-alpha.13
version: 0.1.2-alpha.13(react@19.2.7)
'@ng-org/orm':
specifier: 0.1.2-alpha.20
version: 0.1.2-alpha.20(react@19.2.7)
'@ng-org/shex-orm':
specifier: 0.1.2-alpha.9
version: 0.1.2-alpha.9(typescript@5.9.3)
'@ng-org/web':
specifier: 0.1.2-alpha.14
version: 0.1.2-alpha.14
'@refinedev/core':
specifier: ^5.0.12
version: 5.0.12(@tanstack/react-query@5.101.2(react@19.2.7))(@types/react-dom@19.2.3(@types/react@19.2.17))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)
@@ -629,6 +629,20 @@ packages:
vue:
optional: true
'@ng-org/alien-deepsignals@0.1.2-alpha.13':
resolution: {integrity: sha512-yOEh/J+9IrCo8WDXTdZLxRcO9IHAczrUA4pjSD4BaZzmWhnCFE/amy/0PsAdh/yePurBrtQj3tG/y+hReM15Ew==}
peerDependencies:
react: ^19.0.0 || ^18.0.0
svelte: ^5.0.0 || ^4.0.0
vue: ^3.0.0
peerDependenciesMeta:
react:
optional: true
svelte:
optional: true
vue:
optional: true
'@ng-org/orm@0.1.2-alpha.19':
resolution: {integrity: sha512-wPDQ0OEitpoEKrvj4IJKIRxeTHr3X5+rApvZJOh54CNV1Q1b5MaT2XvyJ9YDvlgyUX2CxNkcmumV4k4ASmBXNA==}
peerDependencies:
@@ -643,15 +657,38 @@ packages:
vue:
optional: true
'@ng-org/orm@0.1.2-alpha.20':
resolution: {integrity: sha512-T7lzAi2QRI0WWHMXab63zqvP7x6hCwQYzYWvZxfMWLYuwJVycLgnHP97gemPrBwXg+GEa2KZ9LqzLMR2bA3oVw==}
peerDependencies:
react: ^19.0.0 || ^18.0.0
svelte: ^5.0.0 || ^4.0.0
vue: ^3.0.0
peerDependenciesMeta:
react:
optional: true
svelte:
optional: true
vue:
optional: true
'@ng-org/shex-orm@0.1.2-alpha.8':
resolution: {integrity: sha512-jogxiLfUtI3WkuF5O3PPwRBRWylpapk/JlvElGUqZnEavXXlEMmEGbK3VwqMUsbp1pweNA0sEKIFLIk3Lzt2Gg==}
hasBin: true
peerDependencies:
typescript: ^4.9.0 || ^5.0.0 || ^6.0.0
'@ng-org/shex-orm@0.1.2-alpha.9':
resolution: {integrity: sha512-M69oIHrcjl24xKXIaiZjZ64rJvispAPIqn73asLPR73GWpEMvbiot/EN0vDkcfrbRy3cMEql36A9e1Nwv2csOA==}
hasBin: true
peerDependencies:
typescript: ^4.9.0 || ^5.0.0 || ^6.0.0
'@ng-org/web@0.1.2-alpha.13':
resolution: {integrity: sha512-/xO0c+3NTphnws5Do2LDqgZWmAf+aNnYdChJKdU0dnp1U1iVSgi/y3yb8AYryf0v9sooj0aYJxt08B6DpirFMQ==}
'@ng-org/web@0.1.2-alpha.14':
resolution: {integrity: sha512-FPQ7kyngMhAXK/WJtZ6pkoEJwGcau6GaBH2nhjjYorMq7OG//I+zwghat90FsIeMrfYsps0+5Y0UrRqfxNdUXA==}
'@nodelib/fs.scandir@2.1.5':
resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==}
engines: {node: '>= 8'}
@@ -4873,12 +4910,24 @@ snapshots:
optionalDependencies:
react: 19.2.7
'@ng-org/alien-deepsignals@0.1.2-alpha.13(react@19.2.7)':
dependencies:
alien-signals: 2.0.8
optionalDependencies:
react: 19.2.7
'@ng-org/orm@0.1.2-alpha.19(react@19.2.7)':
dependencies:
'@ng-org/alien-deepsignals': 0.1.2-alpha.12(react@19.2.7)
optionalDependencies:
react: 19.2.7
'@ng-org/orm@0.1.2-alpha.20(react@19.2.7)':
dependencies:
'@ng-org/alien-deepsignals': 0.1.2-alpha.13(react@19.2.7)
optionalDependencies:
react: 19.2.7
'@ng-org/shex-orm@0.1.2-alpha.8(typescript@5.9.3)':
dependencies:
'@ldo/traverser-shexj': 1.0.0-alpha.28
@@ -4895,10 +4944,30 @@ snapshots:
transitivePeerDependencies:
- encoding
'@ng-org/shex-orm@0.1.2-alpha.9(typescript@5.9.3)':
dependencies:
'@ldo/traverser-shexj': 1.0.0-alpha.28
'@ldo/type-traverser': 1.0.0-alpha.28
'@shexjs/parser': 1.0.0-alpha.28
commander: 14.0.3
dts-dom: 3.6.0
ejs: 3.1.10
fs-extra: 10.1.0
jsonld2graphobject: 0.0.5
loading-cli: 1.1.2
prettier: 3.9.5
typescript: 5.9.3
transitivePeerDependencies:
- encoding
'@ng-org/web@0.1.2-alpha.13':
dependencies:
async-proxy: 0.4.1
'@ng-org/web@0.1.2-alpha.14':
dependencies:
async-proxy: 0.4.1
'@nodelib/fs.scandir@2.1.5':
dependencies:
'@nodelib/fs.stat': 2.0.5
+21 -4
View File
@@ -1,18 +1,35 @@
import { DataProvider } from "@refinedev/core";
import { ng } from "@ng-org/web";
import { getObjects } from "@ng-org/orm";
import { addIdToObject, isGraphKey, getSignalObject } from "./utils";
import { getObjects } from "./getObjects";
import { DataProviderConfig } from "./types";
const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataProvider => ({
// Note: the `pagination` parameter is not used, because the ORM handle currently handle pagination within the ORM objects.
// In the future, it may use offset-based or cursor-based pagination, which would work with this stateless data provider.
// Fortunately, Refine handle pagination automatically if the total number of objects is larger than the page size.
getList: async ({ resource, pagination, sorters, filters, meta }) => {
console.log('list', resource, pagination, sorters, filters, meta);
const objects = await getObjects(shapeTypes[resource], "");
const objects = await getObjects(shapeTypes[resource], {
graphs: [""],
orderBy: sorters && sorters.length > 0
? sorters.map(s => ({ [s.field]: s.order })) as any
: undefined,
where: filters && filters.length > 0
? filters.reduce((acc, filter) => {
if ("field" in filter && filter.operator === "eq") {
acc[filter.field] = filter.value;
}
return acc;
}, {} as any)
: undefined
});
return {
data: [...objects].map(addIdToObject) as any,
total: 1,
total: objects.size,
};
},
create: async ({ resource, variables, meta }) => {
@@ -85,7 +102,7 @@ const dataProvider = ({ shapeTypes, authProvider }: DataProviderConfig) : DataPr
console.log('getOne', resource, id, meta);
// The ID should be a graph URI, but if it's an object key, we can use the subjects filter to the the object
const objects = await getObjects(shapeTypes[resource], isGraphKey(id) ? `${id}` : { subjects: [`${id}`] });
const objects = await getObjects(shapeTypes[resource], isGraphKey(id) ? { graphs: [`${id}`] } : { graphs: [""], subjects: [`${id}`] });
return {
data: addIdToObject([...objects][0])
+26
View File
@@ -0,0 +1,26 @@
import type { BaseType, ShapeType } from "@ng-org/shex-orm";
import { RdfOrmSubscription, normalizeConf } from "@ng-org/orm";
import type { RdfOrmConfig } from "@ng-org/orm/all";
import { RAW_KEY } from "@ng-org/alien-deepsignals";
/**
* Local copy of `@ng-org/orm`'s `getObjects` until the fix is released
* https://git.nextgraph.org/NextGraph/nextgraph-rs/commit/02cb531f53dfb7a64014917e9b38cd5134efcdd8
*/
export async function getObjects<T extends BaseType>(
shapeType: ShapeType<T>,
config: Omit<RdfOrmConfig<T>, "pageSize" | "maxActivePages">
) {
const connection = RdfOrmSubscription.getOrCreate(
shapeType,
normalizeConf(config) as any
);
await connection.readyPromise;
setTimeout(() => {
connection.close();
}, 1_000);
return structuredClone(connection.signalObject[RAW_KEY]);
}
+2 -2
View File
@@ -1,10 +1,10 @@
import { BaseKey } from "@refinedev/core";
import { OrmSubscription } from "@ng-org/orm";
import { RdfOrmSubscription } from "@ng-org/orm";
import type { ShapeType } from "@ng-org/shex-orm";
import { DeepSignalSet, DeepPatch } from "@ng-org/alien-deepsignals"
export const getSignalObject = async (shapeType: ShapeType<any>, ids?: string[], closeSubscription: boolean = true) : Promise<DeepSignalSet<any>> => {
const subscription = OrmSubscription.getOrCreate(shapeType, { graphs: ids || [''] });
const subscription = RdfOrmSubscription.getOrCreate(shapeType, { graphs: ids || [''] });
await subscription.readyPromise;
const { signalObject } = subscription;
if (closeSubscription) subscription.close();