@base44-preview/sdk 0.8.50-pr.292.d7cb5e4 → 0.8.51-pr.293.e71320c
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.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl } from
|
|
|
4
4
|
export { createClient, createClientFromRequest, Base44Error, getAccessToken, saveAccessToken, removeAccessToken, getLoginUrl, };
|
|
5
5
|
export type { Base44Client, CreateClientAnalyticsConfig, CreateClientConfig, CreateClientOptions, Base44ErrorJSON, };
|
|
6
6
|
export * from "./types.js";
|
|
7
|
-
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityAggregateResult, EntityAggregateSpec, EntityDateBucketUnit, EntityDistinctOptions, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityListOptions, EntityPage, EntityRecord, EntityTypeRegistry, EntityUpsertOptions, EntityUpsertResult, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
|
|
7
|
+
export type { DeleteManyResult, DeleteResult, EntitiesModule, EntityAggregateResult, EntityAggregateSpec, EntityDateBucketUnit, EntityDistinctOptions, EntityFilterOperators, EntityFilterQuery, EntityFilterValue, EntityHandler, EntityListOptions, EntityArrayOptions, EntityPage, EntityRecord, EntityTypeRegistry, EntityUpsertOptions, EntityUpsertResult, ImportResult, RealtimeEventType, RealtimeEvent, RealtimeCallback, SortField, UpdateManyResult, } from "./modules/entities.types.js";
|
|
8
8
|
export type { AuthModule, LoginResponse, RegisterParams, VerifyOtpParams, ChangePasswordParams, ResetPasswordParams, User, } from "./modules/auth.types.js";
|
|
9
9
|
export type { IntegrationsModule, IntegrationEndpointFunction, CoreIntegrations, InvokeLLMParams, GenerateImageParams, GenerateImageResult, UploadFileParams, UploadFileResult, SendEmailParams, SendEmailResult, ExtractDataFromUploadedFileParams, ExtractDataFromUploadedFileResult, UploadPrivateFileParams, UploadPrivateFileResult, CreateFileSignedUrlParams, CreateFileSignedUrlResult, } from "./modules/integrations.types.js";
|
|
10
10
|
export type { FunctionsModule, FunctionName, FunctionNameRegistry, } from "./modules/functions.types.js";
|
|
@@ -33,7 +33,7 @@ export interface AiGatewayModuleConfig {
|
|
|
33
33
|
* `connection()` hands you a `baseURL` and `token` that authenticate as your
|
|
34
34
|
* Base44 app. An OpenAI-compatible client is any library, such as the `openai`
|
|
35
35
|
* SDK or the Vercel AI SDK, that has the same request and response format
|
|
36
|
-
* as OpenAI's
|
|
36
|
+
* as OpenAI's API and lets you point it at a custom `baseURL`
|
|
37
37
|
* instead of OpenAI's own servers. Pass `connection()`'s values to one of
|
|
38
38
|
* these clients and it works against Base44's gateway exactly as it would
|
|
39
39
|
* against the provider directly, no separate account, API key, or billing
|
|
@@ -55,6 +55,15 @@ export interface AiGatewayModuleConfig {
|
|
|
55
55
|
* Pass `'automatic'` to let Base44 choose one, or pin a specific model such
|
|
56
56
|
* as `'claude_sonnet_4_6'`, `'gpt_5_5'`, or `'gemini_3_1_pro'`.
|
|
57
57
|
*
|
|
58
|
+
* ## Images
|
|
59
|
+
*
|
|
60
|
+
* The gateway also serves OpenAI's image endpoints, `/images/generations`
|
|
61
|
+
* and `/images/edits`, so you can generate images and edit them using
|
|
62
|
+
* reference images. Image requests use their own set of models: pass
|
|
63
|
+
* `'automatic'` to let Base44 choose one, or pin a model such as
|
|
64
|
+
* `'gemini_3_1_flash_image'` or `'gpt_image_2'`. For request options, the
|
|
65
|
+
* full model list, and limits, see [Generate images with the AI Gateway](/developers/references/sdk/getting-started/ai-gateway-images).
|
|
66
|
+
*
|
|
58
67
|
* ## Authentication Modes
|
|
59
68
|
*
|
|
60
69
|
* There's no permission difference between modes. Both just determine which
|
|
@@ -145,6 +154,29 @@ export interface AiGatewayModule {
|
|
|
145
154
|
*
|
|
146
155
|
* await agent.generate({ prompt: `Review this return request: ${JSON.stringify(returnRequest)}` });
|
|
147
156
|
* ```
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // Generate an image
|
|
161
|
+
* import { createClientFromRequest } from "@base44/sdk";
|
|
162
|
+
* import { generateImage } from "ai";
|
|
163
|
+
* import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
164
|
+
*
|
|
165
|
+
* // Runs inside a backend function
|
|
166
|
+
* const base44 = createClientFromRequest(request);
|
|
167
|
+
* const { baseURL, token } = base44.aiGateway.connection();
|
|
168
|
+
* const models = createOpenAICompatible({ name: "base44", baseURL, apiKey: token });
|
|
169
|
+
*
|
|
170
|
+
* const { image } = await generateImage({
|
|
171
|
+
* model: models.imageModel("automatic"),
|
|
172
|
+
* prompt: "A watercolor illustration of a lighthouse at dawn",
|
|
173
|
+
* // Base44 options go under the provider name you passed above
|
|
174
|
+
* providerOptions: { base44: { aspect_ratio: "16:9" } },
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* const file = new File([image.uint8Array], "lighthouse.png", { type: image.mediaType });
|
|
178
|
+
* const { file_url } = await base44.integrations.Core.UploadFile({ file });
|
|
179
|
+
* ```
|
|
148
180
|
*/
|
|
149
181
|
connection(options?: AiGatewayConnectionOptions): AiGatewayConnection;
|
|
150
182
|
}
|
package/dist/modules/entities.js
CHANGED
|
@@ -42,8 +42,14 @@ function parseRealtimeMessage(dataStr) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const DEFAULT_PAGE_LIMIT = 100;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// Keys of the object form of list()/filter(). An object passed to list() with none of them is a filter query.
|
|
46
|
+
const ARRAY_OPTION_KEYS = ["sort", "limit", "skip", "fields", "filter", "query"];
|
|
47
|
+
function isPlainObject(value) {
|
|
48
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
// Code written for 0.8.49 reads a page from list()/filter() with a cursor or distinct option; keep it working.
|
|
51
|
+
function isPageRequest(value) {
|
|
52
|
+
return "cursor" in value || "distinct" in value;
|
|
47
53
|
}
|
|
48
54
|
/**
|
|
49
55
|
* Creates a handler for a specific entity.
|
|
@@ -73,7 +79,7 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
73
79
|
params.fields = fieldsParam(fields);
|
|
74
80
|
return axios.get(baseURL, { params });
|
|
75
81
|
};
|
|
76
|
-
// GET /{entity}/v2/list: one cursor page of records or distinct values
|
|
82
|
+
// GET /{entity}/v2/list: one cursor page of records or distinct values
|
|
77
83
|
const readPage = (options, query) => {
|
|
78
84
|
const params = {};
|
|
79
85
|
if (query)
|
|
@@ -93,15 +99,31 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
93
99
|
return axios.get(`${baseURL}/v2/list`, { params });
|
|
94
100
|
};
|
|
95
101
|
return {
|
|
96
|
-
// list(sort, limit, skip, fields) returns an array; list(options) returns one cursor page.
|
|
97
102
|
async list(...args) {
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
var _a;
|
|
104
|
+
const [first, ...rest] = args;
|
|
105
|
+
if (!isPlainObject(first))
|
|
106
|
+
return readArray(first, ...rest);
|
|
107
|
+
if (isPageRequest(first))
|
|
108
|
+
return readPage(first, first.query);
|
|
109
|
+
if (Object.keys(first).some((key) => ARRAY_OPTION_KEYS.includes(key))) {
|
|
110
|
+
return readArray(first.sort, first.limit, first.skip, first.fields, (_a = first.filter) !== null && _a !== void 0 ? _a : first.query);
|
|
111
|
+
}
|
|
112
|
+
// The object took sort's slot: list({}, 5) means limit 5; list({ email }, '-created_date', 100) follows filter()'s order.
|
|
113
|
+
return typeof rest[0] === "string"
|
|
114
|
+
? readArray(rest[0], rest[1], rest[2], rest[3], first)
|
|
115
|
+
: readArray(undefined, rest[0], rest[1], rest[2], first);
|
|
100
116
|
},
|
|
101
|
-
// filter(query, sort, limit, skip, fields) returns an array; filter(query, options) returns one cursor page.
|
|
102
117
|
async filter(query, ...args) {
|
|
103
|
-
const [
|
|
104
|
-
|
|
118
|
+
const [second, ...rest] = args;
|
|
119
|
+
if (!isPlainObject(second))
|
|
120
|
+
return readArray(second, rest[0], rest[1], rest[2], query);
|
|
121
|
+
if (isPageRequest(second))
|
|
122
|
+
return readPage(second, query);
|
|
123
|
+
return readArray(second.sort, second.limit, second.skip, second.fields, query);
|
|
124
|
+
},
|
|
125
|
+
async page(options = {}) {
|
|
126
|
+
return readPage(options, options.query);
|
|
105
127
|
},
|
|
106
128
|
// Get entity by ID
|
|
107
129
|
async get(id) {
|
|
@@ -51,13 +51,14 @@ export interface UpdateManyResult {
|
|
|
51
51
|
has_more: boolean;
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Options object accepted by {@linkcode EntityHandler.
|
|
55
|
-
* {@linkcode EntityHandler.filter | filter()} to read one cursor page.
|
|
54
|
+
* Options object accepted by {@linkcode EntityHandler.page | page()} to read one cursor page of records.
|
|
56
55
|
*
|
|
57
56
|
* @typeParam T - Entity record type.
|
|
58
57
|
* @typeParam K - The fields to include in each record.
|
|
59
58
|
*/
|
|
60
59
|
export interface EntityListOptions<T, K extends keyof T = keyof T> {
|
|
60
|
+
/** Filter for the records, in the same form as {@linkcode EntityHandler.filter | filter()}'s query. Defaults to all records. */
|
|
61
|
+
query?: EntityFilterQuery<T>;
|
|
61
62
|
/** Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`. */
|
|
62
63
|
sort?: SortField<T>;
|
|
63
64
|
/** Maximum number of records per page, up to 5,000. Defaults to 100. */
|
|
@@ -73,14 +74,15 @@ export interface EntityListOptions<T, K extends keyof T = keyof T> {
|
|
|
73
74
|
fields?: K[];
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
|
-
* Options object accepted by {@linkcode EntityHandler.
|
|
77
|
-
* {@linkcode EntityHandler.filter | filter()} to read the distinct values of one field
|
|
77
|
+
* Options object accepted by {@linkcode EntityHandler.page | page()} to read the distinct values of one field
|
|
78
78
|
* instead of records.
|
|
79
79
|
*
|
|
80
80
|
* @typeParam T - Entity record type.
|
|
81
81
|
* @typeParam K - The field whose distinct values to read.
|
|
82
82
|
*/
|
|
83
83
|
export interface EntityDistinctOptions<T, K extends keyof T = keyof T> {
|
|
84
|
+
/** Filter for the records whose values are read. Defaults to all records. */
|
|
85
|
+
query?: EntityFilterQuery<T>;
|
|
84
86
|
/** Field whose distinct values to return, in ascending order. Array fields contribute each element. */
|
|
85
87
|
distinct: K;
|
|
86
88
|
/** Maximum number of values per page, up to 1,000. Defaults to 100. */
|
|
@@ -89,8 +91,26 @@ export interface EntityDistinctOptions<T, K extends keyof T = keyof T> {
|
|
|
89
91
|
cursor?: string | null;
|
|
90
92
|
}
|
|
91
93
|
/**
|
|
92
|
-
*
|
|
93
|
-
* {@linkcode EntityHandler.filter | filter()}
|
|
94
|
+
* Options object accepted by {@linkcode EntityHandler.list | list()} and
|
|
95
|
+
* {@linkcode EntityHandler.filter | filter()} in place of positional arguments. Both still return an array.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam T - Entity record type.
|
|
98
|
+
* @typeParam K - The fields to include in each record.
|
|
99
|
+
*/
|
|
100
|
+
export interface EntityArrayOptions<T, K extends keyof T = keyof T> {
|
|
101
|
+
/** Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`. */
|
|
102
|
+
sort?: SortField<T>;
|
|
103
|
+
/** Maximum number of records to return. Defaults to `5000`. */
|
|
104
|
+
limit?: number;
|
|
105
|
+
/** Number of records to skip. Defaults to `0`. For loops over many records, use {@linkcode EntityHandler.page | page()}. */
|
|
106
|
+
skip?: number;
|
|
107
|
+
/** Array of field names to include in each record. Defaults to all fields. */
|
|
108
|
+
fields?: K[];
|
|
109
|
+
/** Filter for the records. Only read by `list()`; `filter()` takes its query as the first argument. */
|
|
110
|
+
filter?: EntityFilterQuery<T>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* One page of records, returned by {@linkcode EntityHandler.page | page()}.
|
|
94
114
|
*
|
|
95
115
|
* @typeParam T - Record type of the items.
|
|
96
116
|
*/
|
|
@@ -336,17 +356,19 @@ export interface EntityHandler<T = any> {
|
|
|
336
356
|
* pagination, and field selection.
|
|
337
357
|
*
|
|
338
358
|
* **Note:** The maximum limit is 5,000 items per request. To read more than
|
|
339
|
-
* one page,
|
|
340
|
-
* `
|
|
341
|
-
*
|
|
342
|
-
*
|
|
359
|
+
* one page, use {@linkcode EntityHandler.page | page()} with a cursor instead of
|
|
360
|
+
* `skip`: every page costs the same however deep you are, and records deleted
|
|
361
|
+
* between pages never shift the boundary.
|
|
362
|
+
*
|
|
363
|
+
* The arguments can also be passed as one {@linkcode EntityArrayOptions | options object}
|
|
364
|
+
* (`{ sort, limit, skip, fields, filter }`); the result is still an array.
|
|
343
365
|
*
|
|
344
366
|
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
345
367
|
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
|
|
346
368
|
* @param limit - Maximum number of results to return. Defaults to `5000`.
|
|
347
|
-
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
369
|
+
* @param skip - Number of results to skip for pagination. Defaults to `0`. For loops, use `page()`.
|
|
348
370
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
349
|
-
* @returns Promise resolving to an array of records with selected fields.
|
|
371
|
+
* @returns Promise resolving to an array of records with selected fields.
|
|
350
372
|
*
|
|
351
373
|
* @example
|
|
352
374
|
* ```typescript
|
|
@@ -375,25 +397,18 @@ export interface EntityHandler<T = any> {
|
|
|
375
397
|
*
|
|
376
398
|
* @example
|
|
377
399
|
* ```typescript
|
|
378
|
-
* //
|
|
379
|
-
*
|
|
380
|
-
* let page = await base44.entities.MyEntity.list({ sort: '-created_date', limit: 1000 });
|
|
381
|
-
* await exportRows(page.items);
|
|
382
|
-
* while (page.has_more) {
|
|
383
|
-
* page = await base44.entities.MyEntity.list({ cursor: page.next_cursor, limit: 1000 });
|
|
384
|
-
* await exportRows(page.items);
|
|
385
|
-
* }
|
|
386
|
-
* ```
|
|
387
|
-
*
|
|
388
|
-
* @example
|
|
389
|
-
* ```typescript
|
|
390
|
-
* // Distinct values of one field, instead of records
|
|
391
|
-
* const { items: categories } = await base44.entities.Product.list({ distinct: 'category' });
|
|
400
|
+
* // The same arguments as one options object; still an array
|
|
401
|
+
* const recent = await base44.entities.MyEntity.list({ sort: '-created_date', limit: 10 });
|
|
392
402
|
* ```
|
|
393
403
|
*/
|
|
394
404
|
list<K extends keyof T = keyof T>(sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
405
|
+
list<K extends keyof T = keyof T>(options: EntityArrayOptions<T, K>): Promise<Pick<T, K>[]>;
|
|
406
|
+
/** @deprecated Use {@linkcode EntityHandler.page | page()}. */
|
|
395
407
|
list<K extends keyof T>(options: EntityDistinctOptions<T, K>): Promise<EntityPage<T[K]>>;
|
|
396
|
-
|
|
408
|
+
/** @deprecated Use {@linkcode EntityHandler.page | page()}. */
|
|
409
|
+
list<K extends keyof T = keyof T>(options: EntityListOptions<T, K> & {
|
|
410
|
+
cursor: string | null;
|
|
411
|
+
}): Promise<EntityPage<Pick<T, K>>>;
|
|
397
412
|
/**
|
|
398
413
|
* Filters records based on a query.
|
|
399
414
|
*
|
|
@@ -401,10 +416,13 @@ export interface EntityHandler<T = any> {
|
|
|
401
416
|
* sorting, pagination, and field selection.
|
|
402
417
|
*
|
|
403
418
|
* **Note:** The maximum limit is 5,000 items per request. To read more than
|
|
404
|
-
* one page,
|
|
405
|
-
* `
|
|
406
|
-
*
|
|
407
|
-
*
|
|
419
|
+
* one page, use {@linkcode EntityHandler.page | page()} with a cursor instead of
|
|
420
|
+
* `skip`: every page costs the same however deep you are, and records deleted
|
|
421
|
+
* between pages never shift the boundary.
|
|
422
|
+
*
|
|
423
|
+
* The arguments after the query can also be passed as one
|
|
424
|
+
* {@linkcode EntityArrayOptions | options object} (`{ sort, limit, skip, fields }`);
|
|
425
|
+
* the result is still an array.
|
|
408
426
|
*
|
|
409
427
|
* @typeParam K - The fields to include in the response. Defaults to all fields.
|
|
410
428
|
* @param query - Query object with field-value pairs. Each key should be a field name
|
|
@@ -414,9 +432,9 @@ export interface EntityHandler<T = any> {
|
|
|
414
432
|
* provided values, or documented MongoDB query operators for advanced filtering.
|
|
415
433
|
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
|
|
416
434
|
* @param limit - Maximum number of results to return. Defaults to `5000`.
|
|
417
|
-
* @param skip - Number of results to skip for pagination. Defaults to `0`.
|
|
435
|
+
* @param skip - Number of results to skip for pagination. Defaults to `0`. For loops, use `page()`.
|
|
418
436
|
* @param fields - Array of field names to include in the response. Defaults to all fields.
|
|
419
|
-
* @returns Promise resolving to an array of filtered records with selected fields.
|
|
437
|
+
* @returns Promise resolving to an array of filtered records with selected fields.
|
|
420
438
|
*
|
|
421
439
|
* @example
|
|
422
440
|
* ```typescript
|
|
@@ -496,15 +514,39 @@ export interface EntityHandler<T = any> {
|
|
|
496
514
|
*
|
|
497
515
|
* @example
|
|
498
516
|
* ```typescript
|
|
499
|
-
* //
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
517
|
+
* // Sort and limit as an options object; still an array
|
|
518
|
+
* const open = await base44.entities.Order.filter({ status: 'open' }, { sort: '-created_date', limit: 20 });
|
|
519
|
+
* ```
|
|
520
|
+
*/
|
|
521
|
+
filter<K extends keyof T = keyof T>(query: EntityFilterQuery<T>, sort?: SortField<T>, limit?: number, skip?: number, fields?: K[]): Promise<Pick<T, K>[]>;
|
|
522
|
+
filter<K extends keyof T = keyof T>(query: EntityFilterQuery<T>, options: EntityArrayOptions<T, K>): Promise<Pick<T, K>[]>;
|
|
523
|
+
/** @deprecated Use {@linkcode EntityHandler.page | page()}. */
|
|
524
|
+
filter<K extends keyof T>(query: EntityFilterQuery<T>, options: EntityDistinctOptions<T, K>): Promise<EntityPage<T[K]>>;
|
|
525
|
+
/** @deprecated Use {@linkcode EntityHandler.page | page()}. */
|
|
526
|
+
filter<K extends keyof T = keyof T>(query: EntityFilterQuery<T>, options: EntityListOptions<T, K> & {
|
|
527
|
+
cursor: string | null;
|
|
528
|
+
}): Promise<EntityPage<Pick<T, K>>>;
|
|
529
|
+
/**
|
|
530
|
+
* Reads one page of records, or of one field's distinct values, with a cursor.
|
|
531
|
+
*
|
|
532
|
+
* Use it for "load more", infinite scroll and exports. Every page costs the same
|
|
533
|
+
* however deep you are, records deleted between pages never shift the boundary,
|
|
534
|
+
* and records that share a sort value are each returned once. Pass `next_cursor`
|
|
535
|
+
* from one page as `cursor` on the next; the token carries the query, sort and
|
|
536
|
+
* fields, so a later page needs only `cursor` and `limit`. Stop when `has_more`
|
|
537
|
+
* is false. Every page holds `limit` items except the last.
|
|
538
|
+
*
|
|
539
|
+
* @typeParam K - The fields to include in each record, or the field whose values to read.
|
|
540
|
+
* @param options - `{ query, sort, limit, fields, cursor }` for records, or `{ query, distinct, limit, cursor }` for distinct values.
|
|
541
|
+
* @returns Promise resolving to an {@linkcode EntityPage | EntityPage} with `items`, `next_cursor` and `has_more`.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* ```typescript
|
|
545
|
+
* // Walk all matching records
|
|
546
|
+
* let page = await base44.entities.Order.page({ query: { status: 'open' }, sort: '-created_date', limit: 1000 });
|
|
505
547
|
* await exportRows(page.items);
|
|
506
548
|
* while (page.has_more) {
|
|
507
|
-
* page = await base44.entities.Order.
|
|
549
|
+
* page = await base44.entities.Order.page({ cursor: page.next_cursor, limit: 1000 });
|
|
508
550
|
* await exportRows(page.items);
|
|
509
551
|
* }
|
|
510
552
|
* ```
|
|
@@ -512,15 +554,11 @@ export interface EntityHandler<T = any> {
|
|
|
512
554
|
* @example
|
|
513
555
|
* ```typescript
|
|
514
556
|
* // Distinct values of one field among the matching records
|
|
515
|
-
* const { items: agents } = await base44.entities.Order.
|
|
516
|
-
* { status: 'open' },
|
|
517
|
-
* { distinct: 'agent_id' }
|
|
518
|
-
* );
|
|
557
|
+
* const { items: agents } = await base44.entities.Order.page({ query: { status: 'open' }, distinct: 'agent_id' });
|
|
519
558
|
* ```
|
|
520
559
|
*/
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
filter<K extends keyof T = keyof T>(query: EntityFilterQuery<T>, options: EntityListOptions<T, K>): Promise<EntityPage<Pick<T, K>>>;
|
|
560
|
+
page<K extends keyof T>(options: EntityDistinctOptions<T, K>): Promise<EntityPage<T[K]>>;
|
|
561
|
+
page<K extends keyof T = keyof T>(options?: EntityListOptions<T, K>): Promise<EntityPage<Pick<T, K>>>;
|
|
524
562
|
/**
|
|
525
563
|
* Gets a single record by ID.
|
|
526
564
|
*
|
|
@@ -59,8 +59,17 @@ export interface InvokeLLMParams {
|
|
|
59
59
|
* Parameters for the GenerateImage function.
|
|
60
60
|
*/
|
|
61
61
|
export interface GenerateImageParams {
|
|
62
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Description of the image to generate. When you pass `existing_image_urls`,
|
|
64
|
+
* describe what to do with the reference images instead.
|
|
65
|
+
*/
|
|
63
66
|
prompt: string;
|
|
67
|
+
/**
|
|
68
|
+
* URLs of images to use as references, for example to edit an existing
|
|
69
|
+
* image, match a style, or add visual context. Images that can't be read are
|
|
70
|
+
* skipped. If none of them can be read, the request fails.
|
|
71
|
+
*/
|
|
72
|
+
existing_image_urls?: string[];
|
|
64
73
|
}
|
|
65
74
|
export interface GenerateImageResult {
|
|
66
75
|
/** URL of the generated image. */
|
|
@@ -173,12 +182,17 @@ export interface CoreIntegrations {
|
|
|
173
182
|
*/
|
|
174
183
|
InvokeLLM(params: InvokeLLMParams): Promise<string | object>;
|
|
175
184
|
/**
|
|
176
|
-
* Create AI-generated images from text prompts.
|
|
185
|
+
* Create AI-generated images from text prompts, optionally guided by reference images.
|
|
177
186
|
*
|
|
178
187
|
* Images are generated as PNG files at approximately 1024px on the shorter side. The
|
|
179
188
|
* exact dimensions vary by aspect ratio.
|
|
180
189
|
*
|
|
181
|
-
*
|
|
190
|
+
* Pass `existing_image_urls` to edit an existing image or to guide the result
|
|
191
|
+
* with reference images. To choose the model, aspect ratio, resolution, or
|
|
192
|
+
* quality, use the [AI Gateway image endpoints](/developers/references/sdk/getting-started/ai-gateway-images)
|
|
193
|
+
* instead.
|
|
194
|
+
*
|
|
195
|
+
* Prompts that violate the AI provider's content policy are refused.
|
|
182
196
|
*
|
|
183
197
|
* @param params - Parameters for image generation
|
|
184
198
|
* @returns Promise resolving to an object containing the URL of the generated PNG image.
|
|
@@ -191,6 +205,15 @@ export interface CoreIntegrations {
|
|
|
191
205
|
* });
|
|
192
206
|
* console.log(url); // https://...generated_image.png
|
|
193
207
|
* ```
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* // Edit an existing image
|
|
212
|
+
* const {url} = await base44.integrations.Core.GenerateImage({
|
|
213
|
+
* prompt: "Replace the background with a sunset beach",
|
|
214
|
+
* existing_image_urls: [productPhotoUrl]
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
194
217
|
*/
|
|
195
218
|
GenerateImage(params: GenerateImageParams): Promise<GenerateImageResult>;
|
|
196
219
|
/**
|