@loradb/lora-graphql 0.16.2

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 (55) hide show
  1. package/LICENSE +87 -0
  2. package/README.md +994 -0
  3. package/dist/analyze/cypher-check.d.ts +8 -0
  4. package/dist/analyze/diff.d.ts +32 -0
  5. package/dist/analyze/indexes.d.ts +61 -0
  6. package/dist/analyze/lint.d.ts +6 -0
  7. package/dist/analyze/plans.d.ts +31 -0
  8. package/dist/analyze/statistics.d.ts +19 -0
  9. package/dist/cli.d.ts +6 -0
  10. package/dist/cli.js +631 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/codegen.d.ts +32 -0
  13. package/dist/compile/aggregate.d.ts +17 -0
  14. package/dist/compile/auth.d.ts +46 -0
  15. package/dist/compile/context.d.ts +43 -0
  16. package/dist/compile/cursor.d.ts +4 -0
  17. package/dist/compile/cypher.d.ts +175 -0
  18. package/dist/compile/filter.d.ts +19 -0
  19. package/dist/compile/hmac.d.ts +4 -0
  20. package/dist/compile/read.d.ts +89 -0
  21. package/dist/compile/selection.d.ts +18 -0
  22. package/dist/diff-BVP1Jzh3.js +99 -0
  23. package/dist/diff-BVP1Jzh3.js.map +1 -0
  24. package/dist/driver-C8vA5fV-.js +9127 -0
  25. package/dist/driver-C8vA5fV-.js.map +1 -0
  26. package/dist/driver.d.ts +117 -0
  27. package/dist/errors.d.ts +20 -0
  28. package/dist/execute/changes.d.ts +61 -0
  29. package/dist/execute/cypher-mutation.d.ts +4 -0
  30. package/dist/execute/feed.d.ts +10 -0
  31. package/dist/execute/mutate.d.ts +57 -0
  32. package/dist/execute/transaction.d.ts +17 -0
  33. package/dist/guards.d.ts +42 -0
  34. package/dist/index.d.ts +21 -0
  35. package/dist/index.js +24 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/lora-graphql.d.ts +291 -0
  38. package/dist/migrate.d.ts +8 -0
  39. package/dist/model/build.d.ts +25 -0
  40. package/dist/model/cypher-lexer.d.ts +10 -0
  41. package/dist/model/directives.d.ts +3 -0
  42. package/dist/model/points.d.ts +12 -0
  43. package/dist/model/relations.d.ts +7 -0
  44. package/dist/model/types.d.ts +311 -0
  45. package/dist/observe.d.ts +72 -0
  46. package/dist/schema/build.d.ts +38 -0
  47. package/dist/schema/global-id.d.ts +6 -0
  48. package/dist/schema/guard.d.ts +5 -0
  49. package/dist/schema/mutations.d.ts +44 -0
  50. package/dist/schema/names.d.ts +37 -0
  51. package/dist/schema/scalars.d.ts +9 -0
  52. package/dist/testing.d.ts +36 -0
  53. package/dist/testing.js +56 -0
  54. package/dist/testing.js.map +1 -0
  55. package/package.json +85 -0
@@ -0,0 +1,8 @@
1
+ import { LoraDriver } from '../driver.js';
2
+ import { GraphModel } from '../model/types.js';
3
+ export interface CypherFinding {
4
+ type: string;
5
+ field: string;
6
+ message: string;
7
+ }
8
+ export declare function checkCypherFields(driver: LoraDriver, model: GraphModel): Promise<CypherFinding[]>;
@@ -0,0 +1,32 @@
1
+ import { DocumentNode } from 'graphql';
2
+ import { ModelOptions } from '../model/build.js';
3
+ import { SchemaRequirement } from './indexes.js';
4
+ export interface ApiChange {
5
+ /** graphql-js change type, e.g. `FIELD_REMOVED`. */
6
+ type: string;
7
+ description: string;
8
+ }
9
+ export interface SchemaDiff {
10
+ database: {
11
+ create: SchemaRequirement[];
12
+ drop: SchemaRequirement[];
13
+ /**
14
+ * Statements in the order to run them. Drops and data migrations are
15
+ * destructive: review them before running.
16
+ */
17
+ statements: Array<{
18
+ text: string;
19
+ destructive: boolean;
20
+ reason: string;
21
+ }>;
22
+ };
23
+ api: {
24
+ /** Changes that break existing clients. */
25
+ breaking: ApiChange[];
26
+ /** Changes that may change behaviour for existing clients. */
27
+ dangerous: ApiChange[];
28
+ };
29
+ /** Consequences worth a human look, e.g. a rename kept by @alias. */
30
+ notes: string[];
31
+ }
32
+ export declare function diffSchemas(before: string | DocumentNode, after: string | DocumentNode, options?: ModelOptions): SchemaDiff;
@@ -0,0 +1,61 @@
1
+ import { GraphModel, IndexKind, ScalarType } from '../model/types.js';
2
+ export type SchemaRequirement = {
3
+ kind: "constraint";
4
+ constraint: "NODE_KEY" | "UNIQUE" | "NOT_NULL";
5
+ name: string;
6
+ label: string;
7
+ property: string;
8
+ /** Why the library needs it, e.g. `Festival.key is the @key`. */
9
+ reason: string;
10
+ } | {
11
+ kind: "index";
12
+ index: IndexKind;
13
+ name: string;
14
+ label: string;
15
+ property: string;
16
+ reason: string;
17
+ } | {
18
+ /** Queried by name, so matched by name. */
19
+ kind: "fulltext";
20
+ name: string;
21
+ label: string;
22
+ properties: string[];
23
+ analyzer: "STANDARD" | "SIMPLE";
24
+ reason: string;
25
+ } | {
26
+ /** Queried by name, so matched by name. */
27
+ kind: "vector";
28
+ name: string;
29
+ label: string;
30
+ property: string;
31
+ dimensions: number;
32
+ similarity: "COSINE" | "EUCLIDEAN";
33
+ reason: string;
34
+ };
35
+ /**
36
+ * Types a RANGE index must not be inferred for. LoraDB keeps durations out
37
+ * of its sorted index (they have no total order); other temporals are
38
+ * indexed by the instant they denote (E17).
39
+ */
40
+ export declare const RANGE_UNINDEXABLE: Set<ScalarType>;
41
+ /**
42
+ * Derive every constraint and index the model's API needs.
43
+ *
44
+ * - `@key` → node key constraint (unique + present); it also serves
45
+ * exact-match, range and ordered scans, so no extra index.
46
+ * - `@unique` → uniqueness constraint (backed by a RANGE index).
47
+ * - `@sortable` on a non-null field → existence constraint: keyset
48
+ * pagination may then bound the scan with `>=` without losing nulls.
49
+ * - `EQ` / `IN` → nothing: LoraDB builds exact-match indexes lazily.
50
+ * - `LT` / `LTE` / `GT` / `GTE` or `@sortable` → RANGE.
51
+ * - `CONTAINS` / `STARTS_WITH` / `ENDS_WITH` → TEXT.
52
+ * - `WITHIN_BBOX` / `DISTANCE` on a Point → POINT.
53
+ * - `@index(kind:)` → that index.
54
+ */
55
+ export declare function inferRequirements(model: GraphModel): SchemaRequirement[];
56
+ /** A stable identity: equal ids need no change between two models. */
57
+ export declare function requirementId(r: SchemaRequirement): string;
58
+ /** One line for humans, e.g. `RANGE index on :Festival(name)`. */
59
+ export declare function describeRequirement(r: SchemaRequirement): string;
60
+ /** The DDL statement that creates a requirement, idempotently. */
61
+ export declare function requirementDdl(r: SchemaRequirement): string;
@@ -0,0 +1,6 @@
1
+ import { GraphModel, ModelWarning } from '../model/types.js';
2
+ export interface LintOptions {
3
+ /** Statistics are loaded: relationship degrees are known. */
4
+ statistics?: boolean;
5
+ }
6
+ export declare function lintModel(model: GraphModel, options?: LintOptions): ModelWarning[];
@@ -0,0 +1,31 @@
1
+ import { LoraDriver, QueryPlan, Statement } from '../driver.js';
2
+ import { CompiledRead } from '../compile/read.js';
3
+ export interface PlanFinding {
4
+ rule: "full-scan" | "mutating-read" | "result-columns" | "scan-expand" | "row-budget";
5
+ message: string;
6
+ statement: string;
7
+ }
8
+ export interface PlanReport {
9
+ statement: Statement;
10
+ plan: QueryPlan;
11
+ /** Operator names from root to leaves, depth first. */
12
+ operators: string[];
13
+ /**
14
+ * The engine's largest row estimate among the statement's scans and
15
+ * seeks (from graph statistics), or null when it has none. A scan that
16
+ * streams in index order under a LIMIT reads fewer rows than this.
17
+ */
18
+ estimatedRows: number | null;
19
+ findings: PlanFinding[];
20
+ }
21
+ export declare function checkPlans(driver: LoraDriver, compiled: CompiledRead, options?: {
22
+ rowBudget?: number;
23
+ }): Promise<PlanReport[]>;
24
+ /**
25
+ * Expansions that start from a full scan: an `Expand` whose source is a
26
+ * `NodeByLabelScan`, or a `NodeScan` with nothing below it that binds the
27
+ * node. A key test in the same pattern as the expansion plans this way,
28
+ * and the statement then walks every relationship of the type. Statements
29
+ * that start from keys (every mutation statement) must have none.
30
+ */
31
+ export declare function scanExpands(statement: Statement, plan: QueryPlan): PlanFinding[];
@@ -0,0 +1,19 @@
1
+ import { LoraDriver } from '../driver.js';
2
+ import { GraphModel } from '../model/types.js';
3
+ export interface DegreeStats {
4
+ sampled: number;
5
+ mean: number;
6
+ median: number;
7
+ p99: number;
8
+ max: number;
9
+ }
10
+ export interface Statistics {
11
+ /** Node count per @node type. */
12
+ nodes: Record<string, number>;
13
+ /** Degree per list relationship, keyed `Type.field`. */
14
+ degrees: Record<string, DegreeStats>;
15
+ }
16
+ export declare function analyze(driver: LoraDriver, model: GraphModel, options?: {
17
+ sample?: number;
18
+ timeoutMs?: number;
19
+ }): Promise<Statistics>;
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ interface Io {
2
+ out: (line: string) => void;
3
+ err: (line: string) => void;
4
+ }
5
+ export declare function main(argv: string[], io?: Io): Promise<number>;
6
+ export {};