cloesce 0.0.4-unstable.9 → 0.0.5-unstable.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/dist/ast.d.ts +141 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +30 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +375 -279
- package/dist/extractor/err.d.ts +32 -0
- package/dist/extractor/err.d.ts.map +1 -0
- package/dist/extractor/err.js +138 -0
- package/dist/extractor/extract.d.ts +62 -15
- package/dist/extractor/extract.d.ts.map +1 -1
- package/dist/extractor/extract.js +835 -647
- package/dist/generator.wasm +0 -0
- package/dist/orm.wasm +0 -0
- package/dist/router/crud.d.ts +5 -20
- package/dist/router/crud.d.ts.map +1 -1
- package/dist/router/crud.js +53 -64
- package/dist/router/router.d.ts +153 -95
- package/dist/router/router.d.ts.map +1 -1
- package/dist/router/router.js +451 -407
- package/dist/router/validator.d.ts +32 -0
- package/dist/router/validator.d.ts.map +1 -0
- package/dist/router/validator.js +193 -0
- package/dist/router/wasm.d.ts +59 -24
- package/dist/router/wasm.d.ts.map +1 -1
- package/dist/router/wasm.js +93 -79
- package/dist/ui/backend.d.ts +224 -180
- package/dist/ui/backend.d.ts.map +1 -1
- package/dist/ui/backend.js +264 -250
- package/dist/ui/client.d.ts +7 -5
- package/dist/ui/client.d.ts.map +1 -1
- package/dist/ui/client.js +2 -7
- package/dist/ui/common.d.ts +120 -0
- package/dist/ui/common.d.ts.map +1 -0
- package/dist/ui/common.js +210 -0
- package/package.json +4 -3
- package/README.md +0 -632
- package/dist/common.d.ts +0 -237
- package/dist/common.d.ts.map +0 -1
- package/dist/common.js +0 -169
package/dist/common.d.ts
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
export declare enum ExtractorErrorCode {
|
|
2
|
-
MissingExport = 0,
|
|
3
|
-
AppMissingDefaultExport = 1,
|
|
4
|
-
UnknownType = 2,
|
|
5
|
-
MultipleGenericType = 3,
|
|
6
|
-
InvalidDataSourceDefinition = 4,
|
|
7
|
-
InvalidPartialType = 5,
|
|
8
|
-
InvalidIncludeTree = 6,
|
|
9
|
-
InvalidAttributeModifier = 7,
|
|
10
|
-
InvalidApiMethodModifier = 8,
|
|
11
|
-
UnknownNavigationPropertyReference = 9,
|
|
12
|
-
InvalidNavigationPropertyReference = 10,
|
|
13
|
-
MissingNavigationPropertyReference = 11,
|
|
14
|
-
MissingManyToManyUniqueId = 12,
|
|
15
|
-
MissingPrimaryKey = 13,
|
|
16
|
-
MissingDatabaseBinding = 14,
|
|
17
|
-
MissingWranglerEnv = 15,
|
|
18
|
-
TooManyWranglerEnvs = 16,
|
|
19
|
-
MissingFile = 17
|
|
20
|
-
}
|
|
21
|
-
export declare function getErrorInfo(code: ExtractorErrorCode): {
|
|
22
|
-
description: string;
|
|
23
|
-
suggestion: string;
|
|
24
|
-
};
|
|
25
|
-
export declare class ExtractorError {
|
|
26
|
-
code: ExtractorErrorCode;
|
|
27
|
-
context?: string;
|
|
28
|
-
snippet?: string;
|
|
29
|
-
constructor(code: ExtractorErrorCode);
|
|
30
|
-
addContext(fn: (val: string | undefined) => string | undefined): void;
|
|
31
|
-
}
|
|
32
|
-
type DeepPartialInner<T> = T extends (infer U)[] ? DeepPartialInner<U>[] : T extends object ? {
|
|
33
|
-
[K in keyof T]?: DeepPartialInner<T[K]>;
|
|
34
|
-
} : T | (null extends T ? null : never);
|
|
35
|
-
/**
|
|
36
|
-
* Recursively makes all properties of a type optional — including nested objects and arrays.
|
|
37
|
-
*
|
|
38
|
-
* Similar to TypeScript's built-in `Partial<T>`, but applies the transformation deeply across
|
|
39
|
-
* all nested structures. Useful for defining "patch" or "update" objects where only a subset
|
|
40
|
-
* of properties may be provided.
|
|
41
|
-
*
|
|
42
|
-
* **Apart of the Cloesce method grammar**, meaning the type can be apart of method parameters
|
|
43
|
-
* or return types and the generated workers and client API will act accordingly.
|
|
44
|
-
*
|
|
45
|
-
* @template T
|
|
46
|
-
* The target type to make deeply partial.
|
|
47
|
-
*
|
|
48
|
-
* @remarks
|
|
49
|
-
* - **Objects:** All properties become optional, and their values are recursively wrapped in `DeepPartial`.
|
|
50
|
-
* - **Arrays:** Arrays are preserved, but their elements are recursively made partial.
|
|
51
|
-
* - **Scalars:** Primitive values (string, number, boolean, etc.) remain unchanged.
|
|
52
|
-
* - **Nullable types:** If `null` is assignable to the type, it remains allowed.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* class User {
|
|
57
|
-
* id: string;
|
|
58
|
-
* profile: {
|
|
59
|
-
* name: string;
|
|
60
|
-
* age: number;
|
|
61
|
-
* };
|
|
62
|
-
* tags: string[];
|
|
63
|
-
* }
|
|
64
|
-
*
|
|
65
|
-
* // The resulting type:
|
|
66
|
-
* // {
|
|
67
|
-
* // id?: string;
|
|
68
|
-
* // profile?: { name?: string; age?: number };
|
|
69
|
-
* // tags?: (string | undefined)[];
|
|
70
|
-
* // }
|
|
71
|
-
* type PartialUser = DeepPartial<User>;
|
|
72
|
-
*
|
|
73
|
-
* const patch: PartialUser = {
|
|
74
|
-
* profile: { age: 30 } // ok
|
|
75
|
-
* };
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export type DeepPartial<T> = DeepPartialInner<T> & {
|
|
79
|
-
__brand?: "Partial";
|
|
80
|
-
};
|
|
81
|
-
export declare class Either<L, R> {
|
|
82
|
-
private readonly inner;
|
|
83
|
-
private constructor();
|
|
84
|
-
get value(): L | R;
|
|
85
|
-
static left<L, R = never>(value: L): Either<L, R>;
|
|
86
|
-
static right<R, L = never>(value: R): Either<L, R>;
|
|
87
|
-
isLeft(): this is Either<L, never>;
|
|
88
|
-
isRight(): this is Either<never, R>;
|
|
89
|
-
unwrap(): R;
|
|
90
|
-
unwrapLeft(): L;
|
|
91
|
-
map<B>(fn: (val: R) => B): Either<L, B>;
|
|
92
|
-
mapLeft<B>(fn: (val: L) => B): Either<B, R>;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Represents the result of an HTTP operation in a monadic style.
|
|
96
|
-
*
|
|
97
|
-
* This type provides a uniform way to handle both success and error
|
|
98
|
-
* outcomes of HTTP requests, similar to a `Result` or `Either` monad.
|
|
99
|
-
*
|
|
100
|
-
* It ensures that every HTTP response can be handled in a type-safe,
|
|
101
|
-
* predictable way without throwing exceptions.
|
|
102
|
-
*
|
|
103
|
-
* @template T The type of the successful response data.
|
|
104
|
-
*
|
|
105
|
-
* @property {boolean} ok
|
|
106
|
-
* Indicates whether the HTTP request was successful (`true` for success, `false` for error).
|
|
107
|
-
* This is analogous to `Response.ok` in the Fetch API.
|
|
108
|
-
*
|
|
109
|
-
* @property {number} status
|
|
110
|
-
* The numeric HTTP status code (e.g., 200, 404, 500).
|
|
111
|
-
*
|
|
112
|
-
* @property {T} [data]
|
|
113
|
-
* The parsed response payload, present only when `ok` is `true`.
|
|
114
|
-
*
|
|
115
|
-
* @property {string} [message]
|
|
116
|
-
* An optional human-readable error message or diagnostic information,
|
|
117
|
-
* typically provided when `ok` is `false`.
|
|
118
|
-
*
|
|
119
|
-
* ## Worker APIs
|
|
120
|
-
*
|
|
121
|
-
* HttpResult is a first-class-citizen in the grammar in Cloesce. Methods can return HttpResults
|
|
122
|
-
* which will be serialized on the client api.
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* bar(): HttpResult<Integer> {
|
|
127
|
-
* return { ok: false, status: 401, message: "forbidden"}
|
|
128
|
-
* }
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export type HttpResult<T = unknown> = {
|
|
132
|
-
ok: boolean;
|
|
133
|
-
status: number;
|
|
134
|
-
data?: T;
|
|
135
|
-
message?: string;
|
|
136
|
-
};
|
|
137
|
-
export type KeysOfType<T, U> = {
|
|
138
|
-
[K in keyof T]: T[K] extends U ? (K extends string ? K : never) : never;
|
|
139
|
-
}[keyof T];
|
|
140
|
-
export type CrudKind = "SAVE" | "GET" | "LIST";
|
|
141
|
-
export type CidlType = "Void" | "Integer" | "Real" | "Text" | "Blob" | "DateIso" | "Boolean" | {
|
|
142
|
-
DataSource: string;
|
|
143
|
-
} | {
|
|
144
|
-
Inject: string;
|
|
145
|
-
} | {
|
|
146
|
-
Object: string;
|
|
147
|
-
} | {
|
|
148
|
-
Partial: string;
|
|
149
|
-
} | {
|
|
150
|
-
Nullable: CidlType;
|
|
151
|
-
} | {
|
|
152
|
-
Array: CidlType;
|
|
153
|
-
} | {
|
|
154
|
-
HttpResult: CidlType;
|
|
155
|
-
};
|
|
156
|
-
export declare function isNullableType(ty: CidlType): boolean;
|
|
157
|
-
export declare enum HttpVerb {
|
|
158
|
-
GET = "GET",
|
|
159
|
-
POST = "POST",
|
|
160
|
-
PUT = "PUT",
|
|
161
|
-
PATCH = "PATCH",
|
|
162
|
-
DELETE = "DELETE"
|
|
163
|
-
}
|
|
164
|
-
export interface NamedTypedValue {
|
|
165
|
-
name: string;
|
|
166
|
-
cidl_type: CidlType;
|
|
167
|
-
}
|
|
168
|
-
export interface ModelAttribute {
|
|
169
|
-
value: NamedTypedValue;
|
|
170
|
-
foreign_key_reference: string | null;
|
|
171
|
-
}
|
|
172
|
-
export interface ModelMethod {
|
|
173
|
-
name: string;
|
|
174
|
-
is_static: boolean;
|
|
175
|
-
http_verb: HttpVerb;
|
|
176
|
-
return_type: CidlType | null;
|
|
177
|
-
parameters: NamedTypedValue[];
|
|
178
|
-
}
|
|
179
|
-
export type NavigationPropertyKind = {
|
|
180
|
-
OneToOne: {
|
|
181
|
-
reference: string;
|
|
182
|
-
};
|
|
183
|
-
} | {
|
|
184
|
-
OneToMany: {
|
|
185
|
-
reference: string;
|
|
186
|
-
};
|
|
187
|
-
} | {
|
|
188
|
-
ManyToMany: {
|
|
189
|
-
unique_id: string;
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
export interface NavigationProperty {
|
|
193
|
-
var_name: string;
|
|
194
|
-
model_name: string;
|
|
195
|
-
kind: NavigationPropertyKind;
|
|
196
|
-
}
|
|
197
|
-
export declare function getNavigationPropertyCidlType(nav: NavigationProperty): CidlType;
|
|
198
|
-
export interface Model {
|
|
199
|
-
name: string;
|
|
200
|
-
primary_key: NamedTypedValue;
|
|
201
|
-
attributes: ModelAttribute[];
|
|
202
|
-
navigation_properties: NavigationProperty[];
|
|
203
|
-
methods: Record<string, ModelMethod>;
|
|
204
|
-
data_sources: Record<string, DataSource>;
|
|
205
|
-
cruds: CrudKind[];
|
|
206
|
-
source_path: string;
|
|
207
|
-
}
|
|
208
|
-
export interface PlainOldObject {
|
|
209
|
-
name: string;
|
|
210
|
-
attributes: NamedTypedValue[];
|
|
211
|
-
source_path: string;
|
|
212
|
-
}
|
|
213
|
-
export interface CidlIncludeTree {
|
|
214
|
-
[key: string]: CidlIncludeTree;
|
|
215
|
-
}
|
|
216
|
-
export declare const NO_DATA_SOURCE = "none";
|
|
217
|
-
export interface DataSource {
|
|
218
|
-
name: string;
|
|
219
|
-
tree: CidlIncludeTree;
|
|
220
|
-
}
|
|
221
|
-
export interface WranglerEnv {
|
|
222
|
-
name: string;
|
|
223
|
-
source_path: string;
|
|
224
|
-
db_binding: string;
|
|
225
|
-
vars: Record<string, CidlType>;
|
|
226
|
-
}
|
|
227
|
-
export interface CloesceAst {
|
|
228
|
-
version: string;
|
|
229
|
-
project_name: string;
|
|
230
|
-
language: string;
|
|
231
|
-
wrangler_env: WranglerEnv;
|
|
232
|
-
models: Record<string, Model>;
|
|
233
|
-
poos: Record<string, PlainOldObject>;
|
|
234
|
-
app_source: string | null;
|
|
235
|
-
}
|
|
236
|
-
export {};
|
|
237
|
-
//# sourceMappingURL=common.d.ts.map
|
package/dist/common.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC5B,aAAa,IAAA;IACb,uBAAu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AM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACrC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
|
package/dist/common.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
export var ExtractorErrorCode;
|
|
2
|
-
(function (ExtractorErrorCode) {
|
|
3
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingExport"] = 0] = "MissingExport";
|
|
4
|
-
ExtractorErrorCode[ExtractorErrorCode["AppMissingDefaultExport"] = 1] = "AppMissingDefaultExport";
|
|
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["InvalidIncludeTree"] = 6] = "InvalidIncludeTree";
|
|
10
|
-
ExtractorErrorCode[ExtractorErrorCode["InvalidAttributeModifier"] = 7] = "InvalidAttributeModifier";
|
|
11
|
-
ExtractorErrorCode[ExtractorErrorCode["InvalidApiMethodModifier"] = 8] = "InvalidApiMethodModifier";
|
|
12
|
-
ExtractorErrorCode[ExtractorErrorCode["UnknownNavigationPropertyReference"] = 9] = "UnknownNavigationPropertyReference";
|
|
13
|
-
ExtractorErrorCode[ExtractorErrorCode["InvalidNavigationPropertyReference"] = 10] = "InvalidNavigationPropertyReference";
|
|
14
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingNavigationPropertyReference"] = 11] = "MissingNavigationPropertyReference";
|
|
15
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingManyToManyUniqueId"] = 12] = "MissingManyToManyUniqueId";
|
|
16
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingPrimaryKey"] = 13] = "MissingPrimaryKey";
|
|
17
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingDatabaseBinding"] = 14] = "MissingDatabaseBinding";
|
|
18
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingWranglerEnv"] = 15] = "MissingWranglerEnv";
|
|
19
|
-
ExtractorErrorCode[ExtractorErrorCode["TooManyWranglerEnvs"] = 16] = "TooManyWranglerEnvs";
|
|
20
|
-
ExtractorErrorCode[ExtractorErrorCode["MissingFile"] = 17] = "MissingFile";
|
|
21
|
-
})(ExtractorErrorCode || (ExtractorErrorCode = {}));
|
|
22
|
-
const errorInfoMap = {
|
|
23
|
-
[ExtractorErrorCode.MissingExport]: {
|
|
24
|
-
description: "All Cloesce types must be exported.",
|
|
25
|
-
suggestion: "Add `export` to the class definition.",
|
|
26
|
-
},
|
|
27
|
-
[ExtractorErrorCode.AppMissingDefaultExport]: {
|
|
28
|
-
description: "app.cloesce.ts does not export a CloesceApp by default",
|
|
29
|
-
suggestion: "Export an instantiated CloesceApp in app.cloesce.ts",
|
|
30
|
-
},
|
|
31
|
-
[ExtractorErrorCode.UnknownType]: {
|
|
32
|
-
description: "Encountered an unknown or unsupported type",
|
|
33
|
-
suggestion: "Refer to the documentation on valid Cloesce TS types",
|
|
34
|
-
},
|
|
35
|
-
[ExtractorErrorCode.InvalidPartialType]: {
|
|
36
|
-
description: "Partial types must only contain a model or plain old object",
|
|
37
|
-
suggestion: "Refer to the documentation on valid Cloesce TS types",
|
|
38
|
-
},
|
|
39
|
-
[ExtractorErrorCode.MultipleGenericType]: {
|
|
40
|
-
description: "Cloesce does not yet support types with multiple generics",
|
|
41
|
-
suggestion: "Simplify your type to use only a single generic parameter, ie Foo<T>",
|
|
42
|
-
},
|
|
43
|
-
[ExtractorErrorCode.InvalidDataSourceDefinition]: {
|
|
44
|
-
description: "Data Sources must be explicitly typed as a static Include Tree",
|
|
45
|
-
suggestion: "Declare your data source as `static readonly _: IncludeTree<Model>`",
|
|
46
|
-
},
|
|
47
|
-
[ExtractorErrorCode.InvalidIncludeTree]: {
|
|
48
|
-
description: "Invalid Include Tree",
|
|
49
|
-
suggestion: "Include trees must only contain references to a model's navigation properties.",
|
|
50
|
-
},
|
|
51
|
-
[ExtractorErrorCode.InvalidAttributeModifier]: {
|
|
52
|
-
description: "Attributes can only be public on a Model, Plain Old Object or Wrangler Environment",
|
|
53
|
-
suggestion: "Change the attribute modifier to just `public`",
|
|
54
|
-
},
|
|
55
|
-
[ExtractorErrorCode.InvalidApiMethodModifier]: {
|
|
56
|
-
description: "Model methods must be public if they are decorated as GET, POST, PUT, PATCH",
|
|
57
|
-
suggestion: "Change the method modifier to just `public`",
|
|
58
|
-
},
|
|
59
|
-
[ExtractorErrorCode.UnknownNavigationPropertyReference]: {
|
|
60
|
-
description: "Unknown Navigation Property Reference",
|
|
61
|
-
suggestion: "Verify that the navigation property reference model exists, or create a model.",
|
|
62
|
-
},
|
|
63
|
-
[ExtractorErrorCode.InvalidNavigationPropertyReference]: {
|
|
64
|
-
description: "Invalid Navigation Property Reference",
|
|
65
|
-
suggestion: "Ensure the navigation property points to a valid model field",
|
|
66
|
-
},
|
|
67
|
-
[ExtractorErrorCode.MissingNavigationPropertyReference]: {
|
|
68
|
-
description: "Missing Navigation Property Reference",
|
|
69
|
-
suggestion: "Navigation properties require a foreign key model attribute reference",
|
|
70
|
-
},
|
|
71
|
-
[ExtractorErrorCode.MissingManyToManyUniqueId]: {
|
|
72
|
-
description: "Missing unique id on Many to Many navigation property",
|
|
73
|
-
suggestion: "Define a unique identifier field for the Many-to-Many relationship",
|
|
74
|
-
},
|
|
75
|
-
[ExtractorErrorCode.MissingPrimaryKey]: {
|
|
76
|
-
description: "Missing primary key on a model",
|
|
77
|
-
suggestion: "Add a primary key field to your model (e.g., `id: number`)",
|
|
78
|
-
},
|
|
79
|
-
[ExtractorErrorCode.MissingDatabaseBinding]: {
|
|
80
|
-
description: "Missing a database binding in the WranglerEnv definition",
|
|
81
|
-
suggestion: "Add a `D1Database` to your WranglerEnv",
|
|
82
|
-
},
|
|
83
|
-
[ExtractorErrorCode.MissingWranglerEnv]: {
|
|
84
|
-
description: "Missing a wrangler environment definition in the project",
|
|
85
|
-
suggestion: "Add a @WranglerEnv class in your project.",
|
|
86
|
-
},
|
|
87
|
-
[ExtractorErrorCode.TooManyWranglerEnvs]: {
|
|
88
|
-
description: "Too many wrangler environments defined in the project",
|
|
89
|
-
suggestion: "Consolidate or remove unused @WranglerEnv's",
|
|
90
|
-
},
|
|
91
|
-
[ExtractorErrorCode.MissingFile]: {
|
|
92
|
-
description: "A specified input file could not be found",
|
|
93
|
-
suggestion: "Verify the input file path is correct",
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
export function getErrorInfo(code) {
|
|
97
|
-
return errorInfoMap[code];
|
|
98
|
-
}
|
|
99
|
-
export class ExtractorError {
|
|
100
|
-
code;
|
|
101
|
-
context;
|
|
102
|
-
snippet;
|
|
103
|
-
constructor(code) {
|
|
104
|
-
this.code = code;
|
|
105
|
-
}
|
|
106
|
-
addContext(fn) {
|
|
107
|
-
this.context = fn(this.context ?? "");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export class Either {
|
|
111
|
-
inner;
|
|
112
|
-
constructor(inner) {
|
|
113
|
-
this.inner = inner;
|
|
114
|
-
}
|
|
115
|
-
get value() {
|
|
116
|
-
return this.inner.ok ? this.inner.right : this.inner.left;
|
|
117
|
-
}
|
|
118
|
-
static left(value) {
|
|
119
|
-
return new Either({ ok: false, left: value });
|
|
120
|
-
}
|
|
121
|
-
static right(value) {
|
|
122
|
-
return new Either({ ok: true, right: value });
|
|
123
|
-
}
|
|
124
|
-
isLeft() {
|
|
125
|
-
return !this.inner.ok;
|
|
126
|
-
}
|
|
127
|
-
isRight() {
|
|
128
|
-
return this.inner.ok;
|
|
129
|
-
}
|
|
130
|
-
unwrap() {
|
|
131
|
-
if (!this.inner.ok) {
|
|
132
|
-
throw new Error("Tried to unwrap a Left value");
|
|
133
|
-
}
|
|
134
|
-
return this.inner.right;
|
|
135
|
-
}
|
|
136
|
-
unwrapLeft() {
|
|
137
|
-
if (this.inner.ok) {
|
|
138
|
-
throw new Error("Tried to unwrapLeft a Right value");
|
|
139
|
-
}
|
|
140
|
-
return this.inner.left;
|
|
141
|
-
}
|
|
142
|
-
map(fn) {
|
|
143
|
-
return this.inner.ok
|
|
144
|
-
? Either.right(fn(this.inner.right))
|
|
145
|
-
: Either.left(this.inner.left);
|
|
146
|
-
}
|
|
147
|
-
mapLeft(fn) {
|
|
148
|
-
return this.inner.ok
|
|
149
|
-
? Either.right(this.inner.right)
|
|
150
|
-
: Either.left(fn(this.inner.left));
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
export function isNullableType(ty) {
|
|
154
|
-
return typeof ty === "object" && ty !== null && "Nullable" in ty;
|
|
155
|
-
}
|
|
156
|
-
export var HttpVerb;
|
|
157
|
-
(function (HttpVerb) {
|
|
158
|
-
HttpVerb["GET"] = "GET";
|
|
159
|
-
HttpVerb["POST"] = "POST";
|
|
160
|
-
HttpVerb["PUT"] = "PUT";
|
|
161
|
-
HttpVerb["PATCH"] = "PATCH";
|
|
162
|
-
HttpVerb["DELETE"] = "DELETE";
|
|
163
|
-
})(HttpVerb || (HttpVerb = {}));
|
|
164
|
-
export function getNavigationPropertyCidlType(nav) {
|
|
165
|
-
return "OneToOne" in nav.kind
|
|
166
|
-
? { Object: nav.model_name }
|
|
167
|
-
: { Array: { Object: nav.model_name } };
|
|
168
|
-
}
|
|
169
|
-
export const NO_DATA_SOURCE = "none";
|