@dyrected/core 0.0.1 → 1.0.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.
@@ -0,0 +1,243 @@
1
+ import * as hono_types from 'hono/types';
2
+ import * as hono from 'hono';
3
+ import { Hono, Context } from 'hono';
4
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-RylhgOwj.cjs';
5
+ import * as hono_utils_http_status from 'hono/utils/http-status';
6
+ import * as hono_utils_types from 'hono/utils/types';
7
+
8
+ interface DyrectedContext {
9
+ Variables: {
10
+ config: DyrectedConfig;
11
+ siteId?: string;
12
+ workspaceId?: string;
13
+ /** Decoded JWT payload set by requireAuth() or optionalAuth() middleware. */
14
+ user?: {
15
+ sub: string;
16
+ email: string;
17
+ collection: string;
18
+ [key: string]: any;
19
+ };
20
+ };
21
+ }
22
+ /**
23
+ * Create the main Dyrected Hono application.
24
+ */
25
+ declare function createDyrectedApp(rawConfig: DyrectedConfig): Promise<Hono<DyrectedContext, hono_types.BlankSchema, "/">>;
26
+
27
+ /**
28
+ * Register dynamic routes based on the provided configuration.
29
+ */
30
+ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConfig): void;
31
+
32
+ /**
33
+ * Handles auth endpoints for collections with `auth: true`.
34
+ *
35
+ * Routes registered (relative to `/api/collections/:slug`):
36
+ * POST /login
37
+ * POST /logout (stateless — client drops the token)
38
+ * GET /me
39
+ * POST /refresh-token
40
+ * POST /forgot-password
41
+ * POST /reset-password
42
+ * POST /invite
43
+ * POST /accept-invite
44
+ */
45
+ declare class AuthController {
46
+ private collection;
47
+ constructor(collection: CollectionConfig);
48
+ init(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
49
+ message: string;
50
+ }, 500, "json">) | (Response & hono.TypedResponse<{
51
+ initialized: boolean;
52
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
53
+ registerFirstUser(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
54
+ message: string;
55
+ }, 500, "json">) | (Response & hono.TypedResponse<{
56
+ error: true;
57
+ message: string;
58
+ }, 403, "json">) | (Response & hono.TypedResponse<{
59
+ error: true;
60
+ message: string;
61
+ }, 400, "json">) | (Response & hono.TypedResponse<{
62
+ token: string;
63
+ user: any;
64
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
65
+ login(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
66
+ message: string;
67
+ }, 500, "json">) | (Response & hono.TypedResponse<{
68
+ error: true;
69
+ message: string;
70
+ }, 400, "json">) | (Response & hono.TypedResponse<{
71
+ error: true;
72
+ message: string;
73
+ }, 401, "json">) | (Response & hono.TypedResponse<{
74
+ token: string;
75
+ user: any;
76
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
77
+ logout(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
78
+ success: true;
79
+ message: string;
80
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
81
+ me(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
82
+ refreshToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
83
+ error: true;
84
+ message: string;
85
+ }, 401, "json">) | (Response & hono.TypedResponse<{
86
+ token: string;
87
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
88
+ forgotPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
89
+ message: string;
90
+ }, 500, "json">) | (Response & hono.TypedResponse<{
91
+ error: true;
92
+ message: string;
93
+ }, 400, "json">) | (Response & hono.TypedResponse<{
94
+ success: true;
95
+ message: string;
96
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
97
+ resetPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
98
+ message: string;
99
+ }, 500, "json">) | (Response & hono.TypedResponse<{
100
+ error: true;
101
+ message: string;
102
+ }, 400, "json">) | (Response & hono.TypedResponse<{
103
+ success: true;
104
+ message: string;
105
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
106
+ invite(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
107
+ message: string;
108
+ }, 500, "json">) | (Response & hono.TypedResponse<{
109
+ error: true;
110
+ message: string;
111
+ }, 401, "json">) | (Response & hono.TypedResponse<{
112
+ error: true;
113
+ message: string;
114
+ }, 400, "json">) | (Response & hono.TypedResponse<{
115
+ error: true;
116
+ message: string;
117
+ }, 409, "json">) | (Response & hono.TypedResponse<{
118
+ success: true;
119
+ message: string;
120
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
121
+ acceptInvite(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
122
+ message: string;
123
+ }, 500, "json">) | (Response & hono.TypedResponse<{
124
+ error: true;
125
+ message: string;
126
+ }, 400, "json">) | (Response & hono.TypedResponse<{
127
+ error: true;
128
+ message: string;
129
+ }, 409, "json">) | (Response & hono.TypedResponse<{
130
+ token: string;
131
+ user: any;
132
+ }, 201, "json">)>;
133
+ }
134
+
135
+ declare class CollectionController {
136
+ private collection;
137
+ constructor(collection: CollectionConfig);
138
+ find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
139
+ message: string;
140
+ }, 500, "json">) | (Response & hono.TypedResponse<{
141
+ docs: any[];
142
+ total: number;
143
+ limit: number;
144
+ page: number;
145
+ totalPages: number;
146
+ hasNextPage: boolean;
147
+ hasPrevPage: boolean;
148
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
149
+ findOne(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
150
+ create(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
151
+ message: string;
152
+ }, 500, "json">) | (Response & hono.TypedResponse<{
153
+ message: string;
154
+ }, 400, "json">) | (Response & hono.TypedResponse<any, 201, "json">)>;
155
+ upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
156
+ message: string;
157
+ }, 500, "json">) | (Response & hono.TypedResponse<{
158
+ message: string;
159
+ }, 400, "json">) | (Response & hono.TypedResponse<any, 201, "json">)>;
160
+ update(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
161
+ delete(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
162
+ message: string;
163
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
164
+ seed(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
165
+ message: string;
166
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
167
+ }
168
+
169
+ declare class GlobalController {
170
+ private global;
171
+ constructor(global: GlobalConfig);
172
+ get(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
173
+ update(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
174
+ seed(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
175
+ message: string;
176
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
177
+ }
178
+
179
+ declare class MediaController {
180
+ private collection;
181
+ constructor(collection?: string);
182
+ upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<any, 201, "json">) | (Response & hono.TypedResponse<{
183
+ message: string;
184
+ }, 500, "json">) | (Response & hono.TypedResponse<{
185
+ message: string;
186
+ }, 400, "json">)>;
187
+ find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
188
+ docs: any[];
189
+ total: number;
190
+ limit: number;
191
+ page: number;
192
+ totalPages: number;
193
+ hasNextPage: boolean;
194
+ hasPrevPage: boolean;
195
+ }, hono_utils_http_status.ContentfulStatusCode, "json">) | (Response & hono.TypedResponse<{
196
+ message: string;
197
+ }, 500, "json">)>;
198
+ delete(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
199
+ message: string;
200
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
201
+ serve(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
202
+ message: string;
203
+ }, 404, "json">) | (Response & hono.TypedResponse<{
204
+ message: string;
205
+ }, 400, "json">) | (Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "body">)>;
206
+ }
207
+
208
+ declare class PreviewController {
209
+ private getSecret;
210
+ /**
211
+ * POST /api/preview-token
212
+ * Generates a short-lived token for previewing unsaved data.
213
+ */
214
+ createToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
215
+ error: true;
216
+ message: string;
217
+ }, 400, "json">) | (Response & hono.TypedResponse<{
218
+ token: string;
219
+ expiresAt: string;
220
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
221
+ /**
222
+ * GET /api/preview-data?token=<jwt>
223
+ * Returns the data stored in the preview token.
224
+ */
225
+ getData(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
226
+ error: true;
227
+ message: string;
228
+ }, 400, "json">) | (Response & hono.TypedResponse<{
229
+ [x: string]: hono_utils_types.JSONValue;
230
+ iss?: string | undefined;
231
+ sub?: string | undefined;
232
+ aud?: string | string[] | undefined;
233
+ jti?: string | undefined;
234
+ nbf?: number | undefined;
235
+ exp?: number | undefined;
236
+ iat?: number | undefined;
237
+ }, hono_utils_http_status.ContentfulStatusCode, "json">) | (Response & hono.TypedResponse<{
238
+ error: true;
239
+ message: string;
240
+ }, 401, "json">)>;
241
+ }
242
+
243
+ export { AuthController, CollectionController, type DyrectedContext, GlobalController, MediaController, PreviewController, createDyrectedApp, registerRoutes };
@@ -0,0 +1,243 @@
1
+ import * as hono_types from 'hono/types';
2
+ import * as hono from 'hono';
3
+ import { Hono, Context } from 'hono';
4
+ import { D as DyrectedConfig, C as CollectionConfig, G as GlobalConfig } from './index-RylhgOwj.js';
5
+ import * as hono_utils_http_status from 'hono/utils/http-status';
6
+ import * as hono_utils_types from 'hono/utils/types';
7
+
8
+ interface DyrectedContext {
9
+ Variables: {
10
+ config: DyrectedConfig;
11
+ siteId?: string;
12
+ workspaceId?: string;
13
+ /** Decoded JWT payload set by requireAuth() or optionalAuth() middleware. */
14
+ user?: {
15
+ sub: string;
16
+ email: string;
17
+ collection: string;
18
+ [key: string]: any;
19
+ };
20
+ };
21
+ }
22
+ /**
23
+ * Create the main Dyrected Hono application.
24
+ */
25
+ declare function createDyrectedApp(rawConfig: DyrectedConfig): Promise<Hono<DyrectedContext, hono_types.BlankSchema, "/">>;
26
+
27
+ /**
28
+ * Register dynamic routes based on the provided configuration.
29
+ */
30
+ declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConfig): void;
31
+
32
+ /**
33
+ * Handles auth endpoints for collections with `auth: true`.
34
+ *
35
+ * Routes registered (relative to `/api/collections/:slug`):
36
+ * POST /login
37
+ * POST /logout (stateless — client drops the token)
38
+ * GET /me
39
+ * POST /refresh-token
40
+ * POST /forgot-password
41
+ * POST /reset-password
42
+ * POST /invite
43
+ * POST /accept-invite
44
+ */
45
+ declare class AuthController {
46
+ private collection;
47
+ constructor(collection: CollectionConfig);
48
+ init(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
49
+ message: string;
50
+ }, 500, "json">) | (Response & hono.TypedResponse<{
51
+ initialized: boolean;
52
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
53
+ registerFirstUser(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
54
+ message: string;
55
+ }, 500, "json">) | (Response & hono.TypedResponse<{
56
+ error: true;
57
+ message: string;
58
+ }, 403, "json">) | (Response & hono.TypedResponse<{
59
+ error: true;
60
+ message: string;
61
+ }, 400, "json">) | (Response & hono.TypedResponse<{
62
+ token: string;
63
+ user: any;
64
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
65
+ login(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
66
+ message: string;
67
+ }, 500, "json">) | (Response & hono.TypedResponse<{
68
+ error: true;
69
+ message: string;
70
+ }, 400, "json">) | (Response & hono.TypedResponse<{
71
+ error: true;
72
+ message: string;
73
+ }, 401, "json">) | (Response & hono.TypedResponse<{
74
+ token: string;
75
+ user: any;
76
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
77
+ logout(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
78
+ success: true;
79
+ message: string;
80
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
81
+ me(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
82
+ refreshToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
83
+ error: true;
84
+ message: string;
85
+ }, 401, "json">) | (Response & hono.TypedResponse<{
86
+ token: string;
87
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
88
+ forgotPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
89
+ message: string;
90
+ }, 500, "json">) | (Response & hono.TypedResponse<{
91
+ error: true;
92
+ message: string;
93
+ }, 400, "json">) | (Response & hono.TypedResponse<{
94
+ success: true;
95
+ message: string;
96
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
97
+ resetPassword(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
98
+ message: string;
99
+ }, 500, "json">) | (Response & hono.TypedResponse<{
100
+ error: true;
101
+ message: string;
102
+ }, 400, "json">) | (Response & hono.TypedResponse<{
103
+ success: true;
104
+ message: string;
105
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
106
+ invite(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
107
+ message: string;
108
+ }, 500, "json">) | (Response & hono.TypedResponse<{
109
+ error: true;
110
+ message: string;
111
+ }, 401, "json">) | (Response & hono.TypedResponse<{
112
+ error: true;
113
+ message: string;
114
+ }, 400, "json">) | (Response & hono.TypedResponse<{
115
+ error: true;
116
+ message: string;
117
+ }, 409, "json">) | (Response & hono.TypedResponse<{
118
+ success: true;
119
+ message: string;
120
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
121
+ acceptInvite(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
122
+ message: string;
123
+ }, 500, "json">) | (Response & hono.TypedResponse<{
124
+ error: true;
125
+ message: string;
126
+ }, 400, "json">) | (Response & hono.TypedResponse<{
127
+ error: true;
128
+ message: string;
129
+ }, 409, "json">) | (Response & hono.TypedResponse<{
130
+ token: string;
131
+ user: any;
132
+ }, 201, "json">)>;
133
+ }
134
+
135
+ declare class CollectionController {
136
+ private collection;
137
+ constructor(collection: CollectionConfig);
138
+ find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
139
+ message: string;
140
+ }, 500, "json">) | (Response & hono.TypedResponse<{
141
+ docs: any[];
142
+ total: number;
143
+ limit: number;
144
+ page: number;
145
+ totalPages: number;
146
+ hasNextPage: boolean;
147
+ hasPrevPage: boolean;
148
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
149
+ findOne(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
150
+ create(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
151
+ message: string;
152
+ }, 500, "json">) | (Response & hono.TypedResponse<{
153
+ message: string;
154
+ }, 400, "json">) | (Response & hono.TypedResponse<any, 201, "json">)>;
155
+ upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
156
+ message: string;
157
+ }, 500, "json">) | (Response & hono.TypedResponse<{
158
+ message: string;
159
+ }, 400, "json">) | (Response & hono.TypedResponse<any, 201, "json">)>;
160
+ update(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
161
+ delete(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
162
+ message: string;
163
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
164
+ seed(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
165
+ message: string;
166
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
167
+ }
168
+
169
+ declare class GlobalController {
170
+ private global;
171
+ constructor(global: GlobalConfig);
172
+ get(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
173
+ update(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "json">>;
174
+ seed(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
175
+ message: string;
176
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
177
+ }
178
+
179
+ declare class MediaController {
180
+ private collection;
181
+ constructor(collection?: string);
182
+ upload(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<any, 201, "json">) | (Response & hono.TypedResponse<{
183
+ message: string;
184
+ }, 500, "json">) | (Response & hono.TypedResponse<{
185
+ message: string;
186
+ }, 400, "json">)>;
187
+ find(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
188
+ docs: any[];
189
+ total: number;
190
+ limit: number;
191
+ page: number;
192
+ totalPages: number;
193
+ hasNextPage: boolean;
194
+ hasPrevPage: boolean;
195
+ }, hono_utils_http_status.ContentfulStatusCode, "json">) | (Response & hono.TypedResponse<{
196
+ message: string;
197
+ }, 500, "json">)>;
198
+ delete(c: Context<DyrectedContext>): Promise<Response & hono.TypedResponse<{
199
+ message: string;
200
+ }, hono_utils_http_status.ContentfulStatusCode, "json">>;
201
+ serve(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
202
+ message: string;
203
+ }, 404, "json">) | (Response & hono.TypedResponse<{
204
+ message: string;
205
+ }, 400, "json">) | (Response & hono.TypedResponse<any, hono_utils_http_status.ContentfulStatusCode, "body">)>;
206
+ }
207
+
208
+ declare class PreviewController {
209
+ private getSecret;
210
+ /**
211
+ * POST /api/preview-token
212
+ * Generates a short-lived token for previewing unsaved data.
213
+ */
214
+ createToken(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
215
+ error: true;
216
+ message: string;
217
+ }, 400, "json">) | (Response & hono.TypedResponse<{
218
+ token: string;
219
+ expiresAt: string;
220
+ }, hono_utils_http_status.ContentfulStatusCode, "json">)>;
221
+ /**
222
+ * GET /api/preview-data?token=<jwt>
223
+ * Returns the data stored in the preview token.
224
+ */
225
+ getData(c: Context<DyrectedContext>): Promise<(Response & hono.TypedResponse<{
226
+ error: true;
227
+ message: string;
228
+ }, 400, "json">) | (Response & hono.TypedResponse<{
229
+ [x: string]: hono_utils_types.JSONValue;
230
+ iss?: string | undefined;
231
+ sub?: string | undefined;
232
+ aud?: string | string[] | undefined;
233
+ jti?: string | undefined;
234
+ nbf?: number | undefined;
235
+ exp?: number | undefined;
236
+ iat?: number | undefined;
237
+ }, hono_utils_http_status.ContentfulStatusCode, "json">) | (Response & hono.TypedResponse<{
238
+ error: true;
239
+ message: string;
240
+ }, 401, "json">)>;
241
+ }
242
+
243
+ export { AuthController, CollectionController, type DyrectedContext, GlobalController, MediaController, PreviewController, createDyrectedApp, registerRoutes };