cloesce 0.0.5-unstable.1 → 0.0.5-unstable.11
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/dist/ast.d.ts +96 -106
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +12 -12
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +330 -368
- package/dist/common.d.ts +23 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +78 -0
- package/dist/extractor/err.d.ts +25 -26
- package/dist/extractor/err.d.ts.map +1 -1
- package/dist/extractor/err.js +95 -129
- package/dist/extractor/extract.d.ts +24 -61
- package/dist/extractor/extract.d.ts.map +1 -1
- package/dist/extractor/extract.js +1006 -836
- package/dist/generator.wasm +0 -0
- package/dist/orm.wasm +0 -0
- package/dist/router/crud.d.ts +2 -3
- package/dist/router/crud.d.ts.map +1 -1
- package/dist/router/crud.js +58 -48
- package/dist/router/orm.d.ts +66 -0
- package/dist/router/orm.d.ts.map +1 -0
- package/dist/router/orm.js +447 -0
- package/dist/router/router.d.ts +93 -139
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +389 -432
- package/dist/router/validator.d.ts +7 -12
- package/dist/router/validator.d.ts.map +1 -1
- package/dist/router/validator.js +190 -159
- package/dist/router/wasm.d.ts +26 -67
- package/dist/router/wasm.d.ts.map +1 -1
- package/dist/router/wasm.js +52 -103
- package/dist/ui/backend.d.ts +103 -382
- package/dist/ui/backend.d.ts.map +1 -1
- package/dist/ui/backend.js +143 -430
- package/package.json +4 -10
- package/dist/ui/client.d.ts +0 -7
- package/dist/ui/client.d.ts.map +0 -1
- package/dist/ui/client.js +0 -2
- package/dist/ui/common.d.ts +0 -126
- package/dist/ui/common.d.ts.map +0 -1
- package/dist/ui/common.js +0 -203
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CidlType, CloesceAst } from "../ast";
|
|
2
|
-
import { Either } from "../ui/common";
|
|
3
2
|
import { ConstructorRegistry } from "./router";
|
|
3
|
+
import { Either } from "../common";
|
|
4
4
|
/**
|
|
5
5
|
* Runtime type validation, asserting that the structure of a value follows the
|
|
6
6
|
* correlated CidlType.
|
|
@@ -18,15 +18,10 @@ import { ConstructorRegistry } from "./router";
|
|
|
18
18
|
* @returns the instantiated value (if applicable). On error, returns null.
|
|
19
19
|
*/
|
|
20
20
|
export declare class RuntimeValidator {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
cidlType: CidlType,
|
|
27
|
-
ast: CloesceAst,
|
|
28
|
-
ctorReg: ConstructorRegistry,
|
|
29
|
-
): Either<null, any>;
|
|
30
|
-
private recurse;
|
|
21
|
+
private ast;
|
|
22
|
+
private ctorReg;
|
|
23
|
+
constructor(ast: CloesceAst, ctorReg: ConstructorRegistry);
|
|
24
|
+
static validate(value: any, cidlType: CidlType, ast: CloesceAst, ctorReg: ConstructorRegistry): Either<null, any>;
|
|
25
|
+
private recurse;
|
|
31
26
|
}
|
|
32
|
-
//# sourceMappingURL=validator.d.ts.map
|
|
27
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/router/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EAIX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/router/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EAIX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAW,MAAM,WAAW,CAAC;AAK5C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,OAAO;gBADP,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,mBAAmB;IAGtC,MAAM,CAAC,QAAQ,CACb,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC;IAIpB,OAAO,CAAC,OAAO;CA0OhB"}
|
package/dist/router/validator.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "../ast";
|
|
6
|
-
import { Either, b64ToU8 } from "../ui/common";
|
|
1
|
+
import { NO_DATA_SOURCE, getNavigationPropertyCidlType, isNullableType, } from "../ast";
|
|
2
|
+
import { Either, b64ToU8 } from "../common";
|
|
3
|
+
import { KValue } from "../ui/backend";
|
|
4
|
+
// TODO: Create a "cleaned" object only with the values checked, discarding any extra.
|
|
7
5
|
/**
|
|
8
6
|
* Runtime type validation, asserting that the structure of a value follows the
|
|
9
7
|
* correlated CidlType.
|
|
@@ -21,173 +19,206 @@ import { Either, b64ToU8 } from "../ui/common";
|
|
|
21
19
|
* @returns the instantiated value (if applicable). On error, returns null.
|
|
22
20
|
*/
|
|
23
21
|
export class RuntimeValidator {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
static validate(value, cidlType, ast, ctorReg) {
|
|
31
|
-
return new RuntimeValidator(ast, ctorReg).recurse(value, cidlType, false);
|
|
32
|
-
}
|
|
33
|
-
recurse(value, cidlType, isPartial) {
|
|
34
|
-
isPartial ||= typeof cidlType !== "string" && "Partial" in cidlType;
|
|
35
|
-
if (value === undefined) {
|
|
36
|
-
// We will let arrays be undefined and interpret that as an empty array.
|
|
37
|
-
if (typeof cidlType !== "string" && "Array" in cidlType) {
|
|
38
|
-
return Either.right([]);
|
|
39
|
-
}
|
|
40
|
-
return rightIf(() => value, isPartial === true);
|
|
22
|
+
ast;
|
|
23
|
+
ctorReg;
|
|
24
|
+
constructor(ast, ctorReg) {
|
|
25
|
+
this.ast = ast;
|
|
26
|
+
this.ctorReg = ctorReg;
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const nullable = isNullableType(cidlType);
|
|
45
|
-
if (value == null || value === "null") {
|
|
46
|
-
return rightIf(() => null, nullable);
|
|
28
|
+
static validate(value, cidlType, ast, ctorReg) {
|
|
29
|
+
return new RuntimeValidator(ast, ctorReg).recurse(value, cidlType, false);
|
|
47
30
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// Primitives
|
|
53
|
-
if (typeof cidlType === "string") {
|
|
54
|
-
switch (cidlType) {
|
|
55
|
-
case "Integer":
|
|
56
|
-
return rightIf(() => Number(value), Number.isInteger(Number(value)));
|
|
57
|
-
case "Real":
|
|
58
|
-
return rightIf(() => Number(value), !Number.isNaN(Number(value)));
|
|
59
|
-
case "Text":
|
|
60
|
-
return rightIf(() => String(value), typeof value === "string");
|
|
61
|
-
case "Boolean": {
|
|
62
|
-
if (typeof value === "boolean") return Either.right(value);
|
|
63
|
-
if (value === "true") return Either.right(true);
|
|
64
|
-
if (value === "false") return Either.right(false);
|
|
65
|
-
return Either.left(null);
|
|
31
|
+
recurse(value, cidlType, isPartial) {
|
|
32
|
+
// JsonValue accepts anything
|
|
33
|
+
if (cidlType === "JsonValue") {
|
|
34
|
+
return Either.right(value);
|
|
66
35
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
36
|
+
isPartial ||= typeof cidlType !== "string" && "Partial" in cidlType;
|
|
37
|
+
if (value === undefined) {
|
|
38
|
+
// We will let arrays be undefined and interpret that as an empty array.
|
|
39
|
+
if (typeof cidlType !== "string" && "Array" in cidlType) {
|
|
40
|
+
return Either.right([]);
|
|
41
|
+
}
|
|
42
|
+
return rightIf(() => value, isPartial === true);
|
|
71
43
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
44
|
+
// TODO: consequences of null checking like this? 'null' is passed in
|
|
45
|
+
// as a string for GET requests
|
|
46
|
+
const nullable = isNullableType(cidlType);
|
|
47
|
+
if (value == null || value === "null") {
|
|
48
|
+
// NOTE: Partial types are always nullable.
|
|
49
|
+
return rightIf(() => null, nullable || isPartial);
|
|
75
50
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
// Data Sources
|
|
81
|
-
if ("DataSource" in cidlType) {
|
|
82
|
-
const objectName = cidlType.DataSource;
|
|
83
|
-
return rightIf(
|
|
84
|
-
() => value,
|
|
85
|
-
typeof value === "string" &&
|
|
86
|
-
(value === NO_DATA_SOURCE ||
|
|
87
|
-
this.ast.models[objectName]?.data_sources[value] !== undefined),
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const objName = getObjectName(cidlType);
|
|
91
|
-
// Models
|
|
92
|
-
if (objName && this.ast.models[objName]) {
|
|
93
|
-
const model = this.ast.models[objName];
|
|
94
|
-
if (!model || typeof value !== "object") return Either.left(null);
|
|
95
|
-
const valueObj = value;
|
|
96
|
-
// Validate + instantiate PK
|
|
97
|
-
{
|
|
98
|
-
const pk = model.primary_key;
|
|
99
|
-
const res = this.recurse(valueObj[pk.name], pk.cidl_type, isPartial);
|
|
100
|
-
if (res.isLeft()) {
|
|
101
|
-
return res;
|
|
51
|
+
// Unwrap nullable types
|
|
52
|
+
if (nullable) {
|
|
53
|
+
cidlType = cidlType.Nullable;
|
|
102
54
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
55
|
+
// Primitives
|
|
56
|
+
if (typeof cidlType === "string") {
|
|
57
|
+
switch (cidlType) {
|
|
58
|
+
case "Integer":
|
|
59
|
+
return rightIf(() => Number(value), Number.isInteger(Number(value)));
|
|
60
|
+
case "Real":
|
|
61
|
+
return rightIf(() => Number(value), !Number.isNaN(Number(value)));
|
|
62
|
+
case "Text":
|
|
63
|
+
return rightIf(() => String(value), typeof value === "string");
|
|
64
|
+
case "Boolean": {
|
|
65
|
+
if (typeof value === "boolean")
|
|
66
|
+
return Either.right(value);
|
|
67
|
+
if (value === "true")
|
|
68
|
+
return Either.right(true);
|
|
69
|
+
if (value === "false")
|
|
70
|
+
return Either.right(false);
|
|
71
|
+
return Either.left(null);
|
|
72
|
+
}
|
|
73
|
+
case "DateIso": {
|
|
74
|
+
// Instantiate
|
|
75
|
+
const date = new Date(value);
|
|
76
|
+
return rightIf(() => date, !isNaN(date.getTime()));
|
|
77
|
+
}
|
|
78
|
+
case "Blob": {
|
|
79
|
+
// Instantiate
|
|
80
|
+
return Either.right(b64ToU8(value));
|
|
81
|
+
}
|
|
82
|
+
default:
|
|
83
|
+
return Either.left(null);
|
|
84
|
+
}
|
|
115
85
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
valueObj[nav.var_name],
|
|
123
|
-
getNavigationPropertyCidlType(nav),
|
|
124
|
-
isPartial,
|
|
125
|
-
);
|
|
126
|
-
if (res.isLeft()) {
|
|
127
|
-
return res;
|
|
86
|
+
// Data Sources
|
|
87
|
+
if ("DataSource" in cidlType) {
|
|
88
|
+
const objectName = cidlType.DataSource;
|
|
89
|
+
return rightIf(() => value, typeof value === "string" &&
|
|
90
|
+
(value === NO_DATA_SOURCE ||
|
|
91
|
+
this.ast.models[objectName]?.data_sources[value] !== undefined));
|
|
128
92
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
93
|
+
const objName = getObjectName(cidlType);
|
|
94
|
+
// Models
|
|
95
|
+
if (objName && this.ast.models[objName]) {
|
|
96
|
+
const model = this.ast.models[objName];
|
|
97
|
+
if (!model || typeof value !== "object")
|
|
98
|
+
return Either.left(null);
|
|
99
|
+
const valueObj = value;
|
|
100
|
+
// Validate + instantiate PK
|
|
101
|
+
if (model.primary_key !== null) {
|
|
102
|
+
const pk = model.primary_key;
|
|
103
|
+
const res = this.recurse(valueObj[pk.name], pk.cidl_type, isPartial);
|
|
104
|
+
if (res.isLeft()) {
|
|
105
|
+
return res;
|
|
106
|
+
}
|
|
107
|
+
value[pk.name] = res.unwrap();
|
|
108
|
+
}
|
|
109
|
+
// Validate + instantiate attributes
|
|
110
|
+
for (let i = 0; i < model.columns.length; i++) {
|
|
111
|
+
const attr = model.columns[i];
|
|
112
|
+
const res = this.recurse(valueObj[attr.value.name], attr.value.cidl_type, isPartial);
|
|
113
|
+
if (res.isLeft()) {
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
value[attr.value.name] = res.unwrap();
|
|
117
|
+
}
|
|
118
|
+
// Validate + instantiate navigation properties
|
|
119
|
+
for (let i = 0; i < model.navigation_properties.length; i++) {
|
|
120
|
+
const nav = model.navigation_properties[i];
|
|
121
|
+
const res = this.recurse(valueObj[nav.var_name], getNavigationPropertyCidlType(nav), isPartial);
|
|
122
|
+
if (res.isLeft()) {
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
value[nav.var_name] = res.unwrap();
|
|
126
|
+
}
|
|
127
|
+
// Validate KV Objects
|
|
128
|
+
for (let i = 0; i < model.kv_objects.length; i++) {
|
|
129
|
+
const kvObjMeta = model.kv_objects[i];
|
|
130
|
+
const kvObj = valueObj[kvObjMeta.value.name];
|
|
131
|
+
if (kvObj === undefined) {
|
|
132
|
+
// only allowed if partial
|
|
133
|
+
if (isPartial) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return Either.left(null);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (typeof kvObj !== "object") {
|
|
141
|
+
return Either.left(null);
|
|
142
|
+
}
|
|
143
|
+
// value["raw"] should exist and be of type kvObj.value.cidl_type
|
|
144
|
+
const rawRes = this.recurse(kvObj.raw, kvObjMeta.value.cidl_type, isPartial);
|
|
145
|
+
if (rawRes.isLeft()) {
|
|
146
|
+
return rawRes;
|
|
147
|
+
}
|
|
148
|
+
// if value["metadata"] exists, it should be a JsonValue
|
|
149
|
+
const metadataRes = this.recurse(kvObj.metadata, "JsonValue", isPartial);
|
|
150
|
+
if (metadataRes.isLeft()) {
|
|
151
|
+
return metadataRes;
|
|
152
|
+
}
|
|
153
|
+
// key must exist and be a string
|
|
154
|
+
// TODO: validate it follows the format?
|
|
155
|
+
const keyRes = this.recurse(kvObj.key, "Text", isPartial);
|
|
156
|
+
if (keyRes.isLeft()) {
|
|
157
|
+
return keyRes;
|
|
158
|
+
}
|
|
159
|
+
value[kvObjMeta.value.name] = Object.assign(new KValue(), {
|
|
160
|
+
key: keyRes.unwrap(),
|
|
161
|
+
raw: rawRes.unwrap(),
|
|
162
|
+
metadata: metadataRes.unwrap(),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
// Don't instantiate partials
|
|
166
|
+
if (isPartial) {
|
|
167
|
+
return Either.right(value);
|
|
168
|
+
}
|
|
169
|
+
// Instantiate
|
|
170
|
+
return Either.right(Object.assign(new this.ctorReg[objName](), value));
|
|
153
171
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
// Plain old Objects
|
|
173
|
+
if (objName && this.ast.poos[objName]) {
|
|
174
|
+
const poo = this.ast.poos[objName];
|
|
175
|
+
if (!poo || typeof value !== "object")
|
|
176
|
+
return Either.left(null);
|
|
177
|
+
const valueObj = value;
|
|
178
|
+
// Validate + instantiate attributes
|
|
179
|
+
for (let i = 0; i < poo.attributes.length; i++) {
|
|
180
|
+
const attr = poo.attributes[i];
|
|
181
|
+
const res = this.recurse(valueObj[attr.name], attr.cidl_type, isPartial);
|
|
182
|
+
if (res.isLeft()) {
|
|
183
|
+
return res;
|
|
184
|
+
}
|
|
185
|
+
value[attr.name] = res.unwrap();
|
|
186
|
+
}
|
|
187
|
+
if (isPartial) {
|
|
188
|
+
return Either.right(value);
|
|
189
|
+
}
|
|
190
|
+
// Instantiate
|
|
191
|
+
return Either.right(Object.assign(new this.ctorReg[objName](), value));
|
|
171
192
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
193
|
+
// Arrays
|
|
194
|
+
if ("Array" in cidlType) {
|
|
195
|
+
if (!Array.isArray(value)) {
|
|
196
|
+
return Either.left(null);
|
|
197
|
+
}
|
|
198
|
+
for (let i = 0; i < value.length; i++) {
|
|
199
|
+
const res = this.recurse(value[i], cidlType.Array, isPartial);
|
|
200
|
+
if (res.isLeft()) {
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
value[i] = res.unwrap();
|
|
204
|
+
}
|
|
205
|
+
return Either.right(value);
|
|
206
|
+
}
|
|
207
|
+
return Either.left(null);
|
|
175
208
|
}
|
|
176
|
-
return Either.left(null);
|
|
177
|
-
}
|
|
178
209
|
}
|
|
179
210
|
function getObjectName(ty) {
|
|
180
|
-
|
|
211
|
+
if (typeof ty === "string") {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
if ("Partial" in ty) {
|
|
215
|
+
return ty.Partial;
|
|
216
|
+
}
|
|
217
|
+
if ("Object" in ty) {
|
|
218
|
+
return ty.Object;
|
|
219
|
+
}
|
|
181
220
|
return undefined;
|
|
182
|
-
}
|
|
183
|
-
if ("Partial" in ty) {
|
|
184
|
-
return ty.Partial;
|
|
185
|
-
}
|
|
186
|
-
if ("Object" in ty) {
|
|
187
|
-
return ty.Object;
|
|
188
|
-
}
|
|
189
|
-
return undefined;
|
|
190
221
|
}
|
|
191
222
|
function rightIf(value, cond) {
|
|
192
|
-
|
|
223
|
+
return cond ? Either.right(value()) : Either.left(null);
|
|
193
224
|
}
|
package/dist/router/wasm.d.ts
CHANGED
|
@@ -1,79 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Either } from "../ui/common.js";
|
|
1
|
+
import { CloesceAst } from "../ast.js";
|
|
2
|
+
import { Either } from "../common.js";
|
|
4
3
|
/**
|
|
5
|
-
* WASM ABI
|
|
4
|
+
* Cloesce WASM ABI
|
|
6
5
|
*/
|
|
7
6
|
export interface OrmWasmExports {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
model_name_ptr: number,
|
|
16
|
-
model_name_len: number,
|
|
17
|
-
sql_rows_ptr: number,
|
|
18
|
-
sql_rows_len: number,
|
|
19
|
-
include_tree_ptr: number,
|
|
20
|
-
include_tree_len: number,
|
|
21
|
-
): boolean;
|
|
22
|
-
upsert_model(
|
|
23
|
-
model_name_ptr: number,
|
|
24
|
-
model_name_len: number,
|
|
25
|
-
new_model_ptr: number,
|
|
26
|
-
new_model_len: number,
|
|
27
|
-
include_tree_ptr: number,
|
|
28
|
-
include_tree_len: number,
|
|
29
|
-
): boolean;
|
|
30
|
-
list_models(
|
|
31
|
-
model_name_ptr: number,
|
|
32
|
-
model_name_len: number,
|
|
33
|
-
include_tree_ptr: number,
|
|
34
|
-
include_tree_len: number,
|
|
35
|
-
tag_cte_ptr: number,
|
|
36
|
-
tag_cte_len: number,
|
|
37
|
-
custom_from_ptr: number,
|
|
38
|
-
custom_from_len: number,
|
|
39
|
-
): boolean;
|
|
7
|
+
memory: WebAssembly.Memory;
|
|
8
|
+
get_return_len(): number;
|
|
9
|
+
get_return_ptr(): number;
|
|
10
|
+
set_meta_ptr(ptr: number, len: number): number;
|
|
11
|
+
alloc(len: number): number;
|
|
12
|
+
dealloc(ptr: number, len: number): void;
|
|
13
|
+
upsert_model(model_name_ptr: number, model_name_len: number, new_model_ptr: number, new_model_len: number, include_tree_ptr: number, include_tree_len: number): boolean;
|
|
14
|
+
select_model(model_name_ptr: number, model_name_len: number, from_ptr: number, from_len: number, include_tree_ptr: number, include_tree_len: number): boolean;
|
|
15
|
+
map(model_name_ptr: number, model_name_len: number, d1_result_ptr: number, d1_result_len: number, include_tree_ptr: number, include_tree_len: number): boolean;
|
|
40
16
|
}
|
|
41
|
-
/**
|
|
42
|
-
* RAII for wasm memory
|
|
43
|
-
*/
|
|
44
17
|
export declare class WasmResource {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
18
|
+
private wasm;
|
|
19
|
+
ptr: number;
|
|
20
|
+
len: number;
|
|
21
|
+
private constructor();
|
|
22
|
+
free(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Copies a value from TS memory to WASM memory.
|
|
25
|
+
*
|
|
26
|
+
* A subsequent call to `free` is necessary.
|
|
27
|
+
*/
|
|
28
|
+
static fromString(str: string, wasm: OrmWasmExports): WasmResource;
|
|
54
29
|
}
|
|
55
|
-
export declare function loadOrmWasm(
|
|
56
|
-
ast: CloesceAst,
|
|
57
|
-
wasm?: WebAssembly.Instance,
|
|
58
|
-
): Promise<OrmWasmExports>;
|
|
30
|
+
export declare function loadOrmWasm(ast: CloesceAst, wasm?: WebAssembly.Instance): Promise<OrmWasmExports>;
|
|
59
31
|
/**
|
|
60
32
|
* Invokes a WASM ORM function with the provided arguments, handling memory
|
|
61
33
|
* allocation and deallocation.
|
|
62
34
|
*
|
|
63
35
|
* Returns an Either where Left is an error message and Right the raw string result.
|
|
64
36
|
*/
|
|
65
|
-
export declare function invokeOrmWasm(
|
|
66
|
-
|
|
67
|
-
args: WasmResource[],
|
|
68
|
-
wasm: OrmWasmExports,
|
|
69
|
-
): Either<string, string>;
|
|
70
|
-
/**
|
|
71
|
-
* Calls the object relational mapping function to turn a row of SQL records into
|
|
72
|
-
* an instantiated object.
|
|
73
|
-
*/
|
|
74
|
-
export declare function mapSql<T extends object>(
|
|
75
|
-
ctor: new () => T,
|
|
76
|
-
records: Record<string, any>[],
|
|
77
|
-
includeTree: IncludeTree<T> | CidlIncludeTree | null,
|
|
78
|
-
): Either<string, T[]>;
|
|
79
|
-
//# sourceMappingURL=wasm.d.ts.map
|
|
37
|
+
export declare function invokeOrmWasm(fn: (...args: number[]) => boolean, args: WasmResource[], wasm: OrmWasmExports): Either<string, string>;
|
|
38
|
+
//# sourceMappingURL=wasm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/router/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"wasm.d.ts","sourceRoot":"","sources":["../../src/router/wasm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;IAC3B,cAAc,IAAI,MAAM,CAAC;IACzB,cAAc,IAAI,MAAM,CAAC;IACzB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/C,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC,YAAY,CACV,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;IAEX,YAAY,CACV,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;IAEX,GAAG,CACD,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;CACZ;AAED,qBAAa,YAAY;IAErB,OAAO,CAAC,IAAI;IACL,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;IAHpB,OAAO;IAMP,IAAI;IAIJ;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,YAAY;CASnE;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,UAAU,EACf,IAAI,CAAC,EAAE,WAAW,CAAC,QAAQ,GAC1B,OAAO,CAAC,cAAc,CAAC,CA2BzB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,EAClC,IAAI,EAAE,YAAY,EAAE,EACpB,IAAI,EAAE,cAAc,GACnB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB"}
|