cloesce 0.0.5-unstable.1 → 0.0.5-unstable.10
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
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Denotes that some error occured internally in Cloesce that should not happen.
|
|
3
|
+
*/
|
|
4
|
+
export declare class InternalError extends Error {
|
|
5
|
+
constructor(description: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class Either<L, R> {
|
|
8
|
+
private readonly inner;
|
|
9
|
+
private constructor();
|
|
10
|
+
get value(): L | R;
|
|
11
|
+
static left<R>(): Either<void, R>;
|
|
12
|
+
static left<L, R = never>(value: L): Either<L, R>;
|
|
13
|
+
static right<R, L = never>(value: R): Either<L, R>;
|
|
14
|
+
isLeft(): this is Either<L, never>;
|
|
15
|
+
isRight(): this is Either<never, R>;
|
|
16
|
+
unwrap(): R;
|
|
17
|
+
unwrapLeft(): L;
|
|
18
|
+
map<B>(fn: (val: R) => B): Either<L, B>;
|
|
19
|
+
mapLeft<B>(fn: (val: L) => B): Either<B, R>;
|
|
20
|
+
}
|
|
21
|
+
export declare function b64ToU8(b64: string): Uint8Array;
|
|
22
|
+
export declare function u8ToB64(u8: Uint8Array): string;
|
|
23
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,WAAW,EAAE,MAAM;CAIhC;AAED,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC;IAEpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IADxB,OAAO;IAIP,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,CAEjB;IAED,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAMjD,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAIlD,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC;IAIlC,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAInC,MAAM,IAAI,CAAC;IAOX,UAAU,IAAI,CAAC;IAOf,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAMvC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;CAK5C;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAc/C;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,CAY9C"}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Denotes that some error occured internally in Cloesce that should not happen.
|
|
3
|
+
*/
|
|
4
|
+
export class InternalError extends Error {
|
|
5
|
+
constructor(description) {
|
|
6
|
+
super(`An internal Cloesce error occurred: ${description}`);
|
|
7
|
+
Object.setPrototypeOf(this, InternalError.prototype);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class Either {
|
|
11
|
+
inner;
|
|
12
|
+
constructor(inner) {
|
|
13
|
+
this.inner = inner;
|
|
14
|
+
}
|
|
15
|
+
get value() {
|
|
16
|
+
return this.inner.ok ? this.inner.right : this.inner.left;
|
|
17
|
+
}
|
|
18
|
+
static left(value) {
|
|
19
|
+
return new Either({ ok: false, left: value });
|
|
20
|
+
}
|
|
21
|
+
static right(value) {
|
|
22
|
+
return new Either({ ok: true, right: value });
|
|
23
|
+
}
|
|
24
|
+
isLeft() {
|
|
25
|
+
return !this.inner.ok;
|
|
26
|
+
}
|
|
27
|
+
isRight() {
|
|
28
|
+
return this.inner.ok;
|
|
29
|
+
}
|
|
30
|
+
unwrap() {
|
|
31
|
+
if (!this.inner.ok) {
|
|
32
|
+
throw new Error("Tried to unwrap a Left value");
|
|
33
|
+
}
|
|
34
|
+
return this.inner.right;
|
|
35
|
+
}
|
|
36
|
+
unwrapLeft() {
|
|
37
|
+
if (this.inner.ok) {
|
|
38
|
+
throw new Error("Tried to unwrapLeft a Right value");
|
|
39
|
+
}
|
|
40
|
+
return this.inner.left;
|
|
41
|
+
}
|
|
42
|
+
map(fn) {
|
|
43
|
+
return this.inner.ok
|
|
44
|
+
? Either.right(fn(this.inner.right))
|
|
45
|
+
: Either.left(this.inner.left);
|
|
46
|
+
}
|
|
47
|
+
mapLeft(fn) {
|
|
48
|
+
return this.inner.ok
|
|
49
|
+
? Either.right(this.inner.right)
|
|
50
|
+
: Either.left(fn(this.inner.left));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function b64ToU8(b64) {
|
|
54
|
+
// Prefer Buffer in Node.js environments
|
|
55
|
+
if (typeof Buffer !== "undefined") {
|
|
56
|
+
const buffer = Buffer.from(b64, "base64");
|
|
57
|
+
return new Uint8Array(buffer);
|
|
58
|
+
}
|
|
59
|
+
// Use atob only in browser environments
|
|
60
|
+
const s = atob(b64);
|
|
61
|
+
const u8 = new Uint8Array(s.length);
|
|
62
|
+
for (let i = 0; i < s.length; i++) {
|
|
63
|
+
u8[i] = s.charCodeAt(i);
|
|
64
|
+
}
|
|
65
|
+
return u8;
|
|
66
|
+
}
|
|
67
|
+
export function u8ToB64(u8) {
|
|
68
|
+
// Prefer Buffer in Node.js environments
|
|
69
|
+
if (typeof Buffer !== "undefined") {
|
|
70
|
+
return Buffer.from(u8).toString("base64");
|
|
71
|
+
}
|
|
72
|
+
// Use btoa only in browser environments
|
|
73
|
+
let s = "";
|
|
74
|
+
for (let i = 0; i < u8.length; i++) {
|
|
75
|
+
s += String.fromCharCode(u8[i]);
|
|
76
|
+
}
|
|
77
|
+
return btoa(s);
|
|
78
|
+
}
|
package/dist/extractor/err.d.ts
CHANGED
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
export declare enum ExtractorErrorCode {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
InvalidServiceAttribute = 17,
|
|
2
|
+
MissingExport = 0,
|
|
3
|
+
InvalidMain = 1,
|
|
4
|
+
UnknownType = 2,
|
|
5
|
+
MultipleGenericType = 3,
|
|
6
|
+
InvalidDataSourceDefinition = 4,
|
|
7
|
+
InvalidPartialType = 5,
|
|
8
|
+
InvalidPropertyModifier = 6,
|
|
9
|
+
InvalidApiMethodModifier = 7,
|
|
10
|
+
InvalidSelectorSyntax = 8,
|
|
11
|
+
InvalidOneToOneSelector = 9,
|
|
12
|
+
InvalidNavigationProperty = 10,
|
|
13
|
+
TooManyWranglerEnvs = 11,
|
|
14
|
+
MissingFile = 12,
|
|
15
|
+
InvalidServiceProperty = 13,
|
|
16
|
+
InvalidTypescriptSyntax = 14,
|
|
17
|
+
MissingKValue = 15,
|
|
18
|
+
MissingR2ObjectBody = 16
|
|
20
19
|
}
|
|
21
20
|
export declare function getErrorInfo(code: ExtractorErrorCode): {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
description: string;
|
|
22
|
+
suggestion: string;
|
|
24
23
|
};
|
|
25
24
|
export declare class ExtractorError {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
code: ExtractorErrorCode;
|
|
26
|
+
context?: string;
|
|
27
|
+
snippet?: string;
|
|
28
|
+
constructor(code: ExtractorErrorCode);
|
|
29
|
+
addContext(fn: (val: string | undefined) => string | undefined): void;
|
|
31
30
|
}
|
|
32
|
-
//# sourceMappingURL=err.d.ts.map
|
|
31
|
+
//# sourceMappingURL=err.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"err.d.ts","sourceRoot":"","sources":["../../src/extractor/err.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC5B,aAAa,IAAA;IACb,
|
|
1
|
+
{"version":3,"file":"err.d.ts","sourceRoot":"","sources":["../../src/extractor/err.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC5B,aAAa,IAAA;IACb,WAAW,IAAA;IACX,WAAW,IAAA;IACX,mBAAmB,IAAA;IACnB,2BAA2B,IAAA;IAC3B,kBAAkB,IAAA;IAClB,uBAAuB,IAAA;IACvB,wBAAwB,IAAA;IACxB,qBAAqB,IAAA;IACrB,uBAAuB,IAAA;IACvB,yBAAyB,KAAA;IACzB,mBAAmB,KAAA;IACnB,WAAW,KAAA;IACX,sBAAsB,KAAA;IACtB,uBAAuB,KAAA;IACvB,aAAa,KAAA;IACb,mBAAmB,KAAA;CACpB;AAuFD,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB;iBAnFpC,MAAM;gBAAc,MAAM;EAqF1C;AAED,qBAAa,cAAc;IAIN,IAAI,EAAE,kBAAkB;IAH3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEE,IAAI,EAAE,kBAAkB;IAE3C,UAAU,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,SAAS;CAG/D"}
|
package/dist/extractor/err.js
CHANGED
|
@@ -1,138 +1,104 @@
|
|
|
1
1
|
export var ExtractorErrorCode;
|
|
2
2
|
(function (ExtractorErrorCode) {
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
ExtractorErrorCode[
|
|
21
|
-
(ExtractorErrorCode["UnknownNavigationPropertyReference"] = 9)
|
|
22
|
-
] = "UnknownNavigationPropertyReference";
|
|
23
|
-
ExtractorErrorCode[
|
|
24
|
-
(ExtractorErrorCode["InvalidNavigationPropertyReference"] = 10)
|
|
25
|
-
] = "InvalidNavigationPropertyReference";
|
|
26
|
-
ExtractorErrorCode[
|
|
27
|
-
(ExtractorErrorCode["MissingNavigationPropertyReference"] = 11)
|
|
28
|
-
] = "MissingNavigationPropertyReference";
|
|
29
|
-
ExtractorErrorCode[(ExtractorErrorCode["MissingManyToManyUniqueId"] = 12)] =
|
|
30
|
-
"MissingManyToManyUniqueId";
|
|
31
|
-
ExtractorErrorCode[(ExtractorErrorCode["MissingPrimaryKey"] = 13)] =
|
|
32
|
-
"MissingPrimaryKey";
|
|
33
|
-
ExtractorErrorCode[(ExtractorErrorCode["MissingDatabaseBinding"] = 14)] =
|
|
34
|
-
"MissingDatabaseBinding";
|
|
35
|
-
ExtractorErrorCode[(ExtractorErrorCode["TooManyWranglerEnvs"] = 15)] =
|
|
36
|
-
"TooManyWranglerEnvs";
|
|
37
|
-
ExtractorErrorCode[(ExtractorErrorCode["MissingFile"] = 16)] = "MissingFile";
|
|
38
|
-
ExtractorErrorCode[(ExtractorErrorCode["InvalidServiceAttribute"] = 17)] =
|
|
39
|
-
"InvalidServiceAttribute";
|
|
3
|
+
ExtractorErrorCode[ExtractorErrorCode["MissingExport"] = 0] = "MissingExport";
|
|
4
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidMain"] = 1] = "InvalidMain";
|
|
5
|
+
ExtractorErrorCode[ExtractorErrorCode["UnknownType"] = 2] = "UnknownType";
|
|
6
|
+
ExtractorErrorCode[ExtractorErrorCode["MultipleGenericType"] = 3] = "MultipleGenericType";
|
|
7
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidDataSourceDefinition"] = 4] = "InvalidDataSourceDefinition";
|
|
8
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidPartialType"] = 5] = "InvalidPartialType";
|
|
9
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidPropertyModifier"] = 6] = "InvalidPropertyModifier";
|
|
10
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidApiMethodModifier"] = 7] = "InvalidApiMethodModifier";
|
|
11
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidSelectorSyntax"] = 8] = "InvalidSelectorSyntax";
|
|
12
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidOneToOneSelector"] = 9] = "InvalidOneToOneSelector";
|
|
13
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidNavigationProperty"] = 10] = "InvalidNavigationProperty";
|
|
14
|
+
ExtractorErrorCode[ExtractorErrorCode["TooManyWranglerEnvs"] = 11] = "TooManyWranglerEnvs";
|
|
15
|
+
ExtractorErrorCode[ExtractorErrorCode["MissingFile"] = 12] = "MissingFile";
|
|
16
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidServiceProperty"] = 13] = "InvalidServiceProperty";
|
|
17
|
+
ExtractorErrorCode[ExtractorErrorCode["InvalidTypescriptSyntax"] = 14] = "InvalidTypescriptSyntax";
|
|
18
|
+
ExtractorErrorCode[ExtractorErrorCode["MissingKValue"] = 15] = "MissingKValue";
|
|
19
|
+
ExtractorErrorCode[ExtractorErrorCode["MissingR2ObjectBody"] = 16] = "MissingR2ObjectBody";
|
|
40
20
|
})(ExtractorErrorCode || (ExtractorErrorCode = {}));
|
|
41
21
|
const errorInfoMap = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
},
|
|
111
|
-
[ExtractorErrorCode.TooManyWranglerEnvs]: {
|
|
112
|
-
description: "Too many wrangler environments defined in the project",
|
|
113
|
-
suggestion: "Consolidate or remove unused @WranglerEnv's",
|
|
114
|
-
},
|
|
115
|
-
[ExtractorErrorCode.MissingFile]: {
|
|
116
|
-
description: "A specified input file could not be found",
|
|
117
|
-
suggestion: "Verify the input file path is correct",
|
|
118
|
-
},
|
|
119
|
-
[ExtractorErrorCode.InvalidServiceAttribute]: {
|
|
120
|
-
description:
|
|
121
|
-
"Services must contain only dependency injected instances as attributes.",
|
|
122
|
-
suggestion: "Remove the attribute.",
|
|
123
|
-
},
|
|
22
|
+
[ExtractorErrorCode.MissingExport]: {
|
|
23
|
+
description: "All Cloesce types must be exported.",
|
|
24
|
+
suggestion: "Add `export` to the class definition.",
|
|
25
|
+
},
|
|
26
|
+
[ExtractorErrorCode.InvalidMain]: {
|
|
27
|
+
description: "The main function must follow the expected signature.",
|
|
28
|
+
suggestion: "Change to: export default async function main(request: Request, env: WranglerEnv, app: CloesceApp, ctx: ExecutionContext): Promise<Response> {...}",
|
|
29
|
+
},
|
|
30
|
+
[ExtractorErrorCode.UnknownType]: {
|
|
31
|
+
description: "Encountered an unknown or unsupported type",
|
|
32
|
+
suggestion: "Refer to the documentation on valid Cloesce TS types",
|
|
33
|
+
},
|
|
34
|
+
[ExtractorErrorCode.InvalidPartialType]: {
|
|
35
|
+
description: "Partial types must only contain a model or plain old object",
|
|
36
|
+
suggestion: "Refer to the documentation on valid Cloesce TS types",
|
|
37
|
+
},
|
|
38
|
+
[ExtractorErrorCode.MultipleGenericType]: {
|
|
39
|
+
description: "Cloesce does not yet support types with multiple generics",
|
|
40
|
+
suggestion: "Simplify your type to use only a single generic parameter, ie Foo<T>",
|
|
41
|
+
},
|
|
42
|
+
[ExtractorErrorCode.InvalidDataSourceDefinition]: {
|
|
43
|
+
description: "Data Sources must be explicitly typed as a static Include Tree",
|
|
44
|
+
suggestion: "Declare your data source as `static readonly _: IncludeTree<Model>`",
|
|
45
|
+
},
|
|
46
|
+
[ExtractorErrorCode.InvalidPropertyModifier]: {
|
|
47
|
+
description: "Attributes can only be public on a Model, Plain Old Object or Wrangler Environment",
|
|
48
|
+
suggestion: "Change the attribute modifier to just `public`",
|
|
49
|
+
},
|
|
50
|
+
[ExtractorErrorCode.InvalidApiMethodModifier]: {
|
|
51
|
+
description: "Model methods must be public if they are decorated as GET, POST, PUT, PATCH",
|
|
52
|
+
suggestion: "Change the method modifier to just `public`",
|
|
53
|
+
},
|
|
54
|
+
[ExtractorErrorCode.TooManyWranglerEnvs]: {
|
|
55
|
+
description: "Too many wrangler environments defined in the project",
|
|
56
|
+
suggestion: "Consolidate or remove unused @WranglerEnv's",
|
|
57
|
+
},
|
|
58
|
+
[ExtractorErrorCode.MissingFile]: {
|
|
59
|
+
description: "A specified input file could not be found",
|
|
60
|
+
suggestion: "Verify the input file path is correct",
|
|
61
|
+
},
|
|
62
|
+
[ExtractorErrorCode.InvalidServiceProperty]: {
|
|
63
|
+
description: "Services must contain only dependency injected instances as attributes.",
|
|
64
|
+
suggestion: "Remove the attribute.",
|
|
65
|
+
},
|
|
66
|
+
[ExtractorErrorCode.InvalidTypescriptSyntax]: {
|
|
67
|
+
description: "The TypeScript syntax is invalid.",
|
|
68
|
+
suggestion: "Fix the TypeScript syntax errors.",
|
|
69
|
+
},
|
|
70
|
+
[ExtractorErrorCode.MissingKValue]: {
|
|
71
|
+
description: "All KV decorated fields must be of type KValue<T>",
|
|
72
|
+
suggestion: "Change the field type to KValue<T>.",
|
|
73
|
+
},
|
|
74
|
+
[ExtractorErrorCode.MissingR2ObjectBody]: {
|
|
75
|
+
description: "All R2 decorated fields must be of type R2ObjectBody.",
|
|
76
|
+
suggestion: "Change the field type to R2ObjectBody.",
|
|
77
|
+
},
|
|
78
|
+
[ExtractorErrorCode.InvalidSelectorSyntax]: {
|
|
79
|
+
description: "The selector syntax is invalid.",
|
|
80
|
+
suggestion: "Selectors should be of the form `N<T>(m => m.property)` where T is a model type and N is OneToOne or OneToMany.",
|
|
81
|
+
},
|
|
82
|
+
[ExtractorErrorCode.InvalidOneToOneSelector]: {
|
|
83
|
+
description: "OneToOne selectors must select a model constructor or name string.",
|
|
84
|
+
suggestion: "Ensure the selector is of the form `OneToOne<T>(...)` where T is a model type or a string representing the model name.",
|
|
85
|
+
},
|
|
86
|
+
[ExtractorErrorCode.InvalidNavigationProperty]: {
|
|
87
|
+
description: "A navigation property must be of type T, T | undefined, or T[] where T is a model type.",
|
|
88
|
+
suggestion: "Change the property type to be of the correct form.",
|
|
89
|
+
},
|
|
124
90
|
};
|
|
125
91
|
export function getErrorInfo(code) {
|
|
126
|
-
|
|
92
|
+
return errorInfoMap[code];
|
|
127
93
|
}
|
|
128
94
|
export class ExtractorError {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
95
|
+
code;
|
|
96
|
+
context;
|
|
97
|
+
snippet;
|
|
98
|
+
constructor(code) {
|
|
99
|
+
this.code = code;
|
|
100
|
+
}
|
|
101
|
+
addContext(fn) {
|
|
102
|
+
this.context = fn(this.context ?? "");
|
|
103
|
+
}
|
|
138
104
|
}
|
|
@@ -1,64 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
Type,
|
|
4
|
-
SourceFile,
|
|
5
|
-
MethodDeclaration,
|
|
6
|
-
ClassDeclaration,
|
|
7
|
-
Expression,
|
|
8
|
-
} from "ts-morph";
|
|
9
|
-
import {
|
|
10
|
-
CidlIncludeTree,
|
|
11
|
-
CloesceAst,
|
|
12
|
-
CidlType,
|
|
13
|
-
HttpVerb,
|
|
14
|
-
Model,
|
|
15
|
-
ApiMethod,
|
|
16
|
-
WranglerEnv,
|
|
17
|
-
PlainOldObject,
|
|
18
|
-
Service,
|
|
19
|
-
} from "../ast.js";
|
|
1
|
+
import { Project, Type, SourceFile, ClassDeclaration } from "ts-morph";
|
|
2
|
+
import { CloesceAst, CidlType, WranglerEnv } from "../ast.js";
|
|
20
3
|
import { ExtractorError } from "./err.js";
|
|
21
|
-
import { Either } from "../
|
|
4
|
+
import { Either } from "../common.js";
|
|
22
5
|
export declare class CidlExtractor {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
method
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
verb: HttpVerb,
|
|
44
|
-
): Either<ExtractorError, ApiMethod>;
|
|
45
|
-
static poo(
|
|
46
|
-
classDecl: ClassDeclaration,
|
|
47
|
-
sourceFile: SourceFile,
|
|
48
|
-
): Either<ExtractorError, PlainOldObject>;
|
|
49
|
-
static env(
|
|
50
|
-
classDecl: ClassDeclaration,
|
|
51
|
-
sourceFile: SourceFile,
|
|
52
|
-
): Either<ExtractorError, WranglerEnv>;
|
|
53
|
-
private static readonly primTypeMap;
|
|
54
|
-
static cidlType(
|
|
55
|
-
type: Type,
|
|
56
|
-
inject?: boolean,
|
|
57
|
-
): Either<ExtractorError, CidlType>;
|
|
58
|
-
static includeTree(
|
|
59
|
-
expr: Expression | undefined,
|
|
60
|
-
currentClass: ClassDeclaration,
|
|
61
|
-
sf: SourceFile,
|
|
62
|
-
): Either<ExtractorError, CidlIncludeTree>;
|
|
6
|
+
private modelDecls;
|
|
7
|
+
private extractedPoos;
|
|
8
|
+
private constructor();
|
|
9
|
+
static extract(projectName: string, project: Project): Either<ExtractorError, CloesceAst>;
|
|
10
|
+
/**
|
|
11
|
+
* @returns An error if the main function is invalid, or the source code of the app function if valid.
|
|
12
|
+
* Undefined if no main function is defined.
|
|
13
|
+
*/
|
|
14
|
+
private static main;
|
|
15
|
+
private model;
|
|
16
|
+
private service;
|
|
17
|
+
private method;
|
|
18
|
+
private poo;
|
|
19
|
+
static env(classDecl: ClassDeclaration, sourceFile: SourceFile): Either<ExtractorError, WranglerEnv>;
|
|
20
|
+
private static readonly primTypeMap;
|
|
21
|
+
static cidlType(type: Type, inject?: boolean): Either<ExtractorError, CidlType>;
|
|
22
|
+
/**
|
|
23
|
+
* Mutates the property declaration to add inferred decorators based on naming conventions.
|
|
24
|
+
*/
|
|
25
|
+
private inferModelDecorator;
|
|
63
26
|
}
|
|
64
|
-
//# sourceMappingURL=extract.d.ts.map
|
|
27
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/extractor/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,IAAI,EACJ,UAAU,
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/extractor/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EACP,IAAI,EACJ,UAAU,EAIV,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EACV,QAAQ,EAQR,WAAW,EAQZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,cAAc,EAAsB,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAuBtC,qBAAa,aAAa;IAEtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa;IAFvB,OAAO;IAKP,MAAM,CAAC,OAAO,CACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC;IAiHrC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAuEnB,OAAO,CAAC,KAAK;IAwSb,OAAO,CAAC,OAAO;IAmEf,OAAO,CAAC,MAAM;IAuGd,OAAO,CAAC,GAAG;IAuEX,MAAM,CAAC,GAAG,CACR,SAAS,EAAE,gBAAgB,EAC3B,UAAU,EAAE,UAAU,GACrB,MAAM,CAAC,cAAc,EAAE,WAAW,CAAC;IAwDtC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAUjC;IAGF,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE,IAAI,EACV,MAAM,GAAE,OAAe,GACtB,MAAM,CAAC,cAAc,EAAE,QAAQ,CAAC;IA2InC;;OAEG;IACH,OAAO,CAAC,mBAAmB;CA0N5B"}
|