cloesce 0.0.3-fix.1 → 0.0.3-fix.3

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/cloesce.d.ts DELETED
@@ -1,108 +0,0 @@
1
- import { D1Database } from "@cloudflare/workers-types/experimental/index.js";
2
- import { HttpResult, Either, ModelMethod, CloesceAst, Model } from "./common.js";
3
- import { IncludeTree } from "./index.js";
4
- /**
5
- * A map of model names to their respective constructor.
6
- *
7
- * The value accepted into the `cloesce` function is generated by the Cloesce compiler, and
8
- * is guaranteed to contain all model definitions.
9
- */
10
- type ModelConstructorRegistry = Record<string, new () => UserDefinedModel>;
11
- /**
12
- * A dependency injection container, mapping an object type name to an instance of that object.
13
- *
14
- * The value accepted into the `cloesce` function is generated by the Cloesce compiler, and is
15
- * guaranteed to contain all injected model method parameters.
16
- */
17
- type InstanceRegistry = Map<string, any>;
18
- /**
19
- * Users will create Cloesce models, which have metadata for them in the ast.
20
- * For TypeScript's purposes, these models can be anything. We can assume any
21
- * `UserDefinedModel` has been verified by the compiler.
22
- */
23
- type UserDefinedModel = any;
24
- type InstantiatedUserDefinedModel = object;
25
- /**
26
- * Given a request, this represents a map of each body / url param name to
27
- * its actual value. Unknown, as the a request can be anything.
28
- */
29
- type RequestParamMap = Record<string, unknown>;
30
- /**
31
- * Meta information on the wrangler env and db bindings
32
- */
33
- interface MetaWranglerEnv {
34
- envName: string;
35
- dbName: string;
36
- }
37
- /**
38
- * Creates model instances given a properly formatted SQL record
39
- * (either a foreign-key-less model or derived from a Cloesce generated view)
40
- * @param ctor The type of the model
41
- * @param records SQL records
42
- * @param includeTree The include tree to use when parsing the records
43
- * @returns
44
- */
45
- export declare function modelsFromSql<T>(ctor: new () => T, records: Record<string, any>[], includeTree: IncludeTree<T> | null): T[];
46
- /**
47
- * Cloesce entry point. Given a request, undergoes routing, validating,
48
- * hydrating, and method dispatch.
49
- * @param ast The CIDL AST
50
- * @param constructorRegistry A mapping of user defined class names to their respective constructor
51
- * @param instanceRegistry A mapping of a dependency class name to its instantiated object.
52
- * @param request An incoming request to the workers server
53
- * @param api_route The url's path to the api, e.g. api/v1/fooapi/
54
- * @param envMeta Meta information on the wrangler env and D1 databases
55
- * @returns A Response with an `HttpResult` JSON body.
56
- */
57
- export declare function cloesce(request: Request, ast: CloesceAst, constructorRegistry: ModelConstructorRegistry, instanceRegistry: InstanceRegistry, envMeta: MetaWranglerEnv, api_route: string): Promise<Response>;
58
- /**
59
- * Matches a request to a method on a model.
60
- * @param api_route The route from the domain to the actual API, ie https://foo.com/route/to/api => route/to/api/
61
- * @returns 404 or a `MatchedRoute`
62
- */
63
- declare function matchRoute(request: Request, ast: CloesceAst, api_route: string): Either<HttpResult, MatchedRoute>;
64
- /**
65
- * Validates the request's body/search params against a ModelMethod
66
- * @returns 400 or a `RequestParamMap` consisting of each parameters name mapped to its value, and
67
- * a data source
68
- */
69
- declare function validateRequest(request: Request, ast: CloesceAst, model: Model, method: ModelMethod, id: string | null): Promise<Either<HttpResult, [RequestParamMap, string | null]>>;
70
- /**
71
- * Queries D1 for a particular model's ID, then transforms the SQL column output into
72
- * an instance of a model using the provided include tree and metadata as a guide.
73
- * @returns 404 if no record was found for the provided ID
74
- * @returns 500 if the D1 database is not synced with Cloesce and yields an error
75
- * @returns The instantiated model on success
76
- */
77
- declare function hydrateModel(ast: CloesceAst, constructorRegistry: ModelConstructorRegistry, d1: D1Database, model: Model, id: string, dataSource: string | null): Promise<Either<HttpResult, object>>;
78
- /**
79
- * Calls a method on a model given a list of parameters.
80
- * @returns 500 on an uncaught client error, 200 with a result body on success
81
- */
82
- declare function methodDispatch(instance: InstantiatedUserDefinedModel, instanceRegistry: InstanceRegistry, envMeta: MetaWranglerEnv, method: ModelMethod, params: Record<string, unknown>): Promise<HttpResult<unknown>>;
83
- /**
84
- * Actual implementation of sql to model mapping.
85
- *
86
- * TODO: If we don't want to write this in every language, would it be possible to create a
87
- * single WASM binary for this method?
88
- *
89
- * @throws generic errors if the metadata is missing some value
90
- */
91
- declare function _modelsFromSql(modelName: string, ast: CloesceAst, constructorRegistry: ModelConstructorRegistry, records: Record<string, any>[], includeTree: Record<string, UserDefinedModel> | null): InstantiatedUserDefinedModel[];
92
- interface MatchedRoute {
93
- model: Model;
94
- method: ModelMethod;
95
- id: string | null;
96
- }
97
- /**
98
- * Each individual state of the `cloesce` function for testing purposes.
99
- */
100
- export declare const _cloesceInternal: {
101
- matchRoute: typeof matchRoute;
102
- validateRequest: typeof validateRequest;
103
- hydrateModel: typeof hydrateModel;
104
- methodDispatch: typeof methodDispatch;
105
- _modelsFromSql: typeof _modelsFromSql;
106
- };
107
- export {};
108
- //# sourceMappingURL=cloesce.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cloesce.d.ts","sourceRoot":"","sources":["../src/cloesce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iDAAiD,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,MAAM,EACN,WAAW,EAIX,UAAU,EAEV,KAAK,EAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC;;;;;GAKG;AACH,KAAK,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,gBAAgB,CAAC,CAAC;AAE3E;;;;;GAKG;AACH,KAAK,gBAAgB,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAwBzC;;;;GAIG;AACH,KAAK,gBAAgB,GAAG,GAAG,CAAC;AAC5B,KAAK,4BAA4B,GAAG,MAAM,CAAC;AAE3C;;;GAGG;AACH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/C;;GAEG;AACH,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC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AM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAoC9B;AA4ED;;;;;;;GAOG;AACH,iBAAS,cAAc,CACrB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,UAAU,EACf,mBAAmB,EAAE,wBAAwB,EAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,IAAI,GACnD,4BAA4B,EAAE,CA8MhC;AAaD,UAAU,YAAY;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC"}
package/dist/common.d.ts DELETED
@@ -1,96 +0,0 @@
1
- export type Either<L, R> = {
2
- ok: false;
3
- value: L;
4
- } | {
5
- ok: true;
6
- value: R;
7
- };
8
- export declare function left<L>(value: L): Either<L, never>;
9
- export declare function right<R>(value: R): Either<never, R>;
10
- export type HttpResult<T = unknown> = {
11
- ok: boolean;
12
- status: number;
13
- data?: T;
14
- message?: string;
15
- };
16
- export type CidlType = "Void" | "Integer" | "Real" | "Text" | "Blob" | {
17
- Inject: string;
18
- } | {
19
- Model: string;
20
- } | {
21
- Nullable: CidlType;
22
- } | {
23
- Array: CidlType;
24
- } | {
25
- HttpResult: CidlType;
26
- };
27
- export declare function isNullableType(ty: CidlType): boolean;
28
- export declare enum HttpVerb {
29
- GET = "GET",
30
- POST = "POST",
31
- PUT = "PUT",
32
- PATCH = "PATCH",
33
- DELETE = "DELETE"
34
- }
35
- export interface NamedTypedValue {
36
- name: string;
37
- cidl_type: CidlType;
38
- }
39
- export interface ModelAttribute {
40
- value: NamedTypedValue;
41
- foreign_key_reference: string | null;
42
- }
43
- export interface ModelMethod {
44
- name: string;
45
- is_static: boolean;
46
- http_verb: HttpVerb;
47
- return_type: CidlType | null;
48
- parameters: NamedTypedValue[];
49
- }
50
- export type NavigationPropertyKind = {
51
- OneToOne: {
52
- reference: string;
53
- };
54
- } | {
55
- OneToMany: {
56
- reference: string;
57
- };
58
- } | {
59
- ManyToMany: {
60
- unique_id: string;
61
- };
62
- };
63
- export interface NavigationProperty {
64
- var_name: string;
65
- model_name: string;
66
- kind: NavigationPropertyKind;
67
- }
68
- export declare function getNavigationPropertyCidlType(nav: NavigationProperty): CidlType;
69
- export interface Model {
70
- name: string;
71
- primary_key: NamedTypedValue;
72
- attributes: ModelAttribute[];
73
- navigation_properties: NavigationProperty[];
74
- methods: Record<string, ModelMethod>;
75
- data_sources: Record<string, DataSource>;
76
- source_path: string;
77
- }
78
- export interface CidlIncludeTree {
79
- [key: string]: CidlIncludeTree;
80
- }
81
- export interface DataSource {
82
- name: string;
83
- tree: CidlIncludeTree;
84
- }
85
- export interface WranglerEnv {
86
- name: string;
87
- source_path: string;
88
- }
89
- export interface CloesceAst {
90
- version: string;
91
- project_name: string;
92
- language: "TypeScript";
93
- wrangler_env: WranglerEnv;
94
- models: Record<string, Model>;
95
- }
96
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC;AAC5E,wBAAgB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAElD;AACD,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC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E,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GACpC;IAAE,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,kBAAkB,GACtB,QAAQ,CAIV;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,eAAe,CAAC;IAC7B,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACzC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;CAChC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B"}
@@ -1,13 +0,0 @@
1
- import type { Handler } from "./types.js";
2
- /** Use as @GET (no parentheses) */
3
- export declare function GET(_value: Handler, _ctx: ClassMethodDecoratorContext): void;
4
- /** Use as @POST (no parentheses) */
5
- export declare function POST(_value: Handler, _ctx: ClassMethodDecoratorContext): void;
6
- export declare function PUT(_value: Handler, _ctx: ClassMethodDecoratorContext): void;
7
- export declare function PATCH(_value: Handler, _ctx: ClassMethodDecoratorContext): void;
8
- export declare function DELETE(_value: Handler, _ctx: ClassMethodDecoratorContext): void;
9
- /** Class decorator (no-op) */
10
- export declare function D1<T extends new (...a: any[]) => object>(value: T, _ctx: ClassDecoratorContext<T>): T;
11
- /** Field decorator (no-op) */
12
- export declare function PrimaryKey(_v: undefined, _ctx: ClassFieldDecoratorContext): void;
13
- //# sourceMappingURL=decorators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,mCAAmC;AACnC,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,QAAI;AAE1E,oCAAoC;AACpC,wBAAgB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,QAAI;AAE3E,wBAAgB,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,QAAI;AAE1E,wBAAgB,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,QAAI;AAE5E,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,QAAI;AAE7E,8BAA8B;AAC9B,wBAAgB,EAAE,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,MAAM,EACtD,KAAK,EAAE,CAAC,EACR,IAAI,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAG/B;AAED,8BAA8B;AAC9B,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,0BAA0B,QAAI"}
@@ -1,13 +0,0 @@
1
- /** Use as @GET (no parentheses) */
2
- export function GET(_value, _ctx) { }
3
- /** Use as @POST (no parentheses) */
4
- export function POST(_value, _ctx) { }
5
- export function PUT(_value, _ctx) { }
6
- export function PATCH(_value, _ctx) { }
7
- export function DELETE(_value, _ctx) { }
8
- /** Class decorator (no-op) */
9
- export function D1(value, _ctx) {
10
- return value;
11
- }
12
- /** Field decorator (no-op) */
13
- export function PrimaryKey(_v, _ctx) { }
@@ -1,111 +0,0 @@
1
- var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
2
- function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
3
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
4
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
5
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
6
- var _, done = false;
7
- for (var i = decorators.length - 1; i >= 0; i--) {
8
- var context = {};
9
- for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
10
- for (var p in contextIn.access) context.access[p] = contextIn.access[p];
11
- context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
12
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
13
- if (kind === "accessor") {
14
- if (result === void 0) continue;
15
- if (result === null || typeof result !== "object") throw new TypeError("Object expected");
16
- if (_ = accept(result.get)) descriptor.get = _;
17
- if (_ = accept(result.set)) descriptor.set = _;
18
- if (_ = accept(result.init)) initializers.unshift(_);
19
- }
20
- else if (_ = accept(result)) {
21
- if (kind === "field") initializers.unshift(_);
22
- else descriptor[key] = _;
23
- }
24
- }
25
- if (target) Object.defineProperty(target, contextIn.name, descriptor);
26
- done = true;
27
- };
28
- var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
29
- var useValue = arguments.length > 2;
30
- for (var i = 0; i < initializers.length; i++) {
31
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
32
- }
33
- return useValue ? value : void 0;
34
- };
35
- import { WranglerEnv } from './cloesce.js'; // adjust import path
36
- let MyEnvironment = (() => {
37
- let _classDecorators = [WranglerEnv({
38
- name: "my-worker",
39
- compatibility_date: "2024-01-01"
40
- })];
41
- let _classDescriptor;
42
- let _classExtraInitializers = [];
43
- let _classThis;
44
- var MyEnvironment = class {
45
- static { _classThis = this; }
46
- static {
47
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
48
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
49
- MyEnvironment = _classThis = _classDescriptor.value;
50
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
51
- __runInitializers(_classThis, _classExtraInitializers);
52
- }
53
- };
54
- return MyEnvironment = _classThis;
55
- })();
56
- let Dog = (() => {
57
- let _classDecorators = [D1];
58
- let _classDescriptor;
59
- let _classExtraInitializers = [];
60
- let _classThis;
61
- let _staticExtraInitializers = [];
62
- let _instanceExtraInitializers = [];
63
- let _static_woof_decorators;
64
- let _id_decorators;
65
- let _id_initializers = [];
66
- let _id_extraInitializers = [];
67
- let _get_name_decorators;
68
- let _get_breed_decorators;
69
- var Dog = class {
70
- static { _classThis = this; }
71
- static {
72
- const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
73
- _id_decorators = [PrimaryKey];
74
- _get_name_decorators = [GET];
75
- _get_breed_decorators = [GET];
76
- _static_woof_decorators = [POST];
77
- __esDecorate(this, null, _static_woof_decorators, { kind: "method", name: "woof", static: true, private: false, access: { has: obj => "woof" in obj, get: obj => obj.woof }, metadata: _metadata }, null, _staticExtraInitializers);
78
- __esDecorate(this, null, _get_name_decorators, { kind: "method", name: "get_name", static: false, private: false, access: { has: obj => "get_name" in obj, get: obj => obj.get_name }, metadata: _metadata }, null, _instanceExtraInitializers);
79
- __esDecorate(this, null, _get_breed_decorators, { kind: "method", name: "get_breed", static: false, private: false, access: { has: obj => "get_breed" in obj, get: obj => obj.get_breed }, metadata: _metadata }, null, _instanceExtraInitializers);
80
- __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
81
- __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
82
- Dog = _classThis = _classDescriptor.value;
83
- if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
84
- __runInitializers(_classThis, _staticExtraInitializers);
85
- __runInitializers(_classThis, _classExtraInitializers);
86
- }
87
- id = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _id_initializers, void 0));
88
- name = __runInitializers(this, _id_extraInitializers);
89
- breed;
90
- preferred_treat;
91
- async get_name(db, req) {
92
- const who = new URL(req.url).searchParams.get("name");
93
- return new Response(JSON.stringify({ hello: who }), {
94
- headers: { "content-type": "application/json" },
95
- });
96
- }
97
- async get_breed(db, req) {
98
- const breed = new URL(req.url).searchParams.get("breed");
99
- return new Response(JSON.stringify({ hello: breed }), {
100
- headers: { "content-type": "application/json" },
101
- });
102
- }
103
- static async woof(db, req, phrase) {
104
- return new Response(JSON.stringify({ phrase }), {
105
- status: 201,
106
- headers: { "content-type": "application/json" },
107
- });
108
- }
109
- };
110
- return Dog = _classThis;
111
- })();
package/dist/extract.d.ts DELETED
@@ -1,14 +0,0 @@
1
- import { Project } from "ts-morph";
2
- import { CloesceAst, Either } from "./common.js";
3
- export declare class CidlExtractor {
4
- projectName: string;
5
- version: string;
6
- constructor(projectName: string, version: string);
7
- extract(project: Project): Either<string, CloesceAst>;
8
- private static model;
9
- private static readonly primTypeMap;
10
- private static cidlType;
11
- private static includeTree;
12
- private static method;
13
- }
14
- //# sourceMappingURL=extract.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EASR,MAAM,UAAU,CAAC;AAElB,OAAO,EAEL,UAAU,EAGV,MAAM,EAUP,MAAM,aAAa,CAAC;AAqBrB,qBAAa,aAAa;IAEf,WAAW,EAAE,MAAM;IACnB,OAAO,EAAE,MAAM;gBADf,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM;IAGxB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;IA8CrD,OAAO,CAAC,MAAM,CAAC,KAAK;IA+KpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAQjC;IAEF,OAAO,CAAC,MAAM,CAAC,QAAQ;IAgGvB,OAAO,CAAC,MAAM,CAAC,WAAW;IA8D1B,OAAO,CAAC,MAAM,CAAC,MAAM;CAqDtB"}
package/dist/index.d.ts DELETED
@@ -1,24 +0,0 @@
1
- export { cloesce, modelsFromSql } from "./cloesce.js";
2
- export { HttpResult } from "./common.js";
3
- export declare const D1: ClassDecorator;
4
- export declare const WranglerEnv: ClassDecorator;
5
- export declare const PrimaryKey: PropertyDecorator;
6
- export declare const GET: MethodDecorator;
7
- export declare const POST: MethodDecorator;
8
- export declare const PUT: MethodDecorator;
9
- export declare const PATCH: MethodDecorator;
10
- export declare const DELETE: MethodDecorator;
11
- export declare const DataSource: PropertyDecorator;
12
- export declare const OneToMany: (_: string) => PropertyDecorator;
13
- export declare const OneToOne: (_: string) => PropertyDecorator;
14
- export declare const ManyToMany: (_: string) => PropertyDecorator;
15
- export declare const ForeignKey: <T>(_: T) => PropertyDecorator;
16
- export declare const Inject: ParameterDecorator;
17
- type Primitive = string | number | boolean | bigint | symbol | null | undefined;
18
- export type IncludeTree<T> = T extends Primitive ? never : {
19
- [K in keyof T]?: T[K] extends (infer U)[] ? IncludeTree<NonNullable<U>> : IncludeTree<NonNullable<T[K]>>;
20
- };
21
- export declare function instantiateModelArray<T extends object>(data: any, ctor: {
22
- new (): T;
23
- }): T[];
24
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,eAAO,MAAM,EAAE,EAAE,cAAyB,CAAC;AAC3C,eAAO,MAAM,WAAW,EAAE,cAAyB,CAAC;AACpD,eAAO,MAAM,UAAU,EAAE,iBAA4B,CAAC;AACtD,eAAO,MAAM,GAAG,EAAE,eAA0B,CAAC;AAC7C,eAAO,MAAM,IAAI,EAAE,eAA0B,CAAC;AAC9C,eAAO,MAAM,GAAG,EAAE,eAA0B,CAAC;AAC7C,eAAO,MAAM,KAAK,EAAE,eAA0B,CAAC;AAC/C,eAAO,MAAM,MAAM,EAAE,eAA0B,CAAC;AAChD,eAAO,MAAM,UAAU,EAAE,iBAA4B,CAAC;AACtD,eAAO,MAAM,SAAS,MAChB,MAAM,KAAG,iBACL,CAAC;AACX,eAAO,MAAM,QAAQ,MACf,MAAM,KAAG,iBACL,CAAC;AACX,eAAO,MAAM,UAAU,MACjB,MAAM,KAAG,iBACL,CAAC;AACX,eAAO,MAAM,UAAU,GACpB,CAAC,KAAK,CAAC,KAAG,iBACH,CAAC;AACX,eAAO,MAAM,MAAM,EAAE,kBAA6B,CAAC;AAGnD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAChF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAC5C,KAAK,GACL;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACrC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC3B,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC,CAAC;AAGN,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EACpD,IAAI,EAAE,GAAG,EACT,IAAI,EAAE;IAAE,QAAQ,CAAC,CAAA;CAAE,GAClB,CAAC,EAAE,CAKL"}
package/dist/types.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export interface D1Db {
2
- }
3
- export type Handler = (db: D1Db, req: Request, ...args: any[]) => Promise<Response>;
4
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,IAAI;CAAG;AAExB,MAAM,MAAM,OAAO,GAAG,CACpB,EAAE,EAAE,IAAI,EACR,GAAG,EAAE,OAAO,EACZ,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,OAAO,CAAC,QAAQ,CAAC,CAAC"}
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};