@teamkeel/wasm 0.251.1 → 0.253.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.
package/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  export function format(schema: string): Promise<string>;
2
2
 
3
- export function validate(schemaString: string): Promise<ValidationResult>;
3
+ export function validate(
4
+ schemaString: string,
5
+ configFile: string
6
+ ): Promise<ValidationResult>;
4
7
 
5
8
  export function completions(
6
9
  schemaString: string,
7
- position: SimplePosition
10
+ position: SimplePosition,
11
+ configFile: string
8
12
  ): Promise<CompletionResult>;
9
13
 
10
14
  export interface SimplePosition {
package/index.test.ts CHANGED
@@ -1,6 +1,22 @@
1
1
  import { format, validate, completions } from "./index";
2
2
  import { test, expect } from "vitest";
3
3
 
4
+ const configFile = `
5
+ environment:
6
+ default:
7
+ - name: "TEST"
8
+ value: "test"
9
+
10
+ staging:
11
+ - name: "TEST2"
12
+ value: "test2"
13
+
14
+ secrets:
15
+ - name: API_KEY
16
+ required:
17
+ - "production"
18
+ `;
19
+
4
20
  test("format", async () => {
5
21
  const schema = `model Person { fields { name Text } }`;
6
22
  const formatted = await format(schema);
@@ -24,10 +40,14 @@ test("completions", async () => {
24
40
  name Te
25
41
  }
26
42
  }`;
27
- const result = await completions(schema, {
28
- line: 3,
29
- column: 16,
30
- });
43
+ const result = await completions(
44
+ schema,
45
+ {
46
+ line: 3,
47
+ column: 16,
48
+ },
49
+ configFile
50
+ );
31
51
 
32
52
  expect(result.completions.map((x) => x.label)).toContain("Text");
33
53
  });
@@ -38,7 +58,7 @@ test("validate", async () => {
38
58
  name Foo
39
59
  }
40
60
  }`;
41
- const { errors } = await validate(schema);
61
+ const { errors } = await validate(schema, configFile);
42
62
 
43
63
  expect(errors[0].message).toEqual("field name has an unsupported type Foo");
44
64
  });
@@ -46,7 +66,7 @@ test("validate", async () => {
46
66
  test("validate - invalid schema", async () => {
47
67
  const schema = `model Person {
48
68
  fields {`;
49
- const { errors } = await validate(schema);
69
+ const { errors } = await validate(schema, configFile);
50
70
 
51
71
  expect(errors[0].code).toEqual("E025");
52
72
  expect(errors[0].message).toEqual(` unexpected token "<EOF>" (expected "}")`);
package/lib/main.go CHANGED
@@ -6,6 +6,7 @@ import (
6
6
  "encoding/json"
7
7
  "syscall/js"
8
8
 
9
+ "github.com/teamkeel/keel/config"
9
10
  "github.com/teamkeel/keel/schema"
10
11
  "github.com/teamkeel/keel/schema/completions"
11
12
  "github.com/teamkeel/keel/schema/format"
@@ -83,7 +84,7 @@ func provideCompletions(this js.Value, args []js.Value) any {
83
84
  completions := completions.Completions(args[0].String(), &node.Position{
84
85
  Column: column,
85
86
  Line: line,
86
- })
87
+ }, args[2].String())
87
88
 
88
89
  untypedCompletions := toUntypedArray(completions)
89
90
 
@@ -121,6 +122,14 @@ func validate(this js.Value, args []js.Value) any {
121
122
 
122
123
  builder := schema.Builder{}
123
124
 
125
+ if args[1].Truthy() {
126
+ config, err := config.LoadFromBytes([]byte(args[1].String()))
127
+ if err != nil {
128
+ return nil, err
129
+ }
130
+ builder.Config = config
131
+ }
132
+
124
133
  _, err := builder.MakeFromInputs(&reader.Inputs{
125
134
  SchemaFiles: []reader.SchemaFile{schemaFile},
126
135
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/wasm",
3
- "version": "0.251.1",
3
+ "version": "0.253.0",
4
4
  "description": "A wrapper around the Keel WASM binary",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",