@dyrected/sdk 1.0.9 → 2.4.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/index.cjs CHANGED
@@ -32,7 +32,9 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  DyrectedClient: () => DyrectedClient,
34
34
  DyrectedError: () => DyrectedError,
35
- createClient: () => createClient
35
+ createClient: () => createClient,
36
+ generateAIPrompt: () => generateAIPrompt,
37
+ generateFreshSetupPrompt: () => generateFreshSetupPrompt
36
38
  });
37
39
  module.exports = __toCommonJS(index_exports);
38
40
  var import_qs = __toESM(require("qs"), 1);
@@ -79,6 +81,818 @@ var QueryBuilder = class {
79
81
  }
80
82
  };
81
83
 
84
+ // src/utils/setup-prompt.ts
85
+ function buildEnvironmentSection(frameworkLabel, isSelfHosted, config) {
86
+ const credentialLines = isSelfHosted ? "" : `- Site ID : ${config.siteId}
87
+ - API Key : ${config.apiKey}`;
88
+ return `
89
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
90
+ 1. ENVIRONMENT
91
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
92
+ - Framework : ${frameworkLabel || "Detect it"}
93
+ - Host Type : ${isSelfHosted ? "Self-Hosted (Local/Private Server)" : "Managed (Dyrected Cloud)"}
94
+ - API Base : ${config.baseUrl || "http://localhost:3000"}
95
+ ${credentialLines}`;
96
+ }
97
+ function buildDiagnosticSection() {
98
+ return `
99
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
100
+ 2. PHASE 0 \u2014 DISCOVERY
101
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
102
+ Before writing any code, you MUST ask the user these questions.
103
+ Write them exactly as shown below \u2014 in plain language with examples.
104
+ Wait for the user to answer ALL of them before proceeding.
105
+
106
+ \u2500\u2500\u2500 QUESTION 1 \u2500\u2500\u2500
107
+ Ask:
108
+ "Do you already have a website built, or are we starting fresh?
109
+
110
+ \u2192 Already built: share your project or describe what pages you have
111
+ (e.g. Home, About, Services, Contact)
112
+ \u2192 Starting fresh: just say 'new site' and describe what the site is for"
113
+
114
+ \u2500\u2500\u2500 QUESTION 2 \u2500\u2500\u2500
115
+ Ask:
116
+ "What kind of content will your client need to update regularly?
117
+
118
+ Here are some examples to help you think:
119
+ \u2192 Blog posts or news articles
120
+ \u2192 Team member profiles (name, photo, bio)
121
+ \u2192 Services or product descriptions
122
+ \u2192 Testimonials or reviews
123
+ \u2192 Event listings
124
+ \u2192 FAQs
125
+ \u2192 Homepage text (headline, hero image, call-to-action button)
126
+
127
+ Just list the ones that apply. You can say things like:
128
+ 'They need to update blog posts and team members'"
129
+
130
+ \u2500\u2500\u2500 QUESTION 3 \u2500\u2500\u2500
131
+ Ask:
132
+ "Are there any pages on the site that should NEVER change \u2014 like a
133
+ custom-coded page you want to leave exactly as it is?
134
+
135
+ Example answer: 'The homepage has a custom animation, leave that alone.
136
+ Everything else can be managed from the CMS.'
137
+
138
+ If everything should be manageable, just say 'all pages'"
139
+
140
+ \u2500\u2500\u2500 QUESTION 4 \u2500\u2500\u2500
141
+ Ask:
142
+ "What is this website for? Pick the closest description:
143
+
144
+ A) A business or agency marketing site (show services, get leads)
145
+ B) A blog or content site (publish articles regularly)
146
+ C) A SaaS or product site (landing page, pricing, features)
147
+ D) A portfolio (show work, case studies)
148
+ E) An e-commerce or product catalogue
149
+ F) Something else \u2014 describe it in one sentence"
150
+
151
+ \u2500\u2500\u2500 IF EXISTING SITE \u2500\u2500\u2500
152
+ If the user confirms they have an existing site, also:
153
+ - Scan the codebase for all hardcoded text that should be CMS-managed
154
+ - Identify repeated data structures that should become collections
155
+ - Propose saving current content to a migration/ folder as .json files
156
+ BEFORE touching any code
157
+ - Report your findings to the user and get confirmation before proceeding
158
+
159
+ Do NOT write any implementation code until all questions are answered
160
+ and the user has confirmed the content plan.`;
161
+ }
162
+ function buildConstraintsSection() {
163
+ return `
164
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
165
+ 3. ARCHITECTURE & CONSTRAINTS
166
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
167
+ - API ACCESS : Use client.collection(slug) as the only entry point.
168
+ - ZERO-STATE : Always use initialData in all data fetches so the site
169
+ renders correctly on first load and never throws during render.
170
+ - MARKETING FREEDOM : Use a dynamic pages collection with a catch-all route
171
+ so marketing can create and manage pages without a developer.
172
+ - BLOCKS DESIGN : Use blocks for flexible page builders. Store as
173
+ [{ blockType: 'slug', ...fields }] and switch on blockType
174
+ in the frontend renderer.
175
+ - DATA SAFETY : Never overwrite or drop existing content or pages.
176
+ Preserve everything before making changes.
177
+ - RESILIENCE : If Dyrected backend is unreachable, fall back to
178
+ initialData and show stale content \u2014 never an error page.
179
+ All relationship fields must handle null gracefully.
180
+ Every block renderer must have a default fallback case.`;
181
+ }
182
+ function buildSchemaRulesSection() {
183
+ return `
184
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
185
+ 4. SCHEMA EVOLUTION RULES
186
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
187
+ - Never drop existing fields from the schema. Mark unused fields as deprecated only.
188
+ - All new fields must have a defaultValue.
189
+ - Never rename a field slug \u2014 add a new field and migrate data separately.
190
+ - For Cloud deployments, run npx @dyrected/cli sync:schema after every config change. Self-hosted deployments sync automatically on startup.`;
191
+ }
192
+ function buildDoNotSection() {
193
+ return `
194
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
195
+ 5. DO NOT
196
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
197
+ - Do NOT use client.collections \u2014 always use client.collection(slug).
198
+ - Do NOT add custom auth middleware to the admin route.
199
+ Dyrected handles admin authentication internally. Do not wrap,
200
+ protect, or redirect the admin route yourself.
201
+ - Do NOT use renderAdminUI in a Nuxt.js project. Use the DyrectedAdmin
202
+ component which is auto-imported by @dyrected/nuxt.
203
+ - Do NOT modify or overwrite existing pages without first preserving their data.
204
+ - Do NOT drop, rename, or remove fields from an existing schema.
205
+ - Do NOT integrate blog posts or testimonials unless explicitly requested.
206
+ - Do NOT skip the diagnostic or discovery phase.`;
207
+ }
208
+ function buildTechnicalReferenceSection() {
209
+ return `
210
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
211
+ 6. TECHNICAL REFERENCE
212
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
213
+ Use defineCollection, defineGlobal, and defineConfig from '@dyrected/core'.
214
+
215
+ FIELD TYPES:
216
+ - Primitive : text | textarea | richText | number | boolean | date | email | url | json | image
217
+ - Choice : select | multiSelect (requires options: [{ label, value }])
218
+ - Structural : array | object (requires nested fields: [...])
219
+ - Relation : relationship (requires relationTo: '<slug>')
220
+ - Media : relationship to an upload collection (e.g. 'media')
221
+ - Blocks : blocks (requires blocks: [{ slug, labels, fields }])
222
+
223
+ COLLECTION OPTIONS:
224
+ - upload: true \u2014 media library with file upload support
225
+ - auth: true \u2014 adds login/me endpoints; password field is auto-managed
226
+ - audit: true \u2014 enables activity logging
227
+ - admin.useAsTitle \u2014 field used as display title in admin list view
228
+ - admin.group \u2014 groups collection under a sidebar heading
229
+ - admin.hidden \u2014 hides collection from the sidebar (internal/system use)
230
+
231
+ FIELD OPTIONS:
232
+ - label \u2014 user-friendly display name (REQUIRED for all fields)
233
+ - required \u2014 validation
234
+ - unique \u2014 database-level uniqueness constraint
235
+ - hasMany \u2014 allow multiple values (for relationship, select, image)
236
+ - defaultValue \u2014 fallback value (required on all new fields added to existing schemas)
237
+ - admin.condition \u2014 Jexl expression string to conditionally show/hide field
238
+ e.g. "status == \\"published\\""
239
+ - admin.readOnly \u2014 display only, not editable
240
+ - admin.hidden \u2014 hidden from editor UI entirely
241
+ - hooks.beforeChange \u2014 [async (value) => newValue] transform before save
242
+ - hooks.afterRead \u2014 [async (value) => newValue] transform after read
243
+
244
+ GLOBALS:
245
+ Use defineGlobal for single-instance documents like site settings or navigation.
246
+ Access via client.global(slug).get() and client.global(slug).update(data).
247
+
248
+ BLOCKS:
249
+ Blocks are stored as [{ blockType: '<slug>', ...fields }].
250
+ The admin renders a drag-and-drop block editor automatically.
251
+ On the frontend, iterate the array and switch on block.blockType.
252
+ Always include a default case in your switch for unknown block types.
253
+
254
+ COMPLETE SCHEMA EXAMPLE:
255
+ \`\`\`ts
256
+ import { defineCollection, defineGlobal, defineConfig } from '@dyrected/core'
257
+ import { SqliteAdapter } from '@dyrected/db-sqlite'
258
+
259
+ const media = defineCollection({
260
+ slug: 'media',
261
+ upload: true,
262
+ fields: [
263
+ { name: 'alt', label: 'Alt Text', type: 'text' },
264
+ ],
265
+ })
266
+
267
+ const pages = defineCollection({
268
+ slug: 'pages',
269
+ admin: { useAsTitle: 'title', group: 'Content' },
270
+ fields: [
271
+ { name: 'title', label: 'Title', type: 'text', required: true },
272
+ { name: 'slug', label: 'URL Slug', type: 'text', required: true, unique: true },
273
+ { name: 'seo', label: 'SEO Metadata', type: 'object', fields: [
274
+ { name: 'metaTitle', label: 'Meta Title', type: 'text' },
275
+ { name: 'metaDescription', label: 'Meta Description', type: 'textarea' },
276
+ { name: 'ogImage', label: 'OG Image', type: 'relationship', relationTo: 'media' },
277
+ ]},
278
+ {
279
+ name: 'layout',
280
+ label: 'Page Layout',
281
+ type: 'blocks',
282
+ blocks: [
283
+ {
284
+ slug: 'hero',
285
+ labels: { singular: 'Hero', plural: 'Heroes' },
286
+ fields: [
287
+ { name: 'heading', label: 'Heading', type: 'text', required: true },
288
+ { name: 'subheading', label: 'Subheading', type: 'textarea' },
289
+ { name: 'image', label: 'Hero Image', type: 'relationship', relationTo: 'media' },
290
+ { name: 'ctaLabel', label: 'Button Label', type: 'text' },
291
+ { name: 'ctaLink', label: 'Button Link', type: 'url' },
292
+ ],
293
+ },
294
+ {
295
+ slug: 'richContent',
296
+ labels: { singular: 'Rich Content', plural: 'Rich Content Blocks' },
297
+ fields: [
298
+ { name: 'content', label: 'Content', type: 'richText', required: true },
299
+ ],
300
+ },
301
+ {
302
+ slug: 'callToAction',
303
+ labels: { singular: 'Call to Action', plural: 'Calls to Action' },
304
+ fields: [
305
+ { name: 'heading', label: 'Heading', type: 'text', required: true },
306
+ { name: 'description', label: 'Description', type: 'textarea' },
307
+ { name: 'buttonLabel', label: 'Button Text', type: 'text' },
308
+ { name: 'buttonLink', label: 'Button Link', type: 'url' },
309
+ { name: 'theme', label: 'Theme', type: 'select', options: [
310
+ { label: 'Primary', value: 'primary' },
311
+ { label: 'Secondary', value: 'secondary' },
312
+ { label: 'Dark', value: 'dark' },
313
+ ]},
314
+ ],
315
+ },
316
+ ],
317
+ },
318
+ ],
319
+ })
320
+
321
+ const settings = defineGlobal({
322
+ slug: 'settings',
323
+ label: 'Site Settings',
324
+ fields: [
325
+ { name: 'siteName', label: 'Site Name', type: 'text' },
326
+ { name: 'tagline', label: 'Site Tagline', type: 'text' },
327
+ { name: 'logo', label: 'Site Logo', type: 'relationship', relationTo: 'media' },
328
+ { name: 'footerText', label: 'Footer Text', type: 'textarea' },
329
+ ],
330
+ })
331
+
332
+ export default defineConfig({
333
+ collections: [media, pages],
334
+ globals: [settings],
335
+ db: new SqliteAdapter({ filename: './dyrected.db' }),
336
+ })
337
+ \`\`\``;
338
+ }
339
+ function buildDeliverablesSection() {
340
+ return `
341
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
342
+ 7. REQUIRED DELIVERABLES \u2014 IN THIS ORDER
343
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
344
+ Return your response in exactly this order. Do not combine steps. Do not skip steps.
345
+
346
+ 1. Diagnostic findings (what exists, what needs to become CMS-managed)
347
+ 2. dyrected.config.ts \u2014 complete file
348
+ 3. Admin route file \u2014 complete file
349
+ 4. Catch-all frontend page route \u2014 complete file
350
+ 5. Block components \u2014 names and fields only
351
+ 6. Migration/fallback strategy \u2014 numbered steps
352
+ 7. Schema sync command
353
+
354
+ API Reference: https://docs.dyrected.com
355
+ If you are unsure about any syntax or property, refer to the documentation above.`;
356
+ }
357
+ function buildFrameworkSection(activeTab, isSelfHosted, config) {
358
+ const envPrefix = activeTab === "next" ? "NEXT_PUBLIC_" : activeTab === "nuxt" ? "NUXT_PUBLIC_" : "";
359
+ const credentialEnvLines = isSelfHosted ? "" : `
360
+ apiKey: process.env.${envPrefix}DYRECTED_API_KEY || '${config.apiKey}',
361
+ siteId: process.env.${envPrefix}SITE_ID || '${config.siteId}',`;
362
+ const baseUrlLine = `process.env.${envPrefix}DYRECTED_URL || '${config.baseUrl || "http://localhost:3000"}'`;
363
+ const sections = {
364
+ next: `
365
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
366
+ 8. IMPLEMENTATION \u2014 Next.js
367
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
368
+ 1. SDK Setup (lib/dyrected.ts):
369
+ \`\`\`ts
370
+ import { createClient } from '@dyrected/sdk'
371
+
372
+ export const dyrected = createClient({
373
+ baseUrl: ${baseUrlLine},${credentialEnvLines}
374
+ })
375
+ \`\`\`
376
+
377
+ 2. Admin Route (app/cms/page.tsx):
378
+ \`\`\`tsx
379
+ import { DyrectedAdmin } from '@dyrected/next/admin'
380
+
381
+ export default function AdminPage() {
382
+ // DyrectedAdmin handles routing, auth, and CSS automatically.
383
+ // Do NOT wrap this in custom auth middleware.
384
+ return <DyrectedAdmin basename="/cms" />
385
+ }
386
+ \`\`\`
387
+
388
+ 3. Catch-all Page Route (app/[...slug]/page.tsx):
389
+ \`\`\`tsx
390
+ import { dyrected } from '@/lib/dyrected'
391
+
392
+ export default async function CmsPage({ params }: { params: { slug: string[] } }) {
393
+ const slug = params.slug?.join('/') || 'home'
394
+ const page = await dyrected.collection('pages').findOne({ where: { slug: { equals: slug } } })
395
+
396
+ if (!page) return <div>Page not found</div>
397
+
398
+ return (
399
+ <main>
400
+ {page.layout?.map((block: any, i: number) => (
401
+ <BlockRenderer key={i} block={block} />
402
+ ))}
403
+ </main>
404
+ )
405
+ }
406
+ \`\`\``,
407
+ nuxt: `
408
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
409
+ 8. IMPLEMENTATION \u2014 Nuxt.js
410
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
411
+ 1. Nuxt.js Config (nuxt.config.ts):
412
+ \`\`\`ts
413
+ export default defineNuxtConfig({
414
+ modules: ['@dyrected/nuxt'],
415
+ dyrected: {
416
+ baseUrl: process.env.${envPrefix}DYRECTED_URL || '${config.baseUrl || "http://localhost:3000"}',${isSelfHosted ? "" : `
417
+ apiKey: process.env.${envPrefix}DYRECTED_API_KEY || '${config.apiKey}',
418
+ siteId: process.env.${envPrefix}SITE_ID || '${config.siteId}',`}
419
+ },
420
+ })
421
+ \`\`\`
422
+
423
+ 2. Admin Route (pages/cms/index.vue):
424
+ \`\`\`vue
425
+ <script setup lang="ts">
426
+ // DyrectedAdmin is auto-imported by @dyrected/nuxt.
427
+ // Do NOT manually import it.
428
+ // Do NOT use renderAdminUI here.
429
+ // Do NOT add custom auth middleware \u2014 Dyrected handles authentication.
430
+ definePageMeta({ layout: false })
431
+ </script>
432
+
433
+ <template>
434
+ <ClientOnly>
435
+ <DyrectedAdmin basename="/cms" />
436
+ </ClientOnly>
437
+ </template>
438
+ \`\`\`
439
+
440
+ 3. Catch-all Page Route (pages/[...slug].vue):
441
+ \`\`\`vue
442
+ <script setup lang="ts">
443
+ const route = useRoute()
444
+ const slug = computed(() =>
445
+ Array.isArray(route.params.slug)
446
+ ? route.params.slug.join('/')
447
+ : route.params.slug || 'home'
448
+ )
449
+
450
+ const { data: page } = await useDyrected('pages').findOne({
451
+ where: { slug: { equals: slug.value } },
452
+ initialData: null,
453
+ })
454
+ </script>
455
+
456
+ <template>
457
+ <main v-if="page">
458
+ <BlockRenderer
459
+ v-for="(block, i) in page.layout"
460
+ :key="i"
461
+ :block="block"
462
+ />
463
+ </main>
464
+ <div v-else>Page not found</div>
465
+ </template>
466
+ \`\`\``,
467
+ react: `
468
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
469
+ 8. IMPLEMENTATION \u2014 React
470
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
471
+ 1. SDK Setup (lib/dyrected.ts):
472
+ \`\`\`ts
473
+ import { createClient } from '@dyrected/sdk'
474
+
475
+ export const dyrected = createClient({
476
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
477
+ apiKey: '${config.apiKey}',
478
+ siteId: '${config.siteId}',`}
479
+ })
480
+ \`\`\`
481
+
482
+ 2. Admin Route (pages/cms.tsx):
483
+ \`\`\`tsx
484
+ import { AdminUI } from '@dyrected/admin'
485
+ import '@dyrected/admin/styles'
486
+
487
+ export default function AdminPage() {
488
+ return (
489
+ <div style={{ height: '100vh' }}>
490
+ <AdminUI
491
+ baseUrl="${config.baseUrl || "https://api.dyrected.cloud"}"${isSelfHosted ? "" : `
492
+ apiKey="${config.apiKey}"
493
+ siteId="${config.siteId}"`}
494
+ />
495
+ </div>
496
+ )
497
+ }
498
+ \`\`\``,
499
+ vue: `
500
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
501
+ 8. IMPLEMENTATION \u2014 Vue
502
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
503
+ 1. SDK Setup (lib/dyrected.ts):
504
+ \`\`\`ts
505
+ import { createClient } from '@dyrected/sdk'
506
+
507
+ export const dyrected = createClient({
508
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
509
+ apiKey: '${config.apiKey}',
510
+ siteId: '${config.siteId}',`}
511
+ })
512
+ \`\`\`
513
+
514
+ 2. Admin Route (pages/cms.vue):
515
+ \`\`\`vue
516
+ <template>
517
+ <div ref="container" style="height: 100vh" />
518
+ </template>
519
+
520
+ <script setup>
521
+ import { ref, onMounted, onUnmounted } from 'vue'
522
+ import { renderAdminUI } from '@dyrected/admin'
523
+ import '@dyrected/admin/styles'
524
+
525
+ const container = ref(null)
526
+ let cleanup: (() => void) | undefined
527
+
528
+ onMounted(() => {
529
+ cleanup = renderAdminUI(container.value, {
530
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
531
+ apiKey: '${config.apiKey}',
532
+ siteId: '${config.siteId}',`}
533
+ })
534
+ })
535
+
536
+ onUnmounted(() => cleanup?.())
537
+ </script>
538
+ \`\`\``
539
+ };
540
+ return sections[activeTab] || sections.next;
541
+ }
542
+ function generateFreshSetupPrompt(activeTab, config) {
543
+ const frameworkLabel = activeTab === "next" ? "Next.js" : activeTab === "nuxt" ? "Nuxt.js" : activeTab ? activeTab.charAt(0).toUpperCase() + activeTab.slice(1) : "the project's detected framework";
544
+ const isSelfHosted = config.isSelfHosted === true || !config.apiKey && !config.siteId;
545
+ const frameworkSetup = {
546
+ nuxt: `
547
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
548
+ 3. INSTALLATION STEPS \u2014 Run these in order
549
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
550
+ Tell the user to follow these steps exactly. Explain each one in plain
551
+ language before showing the command. Do not skip any step.
552
+
553
+ STEP 1 \u2014 Initialize Dyrected
554
+ Tell the user:
555
+ "Run this command in your terminal inside your Nuxt.js project folder.
556
+ It will set everything up for you automatically."
557
+
558
+ \`\`\`bash
559
+ npx @dyrected/cli init
560
+ \`\`\`
561
+
562
+ When it asks questions, tell the user to:
563
+ - Choose: Nuxt.js 3
564
+ - Choose: SQLite (easiest option, no extra setup needed)
565
+
566
+ The CLI will automatically:
567
+ - Install all required packages
568
+ - Create a dyrected.config.ts file
569
+ - Mount the Admin UI at pages/cms/index.vue
570
+ - Generate a .env.example file
571
+
572
+ STEP 2 \u2014 Register the module
573
+ Tell the user to open nuxt.config.ts and add '@dyrected/nuxt' to modules:
574
+
575
+ \`\`\`ts
576
+ export default defineNuxtConfig({
577
+ modules: ['@dyrected/nuxt'],
578
+ })
579
+ \`\`\`
580
+
581
+ STEP 3 \u2014 Set up environment variables
582
+ Tell the user:
583
+ "Find the file called .env.example in your project.
584
+ Make a copy of it and rename the copy to .env
585
+ Then open .env and fill in the values."
586
+
587
+ STEP 4 \u2014 Start the project
588
+ \`\`\`bash
589
+ pnpm dev
590
+ \`\`\`
591
+
592
+ STEP 5 \u2014 Open the dashboard
593
+ Tell the user to open their browser and go to:
594
+ http://localhost:3000/cms
595
+
596
+ If they see the Dyrected admin dashboard, the installation worked.
597
+ Tell them: "You are ready. Now let's set up your content."`,
598
+ next: `
599
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
600
+ 3. INSTALLATION STEPS \u2014 Run these in order
601
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
602
+ Tell the user to follow these steps exactly. Explain each one in plain
603
+ language before showing the command. Do not skip any step.
604
+
605
+ STEP 1 \u2014 Initialize Dyrected
606
+ Tell the user:
607
+ "Run this command in your terminal inside your Next.js project folder."
608
+
609
+ \`\`\`bash
610
+ npx @dyrected/cli init
611
+ \`\`\`
612
+
613
+ When it asks questions, tell the user to:
614
+ - Choose: Next.js
615
+ - Choose: SQLite (easiest option, no extra setup needed)
616
+
617
+ The CLI will automatically:
618
+ - Install all required packages
619
+ - Create a dyrected.config.ts file
620
+ - Mount the Admin UI at app/cms/page.tsx
621
+ - Generate a .env.example file
622
+
623
+ STEP 2 \u2014 Set up environment variables
624
+ Tell the user:
625
+ "Find the file called .env.example in your project.
626
+ Make a copy of it and rename the copy to .env.local
627
+ Then open .env.local and fill in the values."
628
+
629
+ STEP 3 \u2014 Start the project
630
+ \`\`\`bash
631
+ pnpm dev
632
+ \`\`\`
633
+
634
+ STEP 4 \u2014 Open the dashboard
635
+ Tell the user to open their browser and go to:
636
+ http://localhost:3000/cms
637
+
638
+ If they see the Dyrected admin dashboard, the installation worked.
639
+ Tell them: "You are ready. Now let's set up your content."`,
640
+ react: `
641
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
642
+ 3. INSTALLATION STEPS \u2014 Run these in order
643
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
644
+ STEP 1 \u2014 Install the SDK and admin packages
645
+ \`\`\`bash
646
+ npm install @dyrected/sdk @dyrected/admin
647
+ \`\`\`
648
+
649
+ STEP 2 \u2014 Set up the client (lib/dyrected.ts):
650
+ \`\`\`ts
651
+ import { createClient } from '@dyrected/sdk'
652
+
653
+ export const dyrected = createClient({
654
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
655
+ apiKey: '${config.apiKey}',
656
+ siteId: '${config.siteId}',`}
657
+ })
658
+ \`\`\`
659
+
660
+ STEP 3 \u2014 Mount the Admin UI (pages/cms.tsx):
661
+ \`\`\`tsx
662
+ import { AdminUI } from '@dyrected/admin'
663
+ import '@dyrected/admin/styles'
664
+
665
+ export default function AdminPage() {
666
+ return (
667
+ <div style={{ height: '100vh' }}>
668
+ <AdminUI
669
+ baseUrl="${config.baseUrl || "https://api.dyrected.cloud"}"${isSelfHosted ? "" : `
670
+ apiKey="${config.apiKey}"
671
+ siteId="${config.siteId}"`}
672
+ />
673
+ </div>
674
+ )
675
+ }
676
+ \`\`\``,
677
+ vue: `
678
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
679
+ 3. INSTALLATION STEPS \u2014 Run these in order
680
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
681
+ STEP 1 \u2014 Install the SDK and admin packages
682
+ \`\`\`bash
683
+ npm install @dyrected/sdk @dyrected/admin
684
+ \`\`\`
685
+
686
+ STEP 2 \u2014 Set up the client (lib/dyrected.ts):
687
+ \`\`\`ts
688
+ import { createClient } from '@dyrected/sdk'
689
+
690
+ export const dyrected = createClient({
691
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
692
+ apiKey: '${config.apiKey}',
693
+ siteId: '${config.siteId}',`}
694
+ })
695
+ \`\`\`
696
+
697
+ STEP 3 \u2014 Mount the Admin UI (pages/cms.vue):
698
+ \`\`\`vue
699
+ <template>
700
+ <div ref="container" style="height: 100vh" />
701
+ </template>
702
+
703
+ <script setup>
704
+ import { ref, onMounted, onUnmounted } from 'vue'
705
+ import { renderAdminUI } from '@dyrected/admin'
706
+ import '@dyrected/admin/styles'
707
+
708
+ const container = ref(null)
709
+ let cleanup
710
+
711
+ onMounted(() => {
712
+ cleanup = renderAdminUI(container.value, {
713
+ baseUrl: '${config.baseUrl || "https://api.dyrected.cloud"}',${isSelfHosted ? "" : `
714
+ apiKey: '${config.apiKey}',
715
+ siteId: '${config.siteId}',`}
716
+ })
717
+ })
718
+
719
+ onUnmounted(() => cleanup?.())
720
+ </script>
721
+ \`\`\``
722
+ };
723
+ return [
724
+ `You are a friendly technical assistant helping someone set up Dyrected CMS for the very first time in a ${frameworkLabel} project. They have NOT installed anything yet.
725
+
726
+ Your job is to:
727
+ 1. Understand who you are talking to before giving any instructions
728
+ 2. Ask simple questions about their project and content needs
729
+ 3. Walk them through setup in a way that matches their technical level
730
+ 4. Confirm each step worked before moving to the next
731
+ 5. Help them design their content so their client can manage it
732
+
733
+ Speak in plain language at all times. Never assume technical knowledge.
734
+ Never show more than one step at a time.
735
+ Never mention the terminal, command line, or any commands until you have
736
+ confirmed the user is comfortable running them.`,
737
+ `
738
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
739
+ 1. ENVIRONMENT
740
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
741
+ - Framework : ${frameworkLabel}
742
+ - Host Type : ${isSelfHosted ? "Self-Hosted" : "Dyrected Cloud"}
743
+ - API Base : ${config.baseUrl || "http://localhost:3000"}
744
+ ${isSelfHosted ? "" : `- Site ID : ${config.siteId}
745
+ - API Key : ${config.apiKey}`}`.trim(),
746
+ `
747
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
748
+ 2. PHASE 0 \u2014 UNDERSTAND THE USER FIRST
749
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
750
+ Ask these questions one at a time. Wait for each answer before asking the next.
751
+ Never ask more than one question at a time.
752
+
753
+ \u2500\u2500\u2500 QUESTION 1 \u2014 TECH LEVEL \u2500\u2500\u2500
754
+ This is the most important question. Ask it first.
755
+
756
+ Ask exactly this:
757
+ "Before we dive in \u2014 how would you describe yourself?
758
+
759
+ A) I write code myself (I'm comfortable with the terminal and editing files)
760
+ B) I use tools like Lovable, Bolt, or v0 to build with AI \u2014 I don't write much code myself
761
+ C) I'm a designer or project manager \u2014 someone else usually handles the technical stuff
762
+ D) Something else \u2014 just describe how you work"
763
+
764
+ Use their answer to decide how to guide them for the rest of the setup:
765
+ - If A \u2192 they are TECHNICAL. You may show terminal commands and code directly.
766
+ - If B \u2192 they are SEMI-TECHNICAL. Explain what each step does before showing
767
+ any code or commands. Ask before running anything in the terminal.
768
+ For Lovable users specifically: guide them to use the built-in
769
+ terminal or ask them to paste code into the right file in their editor.
770
+ - If C \u2192 they are NON-TECHNICAL. Do not show terminal commands at all.
771
+ Generate all the code and config for them. Walk them through
772
+ copy-pasting into specific files by name. If a terminal step is
773
+ unavoidable, warn them first and offer to write the exact command
774
+ with a clear explanation of what it does and where to run it.
775
+ - If D \u2192 ask one follow-up question to understand their workflow before
776
+ deciding which path above fits best.
777
+
778
+ \u2500\u2500\u2500 QUESTION 2 \u2014 PROJECT STATUS \u2500\u2500\u2500
779
+ Ask after Q1 is answered:
780
+
781
+ "Do you already have a ${frameworkLabel} project open,
782
+ or are we starting from scratch?
783
+
784
+ \u2192 Already have a project: tell me what the site is about or
785
+ share the folder name
786
+ \u2192 Starting fresh: just say 'new project' and I will help you
787
+ create one first"
788
+
789
+ \u2500\u2500\u2500 QUESTION 3 \u2014 SITE PURPOSE \u2500\u2500\u2500
790
+ Ask after Q2 is answered:
791
+
792
+ "What kind of website is this?
793
+
794
+ A) A business or agency site (show services, get enquiries)
795
+ B) A blog or news site (publish articles regularly)
796
+ C) A SaaS or product landing page (features, pricing, sign up)
797
+ D) A portfolio (show work and past projects)
798
+ E) Something else \u2014 describe it in one sentence"
799
+
800
+ \u2500\u2500\u2500 QUESTION 4 \u2014 CONTENT NEEDS \u2500\u2500\u2500
801
+ Ask after Q3 is answered:
802
+
803
+ "What will your client need to update themselves \u2014 without calling you?
804
+
805
+ Some examples to help you think:
806
+ \u2192 Blog posts or news articles
807
+ \u2192 Team member profiles (name, photo, bio)
808
+ \u2192 Services or product descriptions
809
+ \u2192 Homepage text (headline, buttons, images)
810
+ \u2192 Testimonials or reviews
811
+ \u2192 FAQs
812
+ \u2192 Event listings or announcements
813
+
814
+ Just list the ones that apply. Or say 'not sure yet'
815
+ and we will figure it out together."
816
+
817
+ \u2500\u2500\u2500 AFTER ALL QUESTIONS \u2500\u2500\u2500
818
+ Once all four questions are answered:
819
+ 1. Summarise what you understood in plain English
820
+ 2. Ask the user to confirm before touching any code
821
+ 3. Then move to the installation steps using the correct path
822
+ for their tech level from Question 1`,
823
+ frameworkSetup[activeTab] || frameworkSetup.nuxt,
824
+ `
825
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
826
+ 4. AFTER INSTALLATION \u2014 CONTENT SETUP
827
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
828
+ Once the dashboard is confirmed working, help the user design their
829
+ content model in dyrected.config.ts based on what they told you in
830
+ Phase 0.
831
+
832
+ RULES for this phase:
833
+ - Use defineCollection and defineConfig from '@dyrected/core'
834
+ - Use client.collection(slug) only \u2014 never client.collections
835
+ - Always use initialData in all data fetches
836
+ - Use a catch-all pages collection for marketing-managed pages
837
+ - Use blocks for flexible page layouts
838
+ - Use type: 'relationship', relationTo: 'collectionSlug' for relations
839
+ - Never throw during render \u2014 fall back to initialData on errors
840
+ - All relationship fields must handle null gracefully
841
+
842
+ CONTENT SETUP DELIVERABLES \u2014 in this order:
843
+ 1. dyrected.config.ts \u2014 complete file based on their answers
844
+ 2. Catch-all page route for CMS-managed pages
845
+ 3. Block components list (names and fields only)
846
+ 4. One example fetch showing how to load content on a page
847
+
848
+ After delivering the config, tell the user to sync their schema.
849
+ For TECHNICAL users show the command directly:
850
+ \`\`\`bash
851
+ npx @dyrected/cli sync:schema
852
+ \`\`\`
853
+ For SEMI-TECHNICAL or NON-TECHNICAL users explain it first:
854
+ "This next step tells Dyrected to read your content setup file
855
+ and prepare the database. Here is the command to run:" then show it.
856
+
857
+ Then ask: "Do you want me to help you connect this content to your
858
+ frontend pages now?"
859
+
860
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
861
+ DO NOT
862
+ \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
863
+ - Do NOT show terminal commands before confirming the user's tech level
864
+ - Do NOT assume the user knows what a terminal, CLI, or package manager is
865
+ - Do NOT show all steps at once \u2014 one step at a time always
866
+ - Do NOT use client.collections \u2014 use client.collection(slug)
867
+ - Do NOT add custom auth middleware to the admin route
868
+ - Do NOT use renderAdminUI in a Nuxt.js project
869
+ - Do NOT skip the confirmation after each installation step
870
+ - Do NOT use jargon without explaining it in plain English first
871
+ - Do NOT assume the installation worked \u2014 ask the user to confirm
872
+
873
+ API Reference: https://docs.dyrected.com
874
+ If you are unsure about any syntax, refer to the official documentation above.`
875
+ ].join("\n");
876
+ }
877
+ function generateAIPrompt(activeTab, config) {
878
+ const frameworkLabel = activeTab === "next" ? "Next.js" : activeTab === "nuxt" ? "Nuxt.js" : activeTab ? activeTab.charAt(0).toUpperCase() + activeTab.slice(1) : "the project's detected framework";
879
+ const isSelfHosted = config.isSelfHosted === true || !config.apiKey && !config.siteId;
880
+ const existingSite = config.existingSite ?? false;
881
+ const missionText = existingSite ? `You are a Senior Content Architect. Your mission is to integrate Dyrected CMS into an EXISTING ${frameworkLabel} project. Your absolute priority is DATA PRESERVATION and MIGRATION of existing hardcoded content into a flexible, blocks-based schema that empowers marketing teams to move independently.` : `You are a Senior Content Architect. Your mission is to integrate Dyrected CMS into a NEW ${frameworkLabel} project. Your priority is DATA PRESERVATION and creating a CMS that empowers marketing teams to move independently without raising tickets to engineering.`;
882
+ const sections = [
883
+ missionText,
884
+ buildEnvironmentSection(frameworkLabel, isSelfHosted, config),
885
+ buildDiagnosticSection(),
886
+ buildConstraintsSection(),
887
+ buildSchemaRulesSection(),
888
+ buildDoNotSection(),
889
+ buildTechnicalReferenceSection(),
890
+ buildDeliverablesSection(),
891
+ buildFrameworkSection(activeTab, isSelfHosted, config)
892
+ ];
893
+ return sections.join("\n");
894
+ }
895
+
82
896
  // src/index.ts
83
897
  var DyrectedError = class extends Error {
84
898
  statusCode;
@@ -179,6 +993,7 @@ var DyrectedClient = class {
179
993
  create: (data) => this.create(slug, data),
180
994
  update: (id, data) => this.update(slug, id, data),
181
995
  delete: (id) => this.delete(slug, id),
996
+ deleteMany: (ids) => this.deleteMany(slug, ids),
182
997
  /**
183
998
  * Upload a file to this collection. Sends as multipart/form-data.
184
999
  * @param file - A File or Blob (browser) or Buffer with filename/mimeType (Node.js)
@@ -240,7 +1055,9 @@ var DyrectedClient = class {
240
1055
  this.request(`/api/collections/${collection}/seed`, {
241
1056
  method: "POST",
242
1057
  body: JSON.stringify({ data: [{ id, ...initialData }] })
243
- }).catch((err2) => console.error(`[dyrected/sdk] Failed to auto-seed document "${id}" in collection "${collection}":`, err2));
1058
+ }).catch(
1059
+ (err2) => console.error(`[dyrected/sdk] Failed to auto-seed document "${id}" in collection "${collection}":`, err2)
1060
+ );
244
1061
  return initialData;
245
1062
  }
246
1063
  throw err;
@@ -263,6 +1080,12 @@ var DyrectedClient = class {
263
1080
  method: "DELETE"
264
1081
  });
265
1082
  }
1083
+ async deleteMany(collection, ids) {
1084
+ return this.request(`/api/collections/${collection}/delete-many`, {
1085
+ method: "DELETE",
1086
+ body: import_qs.default.stringify({ ids })
1087
+ });
1088
+ }
266
1089
  async getGlobal(slug, args = {}) {
267
1090
  const { initialData, ...queryArgs } = args;
268
1091
  const query = import_qs.default.stringify(queryArgs, { addQueryPrefix: true });
@@ -357,5 +1180,7 @@ function createClient(config) {
357
1180
  0 && (module.exports = {
358
1181
  DyrectedClient,
359
1182
  DyrectedError,
360
- createClient
1183
+ createClient,
1184
+ generateAIPrompt,
1185
+ generateFreshSetupPrompt
361
1186
  });