@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.
Files changed (75) hide show
  1. package/README.md +44 -0
  2. package/dist/generated/graphql.d.ts +2119 -24
  3. package/dist/generated/graphql.d.ts.map +1 -1
  4. package/dist/generated/graphql.js +470 -12
  5. package/dist/generated/graphql.js.map +1 -1
  6. package/dist/generated/operations.d.ts +2 -0
  7. package/dist/generated/operations.d.ts.map +1 -0
  8. package/dist/generated/operations.js +165 -0
  9. package/dist/generated/operations.js.map +1 -0
  10. package/dist/graphql-clients.d.ts +2 -1
  11. package/dist/graphql-clients.d.ts.map +1 -1
  12. package/dist/graphql-clients.js +2 -1
  13. package/dist/graphql-clients.js.map +1 -1
  14. package/dist/shared/agent-types.d.ts +15 -0
  15. package/dist/shared/agent-types.d.ts.map +1 -1
  16. package/dist/shared/chat-manager.d.ts +1 -1
  17. package/dist/shared/chat-manager.d.ts.map +1 -1
  18. package/dist/shared/chat-manager.js +1 -1
  19. package/dist/shared/chat-manager.js.map +1 -1
  20. package/dist/shared/constants.d.ts +6 -0
  21. package/dist/shared/constants.d.ts.map +1 -1
  22. package/dist/shared/constants.js +6 -0
  23. package/dist/shared/constants.js.map +1 -1
  24. package/dist/shared/datastore-path.d.ts +3 -0
  25. package/dist/shared/datastore-path.d.ts.map +1 -1
  26. package/dist/shared/datastore-path.js +3 -0
  27. package/dist/shared/datastore-path.js.map +1 -1
  28. package/dist/shared/login-status.d.ts +6 -0
  29. package/dist/shared/login-status.d.ts.map +1 -0
  30. package/dist/shared/login-status.js +2 -0
  31. package/dist/shared/login-status.js.map +1 -0
  32. package/dist/shared/memory-schema-limits.d.ts +17 -0
  33. package/dist/shared/memory-schema-limits.d.ts.map +1 -0
  34. package/dist/shared/memory-schema-limits.js +17 -0
  35. package/dist/shared/memory-schema-limits.js.map +1 -0
  36. package/dist/shared/memory-schema-pattern.d.ts +3 -0
  37. package/dist/shared/memory-schema-pattern.d.ts.map +1 -0
  38. package/dist/shared/memory-schema-pattern.js +16 -0
  39. package/dist/shared/memory-schema-pattern.js.map +1 -0
  40. package/dist/shared/memory-schema-property.d.ts +64 -0
  41. package/dist/shared/memory-schema-property.d.ts.map +1 -0
  42. package/dist/shared/memory-schema-property.js +195 -0
  43. package/dist/shared/memory-schema-property.js.map +1 -0
  44. package/dist/shared/memory-schema-values.d.ts +20 -0
  45. package/dist/shared/memory-schema-values.d.ts.map +1 -0
  46. package/dist/shared/memory-schema-values.js +139 -0
  47. package/dist/shared/memory-schema-values.js.map +1 -0
  48. package/dist/shared/operation-root-fields.d.ts +7 -0
  49. package/dist/shared/operation-root-fields.d.ts.map +1 -0
  50. package/dist/shared/operation-root-fields.js +33 -0
  51. package/dist/shared/operation-root-fields.js.map +1 -0
  52. package/dist/shared/rdf-namespaces.d.ts +1 -0
  53. package/dist/shared/rdf-namespaces.d.ts.map +1 -1
  54. package/dist/shared/rdf-namespaces.js +2 -0
  55. package/dist/shared/rdf-namespaces.js.map +1 -1
  56. package/dist/testing/manta-mock.d.ts +25 -0
  57. package/dist/testing/manta-mock.d.ts.map +1 -0
  58. package/dist/testing/manta-mock.js +165 -0
  59. package/dist/testing/manta-mock.js.map +1 -0
  60. package/package.json +32 -6
  61. package/src/generated/graphql.ts +2729 -55
  62. package/src/generated/operations.ts +164 -0
  63. package/src/graphql-clients.ts +3 -2
  64. package/src/shared/agent-types.ts +16 -0
  65. package/src/shared/chat-manager.ts +1 -1
  66. package/src/shared/constants.ts +11 -0
  67. package/src/shared/datastore-path.ts +6 -0
  68. package/src/shared/login-status.ts +1 -0
  69. package/src/shared/memory-schema-limits.ts +16 -0
  70. package/src/shared/memory-schema-pattern.ts +15 -0
  71. package/src/shared/memory-schema-property.ts +280 -0
  72. package/src/shared/memory-schema-values.ts +174 -0
  73. package/src/shared/operation-root-fields.ts +56 -0
  74. package/src/shared/rdf-namespaces.ts +3 -0
  75. 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