@manta-eu/client 0.12.0 → 0.13.0
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 +44 -0
- package/dist/generated/graphql.d.ts +2119 -24
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +470 -12
- package/dist/generated/graphql.js.map +1 -1
- package/dist/generated/operations.d.ts +2 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +165 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/graphql-clients.d.ts +2 -1
- package/dist/graphql-clients.d.ts.map +1 -1
- package/dist/graphql-clients.js +2 -1
- package/dist/graphql-clients.js.map +1 -1
- package/dist/shared/agent-types.d.ts +15 -0
- package/dist/shared/agent-types.d.ts.map +1 -1
- package/dist/shared/chat-manager.d.ts +1 -1
- package/dist/shared/chat-manager.d.ts.map +1 -1
- package/dist/shared/chat-manager.js +1 -1
- package/dist/shared/chat-manager.js.map +1 -1
- package/dist/shared/constants.d.ts +6 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +6 -0
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/datastore-path.d.ts +3 -0
- package/dist/shared/datastore-path.d.ts.map +1 -1
- package/dist/shared/datastore-path.js +3 -0
- package/dist/shared/datastore-path.js.map +1 -1
- package/dist/shared/login-status.d.ts +6 -0
- package/dist/shared/login-status.d.ts.map +1 -0
- package/dist/shared/login-status.js +2 -0
- package/dist/shared/login-status.js.map +1 -0
- package/dist/shared/memory-schema-limits.d.ts +17 -0
- package/dist/shared/memory-schema-limits.d.ts.map +1 -0
- package/dist/shared/memory-schema-limits.js +17 -0
- package/dist/shared/memory-schema-limits.js.map +1 -0
- package/dist/shared/memory-schema-pattern.d.ts +3 -0
- package/dist/shared/memory-schema-pattern.d.ts.map +1 -0
- package/dist/shared/memory-schema-pattern.js +16 -0
- package/dist/shared/memory-schema-pattern.js.map +1 -0
- package/dist/shared/memory-schema-property.d.ts +64 -0
- package/dist/shared/memory-schema-property.d.ts.map +1 -0
- package/dist/shared/memory-schema-property.js +195 -0
- package/dist/shared/memory-schema-property.js.map +1 -0
- package/dist/shared/memory-schema-values.d.ts +20 -0
- package/dist/shared/memory-schema-values.d.ts.map +1 -0
- package/dist/shared/memory-schema-values.js +139 -0
- package/dist/shared/memory-schema-values.js.map +1 -0
- package/dist/shared/operation-root-fields.d.ts +7 -0
- package/dist/shared/operation-root-fields.d.ts.map +1 -0
- package/dist/shared/operation-root-fields.js +33 -0
- package/dist/shared/operation-root-fields.js.map +1 -0
- package/dist/shared/rdf-namespaces.d.ts +1 -0
- package/dist/shared/rdf-namespaces.d.ts.map +1 -1
- package/dist/shared/rdf-namespaces.js +2 -0
- package/dist/shared/rdf-namespaces.js.map +1 -1
- package/dist/testing/manta-mock.d.ts +25 -0
- package/dist/testing/manta-mock.d.ts.map +1 -0
- package/dist/testing/manta-mock.js +165 -0
- package/dist/testing/manta-mock.js.map +1 -0
- package/package.json +32 -6
- package/src/generated/graphql.ts +2729 -55
- package/src/generated/operations.ts +164 -0
- package/src/graphql-clients.ts +3 -2
- package/src/shared/agent-types.ts +16 -0
- package/src/shared/chat-manager.ts +1 -1
- package/src/shared/constants.ts +11 -0
- package/src/shared/datastore-path.ts +6 -0
- package/src/shared/login-status.ts +1 -0
- package/src/shared/memory-schema-limits.ts +16 -0
- package/src/shared/memory-schema-pattern.ts +15 -0
- package/src/shared/memory-schema-property.ts +280 -0
- package/src/shared/memory-schema-values.ts +174 -0
- package/src/shared/operation-root-fields.ts +56 -0
- package/src/shared/rdf-namespaces.ts +3 -0
- package/src/testing/manta-mock.ts +208 -0
package/README.md
CHANGED
|
@@ -56,11 +56,55 @@ const client = mantaGraphQLClient(new URL("https://app.hiremanta.com"), onSigned
|
|
|
56
56
|
| `./shared/*` | Contract pieces shared with the server — page context, models, datastore paths, RDF namespaces |
|
|
57
57
|
| `./types/*` | Standalone type modules |
|
|
58
58
|
| `./shared/tools` | Tool definitions the assistant is given |
|
|
59
|
+
| `./testing` | An in-memory Manta for testing your app's SPARQL reads and writes |
|
|
59
60
|
|
|
60
61
|
Most consumers reach this package through [`@manta-eu/react`](https://www.npmjs.com/package/@manta-eu/react),
|
|
61
62
|
which mounts the copilot and its providers for you. Use it directly when you want the contract
|
|
62
63
|
without the UI.
|
|
63
64
|
|
|
65
|
+
## Testing your app
|
|
66
|
+
|
|
67
|
+
`createMantaMock` from `@manta-eu/client/testing` answers `/sparql` and `/sparql-update` from an
|
|
68
|
+
in-memory store, so tests run your app's real LDKit queries without a Manta stack. It adds the
|
|
69
|
+
prefixes Manta declares, to the seed Turtle too, and refuses the writes Manta refuses: anything but `INSERT DATA`, `DELETE DATA`
|
|
70
|
+
and `DELETE`/`INSERT` with a scoped `WHERE`, and writes that name a graph.
|
|
71
|
+
|
|
72
|
+
It runs on Comunica and N3, which only tests need, so add them as dev dependencies:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pnpm add -D @comunica/query-sparql-rdfjs-lite n3@^1.26.0
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Pass its `fetch` wherever your code takes one, with absolute URLs. As on Manta, reads go to
|
|
79
|
+
`/sparql` and writes to `/sparql-update`:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { createMantaMock } from "@manta-eu/client/testing";
|
|
83
|
+
import { createLens } from "ldkit";
|
|
84
|
+
|
|
85
|
+
const manta = createMantaMock({ turtle: "<https://example.com/todo/1> a <https://example.com/Todo> ." });
|
|
86
|
+
const reads = createLens(TodoSchema, { sources: ["https://manta.test/d/acme/sparql"], fetch: manta.fetch });
|
|
87
|
+
const writes = createLens(TodoSchema, { sources: ["https://manta.test/d/acme/sparql-update"], fetch: manta.fetch });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
In Playwright, route the page's SPARQL requests to it:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { createMantaMock, mantaMockRoutePattern } from "@manta-eu/client/testing";
|
|
94
|
+
|
|
95
|
+
test.beforeEach(async ({ page }) => {
|
|
96
|
+
const manta = createMantaMock();
|
|
97
|
+
await page.route(mantaMockRoutePattern, manta.route);
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`mantaMockRoutePattern` matches `/sparql` and `/sparql-update` on any origin. Pass a narrower pattern, such
|
|
102
|
+
as `https://manta.test/**`, when the page also queries other SPARQL endpoints. Requests the mock
|
|
103
|
+
does not serve fall through to the network. Like Manta, it answers a cross-origin page with CORS headers for that
|
|
104
|
+
origin, and answers the preflight of a write itself.
|
|
105
|
+
|
|
106
|
+
`manta.updates` lists the updates it applied, in order. Every datastore path shares one store.
|
|
107
|
+
|
|
64
108
|
## License
|
|
65
109
|
|
|
66
110
|
MIT
|