@anysoftinc/anydb-sdk 0.1.2 → 0.4.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 (48) hide show
  1. package/README.md +100 -163
  2. package/dist/anydb.datascript.core.js +336 -0
  3. package/dist/anydb.datascript.rules.js +29 -0
  4. package/dist/anydb.datascript.schema.js +35 -0
  5. package/dist/client.d.ts +46 -96
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +332 -305
  8. package/dist/cljs.core.js +38752 -0
  9. package/dist/cljs.reader.js +450 -0
  10. package/dist/cljs.tools.reader.edn.js +945 -0
  11. package/dist/cljs.tools.reader.impl.commons.js +205 -0
  12. package/dist/cljs.tools.reader.impl.errors.js +429 -0
  13. package/dist/cljs.tools.reader.impl.inspect.js +170 -0
  14. package/dist/cljs.tools.reader.impl.utils.js +413 -0
  15. package/dist/cljs.tools.reader.js +1815 -0
  16. package/dist/cljs.tools.reader.reader_types.js +826 -0
  17. package/dist/cljs_env.js +7672 -0
  18. package/dist/clojure.data.js +307 -0
  19. package/dist/clojure.edn.js +107 -0
  20. package/dist/clojure.set.js +394 -0
  21. package/dist/clojure.string.js +490 -0
  22. package/dist/clojure.walk.js +144 -0
  23. package/dist/datascript-backend.d.ts +26 -0
  24. package/dist/datascript-backend.d.ts.map +1 -0
  25. package/dist/datascript-backend.js +113 -0
  26. package/dist/datascript.built_ins.js +680 -0
  27. package/dist/datascript.conn.js +814 -0
  28. package/dist/datascript.core.js +1285 -0
  29. package/dist/datascript.db.js +4058 -0
  30. package/dist/datascript.impl.entity.js +588 -0
  31. package/dist/datascript.lru.js +213 -0
  32. package/dist/datascript.parser.js +8598 -0
  33. package/dist/datascript.pull_api.js +2287 -0
  34. package/dist/datascript.pull_parser.js +865 -0
  35. package/dist/datascript.query.js +2785 -0
  36. package/dist/datascript.serialize.js +352 -0
  37. package/dist/datascript.storage.js +50 -0
  38. package/dist/datascript.util.js +82 -0
  39. package/dist/extend_clj.core.js +134 -0
  40. package/dist/me.tonsky.persistent_sorted_set.arrays.js +54 -0
  41. package/dist/me.tonsky.persistent_sorted_set.js +2485 -0
  42. package/dist/nextauth-adapter.d.ts +7 -2
  43. package/dist/nextauth-adapter.d.ts.map +1 -1
  44. package/dist/nextauth-adapter.js +251 -149
  45. package/package.json +9 -5
  46. package/dist/query-builder.d.ts +0 -126
  47. package/dist/query-builder.d.ts.map +0 -1
  48. package/dist/query-builder.js +0 -207
@@ -1,126 +0,0 @@
1
- import { QueryInput, QueryResult, QueryValue, Keyword, Symbol } from './client';
2
- import type { DatomicDatabase } from './client';
3
- export type QueryVariable = Symbol;
4
- export interface QueryPattern {
5
- entity: QueryValue;
6
- attribute: QueryValue;
7
- value: QueryValue;
8
- tx?: QueryValue;
9
- }
10
- export interface AggregationClause {
11
- function: 'count' | 'sum' | 'avg' | 'min' | 'max' | 'count-distinct';
12
- variable: QueryVariable;
13
- alias?: QueryVariable;
14
- }
15
- export declare class QueryBuilder {
16
- private findClause;
17
- private whereClause;
18
- private inClause;
19
- private withClause;
20
- /**
21
- * Add variables or aggregations to the :find clause
22
- * @example
23
- * .find(sym('?e'), sym('?name')) // Find entity and name
24
- * .find({ function: 'count', variable: sym('?e') }) // Count entities
25
- */
26
- find(...vars: (QueryVariable | AggregationClause)[]): this;
27
- /**
28
- * Add a structured where clause
29
- * @example
30
- * .where({ entity: sym('?e'), attribute: kw(':person/name'), value: sym('?name') })
31
- */
32
- where(clause: QueryPattern): this;
33
- /**
34
- * Helper method to add entity-attribute-value pattern
35
- * @example
36
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).withValue(sym('?name'))
37
- */
38
- entity(entity: QueryValue): EntityQueryBuilder;
39
- /**
40
- * Add input parameters to the :in clause
41
- * @example
42
- * .in(sym('$')) // Database input
43
- * .in(sym('?name')) // Parameter input
44
- */
45
- in(...inputs: QueryVariable[]): this;
46
- /**
47
- * Add variables to the :with clause
48
- * @example
49
- * .with(sym('?tx')) // Include transaction in results
50
- */
51
- with(...variables: QueryVariable[]): this;
52
- /**
53
- * Helper for common patterns - find entities with attribute
54
- * @example
55
- * .findEntitiesWith(kw(':person/name')) // Find entities with any name
56
- * .findEntitiesWith(kw(':person/name'), sym('?name')) // Bind name to variable
57
- * .findEntitiesWith(kw(':person/name'), 'John') // Find entities named John
58
- */
59
- findEntitiesWith(attribute: Keyword, value?: QueryValue): this;
60
- /**
61
- * Helper for aggregation queries
62
- * @example
63
- * .count(sym('?e')) // Count entities
64
- * .sum(sym('?amount')) // Sum amounts
65
- */
66
- count(variable: QueryVariable, alias?: QueryVariable): this;
67
- sum(variable: QueryVariable, alias?: QueryVariable): this;
68
- avg(variable: QueryVariable, alias?: QueryVariable): this;
69
- min(variable: QueryVariable, alias?: QueryVariable): this;
70
- max(variable: QueryVariable, alias?: QueryVariable): this;
71
- countDistinct(variable: QueryVariable, alias?: QueryVariable): this;
72
- /**
73
- * Build the final query array with proper EDN types
74
- */
75
- build(): QueryInput;
76
- /**
77
- * Execute the query directly (requires database context)
78
- */
79
- execute(db: DatomicDatabase, ...args: any[]): Promise<QueryResult>;
80
- }
81
- /**
82
- * Helper class for fluent entity-based query building
83
- */
84
- export declare class EntityQueryBuilder {
85
- private queryBuilder;
86
- private entity;
87
- constructor(queryBuilder: QueryBuilder, entity: QueryValue);
88
- /**
89
- * Add an attribute to the current entity
90
- * @example
91
- * .entity(sym('?e')).hasAttribute(kw(':person/name'))
92
- */
93
- hasAttribute(attribute: Keyword): AttributeQueryBuilder;
94
- /**
95
- * Return to the main query builder
96
- */
97
- build(): QueryInput;
98
- }
99
- /**
100
- * Helper class for fluent attribute-based query building
101
- */
102
- export declare class AttributeQueryBuilder {
103
- private queryBuilder;
104
- private entity;
105
- private attribute;
106
- constructor(queryBuilder: QueryBuilder, entity: QueryValue, attribute: Keyword);
107
- /**
108
- * Add a value constraint to the attribute
109
- * @example
110
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).withValue(sym('?name'))
111
- * .entity(sym('?e')).hasAttribute(kw(':person/age')).withValue(25)
112
- */
113
- withValue(value: QueryValue): QueryBuilder;
114
- /**
115
- * Add the attribute without a specific value constraint (will bind to a variable)
116
- * @example
117
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).bind()
118
- */
119
- bind(variable?: QueryVariable): QueryBuilder;
120
- private generateVariable;
121
- /**
122
- * Return to the main query builder
123
- */
124
- build(): QueryInput;
125
- }
126
- //# sourceMappingURL=query-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../src/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAiB,MAAM,UAAU,CAAC;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAGhD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,UAAU,CAAC;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,EAAE,CAAC,EAAE,UAAU,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,gBAAgB,CAAC;IACrE,QAAQ,EAAE,aAAa,CAAC;IACxB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAA6C;IAC/D,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,UAAU,CAAuB;IAEzC;;;;;OAKG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,aAAa,GAAG,iBAAiB,CAAC,EAAE,GAAG,IAAI;IAK1D;;;;OAIG;IACH,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,I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EG;AACH,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;gBAFT,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,OAAO;IAG5B;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY;IAK1C;;;;OAIG;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,aAAa,GAAG,YAAY;IAM5C,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,KAAK,IAAI,UAAU;CAGpB"}
@@ -1,207 +0,0 @@
1
- import { kw, sym } from './client';
2
- export class QueryBuilder {
3
- constructor() {
4
- this.findClause = [];
5
- this.whereClause = [];
6
- this.inClause = [];
7
- this.withClause = [];
8
- }
9
- /**
10
- * Add variables or aggregations to the :find clause
11
- * @example
12
- * .find(sym('?e'), sym('?name')) // Find entity and name
13
- * .find({ function: 'count', variable: sym('?e') }) // Count entities
14
- */
15
- find(...vars) {
16
- this.findClause.push(...vars);
17
- return this;
18
- }
19
- /**
20
- * Add a structured where clause
21
- * @example
22
- * .where({ entity: sym('?e'), attribute: kw(':person/name'), value: sym('?name') })
23
- */
24
- where(clause) {
25
- this.whereClause.push(clause);
26
- return this;
27
- }
28
- /**
29
- * Helper method to add entity-attribute-value pattern
30
- * @example
31
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).withValue(sym('?name'))
32
- */
33
- entity(entity) {
34
- return new EntityQueryBuilder(this, entity);
35
- }
36
- /**
37
- * Add input parameters to the :in clause
38
- * @example
39
- * .in(sym('$')) // Database input
40
- * .in(sym('?name')) // Parameter input
41
- */
42
- in(...inputs) {
43
- this.inClause.push(...inputs);
44
- return this;
45
- }
46
- /**
47
- * Add variables to the :with clause
48
- * @example
49
- * .with(sym('?tx')) // Include transaction in results
50
- */
51
- with(...variables) {
52
- this.withClause.push(...variables);
53
- return this;
54
- }
55
- /**
56
- * Helper for common patterns - find entities with attribute
57
- * @example
58
- * .findEntitiesWith(kw(':person/name')) // Find entities with any name
59
- * .findEntitiesWith(kw(':person/name'), sym('?name')) // Bind name to variable
60
- * .findEntitiesWith(kw(':person/name'), 'John') // Find entities named John
61
- */
62
- findEntitiesWith(attribute, value) {
63
- const entity = sym('?e');
64
- const valueToUse = value !== undefined ? value : sym('?value');
65
- // Only add value to find clause if it's a variable
66
- if (value === undefined || (typeof valueToUse === 'object' && valueToUse && valueToUse._type === 'symbol')) {
67
- this.find(entity, valueToUse);
68
- }
69
- else {
70
- this.find(entity);
71
- }
72
- this.where({ entity, attribute, value: valueToUse });
73
- return this;
74
- }
75
- /**
76
- * Helper for aggregation queries
77
- * @example
78
- * .count(sym('?e')) // Count entities
79
- * .sum(sym('?amount')) // Sum amounts
80
- */
81
- count(variable, alias) {
82
- return this.find({ function: 'count', variable, alias });
83
- }
84
- sum(variable, alias) {
85
- return this.find({ function: 'sum', variable, alias });
86
- }
87
- avg(variable, alias) {
88
- return this.find({ function: 'avg', variable, alias });
89
- }
90
- min(variable, alias) {
91
- return this.find({ function: 'min', variable, alias });
92
- }
93
- max(variable, alias) {
94
- return this.find({ function: 'max', variable, alias });
95
- }
96
- countDistinct(variable, alias) {
97
- return this.find({ function: 'count-distinct', variable, alias });
98
- }
99
- /**
100
- * Build the final query array with proper EDN types
101
- */
102
- build() {
103
- const query = [kw(":find")];
104
- // Add find clause
105
- this.findClause.forEach(item => {
106
- if (typeof item === 'object' && item && item._type === 'symbol') {
107
- query.push(item);
108
- }
109
- else {
110
- // Aggregation function
111
- const agg = item;
112
- // Build aggregation as a list: (count ?e)
113
- const aggList = [sym(agg.function), agg.variable];
114
- query.push(agg.alias || aggList);
115
- }
116
- });
117
- // Add in clause
118
- if (this.inClause.length > 0) {
119
- query.push(kw(":in"), ...this.inClause);
120
- }
121
- // Add with clause
122
- if (this.withClause.length > 0) {
123
- query.push(kw(":with"), ...this.withClause);
124
- }
125
- // Add where clause
126
- if (this.whereClause.length > 0) {
127
- query.push(kw(":where"));
128
- this.whereClause.forEach(clause => {
129
- // Convert QueryPattern to array format
130
- const clauseArray = [clause.entity, clause.attribute, clause.value];
131
- if (clause.tx)
132
- clauseArray.push(clause.tx);
133
- query.push(clauseArray);
134
- });
135
- }
136
- return query;
137
- }
138
- /**
139
- * Execute the query directly (requires database context)
140
- */
141
- async execute(db, ...args) {
142
- return db.query(this.build(), ...args);
143
- }
144
- }
145
- /**
146
- * Helper class for fluent entity-based query building
147
- */
148
- export class EntityQueryBuilder {
149
- constructor(queryBuilder, entity) {
150
- this.queryBuilder = queryBuilder;
151
- this.entity = entity;
152
- }
153
- /**
154
- * Add an attribute to the current entity
155
- * @example
156
- * .entity(sym('?e')).hasAttribute(kw(':person/name'))
157
- */
158
- hasAttribute(attribute) {
159
- return new AttributeQueryBuilder(this.queryBuilder, this.entity, attribute);
160
- }
161
- /**
162
- * Return to the main query builder
163
- */
164
- build() {
165
- return this.queryBuilder.build();
166
- }
167
- }
168
- /**
169
- * Helper class for fluent attribute-based query building
170
- */
171
- export class AttributeQueryBuilder {
172
- constructor(queryBuilder, entity, attribute) {
173
- this.queryBuilder = queryBuilder;
174
- this.entity = entity;
175
- this.attribute = attribute;
176
- }
177
- /**
178
- * Add a value constraint to the attribute
179
- * @example
180
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).withValue(sym('?name'))
181
- * .entity(sym('?e')).hasAttribute(kw(':person/age')).withValue(25)
182
- */
183
- withValue(value) {
184
- this.queryBuilder.where({ entity: this.entity, attribute: this.attribute, value });
185
- return this.queryBuilder;
186
- }
187
- /**
188
- * Add the attribute without a specific value constraint (will bind to a variable)
189
- * @example
190
- * .entity(sym('?e')).hasAttribute(kw(':person/name')).bind()
191
- */
192
- bind(variable) {
193
- const value = variable || this.generateVariable();
194
- this.queryBuilder.where({ entity: this.entity, attribute: this.attribute, value });
195
- return this.queryBuilder;
196
- }
197
- generateVariable() {
198
- const attrName = this.attribute.value.split('/').pop()?.replace(/[^a-zA-Z0-9]/g, '');
199
- return sym(`?${attrName}`);
200
- }
201
- /**
202
- * Return to the main query builder
203
- */
204
- build() {
205
- return this.queryBuilder.build();
206
- }
207
- }