@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.
- package/LICENSE +87 -0
- package/README.md +994 -0
- package/dist/analyze/cypher-check.d.ts +8 -0
- package/dist/analyze/diff.d.ts +32 -0
- package/dist/analyze/indexes.d.ts +61 -0
- package/dist/analyze/lint.d.ts +6 -0
- package/dist/analyze/plans.d.ts +31 -0
- package/dist/analyze/statistics.d.ts +19 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +631 -0
- package/dist/cli.js.map +1 -0
- package/dist/codegen.d.ts +32 -0
- package/dist/compile/aggregate.d.ts +17 -0
- package/dist/compile/auth.d.ts +46 -0
- package/dist/compile/context.d.ts +43 -0
- package/dist/compile/cursor.d.ts +4 -0
- package/dist/compile/cypher.d.ts +175 -0
- package/dist/compile/filter.d.ts +19 -0
- package/dist/compile/hmac.d.ts +4 -0
- package/dist/compile/read.d.ts +89 -0
- package/dist/compile/selection.d.ts +18 -0
- package/dist/diff-BVP1Jzh3.js +99 -0
- package/dist/diff-BVP1Jzh3.js.map +1 -0
- package/dist/driver-C8vA5fV-.js +9127 -0
- package/dist/driver-C8vA5fV-.js.map +1 -0
- package/dist/driver.d.ts +117 -0
- package/dist/errors.d.ts +20 -0
- package/dist/execute/changes.d.ts +61 -0
- package/dist/execute/cypher-mutation.d.ts +4 -0
- package/dist/execute/feed.d.ts +10 -0
- package/dist/execute/mutate.d.ts +57 -0
- package/dist/execute/transaction.d.ts +17 -0
- package/dist/guards.d.ts +42 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/lora-graphql.d.ts +291 -0
- package/dist/migrate.d.ts +8 -0
- package/dist/model/build.d.ts +25 -0
- package/dist/model/cypher-lexer.d.ts +10 -0
- package/dist/model/directives.d.ts +3 -0
- package/dist/model/points.d.ts +12 -0
- package/dist/model/relations.d.ts +7 -0
- package/dist/model/types.d.ts +311 -0
- package/dist/observe.d.ts +72 -0
- package/dist/schema/build.d.ts +38 -0
- package/dist/schema/global-id.d.ts +6 -0
- package/dist/schema/guard.d.ts +5 -0
- package/dist/schema/mutations.d.ts +44 -0
- package/dist/schema/names.d.ts +37 -0
- package/dist/schema/scalars.d.ts +9 -0
- package/dist/testing.d.ts +36 -0
- package/dist/testing.js +56 -0
- package/dist/testing.js.map +1 -0
- package/package.json +85 -0
package/dist/testing.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { graphql as h } from "graphql";
|
|
2
|
+
import { L as w, l as u } from "./driver-C8vA5fV-.js";
|
|
3
|
+
async function L(l) {
|
|
4
|
+
let s;
|
|
5
|
+
try {
|
|
6
|
+
({ createDatabase: s } = await import("@loradb/lora-node"));
|
|
7
|
+
} catch {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"createTestLoraGraphQL needs @loradb/lora-node: npm install --save-dev @loradb/lora-node"
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
const t = await s(), n = [], { seed: a, onStatement: i, ...c } = l, r = new w({
|
|
13
|
+
...c,
|
|
14
|
+
driver: u(t),
|
|
15
|
+
onStatement: (e) => {
|
|
16
|
+
n.push(e), i?.(e);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (await r.assertSchema({ create: !0 }), typeof a == "function") await a(t);
|
|
20
|
+
else
|
|
21
|
+
for (const e of typeof a == "string" ? [a] : a ?? [])
|
|
22
|
+
await t.execute(e);
|
|
23
|
+
const o = r.getSchema(), m = (e, p = {}, d = {}) => h({ schema: o, source: e, variableValues: p, contextValue: d });
|
|
24
|
+
return {
|
|
25
|
+
lora: r,
|
|
26
|
+
db: t,
|
|
27
|
+
schema: o,
|
|
28
|
+
statements: n,
|
|
29
|
+
run: m,
|
|
30
|
+
data: async (e, p, d) => {
|
|
31
|
+
const f = await m(e, p, d);
|
|
32
|
+
if (f.errors) throw f.errors[0];
|
|
33
|
+
return f.data;
|
|
34
|
+
},
|
|
35
|
+
close: () => t.dispose?.()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async function b(l, s, t = {}, n = {}) {
|
|
39
|
+
const i = (await l.explain(s, t, n)).flatMap(
|
|
40
|
+
(c) => c.reports.flatMap(
|
|
41
|
+
(r) => r.findings.map((o) => `${c.field}: ${o.message}
|
|
42
|
+
${o.statement}`)
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
if (i.length > 0)
|
|
46
|
+
throw new Error(
|
|
47
|
+
`expected every root field to seek:
|
|
48
|
+
${i.join(`
|
|
49
|
+
`)}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
L as createTestLoraGraphQL,
|
|
54
|
+
b as expectSeeks
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sources":["../src/testing.ts"],"sourcesContent":["// Test helpers: an in-memory LoraDB with the schema asserted, and a plan\n// assertion. Import from `@loradb/lora-graphql/testing`; needs\n// `@loradb/lora-node`. Framework-agnostic: failures throw plain errors.\n\nimport {\n graphql,\n type DocumentNode,\n type ExecutionResult,\n type GraphQLSchema,\n} from \"graphql\";\nimport { loraDriver, type LoraDatabaseLike } from \"./driver.js\";\nimport {\n LoraGraphQL,\n type LoraGraphQLOptions,\n type StatementEvent,\n} from \"./lora-graphql.js\";\n\n/** The node binding's database, as far as tests use it. */\nexport type TestDatabase = LoraDatabaseLike & {\n execute(query: string, params?: never): Promise<unknown>;\n dispose?(): void;\n};\n\nexport interface TestLoraGraphQLOptions extends Omit<\n LoraGraphQLOptions,\n \"driver\"\n> {\n /** Cypher to run after the schema is asserted, or a function given the database. */\n seed?: string | string[] | ((db: TestDatabase) => Promise<void>);\n}\n\nexport interface TestLoraGraphQL {\n lora: LoraGraphQL;\n db: TestDatabase;\n schema: GraphQLSchema;\n /** Every statement run so far (clear with `statements.length = 0`). */\n statements: StatementEvent[];\n /** Execute a document; errors stay in the result. */\n run: (\n source: string,\n variables?: Record<string, unknown>,\n context?: Record<string, unknown>,\n ) => Promise<ExecutionResult>;\n /** Execute a document and return its data; throws on the first error. */\n data: <T = Record<string, unknown>>(\n source: string,\n variables?: Record<string, unknown>,\n context?: Record<string, unknown>,\n ) => Promise<T>;\n /** Release the database. */\n close: () => void;\n}\n\n/** A LoraGraphQL over a fresh in-memory database, schema asserted and seeded. */\nexport async function createTestLoraGraphQL(\n options: TestLoraGraphQLOptions,\n): Promise<TestLoraGraphQL> {\n let createDatabase: () => Promise<TestDatabase>;\n try {\n ({ createDatabase } = (await import(\"@loradb/lora-node\")) as unknown as {\n createDatabase: typeof createDatabase;\n });\n } catch {\n throw new Error(\n \"createTestLoraGraphQL needs @loradb/lora-node: npm install --save-dev @loradb/lora-node\",\n );\n }\n const db = await createDatabase();\n const statements: StatementEvent[] = [];\n const { seed, onStatement, ...rest } = options;\n const lora = new LoraGraphQL({\n ...rest,\n driver: loraDriver(db),\n onStatement: (event) => {\n statements.push(event);\n onStatement?.(event);\n },\n });\n await lora.assertSchema({ create: true });\n if (typeof seed === \"function\") await seed(db);\n else {\n for (const text of typeof seed === \"string\" ? [seed] : (seed ?? [])) {\n await db.execute(text);\n }\n }\n const schema = lora.getSchema();\n const run = (\n source: string,\n variables: Record<string, unknown> = {},\n contextValue: Record<string, unknown> = {},\n ) => graphql({ schema, source, variableValues: variables, contextValue });\n return {\n lora,\n db,\n schema,\n statements,\n run,\n data: async <T>(\n source: string,\n variables?: Record<string, unknown>,\n context?: Record<string, unknown>,\n ) => {\n const r = await run(source, variables, context);\n if (r.errors) throw r.errors[0];\n return r.data as T;\n },\n close: () => db.dispose?.(),\n };\n}\n\n/**\n * Assert that every statement of a query's root fields uses the index\n * access it was compiled for (no label scans where a seek was expected,\n * no mutating plans, no row-budget excess). Throws listing each finding.\n */\nexport async function expectSeeks(\n lora: LoraGraphQL,\n document: string | DocumentNode,\n variables: Record<string, unknown> = {},\n options: { rowBudget?: number; context?: unknown } = {},\n): Promise<void> {\n const fields = await lora.explain(document, variables, options);\n const findings = fields.flatMap((f) =>\n f.reports.flatMap((r) =>\n r.findings.map((x) => `${f.field}: ${x.message}\\n ${x.statement}`),\n ),\n );\n if (findings.length > 0) {\n throw new Error(\n `expected every root field to seek:\\n${findings.join(\"\\n\")}`,\n );\n }\n}\n"],"names":["createTestLoraGraphQL","options","createDatabase","db","statements","seed","onStatement","rest","lora","LoraGraphQL","loraDriver","event","text","schema","run","source","variables","contextValue","graphql","context","r","expectSeeks","document","findings","f","x"],"mappings":";;AAsDA,eAAsBA,EACpBC,GAC0B;AAC1B,MAAIC;AACJ,MAAI;AACF,KAAC,EAAE,gBAAAA,EAAA,IAAoB,MAAM,OAAO,mBAAmB;AAAA,EAGzD,QAAQ;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAAA,EAEJ;AACA,QAAMC,IAAK,MAAMD,EAAA,GACXE,IAA+B,CAAA,GAC/B,EAAE,MAAAC,GAAM,aAAAC,GAAa,GAAGC,MAASN,GACjCO,IAAO,IAAIC,EAAY;AAAA,IAC3B,GAAGF;AAAA,IACH,QAAQG,EAAWP,CAAE;AAAA,IACrB,aAAa,CAACQ,MAAU;AACtB,MAAAP,EAAW,KAAKO,CAAK,GACrBL,IAAcK,CAAK;AAAA,IACrB;AAAA,EAAA,CACD;AAED,MADA,MAAMH,EAAK,aAAa,EAAE,QAAQ,IAAM,GACpC,OAAOH,KAAS,WAAY,OAAMA,EAAKF,CAAE;AAAA;AAE3C,eAAWS,KAAQ,OAAOP,KAAS,WAAW,CAACA,CAAI,IAAKA,KAAQ;AAC9D,YAAMF,EAAG,QAAQS,CAAI;AAGzB,QAAMC,IAASL,EAAK,UAAA,GACdM,IAAM,CACVC,GACAC,IAAqC,CAAA,GACrCC,IAAwC,CAAA,MACrCC,EAAQ,EAAE,QAAAL,GAAQ,QAAAE,GAAQ,gBAAgBC,GAAW,cAAAC,GAAc;AACxE,SAAO;AAAA,IACL,MAAAT;AAAA,IACA,IAAAL;AAAA,IACA,QAAAU;AAAA,IACA,YAAAT;AAAA,IACA,KAAAU;AAAA,IACA,MAAM,OACJC,GACAC,GACAG,MACG;AACH,YAAMC,IAAI,MAAMN,EAAIC,GAAQC,GAAWG,CAAO;AAC9C,UAAIC,EAAE,OAAQ,OAAMA,EAAE,OAAO,CAAC;AAC9B,aAAOA,EAAE;AAAA,IACX;AAAA,IACA,OAAO,MAAMjB,EAAG,UAAA;AAAA,EAAU;AAE9B;AAOA,eAAsBkB,EACpBb,GACAc,GACAN,IAAqC,CAAA,GACrCf,IAAqD,IACtC;AAEf,QAAMsB,KADS,MAAMf,EAAK,QAAQc,GAAUN,GAAWf,CAAO,GACtC;AAAA,IAAQ,CAACuB,MAC/BA,EAAE,QAAQ;AAAA,MAAQ,CAAC,MACjB,EAAE,SAAS,IAAI,CAACC,MAAM,GAAGD,EAAE,KAAK,KAAKC,EAAE,OAAO;AAAA,IAAOA,EAAE,SAAS,EAAE;AAAA,IAAA;AAAA,EACpE;AAEF,MAAIF,EAAS,SAAS;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,EAAuCA,EAAS,KAAK;AAAA,CAAI,CAAC;AAAA,IAAA;AAGhE;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loradb/lora-graphql",
|
|
3
|
+
"version": "0.16.2",
|
|
4
|
+
"description": "Schema-first GraphQL for LoraDB: one annotated SDL becomes an executable, index-aware GraphQL API that compiles every operation to a single Cypher statement.",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"packageManager": "yarn@4.5.1",
|
|
7
|
+
"author": "LoraDB, Inc.",
|
|
8
|
+
"homepage": "https://github.com/lora-db/lora/tree/main/packages/lora-graphql#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/lora-db/lora.git",
|
|
12
|
+
"directory": "packages/lora-graphql"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/lora-db/lora/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"lora",
|
|
19
|
+
"loradb",
|
|
20
|
+
"graphql",
|
|
21
|
+
"cypher",
|
|
22
|
+
"graph",
|
|
23
|
+
"database"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "dist/index.js",
|
|
27
|
+
"module": "dist/index.js",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./testing": {
|
|
36
|
+
"types": "./dist/testing.d.ts",
|
|
37
|
+
"import": "./dist/testing.js",
|
|
38
|
+
"default": "./dist/testing.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"bin": "./dist/cli.js",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist/",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE"
|
|
46
|
+
],
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"registry": "https://registry.npmjs.org/"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "vite build",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest",
|
|
59
|
+
"lint": "eslint src test bench",
|
|
60
|
+
"lint:fix": "eslint src test bench --fix",
|
|
61
|
+
"format": "prettier --write src test",
|
|
62
|
+
"format:check": "prettier --check src test",
|
|
63
|
+
"bench": "vitest bench --run"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"@loradb/lora-node": "^0.16.2",
|
|
67
|
+
"graphql": "^16.8.0 || ^17.0.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@loradb/lora-node": "workspace:*",
|
|
71
|
+
"@types/node": "^22.0.0",
|
|
72
|
+
"eslint": "^9.15.0",
|
|
73
|
+
"fast-check": "^4.10.2",
|
|
74
|
+
"graphql": "^16.9.0",
|
|
75
|
+
"typescript": "^5.6.0",
|
|
76
|
+
"vite": "^5.4.0",
|
|
77
|
+
"vite-plugin-dts": "^4.2.0",
|
|
78
|
+
"vitest": "^2.1.0"
|
|
79
|
+
},
|
|
80
|
+
"peerDependenciesMeta": {
|
|
81
|
+
"@loradb/lora-node": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|