@anysoftinc/anydb-sdk 0.5.0 → 0.6.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 (45) hide show
  1. package/README.md +40 -0
  2. package/dist/client.d.ts +9 -5
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +43 -101
  5. package/dist/nextauth-adapter.d.ts +11 -1
  6. package/dist/nextauth-adapter.d.ts.map +1 -1
  7. package/dist/nextauth-adapter.js +25 -4
  8. package/package.json +4 -7
  9. package/dist/anydb.datascript.core.js +0 -336
  10. package/dist/anydb.datascript.rules.js +0 -29
  11. package/dist/anydb.datascript.schema.js +0 -35
  12. package/dist/cljs.core.js +0 -38752
  13. package/dist/cljs.reader.js +0 -450
  14. package/dist/cljs.tools.reader.edn.js +0 -945
  15. package/dist/cljs.tools.reader.impl.commons.js +0 -205
  16. package/dist/cljs.tools.reader.impl.errors.js +0 -429
  17. package/dist/cljs.tools.reader.impl.inspect.js +0 -170
  18. package/dist/cljs.tools.reader.impl.utils.js +0 -413
  19. package/dist/cljs.tools.reader.js +0 -1815
  20. package/dist/cljs.tools.reader.reader_types.js +0 -826
  21. package/dist/cljs_env.js +0 -7672
  22. package/dist/clojure.data.js +0 -307
  23. package/dist/clojure.edn.js +0 -107
  24. package/dist/clojure.set.js +0 -394
  25. package/dist/clojure.string.js +0 -490
  26. package/dist/clojure.walk.js +0 -144
  27. package/dist/datascript-backend.d.ts +0 -26
  28. package/dist/datascript-backend.d.ts.map +0 -1
  29. package/dist/datascript-backend.js +0 -113
  30. package/dist/datascript.built_ins.js +0 -680
  31. package/dist/datascript.conn.js +0 -814
  32. package/dist/datascript.core.js +0 -1285
  33. package/dist/datascript.db.js +0 -4058
  34. package/dist/datascript.impl.entity.js +0 -588
  35. package/dist/datascript.lru.js +0 -213
  36. package/dist/datascript.parser.js +0 -8598
  37. package/dist/datascript.pull_api.js +0 -2287
  38. package/dist/datascript.pull_parser.js +0 -865
  39. package/dist/datascript.query.js +0 -2785
  40. package/dist/datascript.serialize.js +0 -352
  41. package/dist/datascript.storage.js +0 -50
  42. package/dist/datascript.util.js +0 -82
  43. package/dist/extend_clj.core.js +0 -134
  44. package/dist/me.tonsky.persistent_sorted_set.arrays.js +0 -54
  45. package/dist/me.tonsky.persistent_sorted_set.js +0 -2485
@@ -1,113 +0,0 @@
1
- import { stringifyEdn } from "./client";
2
- // Load the DataScript backend if available
3
- let datascriptBackend = null;
4
- try {
5
- // Try to load the compiled DataScript module (shipped alongside dist output)
6
- datascriptBackend =
7
- globalThis.anydbDatascript ||
8
- require("./anydb.datascript.core.js");
9
- }
10
- catch (e) {
11
- console.warn("DataScript backend not available. Run `npx shadow-cljs compile datascript` to enable client-only development mode.");
12
- }
13
- export class DataScriptBackend {
14
- constructor(storageAlias, dbName) {
15
- this.dbAlias = `${storageAlias}/${dbName}`;
16
- if (!datascriptBackend) {
17
- throw new Error("DataScript backend not loaded. Please compile ClojureScript modules first.");
18
- }
19
- }
20
- // Database management
21
- async listDatabases() {
22
- if (!datascriptBackend)
23
- throw new Error("DataScript backend not available");
24
- return datascriptBackend.listDatabases();
25
- }
26
- async createDatabase() {
27
- if (!datascriptBackend)
28
- throw new Error("DataScript backend not available");
29
- return datascriptBackend.createDatabase(this.dbAlias);
30
- }
31
- async deleteDatabase() {
32
- if (!datascriptBackend)
33
- throw new Error("DataScript backend not available");
34
- return datascriptBackend.deleteDatabase(this.dbAlias);
35
- }
36
- // Transaction operations
37
- async transact(txData) {
38
- if (!datascriptBackend)
39
- throw new Error("DataScript backend not available");
40
- const txDataEdn = stringifyEdn(txData);
41
- const result = datascriptBackend.transactData(this.dbAlias, txDataEdn);
42
- // Convert to match Datomic API format
43
- return {
44
- "db-before": { "basis-t": -1, "db/alias": this.dbAlias },
45
- "db-after": { "basis-t": -1, "db/alias": this.dbAlias },
46
- "tx-data": result["tx-data"] || [],
47
- tempids: result.tempids || {},
48
- };
49
- }
50
- // Query operations
51
- async query(query, ...args) {
52
- if (!datascriptBackend)
53
- throw new Error("DataScript backend not available");
54
- const queryEdn = stringifyEdn(query);
55
- const argsEdn = args.map((arg) => stringifyEdn(arg));
56
- return datascriptBackend.queryData(queryEdn, this.dbAlias, ...argsEdn);
57
- }
58
- // Entity operations
59
- async entity(entityId) {
60
- if (!datascriptBackend)
61
- throw new Error("DataScript backend not available");
62
- const entity = datascriptBackend.getEntity(this.dbAlias, entityId);
63
- // Ensure db/id is present
64
- if (entity && !entity["db/id"]) {
65
- entity["db/id"] = entityId;
66
- }
67
- return entity;
68
- }
69
- // Datoms operations
70
- async datoms(index, options = {}) {
71
- if (!datascriptBackend)
72
- throw new Error("DataScript backend not available");
73
- const components = [];
74
- if (options.e !== undefined)
75
- components.push(options.e);
76
- if (options.a !== undefined)
77
- components.push(options.a);
78
- if (options.v !== undefined)
79
- components.push(options.v);
80
- let datoms = datascriptBackend.getDatoms(this.dbAlias, index, ...components);
81
- // Apply client-side limit/offset since DataScript doesn't have built-in pagination
82
- if (options.offset) {
83
- datoms = datoms.slice(options.offset);
84
- }
85
- if (options.limit) {
86
- datoms = datoms.slice(0, options.limit);
87
- }
88
- // Convert to Datomic datom format
89
- return datoms.map((d) => ({
90
- e: d.e || d[0],
91
- a: d.a || d[1],
92
- v: d.v || d[2],
93
- tx: d.tx || d[3],
94
- added: d.added !== false, // Default to true
95
- }));
96
- }
97
- // Database info (mock for compatibility)
98
- async databaseInfo() {
99
- return {
100
- "basis-t": -1, // DataScript doesn't have basis-t concept
101
- "db/alias": this.dbAlias,
102
- };
103
- }
104
- }
105
- // Utility to check if DataScript backend is available
106
- export function isDataScriptAvailable() {
107
- return datascriptBackend !== null;
108
- }
109
- // Utility to detect if we should use DataScript backend
110
- export function shouldUseDataScript(storageAlias) {
111
- // Explicit opt-in: use DataScript when storage alias is exactly "datascript"
112
- return storageAlias === "datascript";
113
- }