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