create-nextblock 0.11.1 → 0.11.3

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 (59) hide show
  1. package/package.json +1 -1
  2. package/templates/nextblock-template/app/actions/interactions.test.ts +301 -0
  3. package/templates/nextblock-template/app/actions/interactions.ts +372 -0
  4. package/templates/nextblock-template/app/api/ai/cortex/build-widget/route.ts +4 -4
  5. package/templates/nextblock-template/app/api/ai/generate-blocks/route.ts +2 -2
  6. package/templates/nextblock-template/app/api/ai/global-agent/route.ts +56 -57
  7. package/templates/nextblock-template/app/api/cron/reset-sandbox/route.ts +1 -1
  8. package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +951 -0
  9. package/templates/nextblock-template/app/article/[slug]/PostClientContent.tsx +6 -0
  10. package/templates/nextblock-template/app/cms/CmsClientLayout.tsx +4 -0
  11. package/templates/nextblock-template/app/cms/components/ConnectGitHubButton.tsx +7 -2
  12. package/templates/nextblock-template/app/cms/components/github-connect-actions.ts +4 -0
  13. package/templates/nextblock-template/app/cms/interactions/InteractionsModerationClient.tsx +408 -0
  14. package/templates/nextblock-template/app/cms/interactions/page.tsx +51 -0
  15. package/templates/nextblock-template/app/cms/settings/cortex-ai/SandboxCortexAiSettingsClient.tsx +4 -3
  16. package/templates/nextblock-template/app/cms/settings/cortex-ai/StoredCortexAiSettingsClient.tsx +1 -1
  17. package/templates/nextblock-template/app/cms/settings/cortex-ai/actions.ts +3 -5
  18. package/templates/nextblock-template/app/cms/settings/cortex-ai/page.tsx +1 -1
  19. package/templates/nextblock-template/app/page.tsx +2 -2
  20. package/templates/nextblock-template/app/product/[slug]/page.tsx +2 -0
  21. package/templates/nextblock-template/components/AppShell.tsx +1 -1
  22. package/templates/nextblock-template/components/PostCommentsSection.tsx +369 -0
  23. package/templates/nextblock-template/components/ProductReviewsSection.tsx +419 -0
  24. package/templates/nextblock-template/components/blocks/renderers/ProductDetailsBlockRenderer.tsx +2 -0
  25. package/templates/nextblock-template/components/privacy/ConsentBanner.tsx +62 -19
  26. package/templates/nextblock-template/docs/08-NEXTBLOCK-CORTEX-AI-ARCHITECTURE.md +19 -19
  27. package/templates/nextblock-template/docs/10-CUSTOM-BLOCKS.md +4 -4
  28. package/templates/nextblock-template/docs/13-STAYING-UP-TO-DATE.md +7 -0
  29. package/templates/nextblock-template/lib/blocks/ProductGridBlock.tsx +2 -0
  30. package/templates/nextblock-template/lib/setup/actions.ts +3 -1
  31. package/templates/nextblock-template/lib/setup/migrations-bundle.ts +40 -0
  32. package/templates/nextblock-template/lib/updates/check-upstream.ts +38 -4
  33. package/templates/nextblock-template/package.json +2 -1
  34. package/templates/nextblock-template/scripts/verify-cortex-ai-build-widget.tsx +2 -4
  35. package/templates/nextblock-template/scripts/verify-cortex-ai-generate-blocks.ts +1 -1
  36. package/templates/nextblock-template/scripts/verify-cortex-ai-global-tools.ts +1 -1
  37. package/templates/nextblock-template/scripts/verify-cortex-ai-routing.ts +1 -1
  38. package/templates/nextblock-template/tsconfig.tsbuildinfo +1 -1
  39. package/templates/nextblock-template/lib/ai-block-generation.ts +0 -339
  40. package/templates/nextblock-template/lib/ai-client.ts +0 -247
  41. package/templates/nextblock-template/lib/ai-config.ts +0 -98
  42. package/templates/nextblock-template/lib/ai-cortex-widget-builder.ts +0 -125
  43. package/templates/nextblock-template/lib/ai-global-agent-custom-block-tools.ts +0 -363
  44. package/templates/nextblock-template/lib/ai-global-agent-db-tools.test.ts +0 -405
  45. package/templates/nextblock-template/lib/ai-global-agent-db-tools.ts +0 -1228
  46. package/templates/nextblock-template/lib/ai-global-agent-ecommerce.ts +0 -5
  47. package/templates/nextblock-template/lib/ai-global-agent-tools-stats.test.ts +0 -223
  48. package/templates/nextblock-template/lib/ai-global-agent-tools.test.ts +0 -2183
  49. package/templates/nextblock-template/lib/ai-global-agent-tools.ts +0 -4807
  50. package/templates/nextblock-template/lib/ai-key-crypto.test.ts +0 -70
  51. package/templates/nextblock-template/lib/ai-key-crypto.ts +0 -132
  52. package/templates/nextblock-template/lib/ai-model-catalog.test.ts +0 -49
  53. package/templates/nextblock-template/lib/ai-model-catalog.ts +0 -41
  54. package/templates/nextblock-template/lib/ai-model-registry.test.ts +0 -231
  55. package/templates/nextblock-template/lib/ai-model-registry.ts +0 -522
  56. package/templates/nextblock-template/lib/cortex-widget-registry.test.ts +0 -199
  57. package/templates/nextblock-template/lib/cortex-widget-registry.ts +0 -88
  58. package/templates/nextblock-template/lib/cortex-widget-schema.test.tsx +0 -237
  59. package/templates/nextblock-template/lib/cortex-widget-schema.ts +0 -393
@@ -3,14 +3,14 @@ import { revalidatePath, revalidateTag } from 'next/cache';
3
3
 
4
4
  import { createClient, verifyPackageOnline } from '@nextblock-cms/db/server';
5
5
 
6
- import { generateCortexWidgetDefinition } from '../../../../../lib/ai-cortex-widget-builder';
6
+ import { generateCortexWidgetDefinition } from '@nextblock/cortex';
7
7
  import {
8
8
  cortexWidgetBuildRequestSchema,
9
- } from '../../../../../lib/cortex-widget-schema';
9
+ } from '@nextblock/cortex';
10
10
  import {
11
11
  CortexWidgetRegistryInsertError,
12
12
  insertCortexWidgetDefinition,
13
- } from '../../../../../lib/cortex-widget-registry';
13
+ } from '@nextblock/cortex';
14
14
  import {
15
15
  CUSTOM_BLOCK_DEFINITIONS_CACHE_TAG,
16
16
  getCustomBlockDefinitionCacheTag,
@@ -18,7 +18,7 @@ import {
18
18
  import {
19
19
  safeParseCortexAiModelSelection,
20
20
  summarizeCortexAiRoutingError,
21
- } from '../../../../../lib/ai-model-registry';
21
+ } from '@nextblock/cortex';
22
22
 
23
23
  export const dynamic = 'force-dynamic';
24
24
 
@@ -5,11 +5,11 @@ import { createClient } from '@nextblock-cms/db/server';
5
5
  import {
6
6
  generateEditorHtmlFragment,
7
7
  generateEditorBlocksRequestSchema,
8
- } from '../../../../lib/ai-block-generation';
8
+ } from '@nextblock/cortex';
9
9
  import {
10
10
  safeParseCortexAiModelSelection,
11
11
  summarizeCortexAiRoutingError,
12
- } from '../../../../lib/ai-model-registry';
12
+ } from '@nextblock/cortex';
13
13
 
14
14
  export const dynamic = 'force-dynamic';
15
15
 
@@ -1,44 +1,40 @@
1
- import { stepCountIs, streamText } from 'ai';
2
- import { NextResponse } from 'next/server';
3
- import { z } from '../../../../lib/zod-config';
4
-
5
- import {
6
- createClient,
7
- getServiceRoleSupabaseClient,
8
- verifyPackageOnline,
9
- } from '@nextblock-cms/db/server';
10
-
11
- import {
12
- buildCortexAiRoutingPolicy,
13
- createCortexAiOpenRouterClient,
14
- isOpenRouterRateLimitError,
15
- omitUnsupportedCortexAiModelOptions,
16
- summarizeCortexAiRoutingError,
17
- } from '../../../../lib/ai-client';
18
- import { safeParseCortexAiModelSelection } from '../../../../lib/ai-model-registry';
19
- import {
20
- buildVisibleContactIntroActionPlan,
21
- cortexAiPageContextSchema,
22
- createCortexGlobalAgentTools,
23
- executeCmsActionPlan,
24
- executeCreateCmsPage,
25
- executeCreateCmsPost,
26
- executeCreateCmsProduct,
27
- executeDeleteCmsItem,
28
- executeInsertContentBlock,
29
- executeUpdateContentBlock,
30
- executeUpdateCmsItemField,
31
- executeUpdateCurrentCmsFields,
32
- executeUpdateFooter,
33
- executeUpdateNavigationBar,
34
- executeUpdateSectionColumnBlock,
35
- type CortexAiPageContext,
36
- } from '../../../../lib/ai-global-agent-tools';
37
- import {
38
- executeDatabaseActionPlan,
39
- executeDatabaseMutation,
40
- } from '../../../../lib/ai-global-agent-db-tools';
41
- import { executeDeleteCustomBlock } from '../../../../lib/ai-global-agent-custom-block-tools';
1
+ import { stepCountIs, streamText } from 'ai';
2
+ import { NextResponse } from 'next/server';
3
+
4
+ import {
5
+ createClient,
6
+ getServiceRoleSupabaseClient,
7
+ verifyPackageOnline,
8
+ } from '@nextblock-cms/db/server';
9
+ import {
10
+ buildCortexAiRoutingPolicy,
11
+ buildVisibleContactIntroActionPlan,
12
+ cortexAiPageContextSchema,
13
+ createCortexGlobalAgentTools,
14
+ createCortexAiOpenRouterClient,
15
+ executeCmsActionPlan,
16
+ executeCreateCmsPage,
17
+ executeCreateCmsPost,
18
+ executeCreateCmsProduct,
19
+ executeDatabaseActionPlan,
20
+ executeDatabaseMutation,
21
+ executeDeleteCmsItem,
22
+ executeDeleteCustomBlock,
23
+ executeInsertContentBlock,
24
+ executeUpdateContentBlock,
25
+ executeUpdateCmsItemField,
26
+ executeUpdateCurrentCmsFields,
27
+ executeUpdateFooter,
28
+ executeUpdateNavigationBar,
29
+ executeUpdateSectionColumnBlock,
30
+ isOpenRouterRateLimitError,
31
+ omitUnsupportedCortexAiModelOptions,
32
+ safeParseCortexAiModelSelection,
33
+ summarizeCortexAiRoutingError,
34
+ type CortexAiPageContext,
35
+ z,
36
+ } from '@nextblock/cortex';
37
+ import { validateBlockContent } from '../../../../lib/blocks/blockRegistry';
42
38
 
43
39
  export const dynamic = 'force-dynamic';
44
40
 
@@ -661,12 +657,13 @@ export async function POST(request: Request) {
661
657
  if (parsedRequest.data.confirmedToolCall) {
662
658
  const confirmedToolCall = parsedRequest.data.confirmedToolCall;
663
659
  const stream = createConfirmedToolCallStream({
664
- context: {
665
- actorUserId: adminAccess.userId,
666
- latestUserMessage: confirmedToolCall.confirmationPhrase,
667
- pageContext,
668
- supabase: getServiceRoleSupabaseClient(),
669
- },
660
+ context: {
661
+ actorUserId: adminAccess.userId,
662
+ latestUserMessage: confirmedToolCall.confirmationPhrase,
663
+ pageContext,
664
+ supabase: getServiceRoleSupabaseClient(),
665
+ validateBlockContent,
666
+ },
670
667
  input: confirmedToolCall.input,
671
668
  toolName: confirmedToolCall.toolName,
672
669
  });
@@ -685,12 +682,13 @@ export async function POST(request: Request) {
685
682
 
686
683
  if (directActionPlan) {
687
684
  const stream = createConfirmedToolCallStream({
688
- context: {
689
- actorUserId: adminAccess.userId,
690
- latestUserMessage,
691
- pageContext,
692
- supabase: getServiceRoleSupabaseClient(),
693
- },
685
+ context: {
686
+ actorUserId: adminAccess.userId,
687
+ latestUserMessage,
688
+ pageContext,
689
+ supabase: getServiceRoleSupabaseClient(),
690
+ validateBlockContent,
691
+ },
694
692
  input: directActionPlan,
695
693
  toolName: 'execute_cms_action_plan',
696
694
  });
@@ -730,10 +728,11 @@ export async function POST(request: Request) {
730
728
  actorUserId: adminAccess.userId,
731
729
  cortexAiApiKey: sandboxKey,
732
730
  cortexAiModelSelection: sandboxKey && modelSelection ? modelSelection : undefined,
733
- latestUserMessage,
734
- pageContext,
735
- supabase: getServiceRoleSupabaseClient(),
736
- });
731
+ latestUserMessage,
732
+ pageContext,
733
+ supabase: getServiceRoleSupabaseClient(),
734
+ validateBlockContent,
735
+ });
737
736
  const systemPrompt = buildGlobalAgentSystemPrompt(pageContext);
738
737
 
739
738
  const stream = new ReadableStream({
@@ -14,7 +14,7 @@ import {
14
14
  } from '@nextblock-cms/ecommerce/server';
15
15
  import postgres from 'postgres';
16
16
 
17
- import { CORTEX_AI_PACKAGE_ID } from '../../../../lib/ai-config';
17
+ import { CORTEX_AI_PACKAGE_ID } from '@nextblock/cortex';
18
18
  import { SANDBOX_RESET_SQL } from './sandboxResetSql';
19
19
 
20
20
  export const dynamic = 'force-dynamic';