@dyrected/sdk 2.5.30 → 2.5.33

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