@prisma-lossless/prisma-schema-wasm 0.0.0-stage → 7.10.1-lossless.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/README.md +50 -2
- package/package.json +15 -4
- package/src/prisma_schema_build.d.ts +105 -0
- package/src/prisma_schema_build.js +556 -0
- package/src/prisma_schema_build_bg.wasm +0 -0
- package/src/prisma_schema_build_bg.wasm.d.ts +30 -0
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @prisma/prisma-schema-wasm
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/prisma/prisma-engines/actions/workflows/publish-prisma-schema-wasm.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@prisma/prisma-schema-wasm)
|
|
5
|
+
[](https://packagephobia.com/result?p=@prisma/prisma-schema-wasm)
|
|
6
|
+
|
|
7
|
+
This directory only contains build logic to package the `prisma-fmt` engine
|
|
8
|
+
into a Node package as a Wasm module. All the functionality is implemented in
|
|
9
|
+
other parts of prisma-engines.
|
|
10
|
+
|
|
11
|
+
The published NPM package is internal to Prisma. Its API will break without prior warning.
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
node -e "const prismaSchema = require('@prisma/prisma-schema-wasm'); console.log(prismaSchema.version())"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Components
|
|
20
|
+
|
|
21
|
+
- The GitHub Actions workflow that publishes the NPM package: https://github.com/prisma/prisma-engines/blob/main/.github/workflows/publish-prisma-schema-wasm.yml
|
|
22
|
+
- It is triggered from the https://github.com/prisma/engines-wrapper publish action.
|
|
23
|
+
- The [Rust source code](https://github.com/prisma/prisma-engines/tree/main/prisma-schema-wasm/src) for the wasm module
|
|
24
|
+
- The [nix build definition](https://github.com/prisma/prisma-engines/blob/main/prisma-schema-wasm/default.nix)
|
|
25
|
+
- It gives us a fully reproducible, thoroughly described build process and environment. The alternative would be a bash script with installs through `rustup`, `cargo install` and `apt`, with underspecified system dependencies and best-effort version pinning.
|
|
26
|
+
- You can read more about nix on [nix.dev](https://nix.dev/) and the [official website](https://nixos.org/).
|
|
27
|
+
|
|
28
|
+
## Local Dev with Language-Tools
|
|
29
|
+
When implementing features for `language-tools` in `prisma-engines`, to sync with your local dev environment for the `language-server`, one can do the following:
|
|
30
|
+
|
|
31
|
+
### On first setup
|
|
32
|
+
```
|
|
33
|
+
# Install the latest Rust version with `rustup`
|
|
34
|
+
# or update the latest Rust version with `rustup`
|
|
35
|
+
rustup update
|
|
36
|
+
rustup target add wasm32-unknown-unknown
|
|
37
|
+
cargo update -p wasm-bindgen
|
|
38
|
+
# Check the version defined in `prisma-schema-wasm/cargo.toml` for `wasm-bindgen` and replace `version` below:
|
|
39
|
+
cargo install -f wasm-bindgen-cli@version
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### On Changes
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
./prisma-schema-wasm/scripts/update-schema-wasm.sh
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This script has the following expectations:
|
|
49
|
+
- `language-tools` is in the same dir as `prisma-engines`
|
|
50
|
+
- i.e. `dir/{prisma-engines,language-tools}`
|
|
51
|
+
- it's run in the `prisma-engines` root folder
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-lossless/prisma-schema-wasm",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "7.10.1-lossless.2",
|
|
4
|
+
"description": "The Wasm package for prisma-fmt",
|
|
5
|
+
"main": "src/prisma_schema_build.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/alexbaretta/prisma-engines",
|
|
12
|
+
"directory": "prisma-schema-wasm"
|
|
13
|
+
},
|
|
14
|
+
"author": "Prisma",
|
|
15
|
+
"license": "Apache-2.0",
|
|
16
|
+
"homepage": "https://github.com/alexbaretta/prisma-engines"
|
|
17
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export function format(schema: string, params: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Docs: https://prisma.github.io/prisma-engines/doc/prisma_fmt/fn.get_config.html
|
|
6
|
+
*/
|
|
7
|
+
export function get_config(params: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Docs: https://prisma.github.io/prisma-engines/doc/prisma_fmt/fn.get_dmmf.html
|
|
10
|
+
*/
|
|
11
|
+
export function get_dmmf(params: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* This API is modelled on an LSP [references
|
|
14
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#find-references-request-leftwards_arrow_with_hook).
|
|
15
|
+
* Input and output are both JSON, the request being a
|
|
16
|
+
* `CodeActionParams` object and the response being a list of
|
|
17
|
+
* `CodeActionOrCommand` objects.
|
|
18
|
+
*/
|
|
19
|
+
export function references(schema: string, params: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* This api is modelled on an LSP [hover request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#hover-request-leftwards_arrow_with_hook).
|
|
22
|
+
* Input and output are both JSON, the request being a `HoverParams` object
|
|
23
|
+
* and the response being a `Hover` object.
|
|
24
|
+
*/
|
|
25
|
+
export function hover(schema_files: string, params: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Serialize DMMF to a caller-owned buffer and return it as a handle.
|
|
28
|
+
* Use `DmmfBuffer.read_chunk()` to read portions as `Uint8Array`, then
|
|
29
|
+
* `DmmfBuffer.free()` (auto-provided by wasm-bindgen) to release WASM memory.
|
|
30
|
+
*
|
|
31
|
+
* This avoids implicit global state — each call returns an independent buffer.
|
|
32
|
+
*
|
|
33
|
+
* See: https://github.com/prisma/prisma/issues/29111
|
|
34
|
+
*/
|
|
35
|
+
export function get_dmmf_buffered(params: string): DmmfBuffer;
|
|
36
|
+
/**
|
|
37
|
+
* Trigger a panic inside the wasm module. This is only useful in development for testing panic
|
|
38
|
+
* handling.
|
|
39
|
+
*/
|
|
40
|
+
export function debug_panic(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the Prisma Lossless fork identity of this module as JSON.
|
|
43
|
+
*/
|
|
44
|
+
export function forkIdentity(): string;
|
|
45
|
+
export function get_datamodel(params: string): string;
|
|
46
|
+
export function lint(input: string): string;
|
|
47
|
+
export function validate(params: string): void;
|
|
48
|
+
export function merge_schemas(input: string): string;
|
|
49
|
+
export function native_types(input: string): string;
|
|
50
|
+
export function referential_actions(input: string): string;
|
|
51
|
+
export function preview_features(): string;
|
|
52
|
+
/**
|
|
53
|
+
* The API is modelled on an LSP [completion
|
|
54
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#completion-request-leftwards_arrow_with_hook).
|
|
55
|
+
* Input and output are both JSON, the request being a `CompletionParams` object and the response
|
|
56
|
+
* being a `CompletionList` object.
|
|
57
|
+
*/
|
|
58
|
+
export function text_document_completion(schema_files: string, params: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* This API is modelled on an LSP [code action
|
|
61
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#code-action-request-leftwards_arrow_with_hook).
|
|
62
|
+
* Input and output are both JSON, the request being a
|
|
63
|
+
* `CodeActionParams` object and the response being a list of
|
|
64
|
+
* `CodeActionOrCommand` objects.
|
|
65
|
+
*/
|
|
66
|
+
export function code_actions(schema: string, params: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Handle-based DMMF buffer that holds serialized DMMF JSON as bytes.
|
|
69
|
+
*
|
|
70
|
+
* This bypasses V8's string length limit (~536MB / 0x1fffffe8 chars) by keeping the
|
|
71
|
+
* serialized JSON as bytes in WASM linear memory. The JS side reads chunks as `Uint8Array`
|
|
72
|
+
* (which has no V8 string limit) and can reassemble them with a streaming JSON parser.
|
|
73
|
+
*
|
|
74
|
+
* Usage from JS:
|
|
75
|
+
* ```js
|
|
76
|
+
* const buffer = get_dmmf_buffered(params);
|
|
77
|
+
* const totalLen = buffer.len();
|
|
78
|
+
* const chunks = [];
|
|
79
|
+
* for (let offset = 0; offset < totalLen; offset += CHUNK_SIZE) {
|
|
80
|
+
* chunks.push(buffer.read_chunk(offset, CHUNK_SIZE));
|
|
81
|
+
* }
|
|
82
|
+
* buffer.free(); // release WASM memory
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* See: https://github.com/prisma/prisma/issues/29111
|
|
86
|
+
*/
|
|
87
|
+
export class DmmfBuffer {
|
|
88
|
+
private constructor();
|
|
89
|
+
free(): void;
|
|
90
|
+
[Symbol.dispose](): void;
|
|
91
|
+
/**
|
|
92
|
+
* Read a chunk of the buffer as `Uint8Array`.
|
|
93
|
+
* `offset` is the byte offset, `length` is the max number of bytes to read.
|
|
94
|
+
* Returns a `Vec<u8>` which wasm-bindgen converts to `Uint8Array` on the JS side.
|
|
95
|
+
*/
|
|
96
|
+
read_chunk(offset: number, length: number): Uint8Array;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the total byte length of the serialized DMMF JSON.
|
|
99
|
+
*/
|
|
100
|
+
len(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Returns `true` if the buffer is empty.
|
|
103
|
+
*/
|
|
104
|
+
is_empty(): boolean;
|
|
105
|
+
}
|
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
let cachedUint8ArrayMemory0 = null;
|
|
6
|
+
|
|
7
|
+
function getUint8ArrayMemory0() {
|
|
8
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
9
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
10
|
+
}
|
|
11
|
+
return cachedUint8ArrayMemory0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
15
|
+
|
|
16
|
+
cachedTextDecoder.decode();
|
|
17
|
+
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getStringFromWasm0(ptr, len) {
|
|
23
|
+
ptr = ptr >>> 0;
|
|
24
|
+
return decodeText(ptr, len);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let WASM_VECTOR_LEN = 0;
|
|
28
|
+
|
|
29
|
+
const cachedTextEncoder = new TextEncoder();
|
|
30
|
+
|
|
31
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
32
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
33
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
34
|
+
view.set(buf);
|
|
35
|
+
return {
|
|
36
|
+
read: arg.length,
|
|
37
|
+
written: buf.length
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
43
|
+
|
|
44
|
+
if (realloc === undefined) {
|
|
45
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
46
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
47
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
48
|
+
WASM_VECTOR_LEN = buf.length;
|
|
49
|
+
return ptr;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let len = arg.length;
|
|
53
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
54
|
+
|
|
55
|
+
const mem = getUint8ArrayMemory0();
|
|
56
|
+
|
|
57
|
+
let offset = 0;
|
|
58
|
+
|
|
59
|
+
for (; offset < len; offset++) {
|
|
60
|
+
const code = arg.charCodeAt(offset);
|
|
61
|
+
if (code > 0x7F) break;
|
|
62
|
+
mem[ptr + offset] = code;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (offset !== len) {
|
|
66
|
+
if (offset !== 0) {
|
|
67
|
+
arg = arg.slice(offset);
|
|
68
|
+
}
|
|
69
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
70
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
71
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
72
|
+
|
|
73
|
+
offset += ret.written;
|
|
74
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
WASM_VECTOR_LEN = offset;
|
|
78
|
+
return ptr;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} schema
|
|
82
|
+
* @param {string} params
|
|
83
|
+
* @returns {string}
|
|
84
|
+
*/
|
|
85
|
+
exports.format = function(schema, params) {
|
|
86
|
+
let deferred3_0;
|
|
87
|
+
let deferred3_1;
|
|
88
|
+
try {
|
|
89
|
+
const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
90
|
+
const len0 = WASM_VECTOR_LEN;
|
|
91
|
+
const ptr1 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
92
|
+
const len1 = WASM_VECTOR_LEN;
|
|
93
|
+
const ret = wasm.format(ptr0, len0, ptr1, len1);
|
|
94
|
+
deferred3_0 = ret[0];
|
|
95
|
+
deferred3_1 = ret[1];
|
|
96
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
97
|
+
} finally {
|
|
98
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Docs: https://prisma.github.io/prisma-engines/doc/prisma_fmt/fn.get_config.html
|
|
104
|
+
* @param {string} params
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
exports.get_config = function(params) {
|
|
108
|
+
let deferred2_0;
|
|
109
|
+
let deferred2_1;
|
|
110
|
+
try {
|
|
111
|
+
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
112
|
+
const len0 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.get_config(ptr0, len0);
|
|
114
|
+
deferred2_0 = ret[0];
|
|
115
|
+
deferred2_1 = ret[1];
|
|
116
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
117
|
+
} finally {
|
|
118
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
function takeFromExternrefTable0(idx) {
|
|
123
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
124
|
+
wasm.__externref_table_dealloc(idx);
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Docs: https://prisma.github.io/prisma-engines/doc/prisma_fmt/fn.get_dmmf.html
|
|
129
|
+
* @param {string} params
|
|
130
|
+
* @returns {string}
|
|
131
|
+
*/
|
|
132
|
+
exports.get_dmmf = function(params) {
|
|
133
|
+
let deferred3_0;
|
|
134
|
+
let deferred3_1;
|
|
135
|
+
try {
|
|
136
|
+
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
137
|
+
const len0 = WASM_VECTOR_LEN;
|
|
138
|
+
const ret = wasm.get_dmmf(ptr0, len0);
|
|
139
|
+
var ptr2 = ret[0];
|
|
140
|
+
var len2 = ret[1];
|
|
141
|
+
if (ret[3]) {
|
|
142
|
+
ptr2 = 0; len2 = 0;
|
|
143
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
144
|
+
}
|
|
145
|
+
deferred3_0 = ptr2;
|
|
146
|
+
deferred3_1 = len2;
|
|
147
|
+
return getStringFromWasm0(ptr2, len2);
|
|
148
|
+
} finally {
|
|
149
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* This API is modelled on an LSP [references
|
|
155
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#find-references-request-leftwards_arrow_with_hook).
|
|
156
|
+
* Input and output are both JSON, the request being a
|
|
157
|
+
* `CodeActionParams` object and the response being a list of
|
|
158
|
+
* `CodeActionOrCommand` objects.
|
|
159
|
+
* @param {string} schema
|
|
160
|
+
* @param {string} params
|
|
161
|
+
* @returns {string}
|
|
162
|
+
*/
|
|
163
|
+
exports.references = function(schema, params) {
|
|
164
|
+
let deferred3_0;
|
|
165
|
+
let deferred3_1;
|
|
166
|
+
try {
|
|
167
|
+
const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
168
|
+
const len0 = WASM_VECTOR_LEN;
|
|
169
|
+
const ptr1 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
const len1 = WASM_VECTOR_LEN;
|
|
171
|
+
const ret = wasm.references(ptr0, len0, ptr1, len1);
|
|
172
|
+
deferred3_0 = ret[0];
|
|
173
|
+
deferred3_1 = ret[1];
|
|
174
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
175
|
+
} finally {
|
|
176
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* This api is modelled on an LSP [hover request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#hover-request-leftwards_arrow_with_hook).
|
|
182
|
+
* Input and output are both JSON, the request being a `HoverParams` object
|
|
183
|
+
* and the response being a `Hover` object.
|
|
184
|
+
* @param {string} schema_files
|
|
185
|
+
* @param {string} params
|
|
186
|
+
* @returns {string}
|
|
187
|
+
*/
|
|
188
|
+
exports.hover = function(schema_files, params) {
|
|
189
|
+
let deferred3_0;
|
|
190
|
+
let deferred3_1;
|
|
191
|
+
try {
|
|
192
|
+
const ptr0 = passStringToWasm0(schema_files, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
193
|
+
const len0 = WASM_VECTOR_LEN;
|
|
194
|
+
const ptr1 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
const len1 = WASM_VECTOR_LEN;
|
|
196
|
+
const ret = wasm.hover(ptr0, len0, ptr1, len1);
|
|
197
|
+
deferred3_0 = ret[0];
|
|
198
|
+
deferred3_1 = ret[1];
|
|
199
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
200
|
+
} finally {
|
|
201
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Serialize DMMF to a caller-owned buffer and return it as a handle.
|
|
207
|
+
* Use `DmmfBuffer.read_chunk()` to read portions as `Uint8Array`, then
|
|
208
|
+
* `DmmfBuffer.free()` (auto-provided by wasm-bindgen) to release WASM memory.
|
|
209
|
+
*
|
|
210
|
+
* This avoids implicit global state — each call returns an independent buffer.
|
|
211
|
+
*
|
|
212
|
+
* See: https://github.com/prisma/prisma/issues/29111
|
|
213
|
+
* @param {string} params
|
|
214
|
+
* @returns {DmmfBuffer}
|
|
215
|
+
*/
|
|
216
|
+
exports.get_dmmf_buffered = function(params) {
|
|
217
|
+
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
218
|
+
const len0 = WASM_VECTOR_LEN;
|
|
219
|
+
const ret = wasm.get_dmmf_buffered(ptr0, len0);
|
|
220
|
+
if (ret[2]) {
|
|
221
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
222
|
+
}
|
|
223
|
+
return DmmfBuffer.__wrap(ret[0]);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Trigger a panic inside the wasm module. This is only useful in development for testing panic
|
|
228
|
+
* handling.
|
|
229
|
+
*/
|
|
230
|
+
exports.debug_panic = function() {
|
|
231
|
+
wasm.debug_panic();
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Returns the Prisma Lossless fork identity of this module as JSON.
|
|
236
|
+
* @returns {string}
|
|
237
|
+
*/
|
|
238
|
+
exports.forkIdentity = function() {
|
|
239
|
+
let deferred1_0;
|
|
240
|
+
let deferred1_1;
|
|
241
|
+
try {
|
|
242
|
+
const ret = wasm.forkIdentity();
|
|
243
|
+
deferred1_0 = ret[0];
|
|
244
|
+
deferred1_1 = ret[1];
|
|
245
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
246
|
+
} finally {
|
|
247
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param {string} params
|
|
253
|
+
* @returns {string}
|
|
254
|
+
*/
|
|
255
|
+
exports.get_datamodel = function(params) {
|
|
256
|
+
let deferred3_0;
|
|
257
|
+
let deferred3_1;
|
|
258
|
+
try {
|
|
259
|
+
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
260
|
+
const len0 = WASM_VECTOR_LEN;
|
|
261
|
+
const ret = wasm.get_datamodel(ptr0, len0);
|
|
262
|
+
var ptr2 = ret[0];
|
|
263
|
+
var len2 = ret[1];
|
|
264
|
+
if (ret[3]) {
|
|
265
|
+
ptr2 = 0; len2 = 0;
|
|
266
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
267
|
+
}
|
|
268
|
+
deferred3_0 = ptr2;
|
|
269
|
+
deferred3_1 = len2;
|
|
270
|
+
return getStringFromWasm0(ptr2, len2);
|
|
271
|
+
} finally {
|
|
272
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @param {string} input
|
|
278
|
+
* @returns {string}
|
|
279
|
+
*/
|
|
280
|
+
exports.lint = function(input) {
|
|
281
|
+
let deferred2_0;
|
|
282
|
+
let deferred2_1;
|
|
283
|
+
try {
|
|
284
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
285
|
+
const len0 = WASM_VECTOR_LEN;
|
|
286
|
+
const ret = wasm.lint(ptr0, len0);
|
|
287
|
+
deferred2_0 = ret[0];
|
|
288
|
+
deferred2_1 = ret[1];
|
|
289
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
290
|
+
} finally {
|
|
291
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {string} params
|
|
297
|
+
*/
|
|
298
|
+
exports.validate = function(params) {
|
|
299
|
+
const ptr0 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
300
|
+
const len0 = WASM_VECTOR_LEN;
|
|
301
|
+
const ret = wasm.validate(ptr0, len0);
|
|
302
|
+
if (ret[1]) {
|
|
303
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @param {string} input
|
|
309
|
+
* @returns {string}
|
|
310
|
+
*/
|
|
311
|
+
exports.merge_schemas = function(input) {
|
|
312
|
+
let deferred3_0;
|
|
313
|
+
let deferred3_1;
|
|
314
|
+
try {
|
|
315
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
316
|
+
const len0 = WASM_VECTOR_LEN;
|
|
317
|
+
const ret = wasm.merge_schemas(ptr0, len0);
|
|
318
|
+
var ptr2 = ret[0];
|
|
319
|
+
var len2 = ret[1];
|
|
320
|
+
if (ret[3]) {
|
|
321
|
+
ptr2 = 0; len2 = 0;
|
|
322
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
323
|
+
}
|
|
324
|
+
deferred3_0 = ptr2;
|
|
325
|
+
deferred3_1 = len2;
|
|
326
|
+
return getStringFromWasm0(ptr2, len2);
|
|
327
|
+
} finally {
|
|
328
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* @param {string} input
|
|
334
|
+
* @returns {string}
|
|
335
|
+
*/
|
|
336
|
+
exports.native_types = function(input) {
|
|
337
|
+
let deferred2_0;
|
|
338
|
+
let deferred2_1;
|
|
339
|
+
try {
|
|
340
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
342
|
+
const ret = wasm.native_types(ptr0, len0);
|
|
343
|
+
deferred2_0 = ret[0];
|
|
344
|
+
deferred2_1 = ret[1];
|
|
345
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
346
|
+
} finally {
|
|
347
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @param {string} input
|
|
353
|
+
* @returns {string}
|
|
354
|
+
*/
|
|
355
|
+
exports.referential_actions = function(input) {
|
|
356
|
+
let deferred2_0;
|
|
357
|
+
let deferred2_1;
|
|
358
|
+
try {
|
|
359
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
const len0 = WASM_VECTOR_LEN;
|
|
361
|
+
const ret = wasm.referential_actions(ptr0, len0);
|
|
362
|
+
deferred2_0 = ret[0];
|
|
363
|
+
deferred2_1 = ret[1];
|
|
364
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
365
|
+
} finally {
|
|
366
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
exports.preview_features = function() {
|
|
374
|
+
let deferred1_0;
|
|
375
|
+
let deferred1_1;
|
|
376
|
+
try {
|
|
377
|
+
const ret = wasm.preview_features();
|
|
378
|
+
deferred1_0 = ret[0];
|
|
379
|
+
deferred1_1 = ret[1];
|
|
380
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
381
|
+
} finally {
|
|
382
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The API is modelled on an LSP [completion
|
|
388
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#completion-request-leftwards_arrow_with_hook).
|
|
389
|
+
* Input and output are both JSON, the request being a `CompletionParams` object and the response
|
|
390
|
+
* being a `CompletionList` object.
|
|
391
|
+
* @param {string} schema_files
|
|
392
|
+
* @param {string} params
|
|
393
|
+
* @returns {string}
|
|
394
|
+
*/
|
|
395
|
+
exports.text_document_completion = function(schema_files, params) {
|
|
396
|
+
let deferred3_0;
|
|
397
|
+
let deferred3_1;
|
|
398
|
+
try {
|
|
399
|
+
const ptr0 = passStringToWasm0(schema_files, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
const ptr1 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
402
|
+
const len1 = WASM_VECTOR_LEN;
|
|
403
|
+
const ret = wasm.text_document_completion(ptr0, len0, ptr1, len1);
|
|
404
|
+
deferred3_0 = ret[0];
|
|
405
|
+
deferred3_1 = ret[1];
|
|
406
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
407
|
+
} finally {
|
|
408
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* This API is modelled on an LSP [code action
|
|
414
|
+
* request](https://github.com/microsoft/language-server-protocol/blob/gh-pages/_specifications/specification-3-16.md#code-action-request-leftwards_arrow_with_hook).
|
|
415
|
+
* Input and output are both JSON, the request being a
|
|
416
|
+
* `CodeActionParams` object and the response being a list of
|
|
417
|
+
* `CodeActionOrCommand` objects.
|
|
418
|
+
* @param {string} schema
|
|
419
|
+
* @param {string} params
|
|
420
|
+
* @returns {string}
|
|
421
|
+
*/
|
|
422
|
+
exports.code_actions = function(schema, params) {
|
|
423
|
+
let deferred3_0;
|
|
424
|
+
let deferred3_1;
|
|
425
|
+
try {
|
|
426
|
+
const ptr0 = passStringToWasm0(schema, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
427
|
+
const len0 = WASM_VECTOR_LEN;
|
|
428
|
+
const ptr1 = passStringToWasm0(params, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
429
|
+
const len1 = WASM_VECTOR_LEN;
|
|
430
|
+
const ret = wasm.code_actions(ptr0, len0, ptr1, len1);
|
|
431
|
+
deferred3_0 = ret[0];
|
|
432
|
+
deferred3_1 = ret[1];
|
|
433
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
434
|
+
} finally {
|
|
435
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
440
|
+
ptr = ptr >>> 0;
|
|
441
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
const DmmfBufferFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
445
|
+
? { register: () => {}, unregister: () => {} }
|
|
446
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_dmmfbuffer_free(ptr >>> 0, 1));
|
|
447
|
+
/**
|
|
448
|
+
* Handle-based DMMF buffer that holds serialized DMMF JSON as bytes.
|
|
449
|
+
*
|
|
450
|
+
* This bypasses V8's string length limit (~536MB / 0x1fffffe8 chars) by keeping the
|
|
451
|
+
* serialized JSON as bytes in WASM linear memory. The JS side reads chunks as `Uint8Array`
|
|
452
|
+
* (which has no V8 string limit) and can reassemble them with a streaming JSON parser.
|
|
453
|
+
*
|
|
454
|
+
* Usage from JS:
|
|
455
|
+
* ```js
|
|
456
|
+
* const buffer = get_dmmf_buffered(params);
|
|
457
|
+
* const totalLen = buffer.len();
|
|
458
|
+
* const chunks = [];
|
|
459
|
+
* for (let offset = 0; offset < totalLen; offset += CHUNK_SIZE) {
|
|
460
|
+
* chunks.push(buffer.read_chunk(offset, CHUNK_SIZE));
|
|
461
|
+
* }
|
|
462
|
+
* buffer.free(); // release WASM memory
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* See: https://github.com/prisma/prisma/issues/29111
|
|
466
|
+
*/
|
|
467
|
+
class DmmfBuffer {
|
|
468
|
+
|
|
469
|
+
static __wrap(ptr) {
|
|
470
|
+
ptr = ptr >>> 0;
|
|
471
|
+
const obj = Object.create(DmmfBuffer.prototype);
|
|
472
|
+
obj.__wbg_ptr = ptr;
|
|
473
|
+
DmmfBufferFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
474
|
+
return obj;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
__destroy_into_raw() {
|
|
478
|
+
const ptr = this.__wbg_ptr;
|
|
479
|
+
this.__wbg_ptr = 0;
|
|
480
|
+
DmmfBufferFinalization.unregister(this);
|
|
481
|
+
return ptr;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
free() {
|
|
485
|
+
const ptr = this.__destroy_into_raw();
|
|
486
|
+
wasm.__wbg_dmmfbuffer_free(ptr, 0);
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Read a chunk of the buffer as `Uint8Array`.
|
|
490
|
+
* `offset` is the byte offset, `length` is the max number of bytes to read.
|
|
491
|
+
* Returns a `Vec<u8>` which wasm-bindgen converts to `Uint8Array` on the JS side.
|
|
492
|
+
* @param {number} offset
|
|
493
|
+
* @param {number} length
|
|
494
|
+
* @returns {Uint8Array}
|
|
495
|
+
*/
|
|
496
|
+
read_chunk(offset, length) {
|
|
497
|
+
const ret = wasm.dmmfbuffer_read_chunk(this.__wbg_ptr, offset, length);
|
|
498
|
+
if (ret[3]) {
|
|
499
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
500
|
+
}
|
|
501
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
502
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
503
|
+
return v1;
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Returns the total byte length of the serialized DMMF JSON.
|
|
507
|
+
* @returns {number}
|
|
508
|
+
*/
|
|
509
|
+
len() {
|
|
510
|
+
const ret = wasm.dmmfbuffer_len(this.__wbg_ptr);
|
|
511
|
+
return ret >>> 0;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Returns `true` if the buffer is empty.
|
|
515
|
+
* @returns {boolean}
|
|
516
|
+
*/
|
|
517
|
+
is_empty() {
|
|
518
|
+
const ret = wasm.dmmfbuffer_is_empty(this.__wbg_ptr);
|
|
519
|
+
return ret !== 0;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (Symbol.dispose) DmmfBuffer.prototype[Symbol.dispose] = DmmfBuffer.prototype.free;
|
|
523
|
+
|
|
524
|
+
exports.DmmfBuffer = DmmfBuffer;
|
|
525
|
+
|
|
526
|
+
exports.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
|
|
527
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
528
|
+
return ret;
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
exports.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
|
|
532
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
exports.__wbg_set_message_f22ac4a6869ee695 = function(arg0, arg1) {
|
|
536
|
+
global.PRISMA_WASM_PANIC_REGISTRY.set_message(getStringFromWasm0(arg0, arg1));
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
exports.__wbindgen_init_externref_table = function() {
|
|
540
|
+
const table = wasm.__wbindgen_externrefs;
|
|
541
|
+
const offset = table.grow(4);
|
|
542
|
+
table.set(0, undefined);
|
|
543
|
+
table.set(offset + 0, undefined);
|
|
544
|
+
table.set(offset + 1, null);
|
|
545
|
+
table.set(offset + 2, true);
|
|
546
|
+
table.set(offset + 3, false);
|
|
547
|
+
;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
const wasmPath = `${__dirname}/prisma_schema_build_bg.wasm`;
|
|
551
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
552
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
553
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
554
|
+
|
|
555
|
+
wasm.__wbindgen_start();
|
|
556
|
+
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_dmmfbuffer_free: (a: number, b: number) => void;
|
|
5
|
+
export const code_actions: (a: number, b: number, c: number, d: number) => [number, number];
|
|
6
|
+
export const debug_panic: () => void;
|
|
7
|
+
export const dmmfbuffer_is_empty: (a: number) => number;
|
|
8
|
+
export const dmmfbuffer_len: (a: number) => number;
|
|
9
|
+
export const dmmfbuffer_read_chunk: (a: number, b: number, c: number) => [number, number, number, number];
|
|
10
|
+
export const forkIdentity: () => [number, number];
|
|
11
|
+
export const format: (a: number, b: number, c: number, d: number) => [number, number];
|
|
12
|
+
export const get_config: (a: number, b: number) => [number, number];
|
|
13
|
+
export const get_datamodel: (a: number, b: number) => [number, number, number, number];
|
|
14
|
+
export const get_dmmf: (a: number, b: number) => [number, number, number, number];
|
|
15
|
+
export const get_dmmf_buffered: (a: number, b: number) => [number, number, number];
|
|
16
|
+
export const hover: (a: number, b: number, c: number, d: number) => [number, number];
|
|
17
|
+
export const lint: (a: number, b: number) => [number, number];
|
|
18
|
+
export const merge_schemas: (a: number, b: number) => [number, number, number, number];
|
|
19
|
+
export const native_types: (a: number, b: number) => [number, number];
|
|
20
|
+
export const preview_features: () => [number, number];
|
|
21
|
+
export const references: (a: number, b: number, c: number, d: number) => [number, number];
|
|
22
|
+
export const referential_actions: (a: number, b: number) => [number, number];
|
|
23
|
+
export const text_document_completion: (a: number, b: number, c: number, d: number) => [number, number];
|
|
24
|
+
export const validate: (a: number, b: number) => [number, number];
|
|
25
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
26
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
27
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
29
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
30
|
+
export const __wbindgen_start: () => void;
|