@dyrected/core 2.5.24 → 2.5.26
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.
- package/dist/__tests__/app.test.d.ts +2 -0
- package/dist/__tests__/app.test.d.ts.map +1 -0
- package/dist/__tests__/app.test.js +27 -0
- package/dist/__tests__/app.test.js.map +1 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +34 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/deleteMany.test.d.ts +2 -0
- package/dist/__tests__/deleteMany.test.d.ts.map +1 -0
- package/dist/__tests__/deleteMany.test.js +75 -0
- package/dist/__tests__/deleteMany.test.js.map +1 -0
- package/dist/__tests__/depth.test.d.ts +2 -0
- package/dist/__tests__/depth.test.d.ts.map +1 -0
- package/dist/__tests__/depth.test.js +81 -0
- package/dist/__tests__/depth.test.js.map +1 -0
- package/dist/__tests__/dynamic-options.test.d.ts +2 -0
- package/dist/__tests__/dynamic-options.test.d.ts.map +1 -0
- package/dist/__tests__/dynamic-options.test.js +132 -0
- package/dist/__tests__/dynamic-options.test.js.map +1 -0
- package/dist/__tests__/field-inference.test-types.d.ts +24 -0
- package/dist/__tests__/field-inference.test-types.d.ts.map +1 -0
- package/dist/__tests__/field-inference.test-types.js +87 -0
- package/dist/__tests__/field-inference.test-types.js.map +1 -0
- package/dist/__tests__/hooks.test.d.ts +2 -0
- package/dist/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/__tests__/hooks.test.js +320 -0
- package/dist/__tests__/hooks.test.js.map +1 -0
- package/dist/__tests__/mocks.d.ts +68 -0
- package/dist/__tests__/mocks.d.ts.map +1 -0
- package/dist/__tests__/mocks.js +151 -0
- package/dist/__tests__/mocks.js.map +1 -0
- package/dist/__tests__/router.test.d.ts +2 -0
- package/dist/__tests__/router.test.d.ts.map +1 -0
- package/dist/__tests__/router.test.js +48 -0
- package/dist/__tests__/router.test.js.map +1 -0
- package/dist/__tests__/where.test.d.ts +2 -0
- package/dist/__tests__/where.test.d.ts.map +1 -0
- package/dist/__tests__/where.test.js +97 -0
- package/dist/__tests__/where.test.js.map +1 -0
- package/dist/app-BOrsS7Tz.d.cts +1771 -0
- package/dist/app-BOrsS7Tz.d.ts +1771 -0
- package/dist/app-BibuoHQG.d.cts +1764 -0
- package/dist/app-BibuoHQG.d.ts +1764 -0
- package/dist/app-aW2FMuYM.d.cts +1759 -0
- package/dist/app-aW2FMuYM.d.ts +1759 -0
- package/dist/app.d.ts +21 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +56 -0
- package/dist/app.js.map +1 -0
- package/dist/auth/jexl.d.ts +10 -0
- package/dist/auth/jexl.d.ts.map +1 -0
- package/dist/auth/jexl.js +22 -0
- package/dist/auth/jexl.js.map +1 -0
- package/dist/auth/password.d.ts +10 -0
- package/dist/auth/password.d.ts.map +1 -0
- package/dist/auth/password.js +28 -0
- package/dist/auth/password.js.map +1 -0
- package/dist/auth/token.d.ts +20 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +40 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/chunk-4EDMZAM5.js +2692 -0
- package/dist/chunk-FDQYPPG3.js +2698 -0
- package/dist/chunk-NKDX67AW.js +2698 -0
- package/dist/chunk-SUGK7UYL.js +311 -0
- package/dist/chunk-ZFAOBRHT.js +2709 -0
- package/dist/controllers/auth.controller.d.ts +125 -0
- package/dist/controllers/auth.controller.d.ts.map +1 -0
- package/dist/controllers/auth.controller.js +323 -0
- package/dist/controllers/auth.controller.js.map +1 -0
- package/dist/controllers/collection.controller.d.ts +88 -0
- package/dist/controllers/collection.controller.d.ts.map +1 -0
- package/dist/controllers/collection.controller.js +554 -0
- package/dist/controllers/collection.controller.js.map +1 -0
- package/dist/controllers/global.controller.d.ts +17 -0
- package/dist/controllers/global.controller.d.ts.map +1 -0
- package/dist/controllers/global.controller.js +116 -0
- package/dist/controllers/global.controller.js.map +1 -0
- package/dist/controllers/media.controller.d.ts +36 -0
- package/dist/controllers/media.controller.d.ts.map +1 -0
- package/dist/controllers/media.controller.js +155 -0
- package/dist/controllers/media.controller.js.map +1 -0
- package/dist/controllers/preview.controller.d.ts +37 -0
- package/dist/controllers/preview.controller.d.ts.map +1 -0
- package/dist/controllers/preview.controller.js +48 -0
- package/dist/controllers/preview.controller.js.map +1 -0
- package/dist/index-Bp7PDOYG.d.cts +1750 -0
- package/dist/index-Bp7PDOYG.d.ts +1750 -0
- package/dist/index-DfAmTZXk.d.cts +1749 -0
- package/dist/index-DfAmTZXk.d.ts +1749 -0
- package/dist/index.cjs +19 -2324
- package/dist/index.d.cts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -0
- package/dist/middleware/auth.d.ts +18 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +45 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/router.d.ts +8 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +463 -0
- package/dist/router.js.map +1 -0
- package/dist/server.cjs +237 -45
- package/dist/server.d.cts +22 -4
- package/dist/server.d.ts +22 -4
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2429 -8
- package/dist/server.js.map +1 -0
- package/dist/services/audit.service.d.ts +23 -0
- package/dist/services/audit.service.d.ts.map +1 -0
- package/dist/services/audit.service.js +28 -0
- package/dist/services/audit.service.js.map +1 -0
- package/dist/services/defaults.service.d.ts +8 -0
- package/dist/services/defaults.service.d.ts.map +1 -0
- package/dist/services/defaults.service.js +55 -0
- package/dist/services/defaults.service.js.map +1 -0
- package/dist/services/email.service.d.ts +33 -0
- package/dist/services/email.service.d.ts.map +1 -0
- package/dist/services/email.service.js +219 -0
- package/dist/services/email.service.js.map +1 -0
- package/dist/services/media.service.d.ts +20 -0
- package/dist/services/media.service.d.ts.map +1 -0
- package/dist/services/media.service.js +49 -0
- package/dist/services/media.service.js.map +1 -0
- package/dist/services/population.service.d.ts +20 -0
- package/dist/services/population.service.d.ts.map +1 -0
- package/dist/services/population.service.js +168 -0
- package/dist/services/population.service.js.map +1 -0
- package/dist/types/index.d.ts +1749 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +153 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/hooks.d.ts +41 -0
- package/dist/utils/hooks.d.ts.map +1 -0
- package/dist/utils/hooks.js +169 -0
- package/dist/utils/hooks.js.map +1 -0
- package/dist/utils/openapi.d.ts +6 -0
- package/dist/utils/openapi.d.ts.map +1 -0
- package/dist/utils/openapi.js +331 -0
- package/dist/utils/openapi.js.map +1 -0
- package/dist/utils/parse-where.d.ts +63 -0
- package/dist/utils/parse-where.d.ts.map +1 -0
- package/dist/utils/parse-where.js +196 -0
- package/dist/utils/parse-where.js.map +1 -0
- package/dist/utils/readonly-db.d.ts +9 -0
- package/dist/utils/readonly-db.d.ts.map +1 -0
- package/dist/utils/readonly-db.js +21 -0
- package/dist/utils/readonly-db.js.map +1 -0
- package/dist/utils/setup-prompt.d.ts +11 -0
- package/dist/utils/setup-prompt.d.ts.map +1 -0
- package/dist/utils/setup-prompt.js +863 -0
- package/dist/utils/setup-prompt.js.map +1 -0
- package/dist/utils/swagger.d.ts +5 -0
- package/dist/utils/swagger.d.ts.map +1 -0
- package/dist/utils/swagger.js +51 -0
- package/dist/utils/swagger.js.map +1 -0
- package/dist/utils/where-sanitizer.d.ts +10 -0
- package/dist/utils/where-sanitizer.d.ts.map +1 -0
- package/dist/utils/where-sanitizer.js +63 -0
- package/dist/utils/where-sanitizer.js.map +1 -0
- package/dist/where-sanitizer-DQIWTQZW.js +50 -0
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { D as DyrectedConfig, F as Field, C as CollectionConfig, P as Prettify, I as InferDocShape, S as SystemDocFields, A as AuthDocFields, U as UploadDocFields, G as GlobalConfig } from './
|
|
2
|
-
export { a as AccessFunction, b as AdminConfig, c as AuthenticatedUser, B as BaseDocument, d as Block, e as CollectionAfterChangeHook, f as CollectionAfterDeleteHook, g as CollectionAfterReadHook, h as CollectionBeforeChangeHook, i as CollectionBeforeDeleteHook, j as CollectionBeforeReadHook, k as DatabaseAdapter, l as DynamicOptionItem, m as DynamicOptionsConfig, n as DynamicOptionsResolver, o as DynamicOptionsResolverArgs, p as
|
|
3
|
-
import 'hono/types';
|
|
4
|
-
import 'hono';
|
|
1
|
+
import { D as DyrectedConfig, F as Field, C as CollectionConfig, P as Prettify, I as InferDocShape, S as SystemDocFields, A as AuthDocFields, U as UploadDocFields, G as GlobalConfig } from './index-Bp7PDOYG.cjs';
|
|
2
|
+
export { a as AccessFunction, b as AdminConfig, c as AuthenticatedUser, B as BaseDocument, d as Block, e as CollectionAfterChangeHook, f as CollectionAfterDeleteHook, g as CollectionAfterReadHook, h as CollectionBeforeChangeHook, i as CollectionBeforeDeleteHook, j as CollectionBeforeReadHook, k as DatabaseAdapter, l as DynamicOptionItem, m as DynamicOptionsConfig, n as DynamicOptionsResolver, o as DynamicOptionsResolverArgs, p as FieldAfterReadHook, q as FieldBeforeChangeHook, r as FieldHook, s as FieldType, t as FileData, u as GlobalAfterChangeHook, v as GlobalAfterReadHook, w as GlobalBeforeChangeHook, x as GlobalBeforeReadHook, H as HookFunction, y as HookRequestContext, z as ImageService, E as PaginatedResult, R as ReadonlyDatabaseAdapter, J as StorageAdapter, K as UploadConfig } from './index-Bp7PDOYG.cjs';
|
|
5
3
|
|
|
6
4
|
interface SetupPromptConfig {
|
|
7
5
|
siteName?: string;
|
|
@@ -102,6 +100,7 @@ declare function runCollectionHooks(hooks: AnyHookFn[] | undefined, args: {
|
|
|
102
100
|
doc?: unknown;
|
|
103
101
|
user?: unknown;
|
|
104
102
|
req?: unknown;
|
|
103
|
+
db?: unknown;
|
|
105
104
|
operation?: "create" | "update" | "delete";
|
|
106
105
|
[key: string]: unknown;
|
|
107
106
|
}, options?: {
|
|
@@ -113,14 +112,14 @@ declare function runCollectionHooks(hooks: AnyHookFn[] | undefined, args: {
|
|
|
113
112
|
* Traverses `array`, `object`, and `blocks` fields depth-first so that nested
|
|
114
113
|
* field hooks fire on every item automatically.
|
|
115
114
|
*/
|
|
116
|
-
declare function executeFieldBeforeChange(fields: Field[], data: Record<string, unknown>, originalDoc: Record<string, unknown> | null, user: unknown): Promise<Record<string, unknown>>;
|
|
115
|
+
declare function executeFieldBeforeChange(fields: Field[], data: Record<string, unknown>, originalDoc: Record<string, unknown> | null, user: unknown, db?: unknown): Promise<Record<string, unknown>>;
|
|
117
116
|
/**
|
|
118
117
|
* Execute field-level `afterRead` hooks recursively on a document.
|
|
119
118
|
*
|
|
120
119
|
* Traverses `array`, `object`, and `blocks` fields depth-first so that nested
|
|
121
120
|
* field hooks fire on every item automatically.
|
|
122
121
|
*/
|
|
123
|
-
declare function executeFieldAfterRead(fields: Field[], doc: Record<string, unknown>, user: unknown): Promise<Record<string, unknown>>;
|
|
122
|
+
declare function executeFieldAfterRead(fields: Field[], doc: Record<string, unknown>, user: unknown, db?: unknown): Promise<Record<string, unknown>>;
|
|
124
123
|
|
|
125
124
|
/**
|
|
126
125
|
* Define a collection. When called without an explicit type argument, TypeScript
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { D as DyrectedConfig, F as Field, C as CollectionConfig, P as Prettify, I as InferDocShape, S as SystemDocFields, A as AuthDocFields, U as UploadDocFields, G as GlobalConfig } from './
|
|
2
|
-
export { a as AccessFunction, b as AdminConfig, c as AuthenticatedUser, B as BaseDocument, d as Block, e as CollectionAfterChangeHook, f as CollectionAfterDeleteHook, g as CollectionAfterReadHook, h as CollectionBeforeChangeHook, i as CollectionBeforeDeleteHook, j as CollectionBeforeReadHook, k as DatabaseAdapter, l as DynamicOptionItem, m as DynamicOptionsConfig, n as DynamicOptionsResolver, o as DynamicOptionsResolverArgs, p as
|
|
3
|
-
import 'hono/types';
|
|
4
|
-
import 'hono';
|
|
1
|
+
import { D as DyrectedConfig, F as Field, C as CollectionConfig, P as Prettify, I as InferDocShape, S as SystemDocFields, A as AuthDocFields, U as UploadDocFields, G as GlobalConfig } from './index-Bp7PDOYG.js';
|
|
2
|
+
export { a as AccessFunction, b as AdminConfig, c as AuthenticatedUser, B as BaseDocument, d as Block, e as CollectionAfterChangeHook, f as CollectionAfterDeleteHook, g as CollectionAfterReadHook, h as CollectionBeforeChangeHook, i as CollectionBeforeDeleteHook, j as CollectionBeforeReadHook, k as DatabaseAdapter, l as DynamicOptionItem, m as DynamicOptionsConfig, n as DynamicOptionsResolver, o as DynamicOptionsResolverArgs, p as FieldAfterReadHook, q as FieldBeforeChangeHook, r as FieldHook, s as FieldType, t as FileData, u as GlobalAfterChangeHook, v as GlobalAfterReadHook, w as GlobalBeforeChangeHook, x as GlobalBeforeReadHook, H as HookFunction, y as HookRequestContext, z as ImageService, E as PaginatedResult, R as ReadonlyDatabaseAdapter, J as StorageAdapter, K as UploadConfig } from './index-Bp7PDOYG.js';
|
|
5
3
|
|
|
6
4
|
interface SetupPromptConfig {
|
|
7
5
|
siteName?: string;
|
|
@@ -102,6 +100,7 @@ declare function runCollectionHooks(hooks: AnyHookFn[] | undefined, args: {
|
|
|
102
100
|
doc?: unknown;
|
|
103
101
|
user?: unknown;
|
|
104
102
|
req?: unknown;
|
|
103
|
+
db?: unknown;
|
|
105
104
|
operation?: "create" | "update" | "delete";
|
|
106
105
|
[key: string]: unknown;
|
|
107
106
|
}, options?: {
|
|
@@ -113,14 +112,14 @@ declare function runCollectionHooks(hooks: AnyHookFn[] | undefined, args: {
|
|
|
113
112
|
* Traverses `array`, `object`, and `blocks` fields depth-first so that nested
|
|
114
113
|
* field hooks fire on every item automatically.
|
|
115
114
|
*/
|
|
116
|
-
declare function executeFieldBeforeChange(fields: Field[], data: Record<string, unknown>, originalDoc: Record<string, unknown> | null, user: unknown): Promise<Record<string, unknown>>;
|
|
115
|
+
declare function executeFieldBeforeChange(fields: Field[], data: Record<string, unknown>, originalDoc: Record<string, unknown> | null, user: unknown, db?: unknown): Promise<Record<string, unknown>>;
|
|
117
116
|
/**
|
|
118
117
|
* Execute field-level `afterRead` hooks recursively on a document.
|
|
119
118
|
*
|
|
120
119
|
* Traverses `array`, `object`, and `blocks` fields depth-first so that nested
|
|
121
120
|
* field hooks fire on every item automatically.
|
|
122
121
|
*/
|
|
123
|
-
declare function executeFieldAfterRead(fields: Field[], doc: Record<string, unknown>, user: unknown): Promise<Record<string, unknown>>;
|
|
122
|
+
declare function executeFieldAfterRead(fields: Field[], doc: Record<string, unknown>, user: unknown, db?: unknown): Promise<Record<string, unknown>>;
|
|
124
123
|
|
|
125
124
|
/**
|
|
126
125
|
* Define a collection. When called without an explicit type argument, TypeScript
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExK;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,OAAO,SAAS,KAAK,EAAE,EAC5D,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,aAAa,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GACvK,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,aAAa,CAAC,CAAC,CAAC;AAEzG,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,OAAO,SAAS,KAAK,EAAE,EAC5D,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,eAAe,CAAC,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,IAAI,CAAA;CAAE,GAC7K,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC;AAE3G,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,OAAO,SAAS,KAAK,EAAE,EAC5D,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAClI,gBAAgB,CAAC,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;AAEzF,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAC7B,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAM1B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,wBAAgB,YAAY,CAAC,KAAK,CAAC,OAAO,SAAS,KAAK,EAAE,EACxD,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAC3F,YAAY,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAElD,wBAAgB,YAAY,CAAC,IAAI,SAAS,MAAM,EAC9C,MAAM,EAAE,YAAY,CAAC,IAAI,CAAC,GACzB,YAAY,CAAC,IAAI,CAAC,CAAC;AAMtB;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAEnE;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
createDyrectedApp,
|
|
3
2
|
executeFieldAfterRead,
|
|
4
3
|
executeFieldBeforeChange,
|
|
5
4
|
normalizeConfig,
|
|
6
5
|
runCollectionHooks
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SUGK7UYL.js";
|
|
8
7
|
|
|
9
8
|
// src/utils/setup-prompt.ts
|
|
10
9
|
function buildEnvironmentSection(frameworkLabel, isSelfHosted, config) {
|
|
@@ -855,10 +854,10 @@ function parseSqlWhere(where, getJsonField, placeholder = "?") {
|
|
|
855
854
|
function buildSingleOp(c, op, operand) {
|
|
856
855
|
switch (op) {
|
|
857
856
|
case "equals":
|
|
858
|
-
params.push(operand);
|
|
857
|
+
params.push(typeof operand === "boolean" ? String(operand) : operand);
|
|
859
858
|
return `${c} = ${next()}`;
|
|
860
859
|
case "not_equals":
|
|
861
|
-
params.push(operand);
|
|
860
|
+
params.push(typeof operand === "boolean" ? String(operand) : operand);
|
|
862
861
|
return `${c} != ${next()}`;
|
|
863
862
|
case "in": {
|
|
864
863
|
const vals = Array.isArray(operand) ? operand : [operand];
|
|
@@ -995,7 +994,6 @@ function defineConfig(config) {
|
|
|
995
994
|
return config;
|
|
996
995
|
}
|
|
997
996
|
export {
|
|
998
|
-
createDyrectedApp,
|
|
999
997
|
defineCollection,
|
|
1000
998
|
defineConfig,
|
|
1001
999
|
defineGlobal,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+CA,iBAAiB;AACjB,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,OAAO,MAAM,CAAC;AAChB,CAAC;AAmCD,iBAAiB;AACjB,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,MAAsB;IACjD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Context, Next } from 'hono';
|
|
2
|
+
import type { DyrectedContext } from '../app.js';
|
|
3
|
+
/**
|
|
4
|
+
* Middleware that requires a valid Bearer JWT.
|
|
5
|
+
* On success: sets `c.get('user')` to the decoded token payload.
|
|
6
|
+
* On failure: returns 401.
|
|
7
|
+
*/
|
|
8
|
+
export declare function requireAuth(): (c: Context<DyrectedContext>, next: Next) => Promise<(Response & import("hono").TypedResponse<{
|
|
9
|
+
error: true;
|
|
10
|
+
message: string;
|
|
11
|
+
}, 401, "json">) | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Middleware that optionally decodes a Bearer JWT.
|
|
14
|
+
* Does NOT block the request if the token is missing or invalid — it just won't set `user`.
|
|
15
|
+
* Use this for routes that behave differently when authenticated.
|
|
16
|
+
*/
|
|
17
|
+
export declare function optionalAuth(): (c: Context<DyrectedContext>, next: Next) => Promise<void>;
|
|
18
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAGjD;;;;GAIG;AACH,wBAAgB,WAAW,KACX,GAAG,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,IAAI;;;8BAgBtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,KACZ,GAAG,OAAO,CAAC,eAAe,CAAC,EAAE,MAAM,IAAI,mBAetD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { verifyCollectionToken } from '../auth/token.js';
|
|
2
|
+
/**
|
|
3
|
+
* Middleware that requires a valid Bearer JWT.
|
|
4
|
+
* On success: sets `c.get('user')` to the decoded token payload.
|
|
5
|
+
* On failure: returns 401.
|
|
6
|
+
*/
|
|
7
|
+
export function requireAuth() {
|
|
8
|
+
return async (c, next) => {
|
|
9
|
+
const authHeader = c.req.header('Authorization');
|
|
10
|
+
const token = authHeader?.replace(/^Bearer\s+/i, '');
|
|
11
|
+
if (!token) {
|
|
12
|
+
return c.json({ error: true, message: 'Authentication required.' }, 401);
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const user = await verifyCollectionToken(token);
|
|
16
|
+
c.set('user', user);
|
|
17
|
+
await next();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return c.json({ error: true, message: 'Invalid or expired token.' }, 401);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Middleware that optionally decodes a Bearer JWT.
|
|
26
|
+
* Does NOT block the request if the token is missing or invalid — it just won't set `user`.
|
|
27
|
+
* Use this for routes that behave differently when authenticated.
|
|
28
|
+
*/
|
|
29
|
+
export function optionalAuth() {
|
|
30
|
+
return async (c, next) => {
|
|
31
|
+
const authHeader = c.req.header('Authorization');
|
|
32
|
+
const token = authHeader?.replace(/^Bearer\s+/i, '');
|
|
33
|
+
if (token) {
|
|
34
|
+
try {
|
|
35
|
+
const user = await verifyCollectionToken(token);
|
|
36
|
+
c.set('user', user);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Invalid token — proceed without user
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
await next();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,EAAE,CAA2B,EAAE,IAAU,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAErD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,0BAA0B,EAAE,EAAE,GAAG,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACpB,MAAM,IAAI,EAAE,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,2BAA2B,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,KAAK,EAAE,CAA2B,EAAE,IAAU,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAErD,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,MAAM,qBAAqB,CAAC,KAAK,CAAC,CAAC;gBAChD,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACtB,CAAC;YAAC,MAAM,CAAC;gBACP,uCAAuC;YACzC,CAAC;QACH,CAAC;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/router.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { DyrectedContext } from "./app.js";
|
|
3
|
+
import type { DyrectedConfig } from "./types/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Register dynamic routes based on the provided configuration.
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerRoutes(app: Hono<DyrectedContext>, config: DyrectedConfig): void;
|
|
8
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAiFvD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,cAAc,QAsZhF"}
|