@basementstudio/sanity-ai-image-plugin 0.0.1 → 0.1.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.
Files changed (110) hide show
  1. package/README.md +281 -257
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +3 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/presets/article-featured-image.d.ts +3 -0
  7. package/dist/presets/article-featured-image.d.ts.map +1 -0
  8. package/dist/presets/article-featured-image.js +17 -0
  9. package/dist/presets/article-featured-image.js.map +1 -0
  10. package/dist/server/constants.d.ts +6 -0
  11. package/dist/server/constants.d.ts.map +1 -0
  12. package/{src/server/constants.ts → dist/server/constants.js} +17 -20
  13. package/dist/server/constants.js.map +1 -0
  14. package/dist/server/handle-request.d.ts +5 -0
  15. package/dist/server/handle-request.d.ts.map +1 -0
  16. package/dist/server/handle-request.js +122 -0
  17. package/dist/server/handle-request.js.map +1 -0
  18. package/dist/server/types.d.ts +28 -0
  19. package/dist/server/types.d.ts.map +1 -0
  20. package/dist/server/types.js +2 -0
  21. package/dist/server/types.js.map +1 -0
  22. package/dist/server/utils.d.ts +50 -0
  23. package/dist/server/utils.d.ts.map +1 -0
  24. package/dist/server/utils.js +274 -0
  25. package/dist/server/utils.js.map +1 -0
  26. package/dist/server.d.ts +3 -0
  27. package/dist/server.d.ts.map +1 -0
  28. package/dist/server.js +3 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/studio/components/asset-source.d.ts +4 -0
  31. package/dist/studio/components/asset-source.d.ts.map +1 -0
  32. package/dist/studio/components/asset-source.js +163 -0
  33. package/dist/studio/components/asset-source.js.map +1 -0
  34. package/dist/studio/components/generate-button-input.d.ts +8 -0
  35. package/dist/studio/components/generate-button-input.d.ts.map +1 -0
  36. package/dist/studio/components/generate-button-input.js +186 -0
  37. package/dist/studio/components/generate-button-input.js.map +1 -0
  38. package/dist/studio/components/input-router.d.ts +7 -0
  39. package/dist/studio/components/input-router.d.ts.map +1 -0
  40. package/dist/studio/components/input-router.js +21 -0
  41. package/dist/studio/components/input-router.js.map +1 -0
  42. package/dist/studio/files.d.ts +9 -0
  43. package/dist/studio/files.d.ts.map +1 -0
  44. package/dist/studio/files.js +86 -0
  45. package/dist/studio/files.js.map +1 -0
  46. package/dist/studio/plugin.d.ts +3 -0
  47. package/dist/studio/plugin.d.ts.map +1 -0
  48. package/dist/studio/plugin.js +47 -0
  49. package/dist/studio/plugin.js.map +1 -0
  50. package/dist/studio/settings/schema.d.ts +8 -0
  51. package/dist/studio/settings/schema.d.ts.map +1 -0
  52. package/dist/studio/settings/schema.js +110 -0
  53. package/dist/studio/settings/schema.js.map +1 -0
  54. package/dist/studio/settings/tool.d.ts +3 -0
  55. package/dist/studio/settings/tool.d.ts.map +1 -0
  56. package/dist/studio/settings/tool.js +292 -0
  57. package/dist/studio/settings/tool.js.map +1 -0
  58. package/dist/studio/settings-data.d.ts +24 -0
  59. package/dist/studio/settings-data.d.ts.map +1 -0
  60. package/dist/studio/settings-data.js +99 -0
  61. package/dist/studio/settings-data.js.map +1 -0
  62. package/dist/studio/shared-secret.d.ts +9 -0
  63. package/dist/studio/shared-secret.d.ts.map +1 -0
  64. package/dist/studio/shared-secret.js +37 -0
  65. package/dist/studio/shared-secret.js.map +1 -0
  66. package/dist/utils/config.d.ts +3 -0
  67. package/dist/utils/config.d.ts.map +1 -0
  68. package/dist/utils/config.js +41 -0
  69. package/dist/utils/config.js.map +1 -0
  70. package/dist/utils/context-fields.d.ts +16 -0
  71. package/dist/utils/context-fields.d.ts.map +1 -0
  72. package/dist/utils/context-fields.js +104 -0
  73. package/dist/utils/context-fields.js.map +1 -0
  74. package/dist/utils/document-paths.d.ts +10 -0
  75. package/dist/utils/document-paths.d.ts.map +1 -0
  76. package/dist/utils/document-paths.js +33 -0
  77. package/dist/utils/document-paths.js.map +1 -0
  78. package/dist/utils/models.d.ts +22 -0
  79. package/dist/utils/models.d.ts.map +1 -0
  80. package/dist/utils/models.js +76 -0
  81. package/dist/utils/models.js.map +1 -0
  82. package/dist/utils/prompts.d.ts +2 -0
  83. package/dist/utils/prompts.d.ts.map +1 -0
  84. package/dist/utils/prompts.js +7 -0
  85. package/dist/utils/prompts.js.map +1 -0
  86. package/dist/utils/shared.d.ts +82 -0
  87. package/dist/utils/shared.d.ts.map +1 -0
  88. package/dist/utils/shared.js +13 -0
  89. package/dist/utils/shared.js.map +1 -0
  90. package/package.json +73 -67
  91. package/src/index.ts +0 -23
  92. package/src/presets/article-featured-image.ts +0 -23
  93. package/src/server/handle-request.ts +0 -207
  94. package/src/server/types.ts +0 -30
  95. package/src/server/utils.ts +0 -395
  96. package/src/server.ts +0 -14
  97. package/src/studio/components/asset-source.tsx +0 -297
  98. package/src/studio/components/generate-button-input.tsx +0 -380
  99. package/src/studio/components/input-router.tsx +0 -41
  100. package/src/studio/files.ts +0 -114
  101. package/src/studio/plugin.tsx +0 -54
  102. package/src/studio/settings/schema.ts +0 -122
  103. package/src/studio/settings/tool.tsx +0 -587
  104. package/src/studio/settings-data.ts +0 -172
  105. package/src/utils/config.ts +0 -55
  106. package/src/utils/context-fields.ts +0 -172
  107. package/src/utils/document-paths.ts +0 -51
  108. package/src/utils/models.ts +0 -126
  109. package/src/utils/prompts.ts +0 -6
  110. package/src/utils/shared.ts +0 -88
package/README.md CHANGED
@@ -1,257 +1,281 @@
1
- # `sanity-ai-image-plugin`
2
-
3
- Portable Sanity Studio plugin and server helper for generating images with
4
- Gemini, OpenAI, and other package-supported image models and dropping the
5
- result straight into Sanity image fields.
6
-
7
- This package is intentionally self-contained so it can be copied into a new repo
8
- or published later without dragging along an app-specific schema layout.
9
-
10
- This repo is source-first while it is being developed here:
11
-
12
- - package exports point at `src/*`
13
-
14
- ## What It Owns
15
-
16
- - a Studio plugin via `aiImagePlugin(...)`
17
- - a plugin-owned settings document and settings tool
18
- - a generic image asset source
19
- - optional generate-button targets for specific image fields
20
- - a server helper export for the app-owned API route
21
-
22
- ## Install Shape
23
-
24
- The package exposes two entrypoints:
25
-
26
- - `sanity-ai-image-plugin`
27
- - `sanity-ai-image-plugin/server`
28
-
29
- ## Consumer Setup
30
-
31
- ### 1. Add the Studio plugin
32
-
33
- ```ts
34
- import { defineConfig } from "sanity";
35
- import {
36
- SUPPORTED_AI_IMAGE_MODELS,
37
- createArticleFeaturedImageTarget,
38
- aiImagePlugin,
39
- } from "sanity-ai-image-plugin";
40
-
41
- const allowedModels = [
42
- SUPPORTED_AI_IMAGE_MODELS[0],
43
- SUPPORTED_AI_IMAGE_MODELS[2],
44
- ] as const;
45
-
46
- export default defineConfig({
47
- // ...your existing config
48
- plugins: [
49
- aiImagePlugin({
50
- apiVersion: "2025-02-19",
51
- allowedModels: [...allowedModels],
52
- assetSource: true,
53
- targets: [
54
- createArticleFeaturedImageTarget(),
55
- {
56
- id: "home-page-featured-image",
57
- type: "generateButton",
58
- title: "Home Page Featured Image",
59
- documentType: "homePage",
60
- fieldPath: "featuredImage",
61
- suggestedContextFieldPaths: ["title", "description"],
62
- },
63
- ],
64
- }),
65
- ],
66
- });
67
- ```
68
-
69
- ### 2. Add the thin app-owned route.
70
-
71
- ```ts
72
- import {
73
- handleAiImageRequest,
74
- SUPPORTED_AI_IMAGE_MODELS,
75
- } from "sanity-ai-image-plugin/server";
76
-
77
- const allowedModels = [
78
- SUPPORTED_AI_IMAGE_MODELS[0],
79
- SUPPORTED_AI_IMAGE_MODELS[2],
80
- ] as const;
81
-
82
- export async function POST(request: Request) {
83
- return handleAiImageRequest(request, {
84
- allowedModels: [...allowedModels],
85
- apiKey: process.env.GEMINI_API_KEY,
86
- openAiApiKey: process.env.OPENAI_API_KEY,
87
- // Same-origin protection is enabled by default.
88
- // Optional overrides:
89
- // model: process.env.AI_IMAGE_MODEL as (typeof allowedModels)[number],
90
- // maxReferenceFileBytes: 8 * 1024 * 1024,
91
- // maxTotalReferenceBytes: 5 * 8 * 1024 * 1024,
92
- })
93
- }
94
- ```
95
-
96
- ### 3. Set env vars
97
-
98
- - `GEMINI_API_KEY` is required when you allow Google models
99
- - `OPENAI_API_KEY` is required when you allow OpenAI models
100
- - `AI_IMAGE_MODEL` is optional and can still override the server default
101
-
102
- ## Supported Models
103
-
104
- The package has an internal supported-model registry. In this first pass it
105
- contains exactly:
106
-
107
- - `gemini-2.5-flash-image`
108
- - `gemini-3.1-flash-image-preview`
109
- - `gpt-image-1`
110
-
111
- Each installation can opt into any non-empty subset of those models with the
112
- ordered `allowedModels` config. The first allowed model becomes the default
113
- model for both the Studio UI and the server helper unless the settings document
114
- or route overrides it.
115
-
116
- ## Settings Model
117
-
118
- The plugin owns one settings document:
119
-
120
- - `_id`: `aiImagePlugin.settings`
121
- - `_type`: `aiImagePluginSettings`
122
-
123
- It stores:
124
-
125
- - `globalModel`
126
- - `globalPrompt`
127
- - `globalReferenceImages`
128
- - `targetConfigs[]`
129
-
130
- Each target config can override:
131
-
132
- - `targetId`
133
- - `prompt`
134
- - `referenceImages`
135
-
136
- ## Behavior
137
-
138
- ### Server helper
139
-
140
- The server helper is same-origin only by default.
141
-
142
- That means requests are accepted when the browser `Origin` matches the API
143
- route origin exactly, for example:
144
-
145
- - `http://localhost:3000/studio` -> `http://localhost:3000/api/ai-image-plugin`
146
- - `https://myapp.vercel.app/studio` -> `https://myapp.vercel.app/api/ai-image-plugin`
147
-
148
- The helper does not inspect the `/studio` path directly because browser
149
- `Origin` headers only include the scheme, host, and port.
150
-
151
- By default it also enforces:
152
-
153
- - `8 MiB` maximum per reference image
154
- - a combined reference-image cap of `maxReferences * 8 MiB`
155
- - the requested `model` must be both package-supported and present in the
156
- route's configured `allowedModels`
157
-
158
- If your framework supports route-level body limits, keep those enabled too.
159
-
160
- ### Asset source
161
-
162
- The generic asset source composes:
163
-
164
- 1. global prompt
165
- 2. asset-source target prompt
166
- 3. editor prompt
167
-
168
- Reference images are combined from:
169
-
170
- 1. global reference images
171
- 2. asset-source target reference images
172
- 3. local editor-uploaded reference images
173
-
174
- The selected model is resolved like this:
175
-
176
- 1. `settings.globalModel` when it is present and allowed
177
- 2. otherwise the first configured `allowedModels` entry
178
-
179
- ### Generate button targets
180
-
181
- Generate-button targets match against:
182
-
183
- - `documentType`
184
- - `fieldPath`
185
-
186
- When matched, the plugin renders a `Generate` button above the normal Sanity
187
- image input.
188
-
189
- Targets can also declare:
190
-
191
- - `suggestedContextFieldPaths`
192
-
193
- When the dialog opens, the plugin inspects the current document schema and shows
194
- eligible top-level document fields as toggle tags. In this first pass, eligible
195
- field types are:
196
-
197
- - `string`
198
- - `text`
199
- - `number`
200
- - `boolean`
201
- - `date`
202
- - `datetime`
203
- - `slug`
204
-
205
- Suggested context field paths are only default-on tags. They are filtered to
206
- fields that exist on the current document type, and editors can toggle them on
207
- or off for each generation.
208
-
209
- Prompt composition order is:
210
-
211
- 1. global prompt
212
- 2. target prompt
213
- 3. optional selected document context
214
- 4. optional editor prompt
215
-
216
- Selected document context is built as generic lines such as:
217
-
218
- - `The field called "title" has content "...".`
219
-
220
- ## Optional Preset
221
-
222
- `createArticleFeaturedImageTarget(...)` is an optional preset for
223
- `article.featuredImage`.
224
-
225
- It feeds the model:
226
-
227
- - shared global settings
228
- - target-specific article settings
229
- - editor-selectable document-derived title + excerpt context suggestions
230
- - optional editor prompt
231
-
232
- If you do not use that preset, the package still works as a generic asset source
233
- and generic generate-button plugin.
234
-
235
- ## Desk Structure
236
-
237
- The plugin does not require custom desk structure wiring. If a consuming app
238
- uses a custom structure and wants to hide `aiImagePluginSettings` from the normal
239
- document list, that is optional and app-owned.
240
-
241
- ## PNG Normalization
242
-
243
- All reference images are converted to PNG before they are sent to the server
244
- helper. That includes:
245
-
246
- - locally uploaded reference files
247
- - stored settings images downloaded from Sanity
248
- - new images uploaded through the settings tool
249
-
250
- ## Development
251
-
252
- ```sh
253
- bun run check
254
- bun run build
255
- bun test
256
- ```
257
-
1
+ # `sanity-ai-image-plugin`
2
+
3
+ Portable Sanity Studio plugin and server helper for generating images with
4
+ Gemini, OpenAI, and other package-supported image models and dropping the
5
+ result straight into Sanity image fields.
6
+
7
+ This package is intentionally self-contained so it can be copied into a new repo
8
+ or published later without dragging along an app-specific schema layout.
9
+
10
+ This repo is source-first while it is being developed here:
11
+
12
+ - package exports point at `src/*`
13
+
14
+ ## What It Owns
15
+
16
+ - a Studio plugin via `aiImagePlugin(...)`
17
+ - a plugin-owned settings document and settings tool
18
+ - a generic image asset source
19
+ - optional generate-button targets for specific image fields
20
+ - a server helper export for the app-owned API route
21
+
22
+ ## Install Shape
23
+
24
+ The package exposes two entrypoints:
25
+
26
+ - `sanity-ai-image-plugin`
27
+ - `sanity-ai-image-plugin/server`
28
+
29
+ ## Consumer Setup
30
+
31
+ ### 1. Add the Studio plugin
32
+
33
+ ```ts
34
+ import { defineConfig } from "sanity";
35
+ import {
36
+ SUPPORTED_AI_IMAGE_MODELS,
37
+ createArticleFeaturedImageTarget,
38
+ aiImagePlugin,
39
+ } from "sanity-ai-image-plugin";
40
+
41
+ const allowedModels = [
42
+ SUPPORTED_AI_IMAGE_MODELS[0],
43
+ SUPPORTED_AI_IMAGE_MODELS[2],
44
+ ] as const;
45
+
46
+ export default defineConfig({
47
+ // ...your existing config
48
+ plugins: [
49
+ aiImagePlugin({
50
+ apiVersion: "2025-02-19",
51
+ allowedModels: [...allowedModels],
52
+ assetSource: true,
53
+ targets: [
54
+ createArticleFeaturedImageTarget(),
55
+ {
56
+ id: "home-page-featured-image",
57
+ type: "generateButton",
58
+ title: "Home Page Featured Image",
59
+ documentType: "homePage",
60
+ fieldPath: "featuredImage",
61
+ suggestedContextFieldPaths: ["title", "description"],
62
+ },
63
+ ],
64
+ }),
65
+ ],
66
+ });
67
+ ```
68
+
69
+ ### 2. Add the thin app-owned route.
70
+
71
+ ```ts
72
+ import {
73
+ handleAiImageRequest,
74
+ SUPPORTED_AI_IMAGE_MODELS,
75
+ } from "sanity-ai-image-plugin/server";
76
+
77
+ const allowedModels = [
78
+ SUPPORTED_AI_IMAGE_MODELS[0],
79
+ SUPPORTED_AI_IMAGE_MODELS[2],
80
+ ] as const;
81
+
82
+ export async function POST(request: Request) {
83
+ return handleAiImageRequest(request, {
84
+ allowedModels: [...allowedModels],
85
+ apiKey: process.env.GEMINI_API_KEY,
86
+ openAiApiKey: process.env.OPENAI_API_KEY,
87
+ sharedSecret: process.env.AI_IMAGE_PLUGIN_SHARED_SECRET!,
88
+ // Shared-secret auth and same-origin protection are enabled by default.
89
+ // Optional overrides:
90
+ // model: process.env.AI_IMAGE_MODEL as (typeof allowedModels)[number],
91
+ // maxReferenceFileBytes: 8 * 1024 * 1024,
92
+ // maxTotalReferenceBytes: 5 * 8 * 1024 * 1024,
93
+ })
94
+ }
95
+ ```
96
+
97
+ ### 3. Set env vars
98
+
99
+ - `GEMINI_API_KEY` is required when you allow Google models
100
+ - `OPENAI_API_KEY` is required when you allow OpenAI models
101
+ - `AI_IMAGE_PLUGIN_SHARED_SECRET` is required for the app-owned route
102
+ - `AI_IMAGE_MODEL` is optional and can still override the server default
103
+
104
+ ### 4. Configure the shared secret in Studio
105
+
106
+ Open the AI Image Plugin settings tool and configure the same shared secret
107
+ value there.
108
+
109
+ The plugin stores that Studio-side value with `@sanity/studio-secrets`, so it
110
+ is fetched at runtime for logged-in Studio users instead of being bundled into
111
+ the Studio source code.
112
+
113
+ ## Supported Models
114
+
115
+ The package has an internal supported-model registry. In this first pass it
116
+ contains exactly:
117
+
118
+ - `gemini-2.5-flash-image`
119
+ - `gemini-3.1-flash-image-preview`
120
+ - `gpt-image-1`
121
+
122
+ Each installation can opt into any non-empty subset of those models with the
123
+ ordered `allowedModels` config. The first allowed model becomes the fallback
124
+ default for both the Studio UI and the server helper unless the settings
125
+ document or route overrides it.
126
+
127
+ ## Settings Model
128
+
129
+ The plugin owns one settings document:
130
+
131
+ - `_id`: `aiImagePlugin.settings`
132
+ - `_type`: `aiImagePluginSettings`
133
+
134
+ It stores:
135
+
136
+ - `globalModel`
137
+ - `globalPrompt`
138
+ - `globalReferenceImages`
139
+ - `targetConfigs[]`
140
+
141
+ Each target config can override:
142
+
143
+ - `targetId`
144
+ - `prompt`
145
+ - `referenceImages`
146
+
147
+ ## Behavior
148
+
149
+ ### Server helper
150
+
151
+ The server helper requires a valid shared secret and same-origin browser
152
+ requests by default.
153
+
154
+ That means requests are accepted only when:
155
+
156
+ 1. the request includes the correct `x-ai-image-plugin-secret` header
157
+ 2. the browser `Origin` matches the API route origin exactly
158
+
159
+ Same-origin matches look like this:
160
+
161
+ - `http://localhost:3000/studio` -> `http://localhost:3000/api/ai-image-plugin`
162
+ - `https://myapp.vercel.app/studio` -> `https://myapp.vercel.app/api/ai-image-plugin`
163
+
164
+ The helper does not inspect the `/studio` path directly because browser
165
+ `Origin` headers only include the scheme, host, and port. The shared secret is
166
+ managed from the plugin settings tool and stored separately from the plugin's
167
+ normal prompt/reference-image settings document.
168
+
169
+ By default it also enforces:
170
+
171
+ - `8 MiB` maximum per reference image
172
+ - a combined reference-image cap of `maxReferences * 8 MiB`
173
+ - the requested `model` must be both package-supported and present in the
174
+ route's configured `allowedModels`
175
+
176
+ If your framework supports route-level body limits, keep those enabled too.
177
+
178
+ ### Asset source
179
+
180
+ The generic asset source composes:
181
+
182
+ 1. global prompt
183
+ 2. asset-source target prompt
184
+ 3. editor prompt
185
+
186
+ Reference images are combined from:
187
+
188
+ 1. global reference images
189
+ 2. asset-source target reference images
190
+ 3. local editor-uploaded reference images
191
+
192
+ The asset-source model picker starts on:
193
+
194
+ 1. `settings.globalModel` when it is present and allowed
195
+ 2. otherwise the first configured `allowedModels` entry
196
+
197
+ Editors can override that selection for the current request before generating.
198
+
199
+ ### Generate button targets
200
+
201
+ Generate-button targets match against:
202
+
203
+ - `documentType`
204
+ - `fieldPath`
205
+
206
+ When matched, the plugin renders a `Generate` button above the normal Sanity
207
+ image input.
208
+
209
+ Targets can also declare:
210
+
211
+ - `suggestedContextFieldPaths`
212
+
213
+ When the dialog opens, the plugin inspects the current document schema and shows
214
+ eligible top-level document fields as toggle tags. In this first pass, eligible
215
+ field types are:
216
+
217
+ - `string`
218
+ - `text`
219
+ - `number`
220
+ - `boolean`
221
+ - `date`
222
+ - `datetime`
223
+ - `slug`
224
+
225
+ Suggested context field paths are only default-on tags. They are filtered to
226
+ fields that exist on the current document type, and editors can toggle them on
227
+ or off for each generation.
228
+
229
+ The generate dialog also includes a model picker. It starts from the same
230
+ global default resolution as the asset source, but editors can switch to a
231
+ different allowed model for that one generation request.
232
+
233
+ Prompt composition order is:
234
+
235
+ 1. global prompt
236
+ 2. target prompt
237
+ 3. optional selected document context
238
+ 4. optional editor prompt
239
+
240
+ Selected document context is built as generic lines such as:
241
+
242
+ - `The field called "title" has content "...".`
243
+
244
+ ## Optional Preset
245
+
246
+ `createArticleFeaturedImageTarget(...)` is an optional preset for
247
+ `article.featuredImage`.
248
+
249
+ It feeds the model:
250
+
251
+ - shared global settings
252
+ - target-specific article settings
253
+ - editor-selectable document-derived title + excerpt context suggestions
254
+ - optional editor prompt
255
+
256
+ If you do not use that preset, the package still works as a generic asset source
257
+ and generic generate-button plugin.
258
+
259
+ ## Desk Structure
260
+
261
+ The plugin does not require custom desk structure wiring. If a consuming app
262
+ uses a custom structure and wants to hide `aiImagePluginSettings` from the normal
263
+ document list, that is optional and app-owned.
264
+
265
+ ## PNG Normalization
266
+
267
+ All reference images are converted to PNG before they are sent to the server
268
+ helper. That includes:
269
+
270
+ - locally uploaded reference files
271
+ - stored settings images downloaded from Sanity
272
+ - new images uploaded through the settings tool
273
+
274
+ ## Development
275
+
276
+ ```sh
277
+ bun run check
278
+ bun run build
279
+ bun test
280
+ ```
281
+
@@ -0,0 +1,3 @@
1
+ export { SUPPORTED_AI_IMAGE_MODELS } from "./utils/models";
2
+ export { aiImagePlugin } from "./studio/plugin";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { SUPPORTED_AI_IMAGE_MODELS } from "./utils/models";
2
+ export { aiImagePlugin } from "./studio/plugin";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GenerateButtonTarget } from "../utils/shared";
2
+ export declare function createArticleFeaturedImageTarget(options?: Partial<Omit<GenerateButtonTarget, "type">>): GenerateButtonTarget;
3
+ //# sourceMappingURL=article-featured-image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article-featured-image.d.ts","sourceRoot":"","sources":["../../src/presets/article-featured-image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D,wBAAgB,gCAAgC,CAC9C,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAM,GACxD,oBAAoB,CAkBtB"}
@@ -0,0 +1,17 @@
1
+ export function createArticleFeaturedImageTarget(options = {}) {
2
+ return {
3
+ id: options.id || "article-featured-image",
4
+ type: "generateButton",
5
+ title: options.title || "Article Featured Image",
6
+ description: options.description ||
7
+ "Adds a Generate button that combines shared art direction, article context, and an optional editor prompt.",
8
+ dialogTitle: options.dialogTitle || "Generate Featured Image",
9
+ documentType: options.documentType || "article",
10
+ fieldPath: options.fieldPath || "featuredImage",
11
+ promptLabel: options.promptLabel || "Custom prompt",
12
+ promptPlaceholder: options.promptPlaceholder ||
13
+ "Optional custom instructions for this article image.",
14
+ suggestedContextFieldPaths: options.suggestedContextFieldPaths || ["title", "excerpt"],
15
+ };
16
+ }
17
+ //# sourceMappingURL=article-featured-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"article-featured-image.js","sourceRoot":"","sources":["../../src/presets/article-featured-image.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gCAAgC,CAC9C,UAAuD,EAAE;IAEzD,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,wBAAwB;QAC1C,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,wBAAwB;QAChD,WAAW,EACT,OAAO,CAAC,WAAW;YACnB,4GAA4G;QAC9G,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,yBAAyB;QAC7D,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,SAAS;QAC/C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,eAAe;QAC/C,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,eAAe;QACnD,iBAAiB,EACf,OAAO,CAAC,iBAAiB;YACzB,sDAAsD;QACxD,0BAA0B,EACxB,OAAO,CAAC,0BAA0B,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;KAC7D,CAAA;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const DEFAULT_MODEL: "gemini-2.5-flash-image" | "gemini-3.1-flash-image-preview" | "gpt-image-1";
2
+ export declare const DEFAULT_PROVIDER_API_URL = "https://generativelanguage.googleapis.com/v1beta";
3
+ export declare const DEFAULT_MAX_REFERENCE_FILE_BYTES: number;
4
+ export declare const SUPPORTED_REFERENCE_IMAGE_TYPES: Set<string>;
5
+ export declare const OPENAI_SUPPORTED_REFERENCE_IMAGE_TYPES: Set<string>;
6
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/server/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,6EAAmC,CAAC;AAC9D,eAAO,MAAM,wBAAwB,qDACe,CAAC;AACrD,eAAO,MAAM,gCAAgC,QAAkB,CAAC;AAEhE,eAAO,MAAM,+BAA+B,aAM1C,CAAC;AAEH,eAAO,MAAM,sCAAsC,aAIjD,CAAC"}
@@ -1,20 +1,17 @@
1
- import { DEFAULT_SUPPORTED_AI_IMAGE_MODEL } from "../utils/models";
2
-
3
- export const DEFAULT_MODEL = DEFAULT_SUPPORTED_AI_IMAGE_MODEL;
4
- export const DEFAULT_PROVIDER_API_URL =
5
- "https://generativelanguage.googleapis.com/v1beta";
6
- export const DEFAULT_MAX_REFERENCE_FILE_BYTES = 8 * 1024 * 1024;
7
-
8
- export const SUPPORTED_REFERENCE_IMAGE_TYPES = new Set([
9
- "image/heic",
10
- "image/heif",
11
- "image/jpeg",
12
- "image/png",
13
- "image/webp",
14
- ]);
15
-
16
- export const OPENAI_SUPPORTED_REFERENCE_IMAGE_TYPES = new Set([
17
- "image/jpeg",
18
- "image/png",
19
- "image/webp",
20
- ]);
1
+ import { DEFAULT_SUPPORTED_AI_IMAGE_MODEL } from "../utils/models";
2
+ export const DEFAULT_MODEL = DEFAULT_SUPPORTED_AI_IMAGE_MODEL;
3
+ export const DEFAULT_PROVIDER_API_URL = "https://generativelanguage.googleapis.com/v1beta";
4
+ export const DEFAULT_MAX_REFERENCE_FILE_BYTES = 8 * 1024 * 1024;
5
+ export const SUPPORTED_REFERENCE_IMAGE_TYPES = new Set([
6
+ "image/heic",
7
+ "image/heif",
8
+ "image/jpeg",
9
+ "image/png",
10
+ "image/webp",
11
+ ]);
12
+ export const OPENAI_SUPPORTED_REFERENCE_IMAGE_TYPES = new Set([
13
+ "image/jpeg",
14
+ "image/png",
15
+ "image/webp",
16
+ ]);
17
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/server/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,CAAC,MAAM,aAAa,GAAG,gCAAgC,CAAC;AAC9D,MAAM,CAAC,MAAM,wBAAwB,GACnC,kDAAkD,CAAC;AACrD,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhE,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAC;IACrD,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,GAAG,CAAC;IAC5D,YAAY;IACZ,WAAW;IACX,YAAY;CACb,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { RequestOptions } from "./types";
2
+ export { DEFAULT_MAX_REFERENCE_FILE_BYTES, DEFAULT_MODEL, DEFAULT_PROVIDER_API_URL, SUPPORTED_REFERENCE_IMAGE_TYPES, } from "./constants";
3
+ export type { RequestOptions, SuccessResponse } from "./types";
4
+ export declare function handleAiImageRequest(request: Request, options: RequestOptions): Promise<Response>;
5
+ //# sourceMappingURL=handle-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-request.d.ts","sourceRoot":"","sources":["../../src/server/handle-request.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,SAAS,CAAC;AAC/D,OAAO,EACL,gCAAgC,EAChC,aAAa,EACb,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/D,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,QAAQ,CAAC,CA4LnB"}