@imgly/plugin-ai-generation-web 1.72.0-rc.2 → 1.72.1-rc.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/.tsbuildinfo +1 -1
- package/dist/core/provider.d.ts +5 -1
- package/dist/gateway/createGatewayClient.d.ts +22 -0
- package/dist/gateway/createGatewayProvider.d.ts +24 -0
- package/dist/gateway/index.d.ts +3 -0
- package/dist/gateway/types.d.ts +163 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +6 -4
- package/dist/index.mjs.map +4 -4
- package/dist/ui/panels/createPanelRenderFunctionFromSchema.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type CreativeEditorSDK from '@cesdk/cesdk-js';
|
|
2
|
+
import type { OutputKind, Output, RenderCustomProperty, QuickActionsInput } from '../core/provider';
|
|
3
|
+
import type { GatewayClient } from './createGatewayClient';
|
|
4
|
+
export interface GatewayProviderConfiguration {
|
|
5
|
+
/**
|
|
6
|
+
* Base URL of the gateway service.
|
|
7
|
+
*
|
|
8
|
+
* @default 'https://gateway.img.ly'
|
|
9
|
+
*/
|
|
10
|
+
gatewayUrl?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Human-readable display name for this model. Overrides the name
|
|
13
|
+
* returned by the gateway schema. If not set, the schema name is
|
|
14
|
+
* used once it loads, with `modelId` as the initial fallback.
|
|
15
|
+
*/
|
|
16
|
+
modelName?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The action ID used to retrieve an auth token via `cesdk.ui.actions.run()`.
|
|
19
|
+
* The registered action should return a token string.
|
|
20
|
+
*
|
|
21
|
+
* @default 'ly.img.ai.getToken'
|
|
22
|
+
*/
|
|
23
|
+
tokenActionId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Additional headers to send with gateway requests.
|
|
26
|
+
*/
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* History storage strategy for generated assets.
|
|
30
|
+
*
|
|
31
|
+
* @default '@imgly/indexedDB'
|
|
32
|
+
*/
|
|
33
|
+
history?: false | '@imgly/local' | '@imgly/indexedDB' | (string & {});
|
|
34
|
+
/**
|
|
35
|
+
* Called when an error occurs during schema loading or provider initialization.
|
|
36
|
+
* Generation errors are handled separately via middleware.
|
|
37
|
+
*/
|
|
38
|
+
onError?: (error: Error) => void;
|
|
39
|
+
/**
|
|
40
|
+
* How long (in milliseconds) to cache auth tokens before re-fetching.
|
|
41
|
+
* Concurrent requests while a fetch is in-flight share the same call.
|
|
42
|
+
*
|
|
43
|
+
* @default 300000 (5 minutes)
|
|
44
|
+
*/
|
|
45
|
+
tokenCacheTTL?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Enable debug logging.
|
|
48
|
+
*/
|
|
49
|
+
debug?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export declare const DEFAULT_GATEWAY_URL = "https://gateway.img.ly";
|
|
52
|
+
export declare const DEFAULT_TOKEN_ACTION_ID = "ly.img.ai.getToken";
|
|
53
|
+
/**
|
|
54
|
+
* Return type for the gateway token action.
|
|
55
|
+
*
|
|
56
|
+
* - Return a **string** for short-lived credentials (JWT, Clerk token, session token).
|
|
57
|
+
* - Return `{ dangerouslyExposeApiKey: string }` if you intentionally want to use
|
|
58
|
+
* a raw API key. This exposes the key to anyone with browser DevTools access.
|
|
59
|
+
*/
|
|
60
|
+
export type GatewayTokenActionResult = string | {
|
|
61
|
+
dangerouslyExposeApiKey: string;
|
|
62
|
+
};
|
|
63
|
+
export type GatewayInput = Record<string, any>;
|
|
64
|
+
export interface GatewayProviderOptions<K extends OutputKind, O extends Output> {
|
|
65
|
+
/** The output kind (e.g., 'image', 'video', 'audio', 'text'). */
|
|
66
|
+
kind: K;
|
|
67
|
+
/**
|
|
68
|
+
* Called once when the provider initializes (e.g., to register icons).
|
|
69
|
+
*/
|
|
70
|
+
onInitialize?: (cesdk: CreativeEditorSDK) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Called after the schema resolves. Return a `renderCustomProperty` map
|
|
73
|
+
* to customize how specific schema properties are rendered in the panel.
|
|
74
|
+
*
|
|
75
|
+
* Only called when a schema-driven panel is used (i.e., `createOutput` is provided).
|
|
76
|
+
*/
|
|
77
|
+
onSchemaReady?: (context: {
|
|
78
|
+
schema: GatewaySchemaResult;
|
|
79
|
+
providerId: string;
|
|
80
|
+
cesdk: CreativeEditorSDK;
|
|
81
|
+
}) => RenderCustomProperty | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Preprocess input before generation (e.g., upload local blob: URLs).
|
|
84
|
+
* If omitted, input is forwarded to the gateway as-is.
|
|
85
|
+
*/
|
|
86
|
+
processInput?: (input: GatewayInput, client: GatewayClient, cesdk: CreativeEditorSDK) => Promise<GatewayInput>;
|
|
87
|
+
/**
|
|
88
|
+
* Construct the typed output from a generated URL.
|
|
89
|
+
* Used for URL-based outputs (image, video, audio).
|
|
90
|
+
*
|
|
91
|
+
* When provided, a schema-driven panel is set up and `getBlockInput` is required.
|
|
92
|
+
* Mutually exclusive with `createStreamOutput`.
|
|
93
|
+
*/
|
|
94
|
+
createOutput?: (url: string) => O | Promise<O>;
|
|
95
|
+
/**
|
|
96
|
+
* Construct the typed output from accumulated streamed text.
|
|
97
|
+
* Used for streaming outputs (text).
|
|
98
|
+
*
|
|
99
|
+
* When provided, no schema panel is created — use `quickActions` for input.
|
|
100
|
+
* Mutually exclusive with `createOutput`.
|
|
101
|
+
*/
|
|
102
|
+
createStreamOutput?: (accumulatedText: string) => O;
|
|
103
|
+
/**
|
|
104
|
+
* Extract block input from user input (for placeholder creation).
|
|
105
|
+
* Required when `createOutput` is provided (panel mode).
|
|
106
|
+
*/
|
|
107
|
+
getBlockInput?: (input: GatewayInput) => Promise<Record<K, any>>;
|
|
108
|
+
/**
|
|
109
|
+
* Filter the SSE output array to find the relevant result.
|
|
110
|
+
* If omitted, the first output entry is used.
|
|
111
|
+
* Only used in URL mode (`createOutput`).
|
|
112
|
+
*/
|
|
113
|
+
outputFilter?: (output: GatewaySSEOutput) => boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Quick actions supported by this provider.
|
|
116
|
+
* Each entry maps a quick action ID to an input transformation.
|
|
117
|
+
*/
|
|
118
|
+
quickActions?: QuickActionsInput<GatewayInput>;
|
|
119
|
+
/**
|
|
120
|
+
* Panel user flow.
|
|
121
|
+
* @default 'placeholder'
|
|
122
|
+
*/
|
|
123
|
+
userFlow?: 'placeholder' | 'generation-only';
|
|
124
|
+
}
|
|
125
|
+
export interface GatewaySchemaResult {
|
|
126
|
+
model: string;
|
|
127
|
+
name?: string;
|
|
128
|
+
type: string;
|
|
129
|
+
input_schema: {
|
|
130
|
+
type: 'object';
|
|
131
|
+
required: string[];
|
|
132
|
+
properties: Record<string, unknown>;
|
|
133
|
+
'x-property-order'?: string[];
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export interface GatewaySSEOutput {
|
|
137
|
+
type: string;
|
|
138
|
+
url: string;
|
|
139
|
+
content_type: string;
|
|
140
|
+
}
|
|
141
|
+
export interface GatewaySSECompletedData {
|
|
142
|
+
request_id: string;
|
|
143
|
+
status: 'completed';
|
|
144
|
+
output: GatewaySSEOutput[];
|
|
145
|
+
}
|
|
146
|
+
export interface GatewaySSEFailedData {
|
|
147
|
+
request_id: string;
|
|
148
|
+
status: 'failed';
|
|
149
|
+
error: {
|
|
150
|
+
message: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export interface GatewaySSEDeltaData {
|
|
154
|
+
contentType: 'text' | 'tool_call';
|
|
155
|
+
data: string;
|
|
156
|
+
request_id: string;
|
|
157
|
+
}
|
|
158
|
+
export interface GatewayUploadResult {
|
|
159
|
+
id: string;
|
|
160
|
+
upload_url: string;
|
|
161
|
+
asset_url: string;
|
|
162
|
+
expires_in: number;
|
|
163
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const CommonProperties: {
|
|
|
5
5
|
StyleTransfer: typeof renderStyleTransferProperty;
|
|
6
6
|
};
|
|
7
7
|
export { CommonProperties };
|
|
8
|
-
export { type default as Provider, type ImageOutput, type VideoOutput, type TextOutput, type AudioOutput, type StickerOutput, type Output, type OutputKind, type PanelInputSchema, type RenderCustomProperty, type GetBlockInput, type GetBlockInputResult, type GetInput } from './core/provider';
|
|
8
|
+
export { type default as Provider, type ImageOutput, type VideoOutput, type TextOutput, type AudioOutput, type StickerOutput, type Output, type OutputKind, type PanelInputSchema, type RenderCustomProperty, type GetBlockInput, type GetBlockInputResult, type GetInput, type QuickActionsInput } from './core/provider';
|
|
9
9
|
export { type GetPropertyInput, type Property } from './openapi/types';
|
|
10
10
|
export { type GetProvider, type CommonProviderConfiguration, type CommonPluginConfiguration, type CommonConfiguration, type InternalPluginConfiguration } from './types';
|
|
11
11
|
export type { PropertyContext, PropertyConfig, PropertiesConfiguration, ExtendPropertyContexts } from './core/propertyConfiguration';
|
|
@@ -29,4 +29,7 @@ export { default as initializeProvider } from './providers/initializeProvider';
|
|
|
29
29
|
export { default as initializeQuickActionComponents } from './ui/quickActions/initializeQuickActionComponents';
|
|
30
30
|
export { extractAndSetSchemaTranslations } from './openapi/extractSchemaTranslations';
|
|
31
31
|
export { AI_EDIT_MODE, AI_METADATA_KEY } from './ui/quickActions/utils';
|
|
32
|
+
export { createGatewayProvider } from './gateway/createGatewayProvider';
|
|
33
|
+
export { createGatewayClient, type GatewayClient } from './gateway/createGatewayClient';
|
|
34
|
+
export type { GatewayProviderConfiguration, GatewayProviderOptions, GatewayInput, GatewaySchemaResult, GatewaySSEOutput, GatewaySSECompletedData, GatewaySSEDeltaData, GatewaySSEFailedData, GatewayUploadResult, GatewayTokenActionResult } from './gateway/types';
|
|
32
35
|
export { setDefaultTranslations, createTranslationCallback, buildTranslationKeys } from './utils/translationHelpers';
|