@kurbo/dkit 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +4 -0
  2. package/dist/bin.js +385 -139
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +4 -1
  5. package/vendor/registry/blocks/blog-detail/ui/minimal/next/blog-detail.tsx +0 -1
  6. package/vendor/registry/blocks/blog-detail/ui/shadcn/next/blog-detail.tsx +0 -1
  7. package/vendor/registry/blocks/blog-list/ui/minimal/next/blog-list.tsx +0 -1
  8. package/vendor/registry/blocks/blog-list/ui/shadcn/next/blog-list.tsx +0 -1
  9. package/vendor/registry/blocks/blog-list-cards/ui/minimal/next/blog-list-cards.tsx +0 -1
  10. package/vendor/registry/blocks/blog-list-cards/ui/shadcn/next/blog-list-cards.tsx +0 -1
  11. package/vendor/registry/blocks/booking-form-ui/ui/minimal/next/booking-form.tsx +0 -1
  12. package/vendor/registry/blocks/booking-form-ui/ui/shadcn/next/booking-form.tsx +0 -1
  13. package/vendor/registry/blocks/contact-form-ui/ui/minimal/next/contact-form.tsx +0 -1
  14. package/vendor/registry/blocks/contact-form-ui/ui/shadcn/next/contact-form.tsx +0 -1
  15. package/vendor/registry/blocks/faq-list/ui/minimal/next/faq-list.tsx +0 -1
  16. package/vendor/registry/blocks/faq-list/ui/shadcn/next/faq-list.tsx +0 -1
  17. package/vendor/registry/blocks/page-detail/ui/minimal/next/page-detail.tsx +0 -1
  18. package/vendor/registry/blocks/page-detail/ui/shadcn/next/page-detail.tsx +0 -1
  19. package/vendor/registry/blocks/project-detail/ui/minimal/next/project-detail.tsx +0 -1
  20. package/vendor/registry/blocks/project-detail/ui/shadcn/next/project-detail.tsx +0 -1
  21. package/vendor/registry/blocks/project-list/ui/minimal/next/project-list.tsx +0 -1
  22. package/vendor/registry/blocks/project-list/ui/shadcn/next/project-list.tsx +0 -1
  23. package/vendor/registry/blocks/project-list-cards/ui/minimal/next/project-list-cards.tsx +0 -1
  24. package/vendor/registry/blocks/project-list-cards/ui/shadcn/next/project-list-cards.tsx +0 -1
  25. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel-client.tsx +0 -4
  26. package/vendor/registry/blocks/projects-carousel/ui/minimal/next/projects-carousel.tsx +0 -1
  27. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel-client.tsx +0 -1
  28. package/vendor/registry/blocks/projects-carousel/ui/shadcn/next/projects-carousel.tsx +0 -1
  29. package/vendor/registry/blocks/service-detail/ui/minimal/next/service-detail.tsx +0 -1
  30. package/vendor/registry/blocks/service-detail/ui/shadcn/next/service-detail.tsx +0 -1
  31. package/vendor/registry/blocks/service-list/ui/minimal/next/service-list.tsx +0 -1
  32. package/vendor/registry/blocks/service-list/ui/shadcn/next/service-list.tsx +0 -1
  33. package/vendor/registry/blocks/service-list-cards/ui/minimal/next/service-list-cards.tsx +0 -1
  34. package/vendor/registry/blocks/service-list-cards/ui/shadcn/next/service-list-cards.tsx +0 -1
  35. package/vendor/registry/blocks/social-links/ui/minimal/next/social-links.tsx +0 -1
  36. package/vendor/registry/blocks/social-links/ui/shadcn/next/social-links.tsx +0 -1
  37. package/vendor/registry/blocks/team-detail/ui/minimal/next/team-detail.tsx +0 -1
  38. package/vendor/registry/blocks/team-detail/ui/shadcn/next/team-detail.tsx +0 -1
  39. package/vendor/registry/blocks/team-list/ui/minimal/next/team-list.tsx +0 -1
  40. package/vendor/registry/blocks/team-list/ui/shadcn/next/team-list.tsx +0 -1
  41. package/vendor/registry/blocks/team-list-cards/ui/minimal/next/team-list-cards.tsx +0 -1
  42. package/vendor/registry/blocks/team-list-cards/ui/shadcn/next/team-list-cards.tsx +0 -1
  43. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel-client.tsx +0 -4
  44. package/vendor/registry/blocks/testimonials-carousel/ui/minimal/next/testimonials-carousel.tsx +0 -1
  45. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel-client.tsx +0 -1
  46. package/vendor/registry/blocks/testimonials-carousel/ui/shadcn/next/testimonials-carousel.tsx +0 -1
  47. package/vendor/registry/blocks/testimonials-list/ui/minimal/next/testimonials-list.tsx +0 -1
  48. package/vendor/registry/blocks/testimonials-list/ui/shadcn/next/testimonials-list.tsx +0 -1
  49. package/vendor/registry/blocks/testimonials-list-cards/ui/minimal/next/testimonials-list-cards.tsx +0 -1
  50. package/vendor/registry/blocks/testimonials-list-cards/ui/shadcn/next/testimonials-list-cards.tsx +0 -1
  51. package/vendor/registry/modules/blog/lib.multilocale.ts +124 -129
  52. package/vendor/registry/modules/blog/lib.ts +12 -9
  53. package/vendor/registry/modules/blog/services/seed.json +1 -1
  54. package/vendor/registry/modules/blog/services/seed.multilocale.json +1 -1
  55. package/vendor/registry/modules/blog/types.multilocale.ts +41 -12
  56. package/vendor/registry/modules/blog/types.ts +8 -6
  57. package/vendor/registry/modules/faq/lib.multilocale.ts +30 -30
  58. package/vendor/registry/modules/faq/lib.ts +4 -5
  59. package/vendor/registry/modules/faq/types.multilocale.ts +13 -2
  60. package/vendor/registry/modules/faq/types.ts +4 -2
  61. package/vendor/registry/modules/navigation/lib.multilocale.ts +207 -76
  62. package/vendor/registry/modules/navigation/lib.ts +18 -17
  63. package/vendor/registry/modules/navigation/types.multilocale.ts +24 -4
  64. package/vendor/registry/modules/navigation/types.ts +6 -4
  65. package/vendor/registry/modules/pages/lib.multilocale.ts +34 -39
  66. package/vendor/registry/modules/pages/lib.ts +4 -3
  67. package/vendor/registry/modules/pages/types.multilocale.ts +14 -3
  68. package/vendor/registry/modules/pages/types.ts +5 -3
  69. package/vendor/registry/modules/projects/lib.multilocale.ts +149 -65
  70. package/vendor/registry/modules/projects/lib.ts +6 -6
  71. package/vendor/registry/modules/projects/services/seed.json +2 -2
  72. package/vendor/registry/modules/projects/services/seed.multilocale.json +2 -2
  73. package/vendor/registry/modules/projects/types.multilocale.ts +15 -3
  74. package/vendor/registry/modules/projects/types.ts +5 -3
  75. package/vendor/registry/modules/services/lib.multilocale.ts +143 -63
  76. package/vendor/registry/modules/services/lib.ts +6 -6
  77. package/vendor/registry/modules/services/services/seed.json +4 -4
  78. package/vendor/registry/modules/services/services/seed.multilocale.json +2 -2
  79. package/vendor/registry/modules/services/types.multilocale.ts +13 -3
  80. package/vendor/registry/modules/services/types.ts +5 -3
  81. package/vendor/registry/modules/settings/lib.multilocale.ts +159 -57
  82. package/vendor/registry/modules/settings/types.multilocale.ts +15 -0
  83. package/vendor/registry/modules/settings/types.ts +2 -2
  84. package/vendor/registry/modules/team/lib.multilocale.ts +116 -49
  85. package/vendor/registry/modules/team/lib.ts +4 -3
  86. package/vendor/registry/modules/team/services/seed.json +4 -4
  87. package/vendor/registry/modules/team/services/seed.multilocale.json +2 -2
  88. package/vendor/registry/modules/team/types.multilocale.ts +16 -3
  89. package/vendor/registry/modules/team/types.ts +5 -3
  90. package/vendor/registry/modules/testimonials/lib.multilocale.ts +82 -50
  91. package/vendor/registry/modules/testimonials/services/seed.json +4 -4
  92. package/vendor/registry/modules/testimonials/services/seed.multilocale.json +2 -2
  93. package/vendor/registry/modules/testimonials/types.multilocale.ts +14 -2
  94. package/vendor/registry/modules/testimonials/types.ts +4 -2
  95. package/vendor/registry/shared/helpers.ts +9 -3
  96. package/vendor/registry/shared/i18n.ts +84 -12
  97. package/vendor/registry/shared/prose.css +1 -1
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command6 } from "commander";
4
+ import { Command as Command7 } from "commander";
5
5
 
6
6
  // src/commands/init.ts
7
7
  import { Command } from "commander";
@@ -186,7 +186,7 @@ var DkitProjectConfigSchema = z2.object({
186
186
  * Prefer env `DKIT_LICENSE_KEY` in CI; do not commit secrets.
187
187
  */
188
188
  licenseKey: z2.string().min(1).optional(),
189
- /** Authenticated premium registry API base (default https://api.dkit.run) */
189
+ /** Authenticated premium registry API base (default https://dkit.run/api) */
190
190
  registryApi: z2.string().url().optional(),
191
191
  tailwind: z2.boolean().default(true),
192
192
  /**
@@ -257,16 +257,16 @@ function normalizeCollectionPrefix(raw) {
257
257
  }
258
258
  var UNPREFIXED_COLLECTIONS = /* @__PURE__ */ new Set(["languages"]);
259
259
  function prefixedCollection(logicalName, prefix) {
260
- const p4 = normalizeCollectionPrefix(prefix);
261
- if (!p4)
260
+ const p5 = normalizeCollectionPrefix(prefix);
261
+ if (!p5)
262
262
  return logicalName;
263
263
  if (logicalName.startsWith("directus_"))
264
264
  return logicalName;
265
265
  if (UNPREFIXED_COLLECTIONS.has(logicalName))
266
266
  return logicalName;
267
- if (logicalName.startsWith(p4))
267
+ if (logicalName.startsWith(p5))
268
268
  return logicalName;
269
- return `${p4}${logicalName}`;
269
+ return `${p5}${logicalName}`;
270
270
  }
271
271
 
272
272
  // ../shared/dist/semver.js
@@ -286,7 +286,7 @@ function majorVersion(version2) {
286
286
  }
287
287
  function parse(version2) {
288
288
  const cleaned = version2.replace(/^v/i, "").split("-")[0] ?? "0.0.0";
289
- const parts = cleaned.split(".").map((p4) => Number.parseInt(p4, 10) || 0);
289
+ const parts = cleaned.split(".").map((p5) => Number.parseInt(p5, 10) || 0);
290
290
  return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0];
291
291
  }
292
292
 
@@ -2594,8 +2594,8 @@ function formatDirectusPayload(err) {
2594
2594
  return null;
2595
2595
  }
2596
2596
  function isCustomPermissionRulesRestricted(err) {
2597
- const text4 = toError(err).message;
2598
- return text4.includes("custom_permission_rules_enabled") || text4.includes("RESOURCE_RESTRICTED");
2597
+ const text5 = toError(err).message;
2598
+ return text5.includes("custom_permission_rules_enabled") || text5.includes("RESOURCE_RESTRICTED");
2599
2599
  }
2600
2600
  function toCoreFlatPermission(perm) {
2601
2601
  return {
@@ -2745,7 +2745,7 @@ function isRestSchema(value) {
2745
2745
  return typeof value === "object" && value !== null && value.format === "dkit.rest";
2746
2746
  }
2747
2747
  async function applyRestSchema(client, schema, options) {
2748
- const log4 = options.onLog ?? (() => void 0);
2748
+ const log5 = options.onLog ?? (() => void 0);
2749
2749
  const lines = [];
2750
2750
  const prepared = expandRestSchemaTranslations(schema);
2751
2751
  const existing = await listCollections(client);
@@ -2769,12 +2769,12 @@ async function applyRestSchema(client, schema, options) {
2769
2769
  });
2770
2770
  for (const col of ordered) {
2771
2771
  if (existingSet.has(col.collection)) {
2772
- log4(`\u2192 Updating collection meta ${col.collection}\u2026`);
2772
+ log5(`\u2192 Updating collection meta ${col.collection}\u2026`);
2773
2773
  await updateCollectionMeta(client, col);
2774
- await upsertFields(client, col, log4, { aliases: false });
2774
+ await upsertFields(client, col, log5, { aliases: false });
2775
2775
  continue;
2776
2776
  }
2777
- log4(`\u2192 Creating collection ${col.collection}\u2026`);
2777
+ log5(`\u2192 Creating collection ${col.collection}\u2026`);
2778
2778
  const { fields, ...rest2 } = col;
2779
2779
  await http(client, {
2780
2780
  path: "/collections",
@@ -2790,11 +2790,11 @@ async function applyRestSchema(client, schema, options) {
2790
2790
  for (const rel of prepared.relations ?? []) {
2791
2791
  const key = `${rel.collection}.${rel.field}`;
2792
2792
  if (existingRelations.has(key)) {
2793
- log4(`\u2192 Updating relation meta ${key}\u2026`);
2793
+ log5(`\u2192 Updating relation meta ${key}\u2026`);
2794
2794
  await updateRelationMeta(client, rel);
2795
2795
  continue;
2796
2796
  }
2797
- log4(`\u2192 Creating relation ${rel.collection}.${rel.field}\u2026`);
2797
+ log5(`\u2192 Creating relation ${rel.collection}.${rel.field}\u2026`);
2798
2798
  await http(client, {
2799
2799
  path: "/relations",
2800
2800
  method: "POST",
@@ -2804,9 +2804,9 @@ async function applyRestSchema(client, schema, options) {
2804
2804
  for (const col of ordered) {
2805
2805
  if (!col.fields?.some(isAliasField))
2806
2806
  continue;
2807
- await upsertFields(client, col, log4, { aliases: true });
2807
+ await upsertFields(client, col, log5, { aliases: true });
2808
2808
  }
2809
- log4("\u2713 REST schema applied");
2809
+ log5("\u2713 REST schema applied");
2810
2810
  return lines;
2811
2811
  }
2812
2812
  function isAliasField(field) {
@@ -2839,7 +2839,7 @@ async function updateCollectionMeta(client, col) {
2839
2839
  body: { meta: col.meta }
2840
2840
  });
2841
2841
  }
2842
- async function upsertFields(client, col, log4, opts) {
2842
+ async function upsertFields(client, col, log5, opts) {
2843
2843
  if (!col.fields?.length)
2844
2844
  return;
2845
2845
  const existingFields = await listFieldNames(client, col.collection);
@@ -2847,7 +2847,7 @@ async function upsertFields(client, col, log4, opts) {
2847
2847
  if (isAliasField(field) !== opts.aliases)
2848
2848
  continue;
2849
2849
  if (existingFields.has(field.field)) {
2850
- log4(`\u2192 Updating field ${col.collection}.${field.field}\u2026`);
2850
+ log5(`\u2192 Updating field ${col.collection}.${field.field}\u2026`);
2851
2851
  await http(client, {
2852
2852
  path: `/fields/${col.collection}/${field.field}`,
2853
2853
  method: "PATCH",
@@ -2857,7 +2857,7 @@ async function upsertFields(client, col, log4, opts) {
2857
2857
  }
2858
2858
  });
2859
2859
  } else {
2860
- log4(`\u2192 Creating field ${col.collection}.${field.field}\u2026`);
2860
+ log5(`\u2192 Creating field ${col.collection}.${field.field}\u2026`);
2861
2861
  await http(client, {
2862
2862
  path: `/fields/${col.collection}`,
2863
2863
  method: "POST",
@@ -2909,7 +2909,7 @@ async function listRelationKeys(client) {
2909
2909
 
2910
2910
  // ../schema/dist/apply.js
2911
2911
  async function applyModule(client, url, payload, options = {}) {
2912
- const log4 = options.onLog ?? (() => void 0);
2912
+ const log5 = options.onLog ?? (() => void 0);
2913
2913
  const warnings = [];
2914
2914
  const dryRunPlan = [];
2915
2915
  const result = {
@@ -2927,39 +2927,39 @@ async function applyModule(client, url, payload, options = {}) {
2927
2927
  if (!versionInfo.supportsMergeMode) {
2928
2928
  const msg = `Directus ${versionInfo.version} lacks schema diff mode=merge (needs 12.2+). Using safer strip-deletes fallback.`;
2929
2929
  warnings.push(msg);
2930
- log4(`\u26A0 ${msg}`);
2930
+ log5(`\u26A0 ${msg}`);
2931
2931
  if (!options.dryRun && !options.confirmReducedSafety) {
2932
2932
  throw new Error(`${msg} Re-run with --yes to continue on this version.`);
2933
2933
  }
2934
2934
  } else {
2935
- log4(`\u2713 Directus ${versionInfo.version} (merge-mode schema apply)`);
2935
+ log5(`\u2713 Directus ${versionInfo.version} (merge-mode schema apply)`);
2936
2936
  }
2937
2937
  if (payload.snapshot) {
2938
2938
  if (isRestSchema(payload.snapshot)) {
2939
2939
  const lines = await applyRestSchema(client, payload.snapshot, {
2940
2940
  dryRun: options.dryRun,
2941
- onLog: log4
2941
+ onLog: log5
2942
2942
  });
2943
2943
  dryRunPlan.push(...lines);
2944
2944
  result.schemaApplied = !options.dryRun && lines.length > 0;
2945
2945
  } else {
2946
- const plan = await planAndApplySchema(client, payload.snapshot, versionInfo.supportsMergeMode, options, log4);
2946
+ const plan = await planAndApplySchema(client, payload.snapshot, versionInfo.supportsMergeMode, options, log5);
2947
2947
  dryRunPlan.push(...plan.lines);
2948
2948
  result.schemaApplied = plan.applied;
2949
2949
  }
2950
2950
  }
2951
2951
  if (payload.access) {
2952
- const plan = await applyAccess(client, payload.access, options, log4);
2952
+ const plan = await applyAccess(client, payload.access, options, log5);
2953
2953
  dryRunPlan.push(...plan.lines);
2954
2954
  result.policiesApplied = plan.applied;
2955
2955
  }
2956
2956
  if (payload.flows?.flows?.length) {
2957
- const plan = await applyFlows(client, payload.flows, options, log4);
2957
+ const plan = await applyFlows(client, payload.flows, options, log5);
2958
2958
  dryRunPlan.push(...plan.lines);
2959
2959
  result.flowsApplied = plan.applied;
2960
2960
  }
2961
2961
  if (options.seed && payload.seed && ((payload.seed.files?.length ?? 0) > 0 || Object.keys(payload.seed.items ?? {}).length > 0)) {
2962
- const plan = await applySeed(client, url, payload.seed, options, log4, singletonCollectionsFromSnapshot(payload.snapshot));
2962
+ const plan = await applySeed(client, url, payload.seed, options, log5, singletonCollectionsFromSnapshot(payload.snapshot));
2963
2963
  dryRunPlan.push(...plan.lines);
2964
2964
  result.seedApplied = plan.applied;
2965
2965
  }
@@ -2975,9 +2975,9 @@ function singletonCollectionsFromSnapshot(snapshot) {
2975
2975
  }
2976
2976
  return out;
2977
2977
  }
2978
- async function planAndApplySchema(client, snapshot, supportsMerge, options, log4) {
2978
+ async function planAndApplySchema(client, snapshot, supportsMerge, options, log5) {
2979
2979
  const lines = [];
2980
- log4("\u2192 Diffing schema\u2026");
2980
+ log5("\u2192 Diffing schema\u2026");
2981
2981
  const diffBody = await http(client, {
2982
2982
  path: "/schema/diff",
2983
2983
  method: "POST",
@@ -2991,23 +2991,23 @@ async function planAndApplySchema(client, snapshot, supportsMerge, options, log4
2991
2991
  const summary = summarizeDiff(diffPayload);
2992
2992
  if (summary.length === 0 || summary.length === 1 && summary[0] === "No schema diff") {
2993
2993
  lines.push("schema: no changes");
2994
- log4("\u2713 Schema already up to date");
2994
+ log5("\u2713 Schema already up to date");
2995
2995
  return { applied: false, lines };
2996
2996
  }
2997
2997
  lines.push(...summary.map((s) => `schema: ${s}`));
2998
2998
  if (options.dryRun)
2999
2999
  return { applied: false, lines };
3000
- log4("\u2192 Applying schema\u2026");
3000
+ log5("\u2192 Applying schema\u2026");
3001
3001
  await http(client, {
3002
3002
  path: "/schema/apply",
3003
3003
  method: "POST",
3004
3004
  params: options.forceSchema ? { force: true } : {},
3005
3005
  body: diffPayload
3006
3006
  });
3007
- log4("\u2713 Schema applied");
3007
+ log5("\u2713 Schema applied");
3008
3008
  return { applied: true, lines };
3009
3009
  }
3010
- async function applyAccess(client, access, options, log4) {
3010
+ async function applyAccess(client, access, options, log5) {
3011
3011
  const lines = [];
3012
3012
  const policies = access.policies ?? [];
3013
3013
  const permissions = access.permissions ?? [];
@@ -3025,16 +3025,16 @@ async function applyAccess(client, access, options, log4) {
3025
3025
  params: { limit: -1, fields: "id,name" }
3026
3026
  });
3027
3027
  const list = Array.isArray(existing) ? existing : existing.data ?? [];
3028
- const byName = new Map(list.map((p4) => [p4.name, p4.id]));
3028
+ const byName = new Map(list.map((p5) => [p5.name, p5.id]));
3029
3029
  const policyIds = /* @__PURE__ */ new Map();
3030
3030
  for (const policy of policies) {
3031
3031
  const existingId = byName.get(policy.name);
3032
3032
  if (existingId) {
3033
- log4(`\u2192 Reusing existing policy ${policy.name}`);
3033
+ log5(`\u2192 Reusing existing policy ${policy.name}`);
3034
3034
  policyIds.set(policy.name, existingId);
3035
3035
  continue;
3036
3036
  }
3037
- log4(`\u2192 Creating policy ${policy.name}\u2026`);
3037
+ log5(`\u2192 Creating policy ${policy.name}\u2026`);
3038
3038
  const created = await http(client, {
3039
3039
  path: "/policies",
3040
3040
  method: "POST",
@@ -3064,7 +3064,7 @@ async function applyAccess(client, access, options, log4) {
3064
3064
  } catch (err) {
3065
3065
  if (isCustomPermissionRulesRestricted(err) || permissionHasCustomRules(rest2)) {
3066
3066
  if (!warnedCoreFlat) {
3067
- log4("\u26A0 Directus Core blocks custom permission rules (row filters / field subsets). Using flat fields:['*'] \u2014 UI should filter published status. Add a Directus license for server-side filters.");
3067
+ log5("\u26A0 Directus Core blocks custom permission rules (row filters / field subsets). Using flat fields:['*'] \u2014 UI should filter published status. Add a Directus license for server-side filters.");
3068
3068
  warnedCoreFlat = true;
3069
3069
  }
3070
3070
  try {
@@ -3094,16 +3094,16 @@ async function applyAccess(client, access, options, log4) {
3094
3094
  } catch (err) {
3095
3095
  const msg = toError(err).message.toLowerCase();
3096
3096
  if (msg.includes("unique") || msg.includes("already")) {
3097
- log4(`\u2192 Access link already exists for ${row.policy}`);
3097
+ log5(`\u2192 Access link already exists for ${row.policy}`);
3098
3098
  continue;
3099
3099
  }
3100
3100
  throw toError(err, `Failed to link access for policy ${row.policy}`);
3101
3101
  }
3102
3102
  }
3103
- log4("\u2713 Access policies applied");
3103
+ log5("\u2713 Access policies applied");
3104
3104
  return { applied: true, lines };
3105
3105
  }
3106
- async function applyFlows(client, flows, options, log4) {
3106
+ async function applyFlows(client, flows, options, log5) {
3107
3107
  const lines = [];
3108
3108
  for (const flow of flows.flows ?? []) {
3109
3109
  lines.push(`flow: create ${flow.name}`);
@@ -3119,7 +3119,7 @@ async function applyFlows(client, flows, options, log4) {
3119
3119
  const byName = new Map(list.map((f) => [f.name, f.id]));
3120
3120
  for (const flow of flows.flows ?? []) {
3121
3121
  if (byName.has(flow.name)) {
3122
- log4(`\u2192 Reusing existing flow ${flow.name}`);
3122
+ log5(`\u2192 Reusing existing flow ${flow.name}`);
3123
3123
  continue;
3124
3124
  }
3125
3125
  const { id: _id, ...rest2 } = flow;
@@ -3128,10 +3128,10 @@ async function applyFlows(client, flows, options, log4) {
3128
3128
  for (const op of flows.operations ?? []) {
3129
3129
  await http(client, { path: "/operations", method: "POST", body: op });
3130
3130
  }
3131
- log4("\u2713 Flows applied");
3131
+ log5("\u2713 Flows applied");
3132
3132
  return { applied: true, lines };
3133
3133
  }
3134
- async function applySeed(client, url, seed, options, log4, singletons = /* @__PURE__ */ new Set()) {
3134
+ async function applySeed(client, url, seed, options, log5, singletons = /* @__PURE__ */ new Set()) {
3135
3135
  const lines = [];
3136
3136
  if (seed.files?.length) {
3137
3137
  lines.push(`seed: ${seed.files.length} file(s)`);
@@ -3147,9 +3147,9 @@ async function applySeed(client, url, seed, options, log4, singletons = /* @__PU
3147
3147
  const { id: actualId, created } = await upsertSeedFile(client, url, file);
3148
3148
  fileIdMap.set(file.id, actualId);
3149
3149
  if (created) {
3150
- log4(actualId === file.id ? `\u2192 Seed uploaded file ${actualId}` : `\u2192 Seed uploaded file ${file.filename_download} \u2192 ${actualId}`);
3150
+ log5(actualId === file.id ? `\u2192 Seed uploaded file ${actualId}` : `\u2192 Seed uploaded file ${file.filename_download} \u2192 ${actualId}`);
3151
3151
  } else {
3152
- log4(`\u2192 Seed reused file ${actualId}`);
3152
+ log5(`\u2192 Seed reused file ${actualId}`);
3153
3153
  }
3154
3154
  } catch (err) {
3155
3155
  throw wrapSeedError(`upload file ${file.filename_download}`, err);
@@ -3162,17 +3162,17 @@ async function applySeed(client, url, seed, options, log4, singletons = /* @__PU
3162
3162
  try {
3163
3163
  const outcome = singletons.has(collection) ? await upsertSeedSingleton(client, collection, remapped) : await upsertSeedItem(client, collection, remapped);
3164
3164
  if (outcome === "created")
3165
- log4(`\u2192 Seed created ${label}`);
3165
+ log5(`\u2192 Seed created ${label}`);
3166
3166
  else if (outcome === "updated")
3167
- log4(`\u2192 Seed updated ${label}`);
3167
+ log5(`\u2192 Seed updated ${label}`);
3168
3168
  else
3169
- log4(`\u2192 Seed skipped ${label} (already exists)`);
3169
+ log5(`\u2192 Seed skipped ${label} (already exists)`);
3170
3170
  } catch (err) {
3171
3171
  throw wrapSeedError(`upsert ${label}`, err);
3172
3172
  }
3173
3173
  }
3174
3174
  }
3175
- log4("\u2713 Seed data applied");
3175
+ log5("\u2713 Seed data applied");
3176
3176
  return { applied: true, lines };
3177
3177
  }
3178
3178
  function wrapSeedError(step, err) {
@@ -3219,8 +3219,8 @@ async function upsertSeedFile(client, url, file) {
3219
3219
  body: form
3220
3220
  });
3221
3221
  if (!res.ok) {
3222
- const text4 = await res.text();
3223
- throw new Error(`Seed file upload failed (${res.status}): ${text4}`);
3222
+ const text5 = await res.text();
3223
+ throw new Error(`Seed file upload failed (${res.status}): ${text5}`);
3224
3224
  }
3225
3225
  const payload = await res.json();
3226
3226
  const actualId = payload.data?.id ?? payload.id;
@@ -3592,10 +3592,10 @@ function isUniqueViolation(err) {
3592
3592
 
3593
3593
  // ../schema/dist/prefix.js
3594
3594
  function applyCollectionPrefixToRestSchema(schema, prefix) {
3595
- const p4 = normalizeCollectionPrefix(prefix);
3596
- if (!p4)
3595
+ const p5 = normalizeCollectionPrefix(prefix);
3596
+ if (!p5)
3597
3597
  return schema;
3598
- const rename = (name) => prefixedCollection(name, p4);
3598
+ const rename = (name) => prefixedCollection(name, p5);
3599
3599
  return {
3600
3600
  ...schema,
3601
3601
  collections: schema.collections.map((col) => ({
@@ -3625,10 +3625,10 @@ function applyCollectionPrefixToRestSchema(schema, prefix) {
3625
3625
  };
3626
3626
  }
3627
3627
  function applyCollectionPrefixToAccess(access, prefix) {
3628
- const p4 = normalizeCollectionPrefix(prefix);
3629
- if (!p4)
3628
+ const p5 = normalizeCollectionPrefix(prefix);
3629
+ if (!p5)
3630
3630
  return access;
3631
- const rename = (name) => prefixedCollection(name, p4);
3631
+ const rename = (name) => prefixedCollection(name, p5);
3632
3632
  return {
3633
3633
  ...access,
3634
3634
  permissions: (access.permissions ?? []).map((perm) => ({
@@ -3638,10 +3638,10 @@ function applyCollectionPrefixToAccess(access, prefix) {
3638
3638
  };
3639
3639
  }
3640
3640
  function applyCollectionPrefixToFlows(flows, prefix) {
3641
- const p4 = normalizeCollectionPrefix(prefix);
3642
- if (!p4)
3641
+ const p5 = normalizeCollectionPrefix(prefix);
3642
+ if (!p5)
3643
3643
  return flows;
3644
- const rename = (name) => prefixedCollection(name, p4);
3644
+ const rename = (name) => prefixedCollection(name, p5);
3645
3645
  return {
3646
3646
  ...flows,
3647
3647
  flows: (flows.flows ?? []).map((flow) => {
@@ -3654,10 +3654,10 @@ function applyCollectionPrefixToFlows(flows, prefix) {
3654
3654
  };
3655
3655
  }
3656
3656
  function applyCollectionPrefixToSeed(seed, prefix) {
3657
- const p4 = normalizeCollectionPrefix(prefix);
3658
- if (!p4)
3657
+ const p5 = normalizeCollectionPrefix(prefix);
3658
+ if (!p5)
3659
3659
  return seed;
3660
- const rename = (name) => prefixedCollection(name, p4);
3660
+ const rename = (name) => prefixedCollection(name, p5);
3661
3661
  const logicalNames = new Set(Object.keys(seed.items ?? {}));
3662
3662
  const items = {};
3663
3663
  for (const [collection, rows] of Object.entries(seed.items ?? {})) {
@@ -3685,10 +3685,10 @@ function remapSeedCollectionField(row, rename, logicalNames) {
3685
3685
  return out;
3686
3686
  }
3687
3687
  function buildCollectionMap(logicalNames, prefix) {
3688
- const p4 = normalizeCollectionPrefix(prefix);
3688
+ const p5 = normalizeCollectionPrefix(prefix);
3689
3689
  const map = {};
3690
3690
  for (const name of logicalNames) {
3691
- map[name] = prefixedCollection(name, p4);
3691
+ map[name] = prefixedCollection(name, p5);
3692
3692
  }
3693
3693
  return map;
3694
3694
  }
@@ -4694,7 +4694,7 @@ shadcn-vue requires Node.js >= ${SHADCN_VUE_MIN_NODE} (current ${process.version
4694
4694
  }
4695
4695
  return `${base} Install shadcn manually, then re-run.`;
4696
4696
  }
4697
- function ensureShadcnComponents(projectRoot, framework, needed, log4) {
4697
+ function ensureShadcnComponents(projectRoot, framework, needed, log5) {
4698
4698
  const unique = [...new Set(needed.map((c) => c.trim()).filter(Boolean))];
4699
4699
  if (!unique.length) return { ok: true };
4700
4700
  if (framework !== "next" && framework !== "nuxt") {
@@ -4710,7 +4710,7 @@ function ensureShadcnComponents(projectRoot, framework, needed, log4) {
4710
4710
  };
4711
4711
  }
4712
4712
  if (!hasShadcnConfig(projectRoot)) {
4713
- log4(
4713
+ log5(
4714
4714
  framework === "nuxt" ? "shadcn-vue not found \u2014 running init --defaults\u2026" : "shadcn/ui not found \u2014 running init --defaults\u2026"
4715
4715
  );
4716
4716
  const init = runShadcn(projectRoot, framework, [
@@ -4728,12 +4728,12 @@ function ensureShadcnComponents(projectRoot, framework, needed, log4) {
4728
4728
  const installed = listInstalledShadcnComponents(projectRoot);
4729
4729
  const missing = unique.filter((c) => !installed.has(c));
4730
4730
  if (!missing.length) {
4731
- log4(
4731
+ log5(
4732
4732
  `shadcn components ok (${unique.join(", ")}; ${detectShadcnPrimitiveBase(projectRoot)})`
4733
4733
  );
4734
4734
  return { ok: true };
4735
4735
  }
4736
- log4(`Adding shadcn components: ${missing.join(", ")}`);
4736
+ log5(`Adding shadcn components: ${missing.join(", ")}`);
4737
4737
  const add = runShadcn(projectRoot, framework, [
4738
4738
  "add",
4739
4739
  ...missing,
@@ -4766,9 +4766,21 @@ import fs8 from "fs";
4766
4766
  import path9 from "path";
4767
4767
  var COLLECTION_TYPES = {
4768
4768
  /* blog */
4769
- posts: { moduleId: "blog", typeName: "BlogPost" },
4770
- authors: { moduleId: "blog", typeName: "BlogAuthor" },
4771
- categories: { moduleId: "blog", typeName: "BlogCategory" },
4769
+ posts: {
4770
+ moduleId: "blog",
4771
+ typeName: "BlogPost",
4772
+ wireTypeName: "BlogPostRow"
4773
+ },
4774
+ authors: {
4775
+ moduleId: "blog",
4776
+ typeName: "BlogAuthor",
4777
+ wireTypeName: "BlogAuthorRow"
4778
+ },
4779
+ categories: {
4780
+ moduleId: "blog",
4781
+ typeName: "BlogCategory",
4782
+ wireTypeName: "BlogCategoryRow"
4783
+ },
4772
4784
  posts_categories: { moduleId: "blog", typeName: "PostsCategoriesRow" },
4773
4785
  posts_translations: { moduleId: "blog", typeName: "BlogPostTranslation" },
4774
4786
  categories_translations: {
@@ -4780,24 +4792,62 @@ var COLLECTION_TYPES = {
4780
4792
  typeName: "BlogAuthorTranslation"
4781
4793
  },
4782
4794
  /* pages */
4783
- pages: { moduleId: "pages", typeName: "SitePage" },
4795
+ pages: {
4796
+ moduleId: "pages",
4797
+ typeName: "SitePage",
4798
+ wireTypeName: "SitePageRow"
4799
+ },
4784
4800
  pages_translations: { moduleId: "pages", typeName: "SitePageTranslation" },
4785
4801
  /* page-builder */
4786
- builder_pages: { moduleId: "page-builder", typeName: "BuilderPage" },
4787
- block_hero: { moduleId: "page-builder", typeName: "BlockHero" },
4788
- block_richtext: { moduleId: "page-builder", typeName: "BlockRichtext" },
4789
- block_cta: { moduleId: "page-builder", typeName: "BlockCta" },
4790
- block_faq: { moduleId: "page-builder", typeName: "BlockFaq" },
4791
- block_faq_items: { moduleId: "page-builder", typeName: "BlockFaqItem" },
4792
- block_card_grid: { moduleId: "page-builder", typeName: "BlockCardGrid" },
4802
+ builder_pages: {
4803
+ moduleId: "page-builder",
4804
+ typeName: "BuilderPage",
4805
+ wireTypeName: "BuilderPageRow"
4806
+ },
4807
+ block_hero: {
4808
+ moduleId: "page-builder",
4809
+ typeName: "BlockHero",
4810
+ wireTypeName: "BlockHeroRow"
4811
+ },
4812
+ block_richtext: {
4813
+ moduleId: "page-builder",
4814
+ typeName: "BlockRichtext",
4815
+ wireTypeName: "BlockRichtextRow"
4816
+ },
4817
+ block_cta: {
4818
+ moduleId: "page-builder",
4819
+ typeName: "BlockCta",
4820
+ wireTypeName: "BlockCtaRow"
4821
+ },
4822
+ block_faq: {
4823
+ moduleId: "page-builder",
4824
+ typeName: "BlockFaq",
4825
+ wireTypeName: "BlockFaqRow"
4826
+ },
4827
+ block_faq_items: {
4828
+ moduleId: "page-builder",
4829
+ typeName: "BlockFaqItem",
4830
+ wireTypeName: "BlockFaqItemRow"
4831
+ },
4832
+ block_card_grid: {
4833
+ moduleId: "page-builder",
4834
+ typeName: "BlockCardGrid",
4835
+ wireTypeName: "BlockCardGridRow"
4836
+ },
4793
4837
  block_card_grid_cards: {
4794
4838
  moduleId: "page-builder",
4795
- typeName: "BlockCardGridCard"
4839
+ typeName: "BlockCardGridCard",
4840
+ wireTypeName: "BlockCardGridCardRow"
4841
+ },
4842
+ block_carousel: {
4843
+ moduleId: "page-builder",
4844
+ typeName: "BlockCarousel",
4845
+ wireTypeName: "BlockCarouselRow"
4796
4846
  },
4797
- block_carousel: { moduleId: "page-builder", typeName: "BlockCarousel" },
4798
4847
  block_carousel_slides: {
4799
4848
  moduleId: "page-builder",
4800
- typeName: "BlockCarouselSlide"
4849
+ typeName: "BlockCarouselSlide",
4850
+ wireTypeName: "BlockCarouselSlideRow"
4801
4851
  },
4802
4852
  block_featured_blog: {
4803
4853
  moduleId: "page-builder",
@@ -4860,6 +4910,7 @@ var COLLECTION_TYPES = {
4860
4910
  site_settings: {
4861
4911
  moduleId: "settings",
4862
4912
  typeName: "SiteSettings",
4913
+ wireTypeName: "SiteSettingsRow",
4863
4914
  singleton: true
4864
4915
  },
4865
4916
  site_settings_translations: {
@@ -4867,8 +4918,16 @@ var COLLECTION_TYPES = {
4867
4918
  typeName: "SiteSettingsTranslation"
4868
4919
  },
4869
4920
  /* navigation */
4870
- nav_menus: { moduleId: "navigation", typeName: "NavMenu" },
4871
- nav_items: { moduleId: "navigation", typeName: "NavItem" },
4921
+ nav_menus: {
4922
+ moduleId: "navigation",
4923
+ typeName: "NavMenu",
4924
+ wireTypeName: "NavMenuRow"
4925
+ },
4926
+ nav_items: {
4927
+ moduleId: "navigation",
4928
+ typeName: "NavItem",
4929
+ wireTypeName: "NavItemRow"
4930
+ },
4872
4931
  nav_menus_translations: {
4873
4932
  moduleId: "navigation",
4874
4933
  typeName: "NavMenuTranslation"
@@ -4878,31 +4937,51 @@ var COLLECTION_TYPES = {
4878
4937
  typeName: "NavItemTranslation"
4879
4938
  },
4880
4939
  /* faq */
4881
- faq_items: { moduleId: "faq", typeName: "FaqItem" },
4940
+ faq_items: {
4941
+ moduleId: "faq",
4942
+ typeName: "FaqItem",
4943
+ wireTypeName: "FaqItemRow"
4944
+ },
4882
4945
  faq_items_translations: {
4883
4946
  moduleId: "faq",
4884
4947
  typeName: "FaqItemTranslation"
4885
4948
  },
4886
4949
  /* testimonials */
4887
- testimonials: { moduleId: "testimonials", typeName: "Testimonial" },
4950
+ testimonials: {
4951
+ moduleId: "testimonials",
4952
+ typeName: "Testimonial",
4953
+ wireTypeName: "TestimonialRow"
4954
+ },
4888
4955
  testimonials_translations: {
4889
4956
  moduleId: "testimonials",
4890
4957
  typeName: "TestimonialTranslation"
4891
4958
  },
4892
4959
  /* projects */
4893
- projects: { moduleId: "projects", typeName: "Project" },
4960
+ projects: {
4961
+ moduleId: "projects",
4962
+ typeName: "Project",
4963
+ wireTypeName: "ProjectRow"
4964
+ },
4894
4965
  projects_translations: {
4895
4966
  moduleId: "projects",
4896
4967
  typeName: "ProjectTranslation"
4897
4968
  },
4898
4969
  /* services */
4899
- services: { moduleId: "services", typeName: "Service" },
4970
+ services: {
4971
+ moduleId: "services",
4972
+ typeName: "Service",
4973
+ wireTypeName: "ServiceRow"
4974
+ },
4900
4975
  services_translations: {
4901
4976
  moduleId: "services",
4902
4977
  typeName: "ServiceTranslation"
4903
4978
  },
4904
4979
  /* team */
4905
- team_members: { moduleId: "team", typeName: "TeamMember" },
4980
+ team_members: {
4981
+ moduleId: "team",
4982
+ typeName: "TeamMember",
4983
+ wireTypeName: "TeamMemberRow"
4984
+ },
4906
4985
  team_members_translations: {
4907
4986
  moduleId: "team",
4908
4987
  typeName: "TeamMemberTranslation"
@@ -4914,17 +4993,19 @@ function writeDkitClient(projectRoot, config, collectionMap = config.collections
4914
4993
  const installed = new Set(Object.keys(config.modules ?? {}));
4915
4994
  const importsByModule = /* @__PURE__ */ new Map();
4916
4995
  const schemaFields = [];
4996
+ const useWire = Boolean(config.multilocale);
4917
4997
  for (const [logical, physical] of Object.entries(collectionMap)) {
4918
4998
  const binding = COLLECTION_TYPES[logical];
4919
4999
  if (!binding) continue;
4920
5000
  if (!installed.has(binding.moduleId)) continue;
5001
+ const schemaType = useWire && binding.wireTypeName ? binding.wireTypeName : binding.typeName;
4921
5002
  let set = importsByModule.get(binding.moduleId);
4922
5003
  if (!set) {
4923
5004
  set = /* @__PURE__ */ new Set();
4924
5005
  importsByModule.set(binding.moduleId, set);
4925
5006
  }
4926
- set.add(binding.typeName);
4927
- const typeExpr = binding.singleton ? binding.typeName : `${binding.typeName}[]`;
5007
+ set.add(schemaType);
5008
+ const typeExpr = binding.singleton ? schemaType : `${schemaType}[]`;
4928
5009
  schemaFields.push(` ${JSON.stringify(physical)}: ${typeExpr};`);
4929
5010
  }
4930
5011
  const importLines = [...importsByModule.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([moduleId, types]) => {
@@ -4956,6 +5037,8 @@ ${schemaFields.length ? `${schemaFields.join("\n")}
4956
5037
  const clientContents = `/** Generated by dkit \u2014 shared typed Directus client + asset helpers.
4957
5038
  * Modules must import getDirectus / directusFileId / directusAssetUrl from here \u2014
4958
5039
  * never redefine them in lib/dkit/<module>.ts.
5040
+ *
5041
+ * Typing pipeline: module *.types \u2192 schema (DkitSchema) \u2192 this client \u2192 services \u2192 UI.
4959
5042
  */
4960
5043
  import {
4961
5044
  createDirectus,
@@ -4971,6 +5054,8 @@ export type { DkitSchema } from "./schema";
4971
5054
 
4972
5055
  export type DirectusFileRef = { id: string };
4973
5056
 
5057
+ export type DkitClient = ReturnType<typeof createDkitClient>;
5058
+
4974
5059
  function directusBaseUrl(): string | undefined {
4975
5060
  return (
4976
5061
  process.env.DIRECTUS_URL ||
@@ -4980,6 +5065,10 @@ function directusBaseUrl(): string | undefined {
4980
5065
  );
4981
5066
  }
4982
5067
 
5068
+ function createDkitClient(url: string) {
5069
+ return createDirectus<DkitSchema>(url).with(rest());
5070
+ }
5071
+
4983
5072
  /**
4984
5073
  * Log soft-fail query problems in development.
4985
5074
  * Production stays quiet so empty lists don\u2019t spam logs.
@@ -4997,7 +5086,7 @@ export function dkitQueryFailed(context: string, err?: unknown): void {
4997
5086
  * Server-side Directus client (public role / no admin token).
4998
5087
  * Returns null when DIRECTUS_URL is unset so pages can fail soft.
4999
5088
  */
5000
- export function getDirectus() {
5089
+ export function getDirectus(): DkitClient | null {
5001
5090
  const url = directusBaseUrl();
5002
5091
  if (!url) {
5003
5092
  dkitQueryFailed(
@@ -5005,7 +5094,7 @@ export function getDirectus() {
5005
5094
  );
5006
5095
  return null;
5007
5096
  }
5008
- return createDirectus<DkitSchema>(url).with(rest());
5097
+ return createDkitClient(url);
5009
5098
  }
5010
5099
 
5011
5100
  /** Normalize a string id or expanded file object to a file id. */
@@ -5761,12 +5850,31 @@ import fs17 from "fs";
5761
5850
  import os2 from "os";
5762
5851
  import path18 from "path";
5763
5852
  import { execFileSync } from "child_process";
5853
+ import { fileURLToPath as fileURLToPath3 } from "url";
5764
5854
 
5765
5855
  // src/lib/license.ts
5766
5856
  import fs16 from "fs";
5767
5857
  import os from "os";
5768
5858
  import path17 from "path";
5769
- var DEFAULT_REGISTRY_API = "https://api.dkit.run";
5859
+ import { fileURLToPath as fileURLToPath2 } from "url";
5860
+ var DEFAULT_REGISTRY_API = "https://dkit.run/api";
5861
+ var LOCAL_REGISTRY_API = "http://localhost:3000/api";
5862
+ function isLocalMonorepoCli() {
5863
+ const here = path17.dirname(fileURLToPath2(import.meta.url));
5864
+ const roots = [
5865
+ path17.resolve(here, ".."),
5866
+ // packages/cli (dist/)
5867
+ path17.resolve(here, "../.."),
5868
+ // packages/cli (src/lib via tsx)
5869
+ path17.resolve(here, "../../..")
5870
+ ];
5871
+ for (const root of roots) {
5872
+ if (fs16.existsSync(path17.join(root, "apps/www/package.json")) && fs16.existsSync(path17.join(root, "packages/cli/package.json"))) {
5873
+ return true;
5874
+ }
5875
+ }
5876
+ return false;
5877
+ }
5770
5878
  function credentialsPath() {
5771
5879
  const override = process.env.DKIT_CONFIG_DIR;
5772
5880
  const dir = override ? path17.resolve(override) : path17.join(os.homedir(), ".config", "dkit");
@@ -5784,8 +5892,10 @@ function readCredentials() {
5784
5892
  function writeCredentials(next) {
5785
5893
  const file = credentialsPath();
5786
5894
  fs16.mkdirSync(path17.dirname(file), { recursive: true });
5787
- const merged = { ...readCredentials(), ...next };
5788
- fs16.writeFileSync(file, JSON.stringify(merged, null, 2) + "\n", {
5895
+ const licenseKey = next.licenseKey?.trim() || readCredentials().licenseKey;
5896
+ const out = {};
5897
+ if (licenseKey) out.licenseKey = licenseKey;
5898
+ fs16.writeFileSync(file, JSON.stringify(out, null, 2) + "\n", {
5789
5899
  mode: 384
5790
5900
  });
5791
5901
  }
@@ -5797,14 +5907,52 @@ function resolveLicenseKey(config) {
5797
5907
  return process.env.DKIT_LICENSE_KEY?.trim() || config?.licenseKey?.trim() || readCredentials().licenseKey?.trim() || void 0;
5798
5908
  }
5799
5909
  function resolveRegistryApi(config) {
5800
- const raw = process.env.DKIT_REGISTRY_API?.trim() || config?.registryApi?.trim() || readCredentials().registryApi?.trim() || DEFAULT_REGISTRY_API;
5801
- return raw.replace(/\/$/, "");
5910
+ const fromEnv = process.env.DKIT_REGISTRY_API?.trim();
5911
+ if (fromEnv) return fromEnv.replace(/\/$/, "");
5912
+ const fromConfig = config?.registryApi?.trim();
5913
+ if (fromConfig) return fromConfig.replace(/\/$/, "");
5914
+ if (isLocalMonorepoCli()) return LOCAL_REGISTRY_API;
5915
+ return DEFAULT_REGISTRY_API;
5802
5916
  }
5803
5917
  var BUY_PAGE_BUILDER_URL = "https://dkit.run/docs/modules/page-builder/";
5918
+ async function verifyLicenseKey(key, registryApi) {
5919
+ const api = (registryApi ?? resolveRegistryApi()).replace(/\/$/, "");
5920
+ const url = `${api}/registry/v1/me`;
5921
+ let res;
5922
+ try {
5923
+ res = await fetch(url, {
5924
+ headers: { Authorization: `Bearer ${key}` }
5925
+ });
5926
+ } catch (err) {
5927
+ const detail = err instanceof Error ? err.message : String(err);
5928
+ throw new Error(
5929
+ `Could not reach registry API at ${api} (${detail}). Is it running? Set DKIT_REGISTRY_API if needed.`
5930
+ );
5931
+ }
5932
+ if (res.status === 401) {
5933
+ throw new Error(
5934
+ `Invalid license key. Buy at ${BUY_PAGE_BUILDER_URL} then run \`dkit login\` with the key from checkout.`
5935
+ );
5936
+ }
5937
+ if (!res.ok) {
5938
+ throw new Error(
5939
+ `License verification failed (HTTP ${res.status}) at ${url}`
5940
+ );
5941
+ }
5942
+ const body = await res.json();
5943
+ return {
5944
+ email: body.email ?? "",
5945
+ products: body.products ?? [],
5946
+ createdAt: body.createdAt
5947
+ };
5948
+ }
5804
5949
 
5805
5950
  // src/lib/premium-fetch.ts
5806
5951
  function localPremiumItemDir(id) {
5952
+ const here = path18.dirname(fileURLToPath3(import.meta.url));
5807
5953
  const candidates = [
5954
+ // Monorepo checkout (works even when cwd is a temp fixture)
5955
+ path18.resolve(here, "../../../registry-premium"),
5808
5956
  path18.resolve(process.cwd(), "packages/registry-premium"),
5809
5957
  path18.resolve(process.cwd(), "../../packages/registry-premium")
5810
5958
  ];
@@ -5825,22 +5973,62 @@ function localPremiumItemDir(id) {
5825
5973
  }
5826
5974
  return null;
5827
5975
  }
5976
+ function allowLocalPremium() {
5977
+ const v = process.env.DKIT_ALLOW_LOCAL_PREMIUM?.trim().toLowerCase();
5978
+ return v === "1" || v === "true" || v === "yes";
5979
+ }
5828
5980
  function needsPremiumFetch(entry) {
5829
5981
  return entry.remote === true || isPremiumAccess(entry.access);
5830
5982
  }
5983
+ async function ensurePremiumAccess(entry, config) {
5984
+ if (!needsPremiumFetch(entry)) return;
5985
+ if (allowLocalPremium() && localPremiumItemDir(entry.id)) return;
5986
+ const license = resolveLicenseKey(config);
5987
+ if (!license) {
5988
+ throw new Error(
5989
+ `"${entry.id}" is a premium module. Buy it at ${BUY_PAGE_BUILDER_URL} then run \`dkit login\`, or set DKIT_LICENSE_KEY.` + (localPremiumItemDir(entry.id) ? ` (monorepo tip: DKIT_ALLOW_LOCAL_PREMIUM=1 to use packages/registry-premium)` : "")
5990
+ );
5991
+ }
5992
+ const me = await verifyLicenseKey(license, resolveRegistryApi(config));
5993
+ const product = entry.access?.product;
5994
+ if (product && !me.products.includes(product)) {
5995
+ throw new Error(
5996
+ `License does not include "${product}" (have: ${me.products.join(", ") || "none"}). Buy at ${BUY_PAGE_BUILDER_URL}`
5997
+ );
5998
+ }
5999
+ }
6000
+ async function ensurePremiumAccessForIds(ids, index, config) {
6001
+ const seen = /* @__PURE__ */ new Set();
6002
+ for (const id of ids) {
6003
+ if (seen.has(id)) continue;
6004
+ seen.add(id);
6005
+ const entry = index.items.find((i) => i.id === id);
6006
+ if (entry) await ensurePremiumAccess(entry, config);
6007
+ }
6008
+ }
5831
6009
  async function resolvePremiumItemDir(entry, config) {
5832
- const local = localPremiumItemDir(entry.id);
5833
- if (local) return local;
6010
+ if (allowLocalPremium()) {
6011
+ const local = localPremiumItemDir(entry.id);
6012
+ if (local) return local;
6013
+ }
5834
6014
  const license = resolveLicenseKey(config);
5835
6015
  if (!license) {
5836
6016
  throw new Error(
5837
- `"${entry.id}" is a premium module. Buy it at ${BUY_PAGE_BUILDER_URL} then run \`dkit login\`, or set DKIT_LICENSE_KEY.`
6017
+ `"${entry.id}" is a premium module. Buy it at ${BUY_PAGE_BUILDER_URL} then run \`dkit login\`, or set DKIT_LICENSE_KEY.` + (localPremiumItemDir(entry.id) ? ` (monorepo tip: DKIT_ALLOW_LOCAL_PREMIUM=1 to use packages/registry-premium)` : "")
5838
6018
  );
5839
6019
  }
5840
6020
  const api = resolveRegistryApi(config);
5841
- const res = await fetch(`${api}/registry/v1/items/${encodeURIComponent(entry.id)}`, {
5842
- headers: { Authorization: `Bearer ${license}` }
5843
- });
6021
+ let res;
6022
+ try {
6023
+ res = await fetch(`${api}/registry/v1/items/${encodeURIComponent(entry.id)}`, {
6024
+ headers: { Authorization: `Bearer ${license}` }
6025
+ });
6026
+ } catch (err) {
6027
+ const detail = err instanceof Error ? err.message : String(err);
6028
+ throw new Error(
6029
+ `Could not download "${entry.id}" from ${api} (${detail}). Is the registry API running?`
6030
+ );
6031
+ }
5844
6032
  if (res.status === 401 || res.status === 403) {
5845
6033
  const body = await res.json().catch(() => ({}));
5846
6034
  throw new Error(
@@ -5970,11 +6158,11 @@ function groupBlockIdsBySlot(blockIds, index) {
5970
6158
  return out;
5971
6159
  }
5972
6160
  function pickDefaultSlotPrimary(slot, candidates, opts) {
6161
+ const override = opts.templateOverrides?.[slot];
6162
+ if (override && candidates.includes(override)) return override;
5973
6163
  if (opts.existing && candidates.includes(opts.existing)) {
5974
6164
  return opts.existing;
5975
6165
  }
5976
- const override = opts.templateOverrides?.[slot];
5977
- if (override && candidates.includes(override)) return override;
5978
6166
  const meta = readModuleTemplateManifest(
5979
6167
  opts.moduleId,
5980
6168
  opts.index,
@@ -6285,7 +6473,7 @@ function routeConflictPaths(projectRoot, framework, basePath, config) {
6285
6473
  path21.join(projectRoot, "app", "pages", ...segments)
6286
6474
  );
6287
6475
  }
6288
- return candidates.filter((p4) => fs20.existsSync(p4));
6476
+ return candidates.filter((p5) => fs20.existsSync(p5));
6289
6477
  }
6290
6478
  function normalizeBasePath(input) {
6291
6479
  let v = input.trim() || "/";
@@ -6344,12 +6532,16 @@ ${collectionsEntries}
6344
6532
  } as const;
6345
6533
 
6346
6534
  export type DkitCollection = keyof typeof collections;
6535
+ /** Physical Directus collection name (schema key). */
6536
+ export type DkitCollectionName = (typeof collections)[DkitCollection];
6347
6537
 
6348
6538
  export const modules = {
6349
6539
  ${modulesEntries}
6350
6540
  } as const;
6351
6541
 
6352
- export function collection(name: DkitCollection): string {
6542
+ export function collection<K extends DkitCollection>(
6543
+ name: K,
6544
+ ): (typeof collections)[K] {
6353
6545
  return collections[name];
6354
6546
  }
6355
6547
 
@@ -6464,7 +6656,7 @@ function routeExportsFromBlocks(blocks, slotPrimaries) {
6464
6656
  }
6465
6657
  function joinModulePath(basePath, ...parts) {
6466
6658
  const base = !basePath || basePath === "/" ? "" : basePath.replace(/\/$/, "");
6467
- const rest2 = parts.map((p4) => p4.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
6659
+ const rest2 = parts.map((p5) => p5.replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
6468
6660
  const joined = `${base}/${rest2}`.replace(/\/{2,}/g, "/");
6469
6661
  return joined.startsWith("/") ? joined : `/${joined}`;
6470
6662
  }
@@ -6729,7 +6921,7 @@ ${withSetLocale ? ` setRequestLocale(${localeParam});
6729
6921
  `;
6730
6922
  }
6731
6923
  function humanizeModuleId(moduleId) {
6732
- return moduleId.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((p4) => p4.charAt(0).toUpperCase() + p4.slice(1)).join(" ");
6924
+ return moduleId.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((p5) => p5.charAt(0).toUpperCase() + p5.slice(1)).join(" ");
6733
6925
  }
6734
6926
  function formPageHeading(moduleId) {
6735
6927
  return humanizeModuleId(moduleId).replace(/\s+Form$/i, "") || "Contact";
@@ -7015,6 +7207,12 @@ function addCommand() {
7015
7207
  process.exit(1);
7016
7208
  }
7017
7209
  const primaryIsBlock = registryEntry.type === "dkit:block";
7210
+ try {
7211
+ await ensurePremiumAccess(registryEntry, config);
7212
+ } catch (e) {
7213
+ p2.cancel(e instanceof Error ? e.message : String(e));
7214
+ process.exit(1);
7215
+ }
7018
7216
  let withBlocks = opts.with ? opts.with.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
7019
7217
  const templateOverrides = parseTemplateFlag(opts.template);
7020
7218
  const hasTemplateOverrides = Object.keys(templateOverrides).length > 0;
@@ -7043,6 +7241,16 @@ function addCommand() {
7043
7241
  withBlocks,
7044
7242
  templateOverrides
7045
7243
  });
7244
+ try {
7245
+ await ensurePremiumAccessForIds(
7246
+ [...plan.modules, ...plan.blocks],
7247
+ index,
7248
+ config
7249
+ );
7250
+ } catch (e) {
7251
+ p2.cancel(e instanceof Error ? e.message : String(e));
7252
+ process.exit(1);
7253
+ }
7046
7254
  p2.log.info(
7047
7255
  `Plan: modules [${plan.modules.join(", ") || "\u2014"}] \xB7 components [${plan.blocks.join(", ") || "\u2014"}] \xB7 framework ${framework} \xB7 ui kit ${config.uiAdapter}`
7048
7256
  );
@@ -7785,43 +7993,80 @@ function loginCommand() {
7785
7993
  }
7786
7994
  key = String(answer).trim();
7787
7995
  }
7788
- const registryApi = opts.registryApi?.trim() || process.env.DKIT_REGISTRY_API?.trim() || readCredentials().registryApi || resolveRegistryApi();
7996
+ const registryApi = opts.registryApi?.trim() || resolveRegistryApi();
7789
7997
  try {
7790
- const res = await fetch(`${registryApi.replace(/\/$/, "")}/registry/v1/me`, {
7791
- headers: { Authorization: `Bearer ${key}` }
7792
- });
7793
- if (res.ok) {
7794
- const me = await res.json();
7795
- p3.log.success(
7796
- `Licensed${me.email ? ` \xB7 ${me.email}` : ""}${me.products?.length ? ` \xB7 ${me.products.join(", ")}` : ""}`
7797
- );
7798
- } else if (res.status === 401) {
7799
- p3.cancel("Invalid license key");
7800
- process.exit(1);
7801
- } else {
7802
- p3.log.warn(
7803
- `Could not verify license (HTTP ${res.status}) \u2014 saving key anyway`
7804
- );
7805
- }
7806
- } catch {
7807
- p3.log.warn(
7808
- `Registry API unreachable at ${registryApi} \u2014 saving key for offline use`
7998
+ const me = await verifyLicenseKey(key, registryApi);
7999
+ p3.log.success(
8000
+ `Licensed${me.email ? ` \xB7 ${me.email}` : ""}${me.products.length ? ` \xB7 ${me.products.join(", ")}` : ""}`
7809
8001
  );
8002
+ p3.log.info(`Registry ${registryApi}`);
8003
+ } catch (e) {
8004
+ p3.cancel(e instanceof Error ? e.message : String(e));
8005
+ process.exit(1);
7810
8006
  }
7811
- writeCredentials({ licenseKey: key, registryApi });
7812
- p3.log.info(`Saved ${credentialsPath()}`);
8007
+ writeCredentials({ licenseKey: key });
8008
+ p3.log.info(`Saved ${credentialsPath()} (key only)`);
7813
8009
  p3.log.info(`Buy / manage: ${BUY_PAGE_BUILDER_URL}`);
7814
8010
  p3.outro("Ready \u2014 try: dkit add page-builder");
7815
8011
  });
7816
8012
  }
7817
8013
 
7818
- // src/commands/doctor.ts
8014
+ // src/commands/license.ts
7819
8015
  import { Command as Command5 } from "commander";
8016
+ import * as p4 from "@clack/prompts";
7820
8017
  import pc5 from "picocolors";
8018
+ function licenseCommand() {
8019
+ const cmd = new Command5("license").description(
8020
+ "Manage your dkit premium license"
8021
+ );
8022
+ cmd.command("recover").description(
8023
+ "Email your license key to the address used at checkout (key is never printed)"
8024
+ ).option("--email <email>", "Checkout email").option("--registry-api <url>", "Premium registry API base URL").action(async (opts) => {
8025
+ p4.intro(pc5.bgCyan(pc5.black(" dkit license recover ")));
8026
+ let email = opts.email?.trim();
8027
+ if (!email) {
8028
+ const answer = await p4.text({
8029
+ message: "Checkout email",
8030
+ placeholder: "you@company.com",
8031
+ validate: (v) => !v?.trim() || !v.includes("@") ? "Valid email required" : void 0
8032
+ });
8033
+ if (p4.isCancel(answer)) {
8034
+ p4.cancel("Cancelled");
8035
+ process.exit(1);
8036
+ }
8037
+ email = String(answer).trim();
8038
+ }
8039
+ const api = (opts.registryApi?.trim() || process.env.DKIT_REGISTRY_API?.trim() || resolveRegistryApi()).replace(/\/$/, "");
8040
+ try {
8041
+ const res = await fetch(`${api}/registry/v1/recover`, {
8042
+ method: "POST",
8043
+ headers: { "Content-Type": "application/json" },
8044
+ body: JSON.stringify({ email })
8045
+ });
8046
+ const data = await res.json().catch(() => ({}));
8047
+ if (!res.ok) {
8048
+ throw new Error(data.error || `Recover failed (HTTP ${res.status})`);
8049
+ }
8050
+ p4.log.success(
8051
+ data.message || "If a license exists for that email, we sent the key. Check your inbox."
8052
+ );
8053
+ p4.log.info("Then: dkit login --key <key-from-email>");
8054
+ p4.outro("Done");
8055
+ } catch (e) {
8056
+ p4.cancel(e instanceof Error ? e.message : String(e));
8057
+ process.exit(1);
8058
+ }
8059
+ });
8060
+ return cmd;
8061
+ }
8062
+
8063
+ // src/commands/doctor.ts
8064
+ import { Command as Command6 } from "commander";
8065
+ import pc6 from "picocolors";
7821
8066
  import path29 from "path";
7822
8067
  import fs28 from "fs";
7823
8068
  function doctorCommand() {
7824
- return new Command5("doctor").description("Check project + Directus connectivity").action(async () => {
8069
+ return new Command6("doctor").description("Check project + Directus connectivity").action(async () => {
7825
8070
  const projectRoot = findProjectRoot();
7826
8071
  const checks = [];
7827
8072
  checks.push({
@@ -7896,10 +8141,10 @@ function doctorCommand() {
7896
8141
  label: "Tip: pnpm directus:up (in the dkit repo) starts a local Directus on :8010 (v11 \u2192 :8011)"
7897
8142
  });
7898
8143
  }
7899
- console.log(pc5.bold("\ndkit doctor\n"));
8144
+ console.log(pc6.bold("\ndkit doctor\n"));
7900
8145
  for (const c of checks) {
7901
8146
  console.log(
7902
- `${c.ok ? pc5.green("\u2713") : pc5.red("\u2717")} ${c.label}`
8147
+ `${c.ok ? pc6.green("\u2713") : pc6.red("\u2717")} ${c.label}`
7903
8148
  );
7904
8149
  }
7905
8150
  console.log();
@@ -8002,7 +8247,7 @@ var require2 = createRequire(import.meta.url);
8002
8247
  var { version } = require2("../package.json");
8003
8248
  async function run(argv) {
8004
8249
  installTelemetryExitFlush();
8005
- const program = new Command6();
8250
+ const program = new Command7();
8006
8251
  program.name("dkit").description(
8007
8252
  "Install Directus modules \u2014 schema, permissions, flows, and frontend code you own"
8008
8253
  ).version(version).option(
@@ -8013,6 +8258,7 @@ async function run(argv) {
8013
8258
  program.addCommand(addCommand());
8014
8259
  program.addCommand(listCommand());
8015
8260
  program.addCommand(loginCommand());
8261
+ program.addCommand(licenseCommand());
8016
8262
  program.addCommand(doctorCommand());
8017
8263
  program.hook("preAction", (_thisCommand, actionCommand) => {
8018
8264
  const rootOpts = program.opts();