@kyro-cms/core 0.3.5 → 0.4.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 (78) hide show
  1. package/README.md +3 -3
  2. package/dist/api-handler.cjs +5 -5
  3. package/dist/api-handler.js +4 -4
  4. package/dist/{chunk-X3CU27OO.cjs → chunk-3FW6WVVP.cjs} +2 -17
  5. package/dist/chunk-3FW6WVVP.cjs.map +1 -0
  6. package/dist/{chunk-R4C4O4SE.cjs → chunk-3ZZPZYCM.cjs} +36 -61
  7. package/dist/chunk-3ZZPZYCM.cjs.map +1 -0
  8. package/dist/{chunk-Y3TM7WH7.js → chunk-C4JJEE42.js} +36 -61
  9. package/dist/chunk-C4JJEE42.js.map +1 -0
  10. package/dist/{chunk-2UOI5MUC.cjs → chunk-FWGHXRRI.cjs} +4 -4
  11. package/dist/{chunk-2UOI5MUC.cjs.map → chunk-FWGHXRRI.cjs.map} +1 -1
  12. package/dist/{chunk-DE7OQOMD.cjs → chunk-M4GFA2UQ.cjs} +19 -19
  13. package/dist/chunk-M4GFA2UQ.cjs.map +1 -0
  14. package/dist/{chunk-4UD44U4Z.js → chunk-OJBK3JYF.js} +18 -18
  15. package/dist/chunk-OJBK3JYF.js.map +1 -0
  16. package/dist/{chunk-5FTY2DLG.js → chunk-SAMZQVC2.js} +3 -3
  17. package/dist/{chunk-5FTY2DLG.js.map → chunk-SAMZQVC2.js.map} +1 -1
  18. package/dist/{chunk-RGIQKTZ7.js → chunk-YMG55RSX.js} +4 -18
  19. package/dist/chunk-YMG55RSX.js.map +1 -0
  20. package/dist/drizzle/index.cjs +10 -10
  21. package/dist/drizzle/index.js +2 -2
  22. package/dist/index.cjs +48 -55
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.js +6 -13
  25. package/dist/index.js.map +1 -1
  26. package/dist/rest/index.cjs +4 -4
  27. package/dist/rest/index.js +2 -2
  28. package/package.json +2 -14
  29. package/dist/WebhookService-118ZTFis.d.ts +0 -112
  30. package/dist/WebhookService-AefJfqX0.d.cts +0 -112
  31. package/dist/api-handler.d.cts +0 -9
  32. package/dist/api-handler.d.ts +0 -9
  33. package/dist/base-DvvNqnM-.d.cts +0 -73
  34. package/dist/base-eVegJ_Pr.d.ts +0 -73
  35. package/dist/chunk-4UD44U4Z.js.map +0 -1
  36. package/dist/chunk-DE7OQOMD.cjs.map +0 -1
  37. package/dist/chunk-R4C4O4SE.cjs.map +0 -1
  38. package/dist/chunk-RGIQKTZ7.js.map +0 -1
  39. package/dist/chunk-X3CU27OO.cjs.map +0 -1
  40. package/dist/chunk-Y3TM7WH7.js.map +0 -1
  41. package/dist/cli/index.d.cts +0 -1
  42. package/dist/cli/index.d.ts +0 -1
  43. package/dist/client.d.cts +0 -12
  44. package/dist/client.d.ts +0 -12
  45. package/dist/drizzle/index.d.cts +0 -135
  46. package/dist/drizzle/index.d.ts +0 -135
  47. package/dist/fields/index.d.cts +0 -27
  48. package/dist/fields/index.d.ts +0 -27
  49. package/dist/graphql/index.d.cts +0 -22
  50. package/dist/graphql/index.d.ts +0 -22
  51. package/dist/index-Bz9JqRGI.d.cts +0 -86
  52. package/dist/index-Bz9JqRGI.d.ts +0 -86
  53. package/dist/index-CLp-DRKA.d.ts +0 -64
  54. package/dist/index-DfO7G4kN.d.cts +0 -64
  55. package/dist/index.d.cts +0 -1363
  56. package/dist/index.d.ts +0 -1363
  57. package/dist/integration.d.cts +0 -27
  58. package/dist/integration.d.ts +0 -27
  59. package/dist/mongodb/index.d.cts +0 -63
  60. package/dist/mongodb/index.d.ts +0 -63
  61. package/dist/mysql-media-AI6YK767.cjs +0 -48
  62. package/dist/mysql-media-AI6YK767.cjs.map +0 -1
  63. package/dist/mysql-media-CDZUS7YX.js +0 -45
  64. package/dist/mysql-media-CDZUS7YX.js.map +0 -1
  65. package/dist/rest/index.d.cts +0 -57
  66. package/dist/rest/index.d.ts +0 -57
  67. package/dist/templates/index.d.cts +0 -59
  68. package/dist/templates/index.d.ts +0 -59
  69. package/dist/trpc/index.d.cts +0 -136
  70. package/dist/trpc/index.d.ts +0 -136
  71. package/dist/types-BnTm7oJG.d.cts +0 -130
  72. package/dist/types-BnTm7oJG.d.ts +0 -130
  73. package/dist/types-Bs1up4yP.d.ts +0 -461
  74. package/dist/types-J3R9nVsZ.d.cts +0 -461
  75. package/dist/types-VtjUxIMp.d.cts +0 -246
  76. package/dist/types-VtjUxIMp.d.ts +0 -246
  77. package/dist/ws/index.d.cts +0 -88
  78. package/dist/ws/index.d.ts +0 -88
@@ -1,246 +0,0 @@
1
- interface FieldAdmin {
2
- description?: string;
3
- placeholder?: string;
4
- readOnly?: boolean;
5
- hidden?: boolean;
6
- width?: string;
7
- position?: "sidebar" | "main";
8
- autoGenerate?: string;
9
- action?: string;
10
- method?: string;
11
- inline?: boolean;
12
- condition?: (data: Record<string, any>, siblingData: Record<string, any>) => boolean;
13
- }
14
- interface BaseField {
15
- name: string;
16
- label?: string;
17
- required?: boolean;
18
- unique?: boolean;
19
- indexed?: boolean;
20
- defaultValue?: any;
21
- admin?: FieldAdmin;
22
- validate?: (value: any, options: ValidateOptions) => string | true | Promise<string | true>;
23
- hooks?: {
24
- beforeValidate?: Hook[];
25
- beforeChange?: Hook[];
26
- afterChange?: Hook[];
27
- afterRead?: Hook[];
28
- };
29
- }
30
- interface ValidateOptions {
31
- data?: Record<string, any>;
32
- siblingData?: Record<string, any>;
33
- user?: any;
34
- operation?: string;
35
- required?: boolean;
36
- }
37
- type Hook = (args: any) => Promise<any> | any;
38
- type TextFieldVariant = "text" | "email" | "password" | "url" | "id";
39
- interface TextField extends BaseField {
40
- type: "text";
41
- variant?: TextFieldVariant;
42
- minLength?: number;
43
- maxLength?: number;
44
- pattern?: string;
45
- hasMany?: boolean;
46
- localized?: boolean;
47
- }
48
- interface NumberField extends BaseField {
49
- type: "number";
50
- min?: number;
51
- max?: number;
52
- step?: number;
53
- integer?: boolean;
54
- hasMany?: boolean;
55
- }
56
- interface CheckboxField extends BaseField {
57
- type: "checkbox";
58
- }
59
- interface DateField extends BaseField {
60
- type: "date";
61
- minDate?: string;
62
- maxDate?: string;
63
- time?: boolean;
64
- }
65
- interface EmailField extends BaseField {
66
- type: "email";
67
- }
68
- interface PasswordField extends BaseField {
69
- type: "password";
70
- }
71
- interface TextareaField extends BaseField {
72
- type: "textarea";
73
- minLength?: number;
74
- maxLength?: number;
75
- rows?: number;
76
- localized?: boolean;
77
- }
78
- interface SelectField extends BaseField {
79
- type: "select";
80
- options: Array<{
81
- label: string;
82
- value: string;
83
- }>;
84
- hasMany?: boolean;
85
- defaultValue?: string | string[];
86
- }
87
- interface RadioField extends BaseField {
88
- type: "radio";
89
- options: Array<{
90
- label: string;
91
- value: string;
92
- }>;
93
- defaultValue?: string;
94
- }
95
- interface ColorField extends BaseField {
96
- type: "color";
97
- format?: "hex" | "rgb" | "hsl";
98
- defaultValue?: string;
99
- }
100
- interface ImageField extends BaseField {
101
- type: "image";
102
- minCount?: number;
103
- maxCount?: number;
104
- allowedTypes?: string[];
105
- maxSize?: number;
106
- }
107
- interface RichTextBlock {
108
- type: string;
109
- data: Record<string, any>;
110
- children?: RichTextBlock[];
111
- }
112
- interface RichTextField extends BaseField {
113
- type: "richtext";
114
- editor?: "lexical" | "slate" | "blocks";
115
- hasBlocks?: boolean;
116
- defaultValue?: RichTextBlock[];
117
- localized?: boolean;
118
- }
119
- interface JSONField extends BaseField {
120
- type: "json";
121
- defaultValue?: Record<string, any>;
122
- }
123
- interface CodeField extends BaseField {
124
- type: "code";
125
- language?: string;
126
- defaultValue?: string;
127
- }
128
- interface UploadField extends BaseField {
129
- type: "upload";
130
- relationTo: string;
131
- hasMany?: boolean;
132
- maxDepth?: number;
133
- defaultValue?: string;
134
- }
135
- interface MarkdownField extends BaseField {
136
- type: "markdown";
137
- localized?: boolean;
138
- defaultValue?: string;
139
- }
140
- interface RelationshipField extends BaseField {
141
- type: "relationship";
142
- relationTo: string | string[];
143
- hasMany?: boolean;
144
- maxDepth?: number;
145
- filterOptions?: (args: {
146
- data: any;
147
- user: any;
148
- }) => Record<string, any>;
149
- defaultValue?: string | string[];
150
- }
151
- interface ArrayField extends BaseField {
152
- type: "array";
153
- fields: Field[];
154
- minRows?: number;
155
- maxRows?: number;
156
- labels?: {
157
- singular?: string;
158
- plural?: string;
159
- };
160
- defaultValue?: Record<string, any>[];
161
- }
162
- interface ListField extends BaseField {
163
- type: "list";
164
- defaultValue?: string[];
165
- }
166
- interface GroupField extends BaseField {
167
- type: "group";
168
- fields: Field[];
169
- defaultValue?: Record<string, any>;
170
- }
171
- interface BlockImage {
172
- url: string;
173
- alt?: string;
174
- }
175
- interface BlockAdmin {
176
- group?: string;
177
- images?: {
178
- icon?: BlockImage | string;
179
- thumbnail?: BlockImage | string;
180
- };
181
- }
182
- interface Block {
183
- slug: string;
184
- label: string;
185
- fields: Field[];
186
- imageURL?: string;
187
- admin?: BlockAdmin;
188
- }
189
- interface BlocksField extends BaseField {
190
- type: "blocks";
191
- blocks?: Block[];
192
- minRows?: number;
193
- maxRows?: number;
194
- defaultValue?: Array<{
195
- blockType: string;
196
- [key: string]: any;
197
- }>;
198
- }
199
- interface RowField extends Omit<BaseField, "name"> {
200
- type: "row";
201
- fields: Field[];
202
- name?: string;
203
- }
204
- interface CollapsibleField extends Omit<BaseField, "name"> {
205
- type: "collapsible";
206
- fields: Field[];
207
- label: string;
208
- name?: string;
209
- }
210
- interface TabsField extends Omit<BaseField, "name"> {
211
- type: "tabs";
212
- tabs: Array<{
213
- label: string;
214
- fields: Field[];
215
- name?: string;
216
- }>;
217
- name?: string;
218
- }
219
- interface ButtonField extends BaseField {
220
- type: "button";
221
- label: string;
222
- action?: string;
223
- method?: string;
224
- inline?: boolean;
225
- }
226
- type Field = TextField | NumberField | CheckboxField | DateField | EmailField | PasswordField | TextareaField | SelectField | RadioField | ColorField | ImageField | RichTextField | JSONField | CodeField | UploadField | MarkdownField | RelationshipField | ArrayField | ListField | GroupField | BlocksField | RowField | CollapsibleField | TabsField | ButtonField;
227
- type FieldType = Field["type"];
228
- declare function isTextField(field: Field): field is TextField;
229
- declare function isNumberField(field: Field): field is NumberField;
230
- declare function isRelationshipField(field: Field): field is RelationshipField;
231
- declare function isArrayField(field: Field): field is ArrayField;
232
- declare function isGroupField(field: Field): field is GroupField;
233
- declare function isBlocksField(field: Field): field is BlocksField;
234
- declare function isUploadField(field: Field): field is UploadField;
235
- declare function isImageField(field: Field): field is ImageField;
236
- declare function isRichTextField(field: Field): field is RichTextField;
237
- declare function isSelectField(field: Field): field is SelectField;
238
- declare function isLayoutField(field: Field): field is RowField | CollapsibleField | TabsField;
239
- declare const PRIMITIVE_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color"];
240
- declare const COMPLEX_FIELD_TYPES: readonly ["richtext", "json", "code", "upload", "image", "markdown"];
241
- declare const RELATIONAL_FIELD_TYPES: readonly ["relationship", "array", "group", "blocks"];
242
- declare const LAYOUT_FIELD_TYPES: readonly ["row", "collapsible", "tabs"];
243
- declare const ALL_FIELD_TYPES: readonly ["text", "number", "checkbox", "date", "email", "password", "textarea", "select", "radio", "color", "richtext", "json", "code", "upload", "image", "markdown", "relationship", "array", "group", "blocks", "row", "collapsible", "tabs"];
244
- declare function createRelationshipFieldConfig(name: string, relationTo: string | string[], options?: Partial<Omit<RelationshipField, "type" | "name" | "relationTo">>): RelationshipField;
245
-
246
- export { type ArrayField as A, type BaseField as B, type CheckboxField as C, type DateField as D, type EmailField as E, type Field as F, type GroupField as G, isRichTextField as H, type ImageField as I, type JSONField as J, isSelectField as K, LAYOUT_FIELD_TYPES as L, type MarkdownField as M, type NumberField as N, isTextField as O, type PasswordField as P, isUploadField as Q, type RadioField as R, type SelectField as S, type TabsField as T, type UploadField as U, type ValidateOptions as V, type ButtonField as W, type Hook as X, type ListField as Y, type TextFieldVariant as Z, createRelationshipFieldConfig as _, type Block as a, type BlockAdmin as b, type BlockImage as c, type BlocksField as d, type CodeField as e, type CollapsibleField as f, type ColorField as g, type FieldAdmin as h, type FieldType as i, type RelationshipField as j, type RichTextBlock as k, type RichTextField as l, type RowField as m, type TextField as n, type TextareaField as o, ALL_FIELD_TYPES as p, COMPLEX_FIELD_TYPES as q, PRIMITIVE_FIELD_TYPES as r, RELATIONAL_FIELD_TYPES as s, isArrayField as t, isBlocksField as u, isGroupField as v, isImageField as w, isLayoutField as x, isNumberField as y, isRelationshipField as z };
@@ -1,88 +0,0 @@
1
- import { WebSocket, WebSocketServer } from 'ws';
2
-
3
- type EventHandler = (data: any) => void | Promise<void>;
4
- declare class PubSub {
5
- private channels;
6
- private maxListeners;
7
- constructor(maxListeners?: number);
8
- subscribe(channel: string, handler: EventHandler): () => void;
9
- publish(channel: string, data: any): void;
10
- hasSubscribers(channel: string): boolean;
11
- getSubscriberCount(channel: string): number;
12
- getChannels(): string[];
13
- clear(): void;
14
- }
15
- interface KyroEvent {
16
- type: 'create' | 'update' | 'delete';
17
- collection: string;
18
- doc?: any;
19
- originalDoc?: any;
20
- id?: string;
21
- tenantID?: string;
22
- timestamp: string;
23
- user?: any;
24
- }
25
- declare class KyroPubSub extends PubSub {
26
- private registry;
27
- constructor(registry: any, maxListeners?: number);
28
- publishCollectionEvent(collection: string, event: KyroEvent): void;
29
- subscribeToCollection(collection: string, handler: EventHandler): () => void;
30
- subscribeToCollectionEvent(collection: string, eventType: 'create' | 'update' | 'delete', handler: EventHandler): () => void;
31
- subscribeToTenant(tenantID: string, handler: EventHandler): () => void;
32
- subscribeToTenantCollection(tenantID: string, collection: string, handler: EventHandler): () => void;
33
- subscribeToAllCollections(handler: EventHandler): () => void;
34
- createAfterChangeHook(collection: string): (args: any) => Promise<void>;
35
- createAfterDeleteHook(collection: string): (args: any) => Promise<void>;
36
- autoRegisterHooks(): void;
37
- }
38
-
39
- interface WSServerOptions {
40
- port?: number;
41
- pubsub: KyroPubSub;
42
- maxConnections?: number;
43
- pingInterval?: number;
44
- requireAuth?: boolean;
45
- verifyToken?: (token: string) => Promise<any>;
46
- }
47
- interface WSSubscription {
48
- channel: string;
49
- unsubscribe: () => void;
50
- }
51
- interface WSClient {
52
- id: string;
53
- ws: WebSocket;
54
- subscriptions: Map<string, WSSubscription>;
55
- authenticated: boolean;
56
- user?: any;
57
- tenantID?: string;
58
- connectedAt: Date;
59
- lastActivity: Date;
60
- }
61
- declare class KyroWSServer {
62
- private wss;
63
- private clients;
64
- private pubsub;
65
- private options;
66
- private pingTimer?;
67
- constructor(options: WSServerOptions);
68
- private setupServer;
69
- private handleMessage;
70
- private handleAuthenticate;
71
- private handleSubscribe;
72
- private handleUnsubscribe;
73
- private handleUnsubscribeAll;
74
- private handleList;
75
- private handleDisconnect;
76
- private sendToClient;
77
- private generateClientId;
78
- private startPingInterval;
79
- broadcast(channel: string, data: any): void;
80
- getConnectedClients(): WSClient[];
81
- getClientCount(): number;
82
- getSubscriptionCount(): number;
83
- close(): Promise<void>;
84
- getServer(): WebSocketServer;
85
- }
86
- declare function createWSServer(options: WSServerOptions): KyroWSServer;
87
-
88
- export { type EventHandler, type KyroEvent, KyroPubSub, KyroWSServer, PubSub, type WSClient, type WSServerOptions, createWSServer };
@@ -1,88 +0,0 @@
1
- import { WebSocket, WebSocketServer } from 'ws';
2
-
3
- type EventHandler = (data: any) => void | Promise<void>;
4
- declare class PubSub {
5
- private channels;
6
- private maxListeners;
7
- constructor(maxListeners?: number);
8
- subscribe(channel: string, handler: EventHandler): () => void;
9
- publish(channel: string, data: any): void;
10
- hasSubscribers(channel: string): boolean;
11
- getSubscriberCount(channel: string): number;
12
- getChannels(): string[];
13
- clear(): void;
14
- }
15
- interface KyroEvent {
16
- type: 'create' | 'update' | 'delete';
17
- collection: string;
18
- doc?: any;
19
- originalDoc?: any;
20
- id?: string;
21
- tenantID?: string;
22
- timestamp: string;
23
- user?: any;
24
- }
25
- declare class KyroPubSub extends PubSub {
26
- private registry;
27
- constructor(registry: any, maxListeners?: number);
28
- publishCollectionEvent(collection: string, event: KyroEvent): void;
29
- subscribeToCollection(collection: string, handler: EventHandler): () => void;
30
- subscribeToCollectionEvent(collection: string, eventType: 'create' | 'update' | 'delete', handler: EventHandler): () => void;
31
- subscribeToTenant(tenantID: string, handler: EventHandler): () => void;
32
- subscribeToTenantCollection(tenantID: string, collection: string, handler: EventHandler): () => void;
33
- subscribeToAllCollections(handler: EventHandler): () => void;
34
- createAfterChangeHook(collection: string): (args: any) => Promise<void>;
35
- createAfterDeleteHook(collection: string): (args: any) => Promise<void>;
36
- autoRegisterHooks(): void;
37
- }
38
-
39
- interface WSServerOptions {
40
- port?: number;
41
- pubsub: KyroPubSub;
42
- maxConnections?: number;
43
- pingInterval?: number;
44
- requireAuth?: boolean;
45
- verifyToken?: (token: string) => Promise<any>;
46
- }
47
- interface WSSubscription {
48
- channel: string;
49
- unsubscribe: () => void;
50
- }
51
- interface WSClient {
52
- id: string;
53
- ws: WebSocket;
54
- subscriptions: Map<string, WSSubscription>;
55
- authenticated: boolean;
56
- user?: any;
57
- tenantID?: string;
58
- connectedAt: Date;
59
- lastActivity: Date;
60
- }
61
- declare class KyroWSServer {
62
- private wss;
63
- private clients;
64
- private pubsub;
65
- private options;
66
- private pingTimer?;
67
- constructor(options: WSServerOptions);
68
- private setupServer;
69
- private handleMessage;
70
- private handleAuthenticate;
71
- private handleSubscribe;
72
- private handleUnsubscribe;
73
- private handleUnsubscribeAll;
74
- private handleList;
75
- private handleDisconnect;
76
- private sendToClient;
77
- private generateClientId;
78
- private startPingInterval;
79
- broadcast(channel: string, data: any): void;
80
- getConnectedClients(): WSClient[];
81
- getClientCount(): number;
82
- getSubscriptionCount(): number;
83
- close(): Promise<void>;
84
- getServer(): WebSocketServer;
85
- }
86
- declare function createWSServer(options: WSServerOptions): KyroWSServer;
87
-
88
- export { type EventHandler, type KyroEvent, KyroPubSub, KyroWSServer, PubSub, type WSClient, type WSServerOptions, createWSServer };