@contractspec/module.ai-chat 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/dist/ai-chat.feature.d.ts +12 -0
  4. package/dist/ai-chat.feature.d.ts.map +1 -0
  5. package/dist/ai-chat.feature.js +95 -0
  6. package/dist/ai-chat.feature.js.map +1 -0
  7. package/dist/ai-chat.operations.d.ts +243 -0
  8. package/dist/ai-chat.operations.d.ts.map +1 -0
  9. package/dist/ai-chat.operations.js +174 -0
  10. package/dist/ai-chat.operations.js.map +1 -0
  11. package/dist/context/context-builder.d.ts +57 -0
  12. package/dist/context/context-builder.d.ts.map +1 -0
  13. package/dist/context/context-builder.js +148 -0
  14. package/dist/context/context-builder.js.map +1 -0
  15. package/dist/context/file-operations.d.ts +100 -0
  16. package/dist/context/file-operations.d.ts.map +1 -0
  17. package/dist/context/file-operations.js +175 -0
  18. package/dist/context/file-operations.js.map +1 -0
  19. package/dist/context/index.d.ts +4 -0
  20. package/dist/context/index.js +5 -0
  21. package/dist/context/workspace-context.d.ts +117 -0
  22. package/dist/context/workspace-context.d.ts.map +1 -0
  23. package/dist/context/workspace-context.js +124 -0
  24. package/dist/context/workspace-context.js.map +1 -0
  25. package/dist/core/chat-service.d.ts +73 -0
  26. package/dist/core/chat-service.d.ts.map +1 -0
  27. package/dist/core/chat-service.js +227 -0
  28. package/dist/core/chat-service.js.map +1 -0
  29. package/dist/core/conversation-store.d.ts +74 -0
  30. package/dist/core/conversation-store.d.ts.map +1 -0
  31. package/dist/core/conversation-store.js +109 -0
  32. package/dist/core/conversation-store.js.map +1 -0
  33. package/dist/core/index.d.ts +4 -0
  34. package/dist/core/index.js +4 -0
  35. package/dist/core/message-types.d.ts +150 -0
  36. package/dist/core/message-types.d.ts.map +1 -0
  37. package/dist/events.d.ts +115 -0
  38. package/dist/events.d.ts.map +1 -0
  39. package/dist/events.js +100 -0
  40. package/dist/events.js.map +1 -0
  41. package/dist/index.d.ts +21 -0
  42. package/dist/index.js +23 -0
  43. package/dist/libs/schema/dist/EnumType.js +2 -0
  44. package/dist/libs/schema/dist/FieldType.js +50 -0
  45. package/dist/libs/schema/dist/FieldType.js.map +1 -0
  46. package/dist/libs/schema/dist/GraphQLSchemaType.js +1 -0
  47. package/dist/libs/schema/dist/JsonSchemaType.js +1 -0
  48. package/dist/libs/schema/dist/ScalarTypeEnum.js +237 -0
  49. package/dist/libs/schema/dist/ScalarTypeEnum.js.map +1 -0
  50. package/dist/libs/schema/dist/SchemaModel.js +40 -0
  51. package/dist/libs/schema/dist/SchemaModel.js.map +1 -0
  52. package/dist/libs/schema/dist/ZodSchemaType.js +1 -0
  53. package/dist/libs/schema/dist/entity/defineEntity.js +1 -0
  54. package/dist/libs/schema/dist/entity/index.js +2 -0
  55. package/dist/libs/schema/dist/entity/types.js +1 -0
  56. package/dist/libs/schema/dist/index.js +9 -0
  57. package/dist/presentation/components/ChatContainer.d.ts +21 -0
  58. package/dist/presentation/components/ChatContainer.d.ts.map +1 -0
  59. package/dist/presentation/components/ChatContainer.js +63 -0
  60. package/dist/presentation/components/ChatContainer.js.map +1 -0
  61. package/dist/presentation/components/ChatInput.d.ts +35 -0
  62. package/dist/presentation/components/ChatInput.d.ts.map +1 -0
  63. package/dist/presentation/components/ChatInput.js +149 -0
  64. package/dist/presentation/components/ChatInput.js.map +1 -0
  65. package/dist/presentation/components/ChatMessage.d.ts +24 -0
  66. package/dist/presentation/components/ChatMessage.d.ts.map +1 -0
  67. package/dist/presentation/components/ChatMessage.js +136 -0
  68. package/dist/presentation/components/ChatMessage.js.map +1 -0
  69. package/dist/presentation/components/CodePreview.d.ts +40 -0
  70. package/dist/presentation/components/CodePreview.d.ts.map +1 -0
  71. package/dist/presentation/components/CodePreview.js +127 -0
  72. package/dist/presentation/components/CodePreview.js.map +1 -0
  73. package/dist/presentation/components/ContextIndicator.d.ts +26 -0
  74. package/dist/presentation/components/ContextIndicator.d.ts.map +1 -0
  75. package/dist/presentation/components/ContextIndicator.js +97 -0
  76. package/dist/presentation/components/ContextIndicator.js.map +1 -0
  77. package/dist/presentation/components/ModelPicker.d.ts +39 -0
  78. package/dist/presentation/components/ModelPicker.d.ts.map +1 -0
  79. package/dist/presentation/components/ModelPicker.js +202 -0
  80. package/dist/presentation/components/ModelPicker.js.map +1 -0
  81. package/dist/presentation/components/index.d.ts +7 -0
  82. package/dist/presentation/components/index.js +8 -0
  83. package/dist/presentation/hooks/index.d.ts +3 -0
  84. package/dist/presentation/hooks/index.js +4 -0
  85. package/dist/presentation/hooks/useChat.d.ts +67 -0
  86. package/dist/presentation/hooks/useChat.d.ts.map +1 -0
  87. package/dist/presentation/hooks/useChat.js +172 -0
  88. package/dist/presentation/hooks/useChat.js.map +1 -0
  89. package/dist/presentation/hooks/useProviders.d.ts +38 -0
  90. package/dist/presentation/hooks/useProviders.d.ts.map +1 -0
  91. package/dist/presentation/hooks/useProviders.js +41 -0
  92. package/dist/presentation/hooks/useProviders.js.map +1 -0
  93. package/dist/presentation/index.d.ts +11 -0
  94. package/dist/presentation/index.js +12 -0
  95. package/dist/providers/chat-utilities.d.ts +15 -0
  96. package/dist/providers/chat-utilities.d.ts.map +1 -0
  97. package/dist/providers/chat-utilities.js +17 -0
  98. package/dist/providers/chat-utilities.js.map +1 -0
  99. package/dist/providers/index.d.ts +3 -0
  100. package/dist/providers/index.js +4 -0
  101. package/dist/schema.d.ts +222 -0
  102. package/dist/schema.d.ts.map +1 -0
  103. package/dist/schema.js +102 -0
  104. package/dist/schema.js.map +1 -0
  105. package/package.json +80 -0
@@ -0,0 +1,115 @@
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
3
+
4
+ //#region src/events.d.ts
5
+ declare const MessageSentEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
6
+ id: {
7
+ type: _contractspec_lib_schema0.FieldType<string, string>;
8
+ isOptional: false;
9
+ };
10
+ role: {
11
+ type: _contractspec_lib_schema0.FieldType<string, string>;
12
+ isOptional: false;
13
+ };
14
+ content: {
15
+ type: _contractspec_lib_schema0.FieldType<string, string>;
16
+ isOptional: false;
17
+ };
18
+ status: {
19
+ type: _contractspec_lib_schema0.FieldType<string, string>;
20
+ isOptional: false;
21
+ };
22
+ createdAt: {
23
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
24
+ isOptional: false;
25
+ };
26
+ }>>;
27
+ declare const MessageReceivedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
28
+ id: {
29
+ type: _contractspec_lib_schema0.FieldType<string, string>;
30
+ isOptional: false;
31
+ };
32
+ role: {
33
+ type: _contractspec_lib_schema0.FieldType<string, string>;
34
+ isOptional: false;
35
+ };
36
+ content: {
37
+ type: _contractspec_lib_schema0.FieldType<string, string>;
38
+ isOptional: false;
39
+ };
40
+ status: {
41
+ type: _contractspec_lib_schema0.FieldType<string, string>;
42
+ isOptional: false;
43
+ };
44
+ createdAt: {
45
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
46
+ isOptional: false;
47
+ };
48
+ }>>;
49
+ declare const ConversationCreatedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
50
+ id: {
51
+ type: _contractspec_lib_schema0.FieldType<string, string>;
52
+ isOptional: false;
53
+ };
54
+ title: {
55
+ type: _contractspec_lib_schema0.FieldType<string, string>;
56
+ isOptional: true;
57
+ };
58
+ status: {
59
+ type: _contractspec_lib_schema0.FieldType<string, string>;
60
+ isOptional: false;
61
+ };
62
+ messages: {
63
+ type: _contractspec_lib_schema0.SchemaModel<{
64
+ id: {
65
+ type: _contractspec_lib_schema0.FieldType<string, string>;
66
+ isOptional: false;
67
+ };
68
+ role: {
69
+ type: _contractspec_lib_schema0.FieldType<string, string>;
70
+ isOptional: false;
71
+ };
72
+ content: {
73
+ type: _contractspec_lib_schema0.FieldType<string, string>;
74
+ isOptional: false;
75
+ };
76
+ status: {
77
+ type: _contractspec_lib_schema0.FieldType<string, string>;
78
+ isOptional: false;
79
+ };
80
+ createdAt: {
81
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
82
+ isOptional: false;
83
+ };
84
+ }>;
85
+ isArray: true;
86
+ isOptional: false;
87
+ };
88
+ provider: {
89
+ type: _contractspec_lib_schema0.FieldType<string, string>;
90
+ isOptional: false;
91
+ };
92
+ model: {
93
+ type: _contractspec_lib_schema0.FieldType<string, string>;
94
+ isOptional: false;
95
+ };
96
+ }>>;
97
+ declare const ConversationDeletedEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
98
+ id: {
99
+ type: _contractspec_lib_schema0.FieldType<string, string>;
100
+ isOptional: false;
101
+ };
102
+ }>>;
103
+ declare const ChatErrorEvent: _contractspec_lib_contracts0.EventSpec<_contractspec_lib_schema0.SchemaModel<{
104
+ code: {
105
+ type: _contractspec_lib_schema0.FieldType<string, string>;
106
+ isOptional: false;
107
+ };
108
+ message: {
109
+ type: _contractspec_lib_schema0.FieldType<string, string>;
110
+ isOptional: false;
111
+ };
112
+ }>>;
113
+ //#endregion
114
+ export { ChatErrorEvent, ConversationCreatedEvent, ConversationDeletedEvent, MessageReceivedEvent, MessageSentEvent };
115
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"sourcesContent":[],"mappings":";;;;cAIa,kBAAgB,4BAAA,CAAA,oCAAA;;UAU3B,yBAAA,CAAA;;EAVW,CAAA;EAUX,IAAA,EAAA;;;;;;;EAV2B,CAAA;EAAA,MAAA,EAAA;IAYhB,IAAA,qCAUX,CAAA,MAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;;;;;;AAV+B,cAApB,oBAAoB,EAAA,4BAAA,CAAA,SAAA,2BAAA,WAAA,CAAA;EAAA,EAAA,EAAA;IAYpB,IAAA,EAFX,yBAAA,CAAA,SAYA,CAAA,MAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;;;;;;;;;;;;EAVmC,CAAA;EAAA,SAAA,EAAA;IAYxB,IAAA,qCAeX,KAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;CAfmC,CAAA,CAAA;AAAA,cAZxB,wBAYwB,EAZA,4BAAA,CAAA,SAYA,2BAZA,WAYA,CAAA;EAiBxB,EAAA,EAAA;IAgBX,IAAA,EAnCA,yBAAA,CAAA,SAmCA,CAAA,MAAA,EAAA,MAAA,CAAA;;;EAhByB,KAAA,EAAA;IAAA,IAAA,qCAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAjBd,0BAAwB,4BAAA,CAAA,oCAAA;;UAenC,yBAAA,CAAA;;;;cAEW,gBAAc,4BAAA,CAAA,oCAAA;;UAgBzB,yBAAA,CAAA"}
package/dist/events.js ADDED
@@ -0,0 +1,100 @@
1
+ import { ScalarTypeEnum } from "./libs/schema/dist/ScalarTypeEnum.js";
2
+ import { defineSchemaModel } from "./libs/schema/dist/SchemaModel.js";
3
+ import "./libs/schema/dist/index.js";
4
+ import { ChatConversationModel, ChatMessageModel } from "./schema.js";
5
+ import { defineEvent } from "@contractspec/lib.contracts";
6
+
7
+ //#region src/events.ts
8
+ const MessageSentEvent = defineEvent({
9
+ meta: {
10
+ key: "ai-chat.message.sent",
11
+ version: 1,
12
+ description: "Message sent by user",
13
+ stability: "stable",
14
+ owners: ["@ai-chat"],
15
+ tags: [
16
+ "ai-chat",
17
+ "message",
18
+ "sent"
19
+ ]
20
+ },
21
+ payload: ChatMessageModel
22
+ });
23
+ const MessageReceivedEvent = defineEvent({
24
+ meta: {
25
+ key: "ai-chat.message.received",
26
+ version: 1,
27
+ description: "Message received from AI",
28
+ stability: "stable",
29
+ owners: ["@ai-chat"],
30
+ tags: [
31
+ "ai-chat",
32
+ "message",
33
+ "received"
34
+ ]
35
+ },
36
+ payload: ChatMessageModel
37
+ });
38
+ const ConversationCreatedEvent = defineEvent({
39
+ meta: {
40
+ key: "ai-chat.conversation.created",
41
+ version: 1,
42
+ description: "New conversation created",
43
+ stability: "stable",
44
+ owners: ["@ai-chat"],
45
+ tags: [
46
+ "ai-chat",
47
+ "conversation",
48
+ "created"
49
+ ]
50
+ },
51
+ payload: ChatConversationModel
52
+ });
53
+ const ConversationDeletedEvent = defineEvent({
54
+ meta: {
55
+ key: "ai-chat.conversation.deleted",
56
+ version: 1,
57
+ description: "Conversation deleted",
58
+ stability: "stable",
59
+ owners: ["@ai-chat"],
60
+ tags: [
61
+ "ai-chat",
62
+ "conversation",
63
+ "deleted"
64
+ ]
65
+ },
66
+ payload: defineSchemaModel({
67
+ name: "ConversationDeletedPayload",
68
+ fields: { id: {
69
+ type: ScalarTypeEnum.String_unsecure(),
70
+ isOptional: false
71
+ } }
72
+ })
73
+ });
74
+ const ChatErrorEvent = defineEvent({
75
+ meta: {
76
+ key: "ai-chat.error",
77
+ version: 1,
78
+ description: "Chat error occurred",
79
+ stability: "stable",
80
+ owners: ["@ai-chat"],
81
+ tags: ["ai-chat", "error"]
82
+ },
83
+ payload: defineSchemaModel({
84
+ name: "ChatErrorPayload",
85
+ fields: {
86
+ code: {
87
+ type: ScalarTypeEnum.String_unsecure(),
88
+ isOptional: false
89
+ },
90
+ message: {
91
+ type: ScalarTypeEnum.String_unsecure(),
92
+ isOptional: false
93
+ }
94
+ }
95
+ })
96
+ });
97
+
98
+ //#endregion
99
+ export { ChatErrorEvent, ConversationCreatedEvent, ConversationDeletedEvent, MessageReceivedEvent, MessageSentEvent };
100
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","names":[],"sources":["../src/events.ts"],"sourcesContent":["import { defineEvent } from '@contractspec/lib.contracts';\nimport { defineSchemaModel, ScalarTypeEnum } from '@contractspec/lib.schema';\nimport { ChatMessageModel, ChatConversationModel } from './schema';\n\nexport const MessageSentEvent = defineEvent({\n meta: {\n key: 'ai-chat.message.sent',\n version: 1,\n description: 'Message sent by user',\n stability: 'stable',\n owners: ['@ai-chat'],\n tags: ['ai-chat', 'message', 'sent'],\n },\n payload: ChatMessageModel,\n});\n\nexport const MessageReceivedEvent = defineEvent({\n meta: {\n key: 'ai-chat.message.received',\n version: 1,\n description: 'Message received from AI',\n stability: 'stable',\n owners: ['@ai-chat'],\n tags: ['ai-chat', 'message', 'received'],\n },\n payload: ChatMessageModel,\n});\n\nexport const ConversationCreatedEvent = defineEvent({\n meta: {\n key: 'ai-chat.conversation.created',\n version: 1,\n description: 'New conversation created',\n stability: 'stable',\n owners: ['@ai-chat'],\n tags: ['ai-chat', 'conversation', 'created'],\n },\n payload: ChatConversationModel,\n});\n\nexport const ConversationDeletedEvent = defineEvent({\n meta: {\n key: 'ai-chat.conversation.deleted',\n version: 1,\n description: 'Conversation deleted',\n stability: 'stable',\n owners: ['@ai-chat'],\n tags: ['ai-chat', 'conversation', 'deleted'],\n },\n payload: defineSchemaModel({\n name: 'ConversationDeletedPayload',\n fields: {\n id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n }),\n});\n\nexport const ChatErrorEvent = defineEvent({\n meta: {\n key: 'ai-chat.error',\n version: 1,\n description: 'Chat error occurred',\n stability: 'stable',\n owners: ['@ai-chat'],\n tags: ['ai-chat', 'error'],\n },\n payload: defineSchemaModel({\n name: 'ChatErrorPayload',\n fields: {\n code: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },\n },\n }),\n});\n"],"mappings":";;;;;;;AAIA,MAAa,mBAAmB,YAAY;CAC1C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,WAAW;EACpB,MAAM;GAAC;GAAW;GAAW;GAAO;EACrC;CACD,SAAS;CACV,CAAC;AAEF,MAAa,uBAAuB,YAAY;CAC9C,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,WAAW;EACpB,MAAM;GAAC;GAAW;GAAW;GAAW;EACzC;CACD,SAAS;CACV,CAAC;AAEF,MAAa,2BAA2B,YAAY;CAClD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,WAAW;EACpB,MAAM;GAAC;GAAW;GAAgB;GAAU;EAC7C;CACD,SAAS;CACV,CAAC;AAEF,MAAa,2BAA2B,YAAY;CAClD,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,WAAW;EACpB,MAAM;GAAC;GAAW;GAAgB;GAAU;EAC7C;CACD,SAAS,kBAAkB;EACzB,MAAM;EACN,QAAQ,EACN,IAAI;GAAE,MAAM,eAAe,iBAAiB;GAAE,YAAY;GAAO,EAClE;EACF,CAAC;CACH,CAAC;AAEF,MAAa,iBAAiB,YAAY;CACxC,MAAM;EACJ,KAAK;EACL,SAAS;EACT,aAAa;EACb,WAAW;EACX,QAAQ,CAAC,WAAW;EACpB,MAAM,CAAC,WAAW,QAAQ;EAC3B;CACD,SAAS,kBAAkB;EACzB,MAAM;EACN,QAAQ;GACN,MAAM;IAAE,MAAM,eAAe,iBAAiB;IAAE,YAAY;IAAO;GACnE,SAAS;IAAE,MAAM,eAAe,iBAAiB;IAAE,YAAY;IAAO;GACvE;EACF,CAAC;CACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { FileInfo, SpecInfo, WorkspaceContext, WorkspaceContextConfig, WorkspaceSummary, createWorkspaceContext } from "./context/workspace-context.js";
2
+ import { BuiltContext, ContextBuilder, ContextBuilderOptions, ContextEntry, createContextBuilder } from "./context/context-builder.js";
3
+ import { FileOperation, FileOperationResult, FileOperations, FileReadResult, FileSystem, FileWriteResult, createNodeFileOperations } from "./context/file-operations.js";
4
+ import { AiChatFeature } from "./ai-chat.feature.js";
5
+ import { ChatContainer } from "./presentation/components/ChatContainer.js";
6
+ import { ChatMessage } from "./presentation/components/ChatMessage.js";
7
+ import { ChatInput } from "./presentation/components/ChatInput.js";
8
+ import { ModelPicker } from "./presentation/components/ModelPicker.js";
9
+ import { ContextIndicator } from "./presentation/components/ContextIndicator.js";
10
+ import { CodePreview } from "./presentation/components/CodePreview.js";
11
+ import "./presentation/components/index.js";
12
+ import { UseChatOptions, UseChatReturn, useChat } from "./presentation/hooks/useChat.js";
13
+ import { UseProvidersReturn, useProviders } from "./presentation/hooks/useProviders.js";
14
+ import "./presentation/hooks/index.js";
15
+ import "./presentation/index.js";
16
+ import { isStudioAvailable, supportsLocalMode } from "./providers/chat-utilities.js";
17
+ import { ChatModelInfo, ChatProvider, ChatProviderConfig, ChatProviderMode, ChatProviderName, DEFAULT_MODELS, MODELS, ModelCapabilities, ProviderAvailability, createProvider, createProviderFromEnv, getAvailableProviders, getDefaultModel, getEnvVarName, getModelInfo, getModelsForProvider, getRecommendedModels, hasCredentials, isOllamaRunning, listOllamaModels, validateProvider } from "./providers/index.js";
18
+ import { ChatConversationModel, ChatMessageModel, ListConversationsOutputModel, SendMessageInputModel, SendMessageOutputModel } from "./schema.js";
19
+ import { DeleteConversationContract, GetConversationContract, ListConversationsContract, ListProvidersContract, ScanContextContract, SendMessageContract, StreamMessageContract } from "./ai-chat.operations.js";
20
+ import { ChatErrorEvent, ConversationCreatedEvent, ConversationDeletedEvent, MessageReceivedEvent, MessageSentEvent } from "./events.js";
21
+ export { AiChatFeature, BuiltContext, ChatContainer, ChatConversationModel, ChatErrorEvent, ChatInput, ChatMessage, ChatMessage as ChatMessageComponent, ChatMessageModel, ChatModelInfo, ChatProvider, ChatProviderConfig, ChatProviderMode, ChatProviderName, CodePreview, ContextBuilder, ContextBuilderOptions, ContextEntry, ContextIndicator, ConversationCreatedEvent, ConversationDeletedEvent, DEFAULT_MODELS, DeleteConversationContract, FileInfo, FileOperation, FileOperationResult, FileOperations, FileReadResult, FileSystem, FileWriteResult, GetConversationContract, ListConversationsContract, ListConversationsOutputModel, ListProvidersContract, MODELS, MessageReceivedEvent, MessageSentEvent, ModelCapabilities, ModelPicker, ProviderAvailability, ScanContextContract, SendMessageContract, SendMessageInputModel, SendMessageOutputModel, SpecInfo, StreamMessageContract, UseChatOptions, UseChatReturn, UseProvidersReturn, WorkspaceContext, WorkspaceContextConfig, WorkspaceSummary, createContextBuilder, createNodeFileOperations, createProvider, createProviderFromEnv, createWorkspaceContext, getAvailableProviders, getDefaultModel, getEnvVarName, getModelInfo, getModelsForProvider, getRecommendedModels, hasCredentials, isOllamaRunning, isStudioAvailable, listOllamaModels, supportsLocalMode, useChat, useProviders, validateProvider };
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ import { AiChatFeature } from "./ai-chat.feature.js";
2
+ import { ChatContainer } from "./presentation/components/ChatContainer.js";
3
+ import { CodePreview } from "./presentation/components/CodePreview.js";
4
+ import { ChatMessage } from "./presentation/components/ChatMessage.js";
5
+ import { ChatInput } from "./presentation/components/ChatInput.js";
6
+ import { ModelPicker } from "./presentation/components/ModelPicker.js";
7
+ import { ContextIndicator } from "./presentation/components/ContextIndicator.js";
8
+ import "./presentation/components/index.js";
9
+ import { useChat } from "./presentation/hooks/useChat.js";
10
+ import { useProviders } from "./presentation/hooks/useProviders.js";
11
+ import "./presentation/hooks/index.js";
12
+ import "./presentation/index.js";
13
+ import { isStudioAvailable, supportsLocalMode } from "./providers/chat-utilities.js";
14
+ import { DEFAULT_MODELS, MODELS, createProvider, createProviderFromEnv, getAvailableProviders, getDefaultModel, getEnvVarName, getModelInfo, getModelsForProvider, getRecommendedModels, hasCredentials, isOllamaRunning, listOllamaModels, validateProvider } from "./providers/index.js";
15
+ import { WorkspaceContext, createWorkspaceContext } from "./context/workspace-context.js";
16
+ import { ContextBuilder, createContextBuilder } from "./context/context-builder.js";
17
+ import { FileOperations, createNodeFileOperations } from "./context/file-operations.js";
18
+ import "./context/index.js";
19
+ import { ChatConversationModel, ChatMessageModel, ListConversationsOutputModel, SendMessageInputModel, SendMessageOutputModel } from "./schema.js";
20
+ import { DeleteConversationContract, GetConversationContract, ListConversationsContract, ListProvidersContract, ScanContextContract, SendMessageContract, StreamMessageContract } from "./ai-chat.operations.js";
21
+ import { ChatErrorEvent, ConversationCreatedEvent, ConversationDeletedEvent, MessageReceivedEvent, MessageSentEvent } from "./events.js";
22
+
23
+ export { AiChatFeature, ChatContainer, ChatConversationModel, ChatErrorEvent, ChatInput, ChatMessage, ChatMessage as ChatMessageComponent, ChatMessageModel, CodePreview, ContextBuilder, ContextIndicator, ConversationCreatedEvent, ConversationDeletedEvent, DEFAULT_MODELS, DeleteConversationContract, FileOperations, GetConversationContract, ListConversationsContract, ListConversationsOutputModel, ListProvidersContract, MODELS, MessageReceivedEvent, MessageSentEvent, ModelPicker, ScanContextContract, SendMessageContract, SendMessageInputModel, SendMessageOutputModel, StreamMessageContract, WorkspaceContext, createContextBuilder, createNodeFileOperations, createProvider, createProviderFromEnv, createWorkspaceContext, getAvailableProviders, getDefaultModel, getEnvVarName, getModelInfo, getModelsForProvider, getRecommendedModels, hasCredentials, isOllamaRunning, isStudioAvailable, listOllamaModels, supportsLocalMode, useChat, useProviders, validateProvider };
@@ -0,0 +1,2 @@
1
+ import "zod";
2
+ import "graphql";
@@ -0,0 +1,50 @@
1
+ import "zod";
2
+ import { GraphQLScalarType } from "graphql";
3
+
4
+ //#region ../../libs/schema/dist/FieldType.js
5
+ /**
6
+ * GraphQL scalar wrapper that carries zod and JSON Schema metadata.
7
+ *
8
+ * TInternal is the runtime representation; TExternal is the GraphQL output.
9
+ */
10
+ var FieldType = class extends GraphQLScalarType {
11
+ zodSchema;
12
+ jsonSchemaDef;
13
+ constructor(config) {
14
+ super(config);
15
+ this.zodSchema = config.zod;
16
+ this.jsonSchemaDef = config.jsonSchema;
17
+ }
18
+ /** Return the attached zod schema for validation. */
19
+ getZod() {
20
+ return this.zodSchema;
21
+ }
22
+ /** GraphQL scalar instance usable by Pothos or vanilla GraphQL. */
23
+ getPothos() {
24
+ return this;
25
+ }
26
+ /** Return the JSON Schema (evaluates factory if provided). */
27
+ getJson() {
28
+ return typeof this.jsonSchemaDef === "function" ? this.jsonSchemaDef() : this.jsonSchemaDef;
29
+ }
30
+ getJsonSchemaDef() {
31
+ return this.jsonSchemaDef;
32
+ }
33
+ getJsonSchema() {
34
+ const deepResolve = (v) => {
35
+ const value = typeof v === "function" ? v() : v;
36
+ if (Array.isArray(value)) return value.map((item) => deepResolve(item));
37
+ if (value && typeof value === "object") {
38
+ const obj = {};
39
+ for (const [k, val] of Object.entries(value)) obj[k] = deepResolve(val);
40
+ return obj;
41
+ }
42
+ return value;
43
+ };
44
+ return deepResolve(this.getJson());
45
+ }
46
+ };
47
+
48
+ //#endregion
49
+ export { FieldType };
50
+ //# sourceMappingURL=FieldType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldType.js","names":[],"sources":["../../../../../../libs/schema/dist/FieldType.js"],"sourcesContent":["import \"zod\";\nimport { GraphQLScalarType } from \"graphql\";\n\n//#region src/FieldType.ts\n/**\n* GraphQL scalar wrapper that carries zod and JSON Schema metadata.\n*\n* TInternal is the runtime representation; TExternal is the GraphQL output.\n*/\nvar FieldType = class extends GraphQLScalarType {\n\tzodSchema;\n\tjsonSchemaDef;\n\tconstructor(config) {\n\t\tsuper(config);\n\t\tthis.zodSchema = config.zod;\n\t\tthis.jsonSchemaDef = config.jsonSchema;\n\t}\n\t/** Return the attached zod schema for validation. */\n\tgetZod() {\n\t\treturn this.zodSchema;\n\t}\n\t/** GraphQL scalar instance usable by Pothos or vanilla GraphQL. */\n\tgetPothos() {\n\t\treturn this;\n\t}\n\t/** Return the JSON Schema (evaluates factory if provided). */\n\tgetJson() {\n\t\treturn typeof this.jsonSchemaDef === \"function\" ? this.jsonSchemaDef() : this.jsonSchemaDef;\n\t}\n\tgetJsonSchemaDef() {\n\t\treturn this.jsonSchemaDef;\n\t}\n\tgetJsonSchema() {\n\t\tconst deepResolve = (v) => {\n\t\t\tconst value = typeof v === \"function\" ? v() : v;\n\t\t\tif (Array.isArray(value)) return value.map((item) => deepResolve(item));\n\t\t\tif (value && typeof value === \"object\") {\n\t\t\t\tconst obj = {};\n\t\t\t\tfor (const [k, val] of Object.entries(value)) obj[k] = deepResolve(val);\n\t\t\t\treturn obj;\n\t\t\t}\n\t\t\treturn value;\n\t\t};\n\t\treturn deepResolve(this.getJson());\n\t}\n};\n\n//#endregion\nexport { FieldType };\n//# sourceMappingURL=FieldType.js.map"],"mappings":";;;;;;;;;AASA,IAAI,YAAY,cAAc,kBAAkB;CAC/C;CACA;CACA,YAAY,QAAQ;AACnB,QAAM,OAAO;AACb,OAAK,YAAY,OAAO;AACxB,OAAK,gBAAgB,OAAO;;;CAG7B,SAAS;AACR,SAAO,KAAK;;;CAGb,YAAY;AACX,SAAO;;;CAGR,UAAU;AACT,SAAO,OAAO,KAAK,kBAAkB,aAAa,KAAK,eAAe,GAAG,KAAK;;CAE/E,mBAAmB;AAClB,SAAO,KAAK;;CAEb,gBAAgB;EACf,MAAM,eAAe,MAAM;GAC1B,MAAM,QAAQ,OAAO,MAAM,aAAa,GAAG,GAAG;AAC9C,OAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,KAAK,SAAS,YAAY,KAAK,CAAC;AACvE,OAAI,SAAS,OAAO,UAAU,UAAU;IACvC,MAAM,MAAM,EAAE;AACd,SAAK,MAAM,CAAC,GAAG,QAAQ,OAAO,QAAQ,MAAM,CAAE,KAAI,KAAK,YAAY,IAAI;AACvE,WAAO;;AAER,UAAO;;AAER,SAAO,YAAY,KAAK,SAAS,CAAC"}
@@ -0,0 +1 @@
1
+ import "zod";
@@ -0,0 +1 @@
1
+ import "zod";
@@ -0,0 +1,237 @@
1
+ import { FieldType } from "./FieldType.js";
2
+ import * as z$1 from "zod";
3
+ import { Kind } from "graphql";
4
+
5
+ //#region ../../libs/schema/dist/ScalarTypeEnum.js
6
+ const localeRegex = /^[A-Za-z]{2}(?:-[A-Za-z0-9]{2,8})*$/;
7
+ const timezoneRegex = /^(?:UTC|[A-Za-z_]+\/[A-Za-z_]+)$/;
8
+ const phoneRegex = /^[+]?\d[\d\s().-]{3,}$/;
9
+ const currencyRegex = /^[A-Z]{3}$/;
10
+ const countryRegex = /^[A-Z]{2}$/;
11
+ const latMin = -90;
12
+ const latMax = 90;
13
+ const lonMin = -180;
14
+ const lonMax = 180;
15
+ /**
16
+ * Factory functions for common scalar FieldTypes with zod/GraphQL/JSON Schema.
17
+ */
18
+ const ScalarTypeEnum = {
19
+ String_unsecure: () => new FieldType({
20
+ name: "String_unsecure",
21
+ description: "Unvalidated string scalar",
22
+ zod: z$1.string(),
23
+ parseValue: (v) => z$1.string().parse(v),
24
+ serialize: (v) => String(v),
25
+ parseLiteral: (ast) => {
26
+ if (ast.kind !== Kind.STRING) throw new TypeError("Invalid literal");
27
+ return ast.value;
28
+ },
29
+ jsonSchema: { type: "string" }
30
+ }),
31
+ Int_unsecure: () => new FieldType({
32
+ name: "Int_unsecure",
33
+ description: "Unvalidated integer scalar",
34
+ zod: z$1.number().int(),
35
+ parseValue: (v) => {
36
+ const num = typeof v === "number" ? v : Number(v);
37
+ return z$1.number().int().parse(num);
38
+ },
39
+ serialize: (v) => Math.trunc(typeof v === "number" ? v : Number(v)),
40
+ parseLiteral: (ast) => {
41
+ if (ast.kind !== Kind.INT) throw new TypeError("Invalid literal");
42
+ return Number(ast.value);
43
+ },
44
+ jsonSchema: { type: "integer" }
45
+ }),
46
+ Float_unsecure: () => new FieldType({
47
+ name: "Float_unsecure",
48
+ description: "Unvalidated float scalar",
49
+ zod: z$1.number(),
50
+ parseValue: (v) => {
51
+ const num = typeof v === "number" ? v : Number(v);
52
+ return z$1.number().parse(num);
53
+ },
54
+ serialize: (v) => Number(v),
55
+ parseLiteral: (ast) => {
56
+ if (ast.kind !== Kind.FLOAT && ast.kind !== Kind.INT) throw new TypeError("Invalid literal");
57
+ return Number(ast.value);
58
+ },
59
+ jsonSchema: { type: "number" }
60
+ }),
61
+ Boolean: () => new FieldType({
62
+ name: "Boolean",
63
+ description: "Unvalidated boolean scalar",
64
+ zod: z$1.boolean(),
65
+ parseValue: (v) => z$1.coerce.boolean().parse(v),
66
+ serialize: (v) => Boolean(v),
67
+ parseLiteral: (ast) => {
68
+ if (ast.kind !== Kind.BOOLEAN) throw new TypeError("Invalid literal");
69
+ return ast.value;
70
+ },
71
+ jsonSchema: { type: "boolean" }
72
+ }),
73
+ ID: () => new FieldType({
74
+ name: "ID",
75
+ description: "Unvalidated id scalar",
76
+ zod: z$1.string(),
77
+ parseValue: (v) => z$1.string().parse(v),
78
+ serialize: (v) => String(v),
79
+ parseLiteral: (ast) => {
80
+ if (ast.kind !== Kind.STRING) throw new TypeError("Invalid literal");
81
+ return ast.value;
82
+ },
83
+ jsonSchema: { type: "string" }
84
+ }),
85
+ JSON: () => new FieldType({
86
+ name: "JSON",
87
+ zod: z$1.any(),
88
+ parseValue: (v) => v,
89
+ serialize: (v) => v,
90
+ jsonSchema: {}
91
+ }),
92
+ JSONObject: () => new FieldType({
93
+ name: "JSONObject",
94
+ zod: z$1.record(z$1.string(), z$1.any()),
95
+ parseValue: (v) => z$1.record(z$1.string(), z$1.any()).parse(v),
96
+ serialize: (v) => v ?? {},
97
+ jsonSchema: { type: "object" }
98
+ }),
99
+ Date: () => new FieldType({
100
+ name: "Date",
101
+ zod: z$1.date(),
102
+ parseValue: (v) => v instanceof Date ? v : new Date(String(v)),
103
+ serialize: (v) => v instanceof Date ? v.toISOString().split("T")[0] : String(v),
104
+ jsonSchema: {
105
+ type: "string",
106
+ format: "date"
107
+ }
108
+ }),
109
+ DateTime: () => new FieldType({
110
+ name: "DateTime",
111
+ zod: z$1.date(),
112
+ parseValue: (v) => v instanceof Date ? v : new Date(String(v)),
113
+ serialize: (v) => {
114
+ return v instanceof Date ? v.toISOString() : String(v);
115
+ },
116
+ jsonSchema: {
117
+ type: "string",
118
+ format: "date-time"
119
+ }
120
+ }),
121
+ Time: () => new FieldType({
122
+ name: "Time",
123
+ zod: z$1.string().regex(/^\d{2}:\d{2}(:\d{2})?$/),
124
+ parseValue: (v) => z$1.string().regex(/^\d{2}:\d{2}(:\d{2})?$/).parse(v),
125
+ serialize: (v) => String(v),
126
+ jsonSchema: {
127
+ type: "string",
128
+ pattern: "^\\d{2}:\\d{2}(:\\d{2})?$"
129
+ }
130
+ }),
131
+ EmailAddress: () => new FieldType({
132
+ name: "EmailAddress",
133
+ zod: z$1.string().email(),
134
+ parseValue: (v) => z$1.string().email().parse(v),
135
+ serialize: (v) => String(v),
136
+ jsonSchema: {
137
+ type: "string",
138
+ format: "email"
139
+ }
140
+ }),
141
+ URL: () => new FieldType({
142
+ name: "URL",
143
+ zod: z$1.string().url(),
144
+ parseValue: (v) => z$1.string().url().parse(v),
145
+ serialize: (v) => String(v),
146
+ jsonSchema: {
147
+ type: "string",
148
+ format: "uri"
149
+ }
150
+ }),
151
+ PhoneNumber: () => new FieldType({
152
+ name: "PhoneNumber",
153
+ zod: z$1.string().regex(phoneRegex),
154
+ parseValue: (v) => z$1.string().regex(phoneRegex).parse(v),
155
+ serialize: (v) => String(v),
156
+ jsonSchema: {
157
+ type: "string",
158
+ pattern: phoneRegex.source
159
+ }
160
+ }),
161
+ NonEmptyString: () => new FieldType({
162
+ name: "NonEmptyString",
163
+ zod: z$1.string().min(1),
164
+ parseValue: (v) => z$1.string().min(1).parse(v),
165
+ serialize: (v) => String(v),
166
+ jsonSchema: {
167
+ type: "string",
168
+ minLength: 1
169
+ }
170
+ }),
171
+ Locale: () => new FieldType({
172
+ name: "Locale",
173
+ zod: z$1.string().regex(localeRegex),
174
+ parseValue: (v) => z$1.string().regex(localeRegex).parse(v),
175
+ serialize: (v) => String(v),
176
+ jsonSchema: {
177
+ type: "string",
178
+ pattern: localeRegex.source
179
+ }
180
+ }),
181
+ TimeZone: () => new FieldType({
182
+ name: "TimeZone",
183
+ zod: z$1.string().regex(timezoneRegex),
184
+ parseValue: (v) => z$1.string().regex(timezoneRegex).parse(v),
185
+ serialize: (v) => String(v),
186
+ jsonSchema: {
187
+ type: "string",
188
+ pattern: timezoneRegex.source
189
+ }
190
+ }),
191
+ Latitude: () => new FieldType({
192
+ name: "Latitude",
193
+ zod: z$1.number().min(latMin).max(latMax),
194
+ parseValue: (v) => z$1.coerce.number().min(latMin).max(latMax).parse(v),
195
+ serialize: (v) => Number(v),
196
+ jsonSchema: {
197
+ type: "number",
198
+ minimum: latMin,
199
+ maximum: latMax
200
+ }
201
+ }),
202
+ Longitude: () => new FieldType({
203
+ name: "Longitude",
204
+ zod: z$1.number().min(lonMin).max(lonMax),
205
+ parseValue: (v) => z$1.coerce.number().min(lonMin).max(lonMax).parse(v),
206
+ serialize: (v) => Number(v),
207
+ jsonSchema: {
208
+ type: "number",
209
+ minimum: lonMin,
210
+ maximum: lonMax
211
+ }
212
+ }),
213
+ Currency: () => new FieldType({
214
+ name: "Currency",
215
+ zod: z$1.string().regex(currencyRegex),
216
+ parseValue: (v) => z$1.string().regex(currencyRegex).parse(v),
217
+ serialize: (v) => String(v),
218
+ jsonSchema: {
219
+ type: "string",
220
+ pattern: currencyRegex.source
221
+ }
222
+ }),
223
+ CountryCode: () => new FieldType({
224
+ name: "CountryCode",
225
+ zod: z$1.string().regex(countryRegex),
226
+ parseValue: (v) => z$1.string().regex(countryRegex).parse(v),
227
+ serialize: (v) => String(v),
228
+ jsonSchema: {
229
+ type: "string",
230
+ pattern: countryRegex.source
231
+ }
232
+ })
233
+ };
234
+
235
+ //#endregion
236
+ export { ScalarTypeEnum };
237
+ //# sourceMappingURL=ScalarTypeEnum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScalarTypeEnum.js","names":[],"sources":["../../../../../../libs/schema/dist/ScalarTypeEnum.js"],"sourcesContent":["import { FieldType } from \"./FieldType.js\";\nimport * as z$1 from \"zod\";\nimport { Kind } from \"graphql\";\n\n//#region src/ScalarTypeEnum.ts\nconst localeRegex = /^[A-Za-z]{2}(?:-[A-Za-z0-9]{2,8})*$/;\nconst timezoneRegex = /^(?:UTC|[A-Za-z_]+\\/[A-Za-z_]+)$/;\nconst phoneRegex = /^[+]?\\d[\\d\\s().-]{3,}$/;\nconst currencyRegex = /^[A-Z]{3}$/;\nconst countryRegex = /^[A-Z]{2}$/;\nconst latMin = -90;\nconst latMax = 90;\nconst lonMin = -180;\nconst lonMax = 180;\n/**\n* Factory functions for common scalar FieldTypes with zod/GraphQL/JSON Schema.\n*/\nconst ScalarTypeEnum = {\n\tString_unsecure: () => new FieldType({\n\t\tname: \"String_unsecure\",\n\t\tdescription: \"Unvalidated string scalar\",\n\t\tzod: z$1.string(),\n\t\tparseValue: (v) => z$1.string().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.STRING) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"string\" }\n\t}),\n\tInt_unsecure: () => new FieldType({\n\t\tname: \"Int_unsecure\",\n\t\tdescription: \"Unvalidated integer scalar\",\n\t\tzod: z$1.number().int(),\n\t\tparseValue: (v) => {\n\t\t\tconst num = typeof v === \"number\" ? v : Number(v);\n\t\t\treturn z$1.number().int().parse(num);\n\t\t},\n\t\tserialize: (v) => Math.trunc(typeof v === \"number\" ? v : Number(v)),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.INT) throw new TypeError(\"Invalid literal\");\n\t\t\treturn Number(ast.value);\n\t\t},\n\t\tjsonSchema: { type: \"integer\" }\n\t}),\n\tFloat_unsecure: () => new FieldType({\n\t\tname: \"Float_unsecure\",\n\t\tdescription: \"Unvalidated float scalar\",\n\t\tzod: z$1.number(),\n\t\tparseValue: (v) => {\n\t\t\tconst num = typeof v === \"number\" ? v : Number(v);\n\t\t\treturn z$1.number().parse(num);\n\t\t},\n\t\tserialize: (v) => Number(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.FLOAT && ast.kind !== Kind.INT) throw new TypeError(\"Invalid literal\");\n\t\t\treturn Number(ast.value);\n\t\t},\n\t\tjsonSchema: { type: \"number\" }\n\t}),\n\tBoolean: () => new FieldType({\n\t\tname: \"Boolean\",\n\t\tdescription: \"Unvalidated boolean scalar\",\n\t\tzod: z$1.boolean(),\n\t\tparseValue: (v) => z$1.coerce.boolean().parse(v),\n\t\tserialize: (v) => Boolean(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.BOOLEAN) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"boolean\" }\n\t}),\n\tID: () => new FieldType({\n\t\tname: \"ID\",\n\t\tdescription: \"Unvalidated id scalar\",\n\t\tzod: z$1.string(),\n\t\tparseValue: (v) => z$1.string().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tparseLiteral: (ast) => {\n\t\t\tif (ast.kind !== Kind.STRING) throw new TypeError(\"Invalid literal\");\n\t\t\treturn ast.value;\n\t\t},\n\t\tjsonSchema: { type: \"string\" }\n\t}),\n\tJSON: () => new FieldType({\n\t\tname: \"JSON\",\n\t\tzod: z$1.any(),\n\t\tparseValue: (v) => v,\n\t\tserialize: (v) => v,\n\t\tjsonSchema: {}\n\t}),\n\tJSONObject: () => new FieldType({\n\t\tname: \"JSONObject\",\n\t\tzod: z$1.record(z$1.string(), z$1.any()),\n\t\tparseValue: (v) => z$1.record(z$1.string(), z$1.any()).parse(v),\n\t\tserialize: (v) => v ?? {},\n\t\tjsonSchema: { type: \"object\" }\n\t}),\n\tDate: () => new FieldType({\n\t\tname: \"Date\",\n\t\tzod: z$1.date(),\n\t\tparseValue: (v) => v instanceof Date ? v : new Date(String(v)),\n\t\tserialize: (v) => v instanceof Date ? v.toISOString().split(\"T\")[0] : String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date\"\n\t\t}\n\t}),\n\tDateTime: () => new FieldType({\n\t\tname: \"DateTime\",\n\t\tzod: z$1.date(),\n\t\tparseValue: (v) => v instanceof Date ? v : new Date(String(v)),\n\t\tserialize: (v) => {\n\t\t\treturn v instanceof Date ? v.toISOString() : String(v);\n\t\t},\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"date-time\"\n\t\t}\n\t}),\n\tTime: () => new FieldType({\n\t\tname: \"Time\",\n\t\tzod: z$1.string().regex(/^\\d{2}:\\d{2}(:\\d{2})?$/),\n\t\tparseValue: (v) => z$1.string().regex(/^\\d{2}:\\d{2}(:\\d{2})?$/).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: \"^\\\\d{2}:\\\\d{2}(:\\\\d{2})?$\"\n\t\t}\n\t}),\n\tEmailAddress: () => new FieldType({\n\t\tname: \"EmailAddress\",\n\t\tzod: z$1.string().email(),\n\t\tparseValue: (v) => z$1.string().email().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"email\"\n\t\t}\n\t}),\n\tURL: () => new FieldType({\n\t\tname: \"URL\",\n\t\tzod: z$1.string().url(),\n\t\tparseValue: (v) => z$1.string().url().parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tformat: \"uri\"\n\t\t}\n\t}),\n\tPhoneNumber: () => new FieldType({\n\t\tname: \"PhoneNumber\",\n\t\tzod: z$1.string().regex(phoneRegex),\n\t\tparseValue: (v) => z$1.string().regex(phoneRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: phoneRegex.source\n\t\t}\n\t}),\n\tNonEmptyString: () => new FieldType({\n\t\tname: \"NonEmptyString\",\n\t\tzod: z$1.string().min(1),\n\t\tparseValue: (v) => z$1.string().min(1).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tminLength: 1\n\t\t}\n\t}),\n\tLocale: () => new FieldType({\n\t\tname: \"Locale\",\n\t\tzod: z$1.string().regex(localeRegex),\n\t\tparseValue: (v) => z$1.string().regex(localeRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: localeRegex.source\n\t\t}\n\t}),\n\tTimeZone: () => new FieldType({\n\t\tname: \"TimeZone\",\n\t\tzod: z$1.string().regex(timezoneRegex),\n\t\tparseValue: (v) => z$1.string().regex(timezoneRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: timezoneRegex.source\n\t\t}\n\t}),\n\tLatitude: () => new FieldType({\n\t\tname: \"Latitude\",\n\t\tzod: z$1.number().min(latMin).max(latMax),\n\t\tparseValue: (v) => z$1.coerce.number().min(latMin).max(latMax).parse(v),\n\t\tserialize: (v) => Number(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: latMin,\n\t\t\tmaximum: latMax\n\t\t}\n\t}),\n\tLongitude: () => new FieldType({\n\t\tname: \"Longitude\",\n\t\tzod: z$1.number().min(lonMin).max(lonMax),\n\t\tparseValue: (v) => z$1.coerce.number().min(lonMin).max(lonMax).parse(v),\n\t\tserialize: (v) => Number(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"number\",\n\t\t\tminimum: lonMin,\n\t\t\tmaximum: lonMax\n\t\t}\n\t}),\n\tCurrency: () => new FieldType({\n\t\tname: \"Currency\",\n\t\tzod: z$1.string().regex(currencyRegex),\n\t\tparseValue: (v) => z$1.string().regex(currencyRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: currencyRegex.source\n\t\t}\n\t}),\n\tCountryCode: () => new FieldType({\n\t\tname: \"CountryCode\",\n\t\tzod: z$1.string().regex(countryRegex),\n\t\tparseValue: (v) => z$1.string().regex(countryRegex).parse(v),\n\t\tserialize: (v) => String(v),\n\t\tjsonSchema: {\n\t\t\ttype: \"string\",\n\t\t\tpattern: countryRegex.source\n\t\t}\n\t})\n};\n\n//#endregion\nexport { ScalarTypeEnum };\n//# sourceMappingURL=ScalarTypeEnum.js.map"],"mappings":";;;;;AAKA,MAAM,cAAc;AACpB,MAAM,gBAAgB;AACtB,MAAM,aAAa;AACnB,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,SAAS;;;;AAIf,MAAM,iBAAiB;CACtB,uBAAuB,IAAI,UAAU;EACpC,MAAM;EACN,aAAa;EACb,KAAK,IAAI,QAAQ;EACjB,aAAa,MAAM,IAAI,QAAQ,CAAC,MAAM,EAAE;EACxC,YAAY,MAAM,OAAO,EAAE;EAC3B,eAAe,QAAQ;AACtB,OAAI,IAAI,SAAS,KAAK,OAAQ,OAAM,IAAI,UAAU,kBAAkB;AACpE,UAAO,IAAI;;EAEZ,YAAY,EAAE,MAAM,UAAU;EAC9B,CAAC;CACF,oBAAoB,IAAI,UAAU;EACjC,MAAM;EACN,aAAa;EACb,KAAK,IAAI,QAAQ,CAAC,KAAK;EACvB,aAAa,MAAM;GAClB,MAAM,MAAM,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE;AACjD,UAAO,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,IAAI;;EAErC,YAAY,MAAM,KAAK,MAAM,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE,CAAC;EACnE,eAAe,QAAQ;AACtB,OAAI,IAAI,SAAS,KAAK,IAAK,OAAM,IAAI,UAAU,kBAAkB;AACjE,UAAO,OAAO,IAAI,MAAM;;EAEzB,YAAY,EAAE,MAAM,WAAW;EAC/B,CAAC;CACF,sBAAsB,IAAI,UAAU;EACnC,MAAM;EACN,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GACN,SAAS;GACT,SAAS;GACT;EACD,CAAC;CACF,iBAAiB,IAAI,UAAU;EAC9B,MAAM;EACN,KAAK,IAAI,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,OAAO;EACzC,aAAa,MAAM,IAAI,OAAO,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE;EACvE,YAAY,MAAM,OAAO,EAAE;EAC3B,YAAY;GACX,MAAM;GACN,SAAS;GACT,SAAS;GACT;EACD,CAAC;CACF,gBAAgB,IAAI,UAAU;EAC7B,MAAM;EACN,KAAK,IAAI,QAAQ,CAAC,MAAM,cAAc;EACtC,aAAa,MAAM,IAAI,QAAQ,CAAC,MAAM,cAAc,CAAC,MAAM,EAAE;EAC7D,YAAY,MAAM,OAAO,EAAE;EAC3B,YAAY;GACX,MAAM;GACN,SAAS,cAAc;GACvB;EACD,CAAC;CACF,mBAAmB,IAAI,UAAU;EAChC,MAAM;EACN,KAAK,IAAI,QAAQ,CAAC,MAAM,aAAa;EACrC,aAAa,MAAM,IAAI,QAAQ,CAAC,MAAM,aAAa,CAAC,MAAM,EAAE;EAC5D,YAAY,MAAM,OAAO,EAAE;EAC3B,YAAY;GACX,MAAM;GACN,SAAS,aAAa;GACtB;EACD,CAAC;CACF"}
@@ -0,0 +1,40 @@
1
+ import "./EnumType.js";
2
+ import "./FieldType.js";
3
+ import * as z$1 from "zod";
4
+
5
+ //#region ../../libs/schema/dist/SchemaModel.js
6
+ /**
7
+ * Named object model built from FieldType/EnumType/SchemaModel fields.
8
+ * Provides zod and GraphQL input helpers, and supports arrays/optional fields.
9
+ */
10
+ var SchemaModel = class {
11
+ constructor(config) {
12
+ this.config = config;
13
+ }
14
+ /**
15
+ * Build a typed ZodObject from the model fields, preserving each field's
16
+ * Zod schema and optionality at the type level when possible.
17
+ */
18
+ getZod() {
19
+ const shape = Object.entries(this.config.fields).reduce((acc, [key, def]) => {
20
+ const base = def.type.getZod();
21
+ const withArray = def.isArray ? z$1.array(base) : base;
22
+ acc[key] = def.isOptional ? withArray.optional() : withArray;
23
+ return acc;
24
+ }, {});
25
+ return z$1.object(shape);
26
+ }
27
+ /** Input object name for GraphQL builder adapters. */
28
+ getPothosInput() {
29
+ return this.config.name;
30
+ }
31
+ };
32
+ /**
33
+ * Helper to define a SchemaModel with type inference.
34
+ * Equivalent to `new SchemaModel(config)` but with better ergonomics.
35
+ */
36
+ const defineSchemaModel = (config) => new SchemaModel(config);
37
+
38
+ //#endregion
39
+ export { SchemaModel, defineSchemaModel };
40
+ //# sourceMappingURL=SchemaModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaModel.js","names":[],"sources":["../../../../../../libs/schema/dist/SchemaModel.js"],"sourcesContent":["import \"./EnumType.js\";\nimport \"./FieldType.js\";\nimport * as z$1 from \"zod\";\n\n//#region src/SchemaModel.ts\n/**\n* Named object model built from FieldType/EnumType/SchemaModel fields.\n* Provides zod and GraphQL input helpers, and supports arrays/optional fields.\n*/\nvar SchemaModel = class {\n\tconstructor(config) {\n\t\tthis.config = config;\n\t}\n\t/**\n\t* Build a typed ZodObject from the model fields, preserving each field's\n\t* Zod schema and optionality at the type level when possible.\n\t*/\n\tgetZod() {\n\t\tconst shape = Object.entries(this.config.fields).reduce((acc, [key, def]) => {\n\t\t\tconst base = def.type.getZod();\n\t\t\tconst withArray = def.isArray ? z$1.array(base) : base;\n\t\t\tacc[key] = def.isOptional ? withArray.optional() : withArray;\n\t\t\treturn acc;\n\t\t}, {});\n\t\treturn z$1.object(shape);\n\t}\n\t/** Input object name for GraphQL builder adapters. */\n\tgetPothosInput() {\n\t\treturn this.config.name;\n\t}\n};\n/**\n* Type guard to check if a value is a SchemaModel (not just any SchemaType).\n* Use this when you need to access SchemaModel-specific properties like `config`.\n*\n* @param model - The model to check\n* @returns True if the model is a SchemaModel instance\n*\n* @example\n* ```typescript\n* if (isSchemaModel(model)) {\n* // TypeScript knows model.config is available\n* console.log(model.config.name);\n* }\n* ```\n*/\nfunction isSchemaModel(model) {\n\treturn model !== null && model !== void 0 && \"config\" in model && typeof model.config === \"object\" && \"name\" in model.config;\n}\n/**\n* Helper to define a SchemaModel with type inference.\n* Equivalent to `new SchemaModel(config)` but with better ergonomics.\n*/\nconst defineSchemaModel = (config) => new SchemaModel(config);\n\n//#endregion\nexport { SchemaModel, defineSchemaModel, isSchemaModel };\n//# sourceMappingURL=SchemaModel.js.map"],"mappings":";;;;;;;;;AASA,IAAI,cAAc,MAAM;CACvB,YAAY,QAAQ;AACnB,OAAK,SAAS;;;;;;CAMf,SAAS;EACR,MAAM,QAAQ,OAAO,QAAQ,KAAK,OAAO,OAAO,CAAC,QAAQ,KAAK,CAAC,KAAK,SAAS;GAC5E,MAAM,OAAO,IAAI,KAAK,QAAQ;GAC9B,MAAM,YAAY,IAAI,UAAU,IAAI,MAAM,KAAK,GAAG;AAClD,OAAI,OAAO,IAAI,aAAa,UAAU,UAAU,GAAG;AACnD,UAAO;KACL,EAAE,CAAC;AACN,SAAO,IAAI,OAAO,MAAM;;;CAGzB,iBAAiB;AAChB,SAAO,KAAK,OAAO;;;;;;;AAyBrB,MAAM,qBAAqB,WAAW,IAAI,YAAY,OAAO"}
@@ -0,0 +1 @@
1
+ import "zod";
@@ -0,0 +1 @@
1
+ import "zod";