@teamkeel/functions-runtime 0.412.0-next.2 → 0.412.0-next.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/index.d.mts +280 -16
- package/dist/index.d.ts +280 -16
- package/dist/index.js +174 -163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +168 -164
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,276 @@
|
|
|
1
|
+
import * as kysely from 'kysely';
|
|
2
|
+
export { default as KSUID } from 'ksuid';
|
|
3
|
+
import opentelemetry from '@opentelemetry/api';
|
|
4
|
+
import * as url from 'url';
|
|
5
|
+
import * as buffer from 'buffer';
|
|
6
|
+
import parseInterval from 'postgres-interval';
|
|
7
|
+
|
|
8
|
+
declare namespace ErrorPresets {
|
|
9
|
+
export { NotFoundError$1 as NotFound };
|
|
10
|
+
export { BadRequestError as BadRequest };
|
|
11
|
+
export { UnknownError as Unknown };
|
|
12
|
+
}
|
|
13
|
+
declare class NotFoundError$1 extends Error {
|
|
14
|
+
constructor(message: any);
|
|
15
|
+
errorCode: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* QueryContext is used to store state about the current query, for example
|
|
20
|
+
* which joins have already been applied. It is used by applyJoins and
|
|
21
|
+
* applyWhereConditions to generate consistent table aliases for joins.
|
|
22
|
+
*
|
|
23
|
+
* This class has the concept of a "table path". This is just a list of tables, starting
|
|
24
|
+
* with some "root" table and ending with the table we're currently joining to. So
|
|
25
|
+
* for example if we started with a "product" table and joined from there to "order_item"
|
|
26
|
+
* and then to "order" and then to "customer" the table path would be:
|
|
27
|
+
* ["product", "order_item", "order", "customer"]
|
|
28
|
+
* At this point the "current" table is "customer" and it's alias would be:
|
|
29
|
+
* "product$order_item$order$customer"
|
|
30
|
+
*/
|
|
31
|
+
declare class QueryContext {
|
|
32
|
+
/**
|
|
33
|
+
* @param {string[]} tablePath This is the path from the "root" table to the "current table".
|
|
34
|
+
* @param {import("./ModelAPI").TableConfigMap} tableConfigMap
|
|
35
|
+
* @param {string[]} joins
|
|
36
|
+
*/
|
|
37
|
+
constructor(tablePath: string[], tableConfigMap: TableConfigMap, joins?: string[]);
|
|
38
|
+
_tablePath: string[];
|
|
39
|
+
_tableConfigMap: {
|
|
40
|
+
[x: string]: {
|
|
41
|
+
[x: string]: RelationshipConfig;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
_joins: string[];
|
|
45
|
+
clone(): QueryContext;
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if, given the current table path, a join to the given
|
|
48
|
+
* table has already been added.
|
|
49
|
+
* @param {string} table
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
hasJoin(table: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Adds table to the QueryContext's path and registers the join,
|
|
55
|
+
* calls fn, then pops the table off the path.
|
|
56
|
+
* @param {string} table
|
|
57
|
+
* @param {Function} fn
|
|
58
|
+
*/
|
|
59
|
+
withJoin(table: string, fn: Function): void;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the alias that will be used for the current table
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
tableAlias(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the current table name
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
tableName(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Return the TableConfig for the current table
|
|
72
|
+
* @returns {import("./ModelAPI").TableConfig | undefined}
|
|
73
|
+
*/
|
|
74
|
+
tableConfig(): TableConfig | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class QueryBuilder {
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} tableName
|
|
80
|
+
* @param {import("./QueryContext").QueryContext} context
|
|
81
|
+
* @param {import("kysely").Kysely} db
|
|
82
|
+
*/
|
|
83
|
+
constructor(tableName: string, context: QueryContext, db: kysely.Kysely<any>);
|
|
84
|
+
_tableName: string;
|
|
85
|
+
_context: QueryContext;
|
|
86
|
+
_db: kysely.Kysely<any>;
|
|
87
|
+
_modelName: any;
|
|
88
|
+
where(where: any): QueryBuilder;
|
|
89
|
+
sql(): any;
|
|
90
|
+
update(values: any): Promise<any>;
|
|
91
|
+
delete(): Promise<any>;
|
|
92
|
+
findOne(): Promise<any>;
|
|
93
|
+
findMany(params: any): Promise<any>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* TableConfig is an object where the keys are relationship field names
|
|
98
|
+
* (which don't exist in the database) and the values are RelationshipConfig
|
|
99
|
+
* objects describing that relationship.
|
|
100
|
+
*/
|
|
101
|
+
type RelationshipConfig = {
|
|
102
|
+
relationshipType: "belongsTo" | "hasMany";
|
|
103
|
+
foreignKey: string;
|
|
104
|
+
referencesTable: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* TableConfigMap is mapping of database table names to TableConfig objects
|
|
108
|
+
*/
|
|
109
|
+
type TableConfig = {
|
|
110
|
+
[x: string]: RelationshipConfig;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* RelationshipConfig is a simple representation of a model field that
|
|
114
|
+
* is a relationship. It is used by applyJoins and applyWhereConditions
|
|
115
|
+
* to build the correct query.
|
|
116
|
+
*/
|
|
117
|
+
type TableConfigMap = {
|
|
118
|
+
[x: string]: {
|
|
119
|
+
[x: string]: RelationshipConfig;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* RelationshipConfig is a simple representation of a model field that
|
|
124
|
+
* is a relationship. It is used by applyJoins and applyWhereConditions
|
|
125
|
+
* to build the correct query.
|
|
126
|
+
* @typedef {{
|
|
127
|
+
* relationshipType: "belongsTo" | "hasMany",
|
|
128
|
+
* foreignKey: string,
|
|
129
|
+
* referencesTable: string,
|
|
130
|
+
* }} RelationshipConfig
|
|
131
|
+
*
|
|
132
|
+
* TableConfig is an object where the keys are relationship field names
|
|
133
|
+
* (which don't exist in the database) and the values are RelationshipConfig
|
|
134
|
+
* objects describing that relationship.
|
|
135
|
+
* @typedef {Object.<string, RelationshipConfig} TableConfig
|
|
136
|
+
*
|
|
137
|
+
* TableConfigMap is mapping of database table names to TableConfig objects
|
|
138
|
+
* @typedef {Object.<string, TableConfig>} TableConfigMap
|
|
139
|
+
*/
|
|
140
|
+
declare class ModelAPI {
|
|
141
|
+
/**
|
|
142
|
+
* @param {string} tableName The name of the table this API is for
|
|
143
|
+
* @param {Function} _ Used to be a function that returns the default values for a row in this table. No longer used.
|
|
144
|
+
* @param {TableConfigMap} tableConfigMap
|
|
145
|
+
*/
|
|
146
|
+
constructor(tableName: string, _: Function, tableConfigMap?: TableConfigMap);
|
|
147
|
+
_tableName: string;
|
|
148
|
+
_tableConfigMap: {
|
|
149
|
+
[x: string]: {
|
|
150
|
+
[x: string]: RelationshipConfig;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
_modelName: any;
|
|
154
|
+
create(values: any): Promise<any>;
|
|
155
|
+
findOne(where?: {}): Promise<any>;
|
|
156
|
+
findMany(params: any): Promise<any>;
|
|
157
|
+
update(where: any, values: any): Promise<any>;
|
|
158
|
+
delete(where: any): Promise<any>;
|
|
159
|
+
where(where: any): QueryBuilder;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @type {import('./types').RequestHeaders} */
|
|
163
|
+
declare class RequestHeaders$1 {
|
|
164
|
+
/**
|
|
165
|
+
* @param {{Object.<string, string>}} requestHeaders Map of request headers submitted from the client
|
|
166
|
+
*/
|
|
167
|
+
constructor(requestHeaders: any);
|
|
168
|
+
_headers: any;
|
|
169
|
+
get(key: any): any;
|
|
170
|
+
has(key: any): any;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare function handleRequest(request: any, config: any): Promise<any>;
|
|
174
|
+
|
|
175
|
+
declare function handleJob(request: any, config: any): Promise<any>;
|
|
176
|
+
|
|
177
|
+
declare function handleSubscriber(request: any, config: any): Promise<any>;
|
|
178
|
+
|
|
179
|
+
declare function handleRoute(request: any, config: any): Promise<any>;
|
|
180
|
+
|
|
181
|
+
declare function handleFlow(request: any, config: any): Promise<any>;
|
|
182
|
+
|
|
183
|
+
declare function useDatabase(): any;
|
|
184
|
+
|
|
185
|
+
declare function checkBuiltInPermissions({ rows, permissionFns, ctx, db, functionName, }: {
|
|
186
|
+
rows: any;
|
|
187
|
+
permissionFns: any;
|
|
188
|
+
ctx: any;
|
|
189
|
+
db: any;
|
|
190
|
+
functionName: any;
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
|
|
193
|
+
declare namespace PERMISSION_STATE {
|
|
194
|
+
let UNKNOWN: string;
|
|
195
|
+
let PERMITTED: string;
|
|
196
|
+
let UNPERMITTED: string;
|
|
197
|
+
}
|
|
198
|
+
declare class Permissions {
|
|
199
|
+
allow(): void;
|
|
200
|
+
deny(): void;
|
|
201
|
+
getState(): string | undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare function getTracer(): opentelemetry.Tracer;
|
|
205
|
+
declare function withSpan(name: any, fn: any): Promise<any>;
|
|
206
|
+
declare function init(): void;
|
|
207
|
+
declare function forceFlush(): Promise<void>;
|
|
208
|
+
declare function spanNameForModelAPI(modelName: any, action: any): string;
|
|
209
|
+
|
|
210
|
+
declare const tracing_forceFlush: typeof forceFlush;
|
|
211
|
+
declare const tracing_getTracer: typeof getTracer;
|
|
212
|
+
declare const tracing_init: typeof init;
|
|
213
|
+
declare const tracing_spanNameForModelAPI: typeof spanNameForModelAPI;
|
|
214
|
+
declare const tracing_withSpan: typeof withSpan;
|
|
215
|
+
declare namespace tracing {
|
|
216
|
+
export { tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare class InlineFile$1 {
|
|
220
|
+
static fromDataURL(dataURL: any): InlineFile$1;
|
|
221
|
+
constructor({ filename, contentType }: {
|
|
222
|
+
filename: any;
|
|
223
|
+
contentType: any;
|
|
224
|
+
});
|
|
225
|
+
_filename: any;
|
|
226
|
+
_contentType: any;
|
|
227
|
+
_contents: buffer.Blob | null;
|
|
228
|
+
get size(): number;
|
|
229
|
+
get contentType(): any;
|
|
230
|
+
get filename(): any;
|
|
231
|
+
write(buffer: any): void;
|
|
232
|
+
read(): Promise<Buffer<ArrayBuffer>>;
|
|
233
|
+
store(expires?: null): Promise<File$1>;
|
|
234
|
+
}
|
|
235
|
+
declare class File$1 extends InlineFile$1 {
|
|
236
|
+
static fromDbRecord({ key, filename, size, contentType }: {
|
|
237
|
+
key: any;
|
|
238
|
+
filename: any;
|
|
239
|
+
size: any;
|
|
240
|
+
contentType: any;
|
|
241
|
+
}): File$1;
|
|
242
|
+
constructor(input: any);
|
|
243
|
+
_key: any;
|
|
244
|
+
_size: any;
|
|
245
|
+
get size(): any;
|
|
246
|
+
get key(): any;
|
|
247
|
+
read(): Promise<any>;
|
|
248
|
+
store(expires?: null): Promise<this>;
|
|
249
|
+
getPresignedUrl(): Promise<url.URL>;
|
|
250
|
+
toDbRecord(): {
|
|
251
|
+
key: any;
|
|
252
|
+
filename: any;
|
|
253
|
+
contentType: any;
|
|
254
|
+
size: any;
|
|
255
|
+
};
|
|
256
|
+
toJSON(): {
|
|
257
|
+
key: any;
|
|
258
|
+
filename: any;
|
|
259
|
+
contentType: any;
|
|
260
|
+
size: any;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare class Duration {
|
|
265
|
+
static fromISOString(isoString: any): Duration;
|
|
266
|
+
constructor(postgresString: any);
|
|
267
|
+
_typename: string;
|
|
268
|
+
pgInterval: any;
|
|
269
|
+
_interval: parseInterval.IPostgresInterval;
|
|
270
|
+
toISOString(): string;
|
|
271
|
+
toPostgres(): string;
|
|
272
|
+
}
|
|
273
|
+
|
|
1
274
|
type IDWhereCondition = {
|
|
2
275
|
equals?: string | null;
|
|
3
276
|
notEquals?: string | null;
|
|
@@ -149,24 +422,13 @@ type FileDbRecord = {
|
|
|
149
422
|
contentType: string;
|
|
150
423
|
size: number;
|
|
151
424
|
};
|
|
152
|
-
declare class Duration {
|
|
153
|
-
constructor(postgresString: string);
|
|
154
|
-
static fromISOString(iso: DurationString): Duration;
|
|
155
|
-
toISOString(): DurationString;
|
|
156
|
-
toPostgres(): string;
|
|
157
|
-
}
|
|
158
425
|
type SortDirection = "asc" | "desc" | "ASC" | "DESC";
|
|
159
426
|
type RequestHeaders = Omit<Headers, "append" | "delete" | "set">;
|
|
160
|
-
declare class Permissions {
|
|
161
|
-
constructor();
|
|
162
|
-
allow(): void;
|
|
163
|
-
deny(): never;
|
|
164
|
-
}
|
|
165
427
|
declare class NotFoundError extends Error {
|
|
166
428
|
}
|
|
167
|
-
declare class BadRequestError extends Error {
|
|
429
|
+
declare class BadRequestError$1 extends Error {
|
|
168
430
|
}
|
|
169
|
-
declare class UnknownError extends Error {
|
|
431
|
+
declare class UnknownError$1 extends Error {
|
|
170
432
|
}
|
|
171
433
|
type Errors = {
|
|
172
434
|
/**
|
|
@@ -178,12 +440,12 @@ type Errors = {
|
|
|
178
440
|
* Returns a 400 HTTP status with an optional message.
|
|
179
441
|
* This error indicates that the request made by the client is invalid or malformed.
|
|
180
442
|
*/
|
|
181
|
-
BadRequest: typeof BadRequestError;
|
|
443
|
+
BadRequest: typeof BadRequestError$1;
|
|
182
444
|
/**
|
|
183
445
|
* Returns a 500 HTTP status with an optional message.
|
|
184
446
|
* This error indicates that an unexpected condition was encountered, preventing the server from fulfilling the request.
|
|
185
447
|
*/
|
|
186
|
-
Unknown: typeof UnknownError;
|
|
448
|
+
Unknown: typeof UnknownError$1;
|
|
187
449
|
};
|
|
188
450
|
type FunctionConfig = {
|
|
189
451
|
/**
|
|
@@ -337,4 +599,6 @@ type Opts = {
|
|
|
337
599
|
timeoutInMs?: number;
|
|
338
600
|
};
|
|
339
601
|
|
|
340
|
-
|
|
602
|
+
declare function ksuid(): string;
|
|
603
|
+
|
|
604
|
+
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, File$1 as File, type FileDbRecord, type FileWriteTypes, type FlowConfig, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile$1 as InlineFile, type InlineFileConstructor, ModelAPI, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders$1 as RequestHeaders, type Response, type SortDirection, type StepContext, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, checkBuiltInPermissions, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,276 @@
|
|
|
1
|
+
import * as kysely from 'kysely';
|
|
2
|
+
export { default as KSUID } from 'ksuid';
|
|
3
|
+
import opentelemetry from '@opentelemetry/api';
|
|
4
|
+
import * as url from 'url';
|
|
5
|
+
import * as buffer from 'buffer';
|
|
6
|
+
import parseInterval from 'postgres-interval';
|
|
7
|
+
|
|
8
|
+
declare namespace ErrorPresets {
|
|
9
|
+
export { NotFoundError$1 as NotFound };
|
|
10
|
+
export { BadRequestError as BadRequest };
|
|
11
|
+
export { UnknownError as Unknown };
|
|
12
|
+
}
|
|
13
|
+
declare class NotFoundError$1 extends Error {
|
|
14
|
+
constructor(message: any);
|
|
15
|
+
errorCode: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* QueryContext is used to store state about the current query, for example
|
|
20
|
+
* which joins have already been applied. It is used by applyJoins and
|
|
21
|
+
* applyWhereConditions to generate consistent table aliases for joins.
|
|
22
|
+
*
|
|
23
|
+
* This class has the concept of a "table path". This is just a list of tables, starting
|
|
24
|
+
* with some "root" table and ending with the table we're currently joining to. So
|
|
25
|
+
* for example if we started with a "product" table and joined from there to "order_item"
|
|
26
|
+
* and then to "order" and then to "customer" the table path would be:
|
|
27
|
+
* ["product", "order_item", "order", "customer"]
|
|
28
|
+
* At this point the "current" table is "customer" and it's alias would be:
|
|
29
|
+
* "product$order_item$order$customer"
|
|
30
|
+
*/
|
|
31
|
+
declare class QueryContext {
|
|
32
|
+
/**
|
|
33
|
+
* @param {string[]} tablePath This is the path from the "root" table to the "current table".
|
|
34
|
+
* @param {import("./ModelAPI").TableConfigMap} tableConfigMap
|
|
35
|
+
* @param {string[]} joins
|
|
36
|
+
*/
|
|
37
|
+
constructor(tablePath: string[], tableConfigMap: TableConfigMap, joins?: string[]);
|
|
38
|
+
_tablePath: string[];
|
|
39
|
+
_tableConfigMap: {
|
|
40
|
+
[x: string]: {
|
|
41
|
+
[x: string]: RelationshipConfig;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
_joins: string[];
|
|
45
|
+
clone(): QueryContext;
|
|
46
|
+
/**
|
|
47
|
+
* Returns true if, given the current table path, a join to the given
|
|
48
|
+
* table has already been added.
|
|
49
|
+
* @param {string} table
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
hasJoin(table: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Adds table to the QueryContext's path and registers the join,
|
|
55
|
+
* calls fn, then pops the table off the path.
|
|
56
|
+
* @param {string} table
|
|
57
|
+
* @param {Function} fn
|
|
58
|
+
*/
|
|
59
|
+
withJoin(table: string, fn: Function): void;
|
|
60
|
+
/**
|
|
61
|
+
* Returns the alias that will be used for the current table
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
tableAlias(): string;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the current table name
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
tableName(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Return the TableConfig for the current table
|
|
72
|
+
* @returns {import("./ModelAPI").TableConfig | undefined}
|
|
73
|
+
*/
|
|
74
|
+
tableConfig(): TableConfig | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
declare class QueryBuilder {
|
|
78
|
+
/**
|
|
79
|
+
* @param {string} tableName
|
|
80
|
+
* @param {import("./QueryContext").QueryContext} context
|
|
81
|
+
* @param {import("kysely").Kysely} db
|
|
82
|
+
*/
|
|
83
|
+
constructor(tableName: string, context: QueryContext, db: kysely.Kysely<any>);
|
|
84
|
+
_tableName: string;
|
|
85
|
+
_context: QueryContext;
|
|
86
|
+
_db: kysely.Kysely<any>;
|
|
87
|
+
_modelName: any;
|
|
88
|
+
where(where: any): QueryBuilder;
|
|
89
|
+
sql(): any;
|
|
90
|
+
update(values: any): Promise<any>;
|
|
91
|
+
delete(): Promise<any>;
|
|
92
|
+
findOne(): Promise<any>;
|
|
93
|
+
findMany(params: any): Promise<any>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* TableConfig is an object where the keys are relationship field names
|
|
98
|
+
* (which don't exist in the database) and the values are RelationshipConfig
|
|
99
|
+
* objects describing that relationship.
|
|
100
|
+
*/
|
|
101
|
+
type RelationshipConfig = {
|
|
102
|
+
relationshipType: "belongsTo" | "hasMany";
|
|
103
|
+
foreignKey: string;
|
|
104
|
+
referencesTable: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* TableConfigMap is mapping of database table names to TableConfig objects
|
|
108
|
+
*/
|
|
109
|
+
type TableConfig = {
|
|
110
|
+
[x: string]: RelationshipConfig;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* RelationshipConfig is a simple representation of a model field that
|
|
114
|
+
* is a relationship. It is used by applyJoins and applyWhereConditions
|
|
115
|
+
* to build the correct query.
|
|
116
|
+
*/
|
|
117
|
+
type TableConfigMap = {
|
|
118
|
+
[x: string]: {
|
|
119
|
+
[x: string]: RelationshipConfig;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* RelationshipConfig is a simple representation of a model field that
|
|
124
|
+
* is a relationship. It is used by applyJoins and applyWhereConditions
|
|
125
|
+
* to build the correct query.
|
|
126
|
+
* @typedef {{
|
|
127
|
+
* relationshipType: "belongsTo" | "hasMany",
|
|
128
|
+
* foreignKey: string,
|
|
129
|
+
* referencesTable: string,
|
|
130
|
+
* }} RelationshipConfig
|
|
131
|
+
*
|
|
132
|
+
* TableConfig is an object where the keys are relationship field names
|
|
133
|
+
* (which don't exist in the database) and the values are RelationshipConfig
|
|
134
|
+
* objects describing that relationship.
|
|
135
|
+
* @typedef {Object.<string, RelationshipConfig} TableConfig
|
|
136
|
+
*
|
|
137
|
+
* TableConfigMap is mapping of database table names to TableConfig objects
|
|
138
|
+
* @typedef {Object.<string, TableConfig>} TableConfigMap
|
|
139
|
+
*/
|
|
140
|
+
declare class ModelAPI {
|
|
141
|
+
/**
|
|
142
|
+
* @param {string} tableName The name of the table this API is for
|
|
143
|
+
* @param {Function} _ Used to be a function that returns the default values for a row in this table. No longer used.
|
|
144
|
+
* @param {TableConfigMap} tableConfigMap
|
|
145
|
+
*/
|
|
146
|
+
constructor(tableName: string, _: Function, tableConfigMap?: TableConfigMap);
|
|
147
|
+
_tableName: string;
|
|
148
|
+
_tableConfigMap: {
|
|
149
|
+
[x: string]: {
|
|
150
|
+
[x: string]: RelationshipConfig;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
_modelName: any;
|
|
154
|
+
create(values: any): Promise<any>;
|
|
155
|
+
findOne(where?: {}): Promise<any>;
|
|
156
|
+
findMany(params: any): Promise<any>;
|
|
157
|
+
update(where: any, values: any): Promise<any>;
|
|
158
|
+
delete(where: any): Promise<any>;
|
|
159
|
+
where(where: any): QueryBuilder;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** @type {import('./types').RequestHeaders} */
|
|
163
|
+
declare class RequestHeaders$1 {
|
|
164
|
+
/**
|
|
165
|
+
* @param {{Object.<string, string>}} requestHeaders Map of request headers submitted from the client
|
|
166
|
+
*/
|
|
167
|
+
constructor(requestHeaders: any);
|
|
168
|
+
_headers: any;
|
|
169
|
+
get(key: any): any;
|
|
170
|
+
has(key: any): any;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare function handleRequest(request: any, config: any): Promise<any>;
|
|
174
|
+
|
|
175
|
+
declare function handleJob(request: any, config: any): Promise<any>;
|
|
176
|
+
|
|
177
|
+
declare function handleSubscriber(request: any, config: any): Promise<any>;
|
|
178
|
+
|
|
179
|
+
declare function handleRoute(request: any, config: any): Promise<any>;
|
|
180
|
+
|
|
181
|
+
declare function handleFlow(request: any, config: any): Promise<any>;
|
|
182
|
+
|
|
183
|
+
declare function useDatabase(): any;
|
|
184
|
+
|
|
185
|
+
declare function checkBuiltInPermissions({ rows, permissionFns, ctx, db, functionName, }: {
|
|
186
|
+
rows: any;
|
|
187
|
+
permissionFns: any;
|
|
188
|
+
ctx: any;
|
|
189
|
+
db: any;
|
|
190
|
+
functionName: any;
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
|
|
193
|
+
declare namespace PERMISSION_STATE {
|
|
194
|
+
let UNKNOWN: string;
|
|
195
|
+
let PERMITTED: string;
|
|
196
|
+
let UNPERMITTED: string;
|
|
197
|
+
}
|
|
198
|
+
declare class Permissions {
|
|
199
|
+
allow(): void;
|
|
200
|
+
deny(): void;
|
|
201
|
+
getState(): string | undefined;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
declare function getTracer(): opentelemetry.Tracer;
|
|
205
|
+
declare function withSpan(name: any, fn: any): Promise<any>;
|
|
206
|
+
declare function init(): void;
|
|
207
|
+
declare function forceFlush(): Promise<void>;
|
|
208
|
+
declare function spanNameForModelAPI(modelName: any, action: any): string;
|
|
209
|
+
|
|
210
|
+
declare const tracing_forceFlush: typeof forceFlush;
|
|
211
|
+
declare const tracing_getTracer: typeof getTracer;
|
|
212
|
+
declare const tracing_init: typeof init;
|
|
213
|
+
declare const tracing_spanNameForModelAPI: typeof spanNameForModelAPI;
|
|
214
|
+
declare const tracing_withSpan: typeof withSpan;
|
|
215
|
+
declare namespace tracing {
|
|
216
|
+
export { tracing_forceFlush as forceFlush, tracing_getTracer as getTracer, tracing_init as init, tracing_spanNameForModelAPI as spanNameForModelAPI, tracing_withSpan as withSpan };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare class InlineFile$1 {
|
|
220
|
+
static fromDataURL(dataURL: any): InlineFile$1;
|
|
221
|
+
constructor({ filename, contentType }: {
|
|
222
|
+
filename: any;
|
|
223
|
+
contentType: any;
|
|
224
|
+
});
|
|
225
|
+
_filename: any;
|
|
226
|
+
_contentType: any;
|
|
227
|
+
_contents: buffer.Blob | null;
|
|
228
|
+
get size(): number;
|
|
229
|
+
get contentType(): any;
|
|
230
|
+
get filename(): any;
|
|
231
|
+
write(buffer: any): void;
|
|
232
|
+
read(): Promise<Buffer<ArrayBuffer>>;
|
|
233
|
+
store(expires?: null): Promise<File$1>;
|
|
234
|
+
}
|
|
235
|
+
declare class File$1 extends InlineFile$1 {
|
|
236
|
+
static fromDbRecord({ key, filename, size, contentType }: {
|
|
237
|
+
key: any;
|
|
238
|
+
filename: any;
|
|
239
|
+
size: any;
|
|
240
|
+
contentType: any;
|
|
241
|
+
}): File$1;
|
|
242
|
+
constructor(input: any);
|
|
243
|
+
_key: any;
|
|
244
|
+
_size: any;
|
|
245
|
+
get size(): any;
|
|
246
|
+
get key(): any;
|
|
247
|
+
read(): Promise<any>;
|
|
248
|
+
store(expires?: null): Promise<this>;
|
|
249
|
+
getPresignedUrl(): Promise<url.URL>;
|
|
250
|
+
toDbRecord(): {
|
|
251
|
+
key: any;
|
|
252
|
+
filename: any;
|
|
253
|
+
contentType: any;
|
|
254
|
+
size: any;
|
|
255
|
+
};
|
|
256
|
+
toJSON(): {
|
|
257
|
+
key: any;
|
|
258
|
+
filename: any;
|
|
259
|
+
contentType: any;
|
|
260
|
+
size: any;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare class Duration {
|
|
265
|
+
static fromISOString(isoString: any): Duration;
|
|
266
|
+
constructor(postgresString: any);
|
|
267
|
+
_typename: string;
|
|
268
|
+
pgInterval: any;
|
|
269
|
+
_interval: parseInterval.IPostgresInterval;
|
|
270
|
+
toISOString(): string;
|
|
271
|
+
toPostgres(): string;
|
|
272
|
+
}
|
|
273
|
+
|
|
1
274
|
type IDWhereCondition = {
|
|
2
275
|
equals?: string | null;
|
|
3
276
|
notEquals?: string | null;
|
|
@@ -149,24 +422,13 @@ type FileDbRecord = {
|
|
|
149
422
|
contentType: string;
|
|
150
423
|
size: number;
|
|
151
424
|
};
|
|
152
|
-
declare class Duration {
|
|
153
|
-
constructor(postgresString: string);
|
|
154
|
-
static fromISOString(iso: DurationString): Duration;
|
|
155
|
-
toISOString(): DurationString;
|
|
156
|
-
toPostgres(): string;
|
|
157
|
-
}
|
|
158
425
|
type SortDirection = "asc" | "desc" | "ASC" | "DESC";
|
|
159
426
|
type RequestHeaders = Omit<Headers, "append" | "delete" | "set">;
|
|
160
|
-
declare class Permissions {
|
|
161
|
-
constructor();
|
|
162
|
-
allow(): void;
|
|
163
|
-
deny(): never;
|
|
164
|
-
}
|
|
165
427
|
declare class NotFoundError extends Error {
|
|
166
428
|
}
|
|
167
|
-
declare class BadRequestError extends Error {
|
|
429
|
+
declare class BadRequestError$1 extends Error {
|
|
168
430
|
}
|
|
169
|
-
declare class UnknownError extends Error {
|
|
431
|
+
declare class UnknownError$1 extends Error {
|
|
170
432
|
}
|
|
171
433
|
type Errors = {
|
|
172
434
|
/**
|
|
@@ -178,12 +440,12 @@ type Errors = {
|
|
|
178
440
|
* Returns a 400 HTTP status with an optional message.
|
|
179
441
|
* This error indicates that the request made by the client is invalid or malformed.
|
|
180
442
|
*/
|
|
181
|
-
BadRequest: typeof BadRequestError;
|
|
443
|
+
BadRequest: typeof BadRequestError$1;
|
|
182
444
|
/**
|
|
183
445
|
* Returns a 500 HTTP status with an optional message.
|
|
184
446
|
* This error indicates that an unexpected condition was encountered, preventing the server from fulfilling the request.
|
|
185
447
|
*/
|
|
186
|
-
Unknown: typeof UnknownError;
|
|
448
|
+
Unknown: typeof UnknownError$1;
|
|
187
449
|
};
|
|
188
450
|
type FunctionConfig = {
|
|
189
451
|
/**
|
|
@@ -337,4 +599,6 @@ type Opts = {
|
|
|
337
599
|
timeoutInMs?: number;
|
|
338
600
|
};
|
|
339
601
|
|
|
340
|
-
|
|
602
|
+
declare function ksuid(): string;
|
|
603
|
+
|
|
604
|
+
export { type BooleanArrayQueryWhereCondition, type BooleanArrayWhereCondition, type BooleanWhereCondition, type ContextAPI, type DateArrayQueryWhereCondition, type DateArrayWhereCondition, type DateQueryInput, type DateWhereCondition, Duration, type DurationString, type DurationWhereCondition, ErrorPresets, type Errors, File$1 as File, type FileDbRecord, type FileWriteTypes, type FlowConfig, type FlowFunction, type FuncWithConfig, type FunctionConfig, type IDWhereCondition, InlineFile$1 as InlineFile, type InlineFileConstructor, ModelAPI, type NumberArrayQueryWhereCondition, type NumberArrayWhereCondition, type NumberWhereCondition, PERMISSION_STATE, type PageInfo, Permissions, type RelativeDateString, RequestHeaders$1 as RequestHeaders, type Response, type SortDirection, type StepContext, type StringArrayQueryWhereCondition, type StringArrayWhereCondition, type StringWhereCondition, type TimestampQueryInput, type UI, checkBuiltInPermissions, handleFlow, handleJob, handleRequest, handleRoute, handleSubscriber, ksuid, tracing, useDatabase };
|