semola 0.5.3 → 0.5.4
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/index-BhGNDjPq.d.mts +13 -0
- package/dist/index-DxSbeGP-.d.cts +13 -0
- package/dist/lib/api/index.cjs +522 -4
- package/dist/lib/api/index.d.cts +270 -4
- package/dist/lib/api/index.d.mts +270 -4
- package/dist/lib/api/index.mjs +520 -2
- package/dist/lib/cache/index.d.cts +16 -4
- package/dist/lib/cache/index.d.mts +16 -4
- package/dist/lib/cache/index.mjs +0 -2
- package/dist/lib/cron/index.cjs +734 -12
- package/dist/lib/cron/index.d.cts +145 -3
- package/dist/lib/cron/index.d.mts +145 -3
- package/dist/lib/cron/index.mjs +725 -3
- package/dist/lib/errors/index.d.cts +2 -13
- package/dist/lib/errors/index.d.mts +2 -13
- package/dist/lib/errors/index.mjs +0 -2
- package/dist/lib/i18n/index.d.cts +12 -4
- package/dist/lib/i18n/index.d.mts +12 -4
- package/dist/lib/i18n/index.mjs +0 -2
- package/dist/lib/logging/index.cjs +386 -17
- package/dist/lib/logging/index.d.cts +107 -6
- package/dist/lib/logging/index.d.mts +107 -6
- package/dist/lib/logging/index.mjs +373 -4
- package/dist/lib/policy/index.cjs +206 -20
- package/dist/lib/policy/index.d.cts +61 -5
- package/dist/lib/policy/index.d.mts +61 -5
- package/dist/lib/policy/index.mjs +187 -3
- package/dist/lib/prompts/index.cjs +374 -14
- package/dist/lib/prompts/index.d.cts +69 -4
- package/dist/lib/prompts/index.d.mts +69 -4
- package/dist/lib/prompts/index.mjs +362 -4
- package/dist/lib/pubsub/index.d.cts +9 -4
- package/dist/lib/pubsub/index.d.mts +9 -4
- package/dist/lib/pubsub/index.mjs +0 -2
- package/dist/lib/queue/index.d.cts +48 -6
- package/dist/lib/queue/index.d.mts +48 -6
- package/dist/lib/queue/index.mjs +0 -2
- package/dist/lib/workflow/index.d.cts +82 -4
- package/dist/lib/workflow/index.d.mts +82 -4
- package/dist/lib/workflow/index.mjs +0 -2
- package/package.json +1 -1
- package/dist/api/core/index.cjs +0 -206
- package/dist/api/core/index.d.cts +0 -21
- package/dist/api/core/index.d.cts.map +0 -1
- package/dist/api/core/index.d.mts +0 -21
- package/dist/api/core/index.d.mts.map +0 -1
- package/dist/api/core/index.mjs +0 -208
- package/dist/api/core/index.mjs.map +0 -1
- package/dist/api/core/types.d.cts +0 -107
- package/dist/api/core/types.d.cts.map +0 -1
- package/dist/api/core/types.d.mts +0 -107
- package/dist/api/core/types.d.mts.map +0 -1
- package/dist/api/middleware/index.cjs +0 -8
- package/dist/api/middleware/index.d.cts +0 -11
- package/dist/api/middleware/index.d.cts.map +0 -1
- package/dist/api/middleware/index.d.mts +0 -11
- package/dist/api/middleware/index.d.mts.map +0 -1
- package/dist/api/middleware/index.mjs +0 -10
- package/dist/api/middleware/index.mjs.map +0 -1
- package/dist/api/middleware/types.d.cts +0 -16
- package/dist/api/middleware/types.d.cts.map +0 -1
- package/dist/api/middleware/types.d.mts +0 -16
- package/dist/api/middleware/types.d.mts.map +0 -1
- package/dist/api/openapi/index.cjs +0 -254
- package/dist/api/openapi/index.mjs +0 -256
- package/dist/api/openapi/index.mjs.map +0 -1
- package/dist/api/openapi/types.d.cts +0 -60
- package/dist/api/openapi/types.d.cts.map +0 -1
- package/dist/api/openapi/types.d.mts +0 -60
- package/dist/api/openapi/types.d.mts.map +0 -1
- package/dist/api/validation/index.cjs +0 -64
- package/dist/api/validation/index.mjs +0 -61
- package/dist/api/validation/index.mjs.map +0 -1
- package/dist/cache/types.d.cts +0 -17
- package/dist/cache/types.d.cts.map +0 -1
- package/dist/cache/types.d.mts +0 -17
- package/dist/cache/types.d.mts.map +0 -1
- package/dist/cron/builder/index.cjs +0 -166
- package/dist/cron/builder/index.d.cts +0 -28
- package/dist/cron/builder/index.d.cts.map +0 -1
- package/dist/cron/builder/index.d.mts +0 -28
- package/dist/cron/builder/index.d.mts.map +0 -1
- package/dist/cron/builder/index.mjs +0 -163
- package/dist/cron/builder/index.mjs.map +0 -1
- package/dist/cron/builder/types.cjs +0 -27
- package/dist/cron/builder/types.d.cts +0 -79
- package/dist/cron/builder/types.d.cts.map +0 -1
- package/dist/cron/builder/types.d.mts +0 -79
- package/dist/cron/builder/types.d.mts.map +0 -1
- package/dist/cron/builder/types.mjs +0 -28
- package/dist/cron/builder/types.mjs.map +0 -1
- package/dist/cron/core/index.cjs +0 -308
- package/dist/cron/core/index.d.cts +0 -39
- package/dist/cron/core/index.d.cts.map +0 -1
- package/dist/cron/core/index.d.mts +0 -39
- package/dist/cron/core/index.d.mts.map +0 -1
- package/dist/cron/core/index.mjs +0 -310
- package/dist/cron/core/index.mjs.map +0 -1
- package/dist/cron/core/scanner.cjs +0 -237
- package/dist/cron/core/scanner.mjs +0 -238
- package/dist/cron/core/scanner.mjs.map +0 -1
- package/dist/cron/core/types.d.cts +0 -11
- package/dist/cron/core/types.d.cts.map +0 -1
- package/dist/cron/core/types.d.mts +0 -11
- package/dist/cron/core/types.d.mts.map +0 -1
- package/dist/errors/types.d.cts +0 -5
- package/dist/errors/types.d.cts.map +0 -1
- package/dist/errors/types.d.mts +0 -5
- package/dist/errors/types.d.mts.map +0 -1
- package/dist/i18n/types.d.cts +0 -13
- package/dist/i18n/types.d.cts.map +0 -1
- package/dist/i18n/types.d.mts +0 -13
- package/dist/i18n/types.d.mts.map +0 -1
- package/dist/lib/cache/index.d.cts.map +0 -1
- package/dist/lib/cache/index.d.mts.map +0 -1
- package/dist/lib/cache/index.mjs.map +0 -1
- package/dist/lib/errors/index.d.cts.map +0 -1
- package/dist/lib/errors/index.d.mts.map +0 -1
- package/dist/lib/errors/index.mjs.map +0 -1
- package/dist/lib/i18n/index.d.cts.map +0 -1
- package/dist/lib/i18n/index.d.mts.map +0 -1
- package/dist/lib/i18n/index.mjs.map +0 -1
- package/dist/lib/orm/index.cjs +0 -20
- package/dist/lib/orm/index.d.cts +0 -7
- package/dist/lib/orm/index.d.mts +0 -7
- package/dist/lib/orm/index.mjs +0 -6
- package/dist/lib/policy/index.d.cts.map +0 -1
- package/dist/lib/policy/index.d.mts.map +0 -1
- package/dist/lib/policy/index.mjs.map +0 -1
- package/dist/lib/prompts/index.d.cts.map +0 -1
- package/dist/lib/prompts/index.d.mts.map +0 -1
- package/dist/lib/prompts/index.mjs.map +0 -1
- package/dist/lib/pubsub/index.d.cts.map +0 -1
- package/dist/lib/pubsub/index.d.mts.map +0 -1
- package/dist/lib/pubsub/index.mjs.map +0 -1
- package/dist/lib/queue/index.d.cts.map +0 -1
- package/dist/lib/queue/index.d.mts.map +0 -1
- package/dist/lib/queue/index.mjs.map +0 -1
- package/dist/lib/workflow/index.d.cts.map +0 -1
- package/dist/lib/workflow/index.d.mts.map +0 -1
- package/dist/lib/workflow/index.mjs.map +0 -1
- package/dist/logging/core/index.cjs +0 -99
- package/dist/logging/core/index.d.cts +0 -26
- package/dist/logging/core/index.d.cts.map +0 -1
- package/dist/logging/core/index.d.mts +0 -26
- package/dist/logging/core/index.d.mts.map +0 -1
- package/dist/logging/core/index.mjs +0 -99
- package/dist/logging/core/index.mjs.map +0 -1
- package/dist/logging/core/types.cjs +0 -10
- package/dist/logging/core/types.d.cts +0 -22
- package/dist/logging/core/types.d.cts.map +0 -1
- package/dist/logging/core/types.d.mts +0 -22
- package/dist/logging/core/types.d.mts.map +0 -1
- package/dist/logging/core/types.mjs +0 -12
- package/dist/logging/core/types.mjs.map +0 -1
- package/dist/logging/formatter/index.cjs +0 -119
- package/dist/logging/formatter/index.d.cts +0 -27
- package/dist/logging/formatter/index.d.cts.map +0 -1
- package/dist/logging/formatter/index.d.mts +0 -27
- package/dist/logging/formatter/index.d.mts.map +0 -1
- package/dist/logging/formatter/index.mjs +0 -115
- package/dist/logging/formatter/index.mjs.map +0 -1
- package/dist/logging/formatter/types.d.cts +0 -5
- package/dist/logging/formatter/types.d.cts.map +0 -1
- package/dist/logging/formatter/types.d.mts +0 -5
- package/dist/logging/formatter/types.d.mts.map +0 -1
- package/dist/logging/provider/index.cjs +0 -165
- package/dist/logging/provider/index.d.cts +0 -28
- package/dist/logging/provider/index.d.cts.map +0 -1
- package/dist/logging/provider/index.d.mts +0 -28
- package/dist/logging/provider/index.d.mts.map +0 -1
- package/dist/logging/provider/index.mjs +0 -165
- package/dist/logging/provider/index.mjs.map +0 -1
- package/dist/logging/provider/types.d.cts +0 -23
- package/dist/logging/provider/types.d.cts.map +0 -1
- package/dist/logging/provider/types.d.mts +0 -23
- package/dist/logging/provider/types.d.mts.map +0 -1
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts +0 -80
- package/dist/node_modules/@standard-schema/spec/dist/index.d.cts.map +0 -1
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts +0 -80
- package/dist/node_modules/@standard-schema/spec/dist/index.d.mts.map +0 -1
- package/dist/orm/column.cjs +0 -137
- package/dist/orm/column.d.cts +0 -121
- package/dist/orm/column.d.cts.map +0 -1
- package/dist/orm/column.d.mts +0 -121
- package/dist/orm/column.d.mts.map +0 -1
- package/dist/orm/column.mjs +0 -132
- package/dist/orm/column.mjs.map +0 -1
- package/dist/orm/dialect/index.cjs +0 -14
- package/dist/orm/dialect/index.mjs +0 -16
- package/dist/orm/dialect/index.mjs.map +0 -1
- package/dist/orm/dialect/mysql.cjs +0 -31
- package/dist/orm/dialect/mysql.mjs +0 -33
- package/dist/orm/dialect/mysql.mjs.map +0 -1
- package/dist/orm/dialect/postgres.cjs +0 -23
- package/dist/orm/dialect/postgres.mjs +0 -25
- package/dist/orm/dialect/postgres.mjs.map +0 -1
- package/dist/orm/dialect/sqlite.cjs +0 -31
- package/dist/orm/dialect/sqlite.mjs +0 -33
- package/dist/orm/dialect/sqlite.mjs.map +0 -1
- package/dist/orm/dialect/utils.cjs +0 -8
- package/dist/orm/dialect/utils.mjs +0 -10
- package/dist/orm/dialect/utils.mjs.map +0 -1
- package/dist/orm/internal/table-columns.cjs +0 -31
- package/dist/orm/internal/table-columns.mjs +0 -32
- package/dist/orm/internal/table-columns.mjs.map +0 -1
- package/dist/orm/internal/table-lookup.cjs +0 -35
- package/dist/orm/internal/table-lookup.mjs +0 -35
- package/dist/orm/internal/table-lookup.mjs.map +0 -1
- package/dist/orm/internal/table-relations.cjs +0 -28
- package/dist/orm/internal/table-relations.mjs +0 -29
- package/dist/orm/internal/table-relations.mjs.map +0 -1
- package/dist/orm/migration/config.cjs +0 -7
- package/dist/orm/migration/config.d.cts +0 -7
- package/dist/orm/migration/config.d.cts.map +0 -1
- package/dist/orm/migration/config.d.mts +0 -7
- package/dist/orm/migration/config.d.mts.map +0 -1
- package/dist/orm/migration/config.mjs +0 -8
- package/dist/orm/migration/config.mjs.map +0 -1
- package/dist/orm/migration/types.d.cts +0 -20
- package/dist/orm/migration/types.d.cts.map +0 -1
- package/dist/orm/migration/types.d.mts +0 -20
- package/dist/orm/migration/types.d.mts.map +0 -1
- package/dist/orm/orm.cjs +0 -41
- package/dist/orm/orm.d.cts +0 -18
- package/dist/orm/orm.d.cts.map +0 -1
- package/dist/orm/orm.d.mts +0 -18
- package/dist/orm/orm.d.mts.map +0 -1
- package/dist/orm/orm.mjs +0 -43
- package/dist/orm/orm.mjs.map +0 -1
- package/dist/orm/relation.cjs +0 -18
- package/dist/orm/relation.d.cts +0 -8
- package/dist/orm/relation.d.cts.map +0 -1
- package/dist/orm/relation.d.mts +0 -8
- package/dist/orm/relation.d.mts.map +0 -1
- package/dist/orm/relation.mjs +0 -19
- package/dist/orm/relation.mjs.map +0 -1
- package/dist/orm/runtime/builders/mutations.cjs +0 -29
- package/dist/orm/runtime/builders/mutations.mjs +0 -28
- package/dist/orm/runtime/builders/mutations.mjs.map +0 -1
- package/dist/orm/runtime/builders/select.cjs +0 -18
- package/dist/orm/runtime/builders/select.mjs +0 -19
- package/dist/orm/runtime/builders/select.mjs.map +0 -1
- package/dist/orm/runtime/client.cjs +0 -90
- package/dist/orm/runtime/client.mjs +0 -92
- package/dist/orm/runtime/client.mjs.map +0 -1
- package/dist/orm/runtime/context.cjs +0 -49
- package/dist/orm/runtime/context.mjs +0 -51
- package/dist/orm/runtime/context.mjs.map +0 -1
- package/dist/orm/runtime/dialect/index.cjs +0 -11
- package/dist/orm/runtime/dialect/index.mjs +0 -13
- package/dist/orm/runtime/dialect/index.mjs.map +0 -1
- package/dist/orm/runtime/dialect/mysql.cjs +0 -95
- package/dist/orm/runtime/dialect/mysql.mjs +0 -97
- package/dist/orm/runtime/dialect/mysql.mjs.map +0 -1
- package/dist/orm/runtime/dialect/postgres.cjs +0 -51
- package/dist/orm/runtime/dialect/postgres.mjs +0 -53
- package/dist/orm/runtime/dialect/postgres.mjs.map +0 -1
- package/dist/orm/runtime/dialect/sqlite.cjs +0 -4
- package/dist/orm/runtime/dialect/sqlite.mjs +0 -7
- package/dist/orm/runtime/dialect/sqlite.mjs.map +0 -1
- package/dist/orm/runtime/errors.cjs +0 -19
- package/dist/orm/runtime/errors.mjs +0 -21
- package/dist/orm/runtime/errors.mjs.map +0 -1
- package/dist/orm/runtime/hydrate/many.cjs +0 -46
- package/dist/orm/runtime/hydrate/many.mjs +0 -48
- package/dist/orm/runtime/hydrate/many.mjs.map +0 -1
- package/dist/orm/runtime/hydrate/one.cjs +0 -38
- package/dist/orm/runtime/hydrate/one.mjs +0 -40
- package/dist/orm/runtime/hydrate/one.mjs.map +0 -1
- package/dist/orm/runtime/hydrate.cjs +0 -49
- package/dist/orm/runtime/hydrate.mjs +0 -51
- package/dist/orm/runtime/hydrate.mjs.map +0 -1
- package/dist/orm/runtime/rows.cjs +0 -30
- package/dist/orm/runtime/rows.mjs +0 -31
- package/dist/orm/runtime/rows.mjs.map +0 -1
- package/dist/orm/runtime/utils.cjs +0 -27
- package/dist/orm/runtime/utils.mjs +0 -27
- package/dist/orm/runtime/utils.mjs.map +0 -1
- package/dist/orm/sql/parse-array.cjs +0 -64
- package/dist/orm/sql/parse-array.mjs +0 -66
- package/dist/orm/sql/parse-array.mjs.map +0 -1
- package/dist/orm/sql/plan/select.cjs +0 -36
- package/dist/orm/sql/plan/select.mjs +0 -38
- package/dist/orm/sql/plan/select.mjs.map +0 -1
- package/dist/orm/sql/plan/where/operators.cjs +0 -95
- package/dist/orm/sql/plan/where/operators.mjs +0 -97
- package/dist/orm/sql/plan/where/operators.mjs.map +0 -1
- package/dist/orm/sql/plan/where.cjs +0 -59
- package/dist/orm/sql/plan/where.mjs +0 -61
- package/dist/orm/sql/plan/where.mjs.map +0 -1
- package/dist/orm/sql/serialize/clauses.cjs +0 -36
- package/dist/orm/sql/serialize/clauses.mjs +0 -37
- package/dist/orm/sql/serialize/clauses.mjs.map +0 -1
- package/dist/orm/sql/serialize/joins.cjs +0 -31
- package/dist/orm/sql/serialize/joins.mjs +0 -33
- package/dist/orm/sql/serialize/joins.mjs.map +0 -1
- package/dist/orm/sql/serialize/values.cjs +0 -30
- package/dist/orm/sql/serialize/values.mjs +0 -32
- package/dist/orm/sql/serialize/values.mjs.map +0 -1
- package/dist/orm/sql/serialize/where/predicate.cjs +0 -73
- package/dist/orm/sql/serialize/where/predicate.mjs +0 -75
- package/dist/orm/sql/serialize/where/predicate.mjs.map +0 -1
- package/dist/orm/sql/serialize/where/tree.cjs +0 -26
- package/dist/orm/sql/serialize/where/tree.mjs +0 -28
- package/dist/orm/sql/serialize/where/tree.mjs.map +0 -1
- package/dist/orm/sql/serialize/where.cjs +0 -10
- package/dist/orm/sql/serialize/where.mjs +0 -12
- package/dist/orm/sql/serialize/where.mjs.map +0 -1
- package/dist/orm/sql/serialize.cjs +0 -24
- package/dist/orm/sql/serialize.mjs +0 -25
- package/dist/orm/sql/serialize.mjs.map +0 -1
- package/dist/orm/table.cjs +0 -12
- package/dist/orm/table.d.cts +0 -12
- package/dist/orm/table.d.cts.map +0 -1
- package/dist/orm/table.d.mts +0 -12
- package/dist/orm/table.d.mts.map +0 -1
- package/dist/orm/table.mjs +0 -14
- package/dist/orm/table.mjs.map +0 -1
- package/dist/orm/types.d.cts +0 -183
- package/dist/orm/types.d.cts.map +0 -1
- package/dist/orm/types.d.mts +0 -183
- package/dist/orm/types.d.mts.map +0 -1
- package/dist/policy/helpers.cjs +0 -206
- package/dist/policy/helpers.d.cts +0 -50
- package/dist/policy/helpers.d.cts.map +0 -1
- package/dist/policy/helpers.d.mts +0 -50
- package/dist/policy/helpers.d.mts.map +0 -1
- package/dist/policy/helpers.mjs +0 -190
- package/dist/policy/helpers.mjs.map +0 -1
- package/dist/policy/types.d.cts +0 -16
- package/dist/policy/types.d.cts.map +0 -1
- package/dist/policy/types.d.mts +0 -16
- package/dist/policy/types.d.mts.map +0 -1
- package/dist/prompts/core/keys.cjs +0 -165
- package/dist/prompts/core/keys.mjs +0 -167
- package/dist/prompts/core/keys.mjs.map +0 -1
- package/dist/prompts/core/runtime.cjs +0 -104
- package/dist/prompts/core/runtime.mjs +0 -106
- package/dist/prompts/core/runtime.mjs.map +0 -1
- package/dist/prompts/core/session.cjs +0 -98
- package/dist/prompts/core/session.mjs +0 -100
- package/dist/prompts/core/session.mjs.map +0 -1
- package/dist/prompts/core/types.d.cts +0 -21
- package/dist/prompts/core/types.d.cts.map +0 -1
- package/dist/prompts/core/types.d.mts +0 -21
- package/dist/prompts/core/types.d.mts.map +0 -1
- package/dist/prompts/types.d.cts +0 -52
- package/dist/prompts/types.d.cts.map +0 -1
- package/dist/prompts/types.d.mts +0 -52
- package/dist/prompts/types.d.mts.map +0 -1
- package/dist/pubsub/types.d.cts +0 -10
- package/dist/pubsub/types.d.cts.map +0 -1
- package/dist/pubsub/types.d.mts +0 -10
- package/dist/pubsub/types.d.mts.map +0 -1
- package/dist/queue/types.d.cts +0 -47
- package/dist/queue/types.d.cts.map +0 -1
- package/dist/queue/types.d.mts +0 -47
- package/dist/queue/types.d.mts.map +0 -1
- package/dist/workflow/types.d.cts +0 -83
- package/dist/workflow/types.d.cts.map +0 -1
- package/dist/workflow/types.d.mts +0 -83
- package/dist/workflow/types.d.mts.map +0 -1
package/dist/lib/api/index.d.cts
CHANGED
|
@@ -1,5 +1,271 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/lib/api/openapi/types.d.ts
|
|
2
|
+
type OpenApiSpec = {
|
|
3
|
+
openapi: string;
|
|
4
|
+
info: {
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
servers?: Array<{
|
|
10
|
+
url: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}>;
|
|
13
|
+
paths: Record<string, OpenApiPath>;
|
|
14
|
+
components?: {
|
|
15
|
+
schemas?: Record<string, unknown>;
|
|
16
|
+
responses?: Record<string, unknown>;
|
|
17
|
+
parameters?: Record<string, unknown>;
|
|
18
|
+
requestBodies?: Record<string, unknown>;
|
|
19
|
+
securitySchemes?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type OpenApiPath = {
|
|
23
|
+
[method: string]: OpenApiOperation;
|
|
24
|
+
};
|
|
25
|
+
type OpenApiOperation = {
|
|
26
|
+
summary?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
operationId?: string;
|
|
29
|
+
tags?: string[];
|
|
30
|
+
parameters?: OpenApiParameter[];
|
|
31
|
+
requestBody?: OpenApiRequestBody;
|
|
32
|
+
responses: Record<string, OpenApiResponse>;
|
|
33
|
+
security?: Array<Record<string, string[]>>;
|
|
34
|
+
};
|
|
35
|
+
type OpenApiParameter = {
|
|
36
|
+
name: string;
|
|
37
|
+
in: "path" | "query" | "header" | "cookie";
|
|
38
|
+
required?: boolean;
|
|
39
|
+
schema: unknown;
|
|
40
|
+
description?: string;
|
|
41
|
+
};
|
|
42
|
+
type OpenApiRequestBody = {
|
|
43
|
+
required?: boolean;
|
|
44
|
+
content: {
|
|
45
|
+
[mediaType: string]: {
|
|
46
|
+
schema: unknown;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
type OpenApiResponse = {
|
|
51
|
+
description: string;
|
|
52
|
+
content?: {
|
|
53
|
+
[mediaType: string]: {
|
|
54
|
+
schema: unknown;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region node_modules/@standard-schema/spec/dist/index.d.ts
|
|
60
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
61
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
62
|
+
/** The Standard properties. */
|
|
63
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
64
|
+
}
|
|
65
|
+
declare namespace StandardTypedV1 {
|
|
66
|
+
/** The Standard Typed properties interface. */
|
|
67
|
+
interface Props<Input = unknown, Output = Input> {
|
|
68
|
+
/** The version number of the standard. */
|
|
69
|
+
readonly version: 1;
|
|
70
|
+
/** The vendor name of the schema library. */
|
|
71
|
+
readonly vendor: string;
|
|
72
|
+
/** Inferred types associated with the schema. */
|
|
73
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
74
|
+
}
|
|
75
|
+
/** The Standard Typed types interface. */
|
|
76
|
+
interface Types<Input = unknown, Output = Input> {
|
|
77
|
+
/** The input type of the schema. */
|
|
78
|
+
readonly input: Input;
|
|
79
|
+
/** The output type of the schema. */
|
|
80
|
+
readonly output: Output;
|
|
81
|
+
}
|
|
82
|
+
/** Infers the input type of a Standard Typed. */
|
|
83
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
84
|
+
/** Infers the output type of a Standard Typed. */
|
|
85
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
86
|
+
}
|
|
87
|
+
/** The Standard Schema interface. */
|
|
88
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
89
|
+
/** The Standard Schema properties. */
|
|
90
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
91
|
+
}
|
|
92
|
+
declare namespace StandardSchemaV1 {
|
|
93
|
+
/** The Standard Schema properties interface. */
|
|
94
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
95
|
+
/** Validates unknown input values. */
|
|
96
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
97
|
+
}
|
|
98
|
+
/** The result interface of the validate function. */
|
|
99
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
100
|
+
/** The result interface if validation succeeds. */
|
|
101
|
+
interface SuccessResult<Output> {
|
|
102
|
+
/** The typed output value. */
|
|
103
|
+
readonly value: Output;
|
|
104
|
+
/** A falsy value for `issues` indicates success. */
|
|
105
|
+
readonly issues?: undefined;
|
|
106
|
+
}
|
|
107
|
+
interface Options {
|
|
108
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
109
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
110
|
+
}
|
|
111
|
+
/** The result interface if validation fails. */
|
|
112
|
+
interface FailureResult {
|
|
113
|
+
/** The issues of failed validation. */
|
|
114
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
115
|
+
}
|
|
116
|
+
/** The issue interface of the failure output. */
|
|
117
|
+
interface Issue {
|
|
118
|
+
/** The error message of the issue. */
|
|
119
|
+
readonly message: string;
|
|
120
|
+
/** The path of the issue, if any. */
|
|
121
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
122
|
+
}
|
|
123
|
+
/** The path segment interface of the issue. */
|
|
124
|
+
interface PathSegment {
|
|
125
|
+
/** The key representing a path segment. */
|
|
126
|
+
readonly key: PropertyKey;
|
|
127
|
+
}
|
|
128
|
+
/** The Standard types interface. */
|
|
129
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
130
|
+
/** Infers the input type of a Standard. */
|
|
131
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
132
|
+
/** Infers the output type of a Standard. */
|
|
133
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
134
|
+
}
|
|
135
|
+
/** The Standard JSON Schema interface. */
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/lib/api/middleware/types.d.ts
|
|
138
|
+
type MiddlewareHandler<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<never, never>> = (c: Context<TReq, TRes>) => Response | TExt | undefined | Promise<Response | TExt | undefined> | Promise<void> | void;
|
|
139
|
+
type MiddlewareOptions<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = {
|
|
140
|
+
request?: TReq;
|
|
141
|
+
response?: TRes;
|
|
142
|
+
handler: MiddlewareHandler<TReq, TRes, TExt>;
|
|
143
|
+
};
|
|
144
|
+
type InferMiddlewareExtension<T> = T extends {
|
|
145
|
+
options: MiddlewareOptions<infer _TReq, infer _TRes, infer E>;
|
|
146
|
+
} ? E : never;
|
|
147
|
+
type MergeMiddlewareExtensions<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? InferMiddlewareExtension<First> & MergeMiddlewareExtensions<Rest> : {};
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/lib/api/core/types.d.ts
|
|
150
|
+
type ResponseSchema = {
|
|
151
|
+
[status: number]: StandardSchemaV1;
|
|
152
|
+
};
|
|
153
|
+
type RequestSchema = {
|
|
154
|
+
params?: StandardSchemaV1;
|
|
155
|
+
body?: StandardSchemaV1;
|
|
156
|
+
query?: StandardSchemaV1;
|
|
157
|
+
headers?: StandardSchemaV1;
|
|
158
|
+
cookies?: StandardSchemaV1;
|
|
159
|
+
};
|
|
160
|
+
type SafeTypeAccess<T, K extends "input" | "output"> = T extends StandardSchemaV1 ? T["~standard"] extends {
|
|
161
|
+
types?: infer U;
|
|
162
|
+
} ? U extends Record<K, infer V> ? V : never : never : undefined;
|
|
163
|
+
type InferOutput<T extends StandardSchemaV1 | undefined> = SafeTypeAccess<T, "output">;
|
|
164
|
+
type InferInput<T extends StandardSchemaV1 | undefined> = SafeTypeAccess<T, "input">;
|
|
165
|
+
type ExtractStatusCodes<T extends ResponseSchema> = keyof T & number;
|
|
166
|
+
type ExtractStatusCodesOrAny<T extends ResponseSchema | undefined> = T extends ResponseSchema ? ExtractStatusCodes<T> : number;
|
|
167
|
+
type ValidationOptions = boolean | {
|
|
168
|
+
input?: boolean;
|
|
169
|
+
output?: boolean;
|
|
170
|
+
};
|
|
171
|
+
type ApiOptions<TMiddlewares extends readonly Middleware[] = readonly []> = {
|
|
172
|
+
prefix?: string;
|
|
173
|
+
openapi?: OpenApiOptions;
|
|
174
|
+
middlewares?: TMiddlewares;
|
|
175
|
+
validation?: ValidationOptions;
|
|
176
|
+
};
|
|
177
|
+
type SecuritySchemeApiKey = {
|
|
178
|
+
type: "apiKey";
|
|
179
|
+
name: string;
|
|
180
|
+
in: "query" | "header" | "cookie";
|
|
181
|
+
description?: string;
|
|
182
|
+
};
|
|
183
|
+
type SecuritySchemeHttp = {
|
|
184
|
+
type: "http";
|
|
185
|
+
scheme: string;
|
|
186
|
+
bearerFormat?: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
};
|
|
189
|
+
type SecuritySchemeOAuth2Flow = {
|
|
190
|
+
authorizationUrl?: string;
|
|
191
|
+
tokenUrl?: string;
|
|
192
|
+
refreshUrl?: string;
|
|
193
|
+
scopes: Record<string, string>;
|
|
194
|
+
};
|
|
195
|
+
type SecuritySchemeOAuth2 = {
|
|
196
|
+
type: "oauth2";
|
|
197
|
+
flows: {
|
|
198
|
+
implicit?: SecuritySchemeOAuth2Flow;
|
|
199
|
+
password?: SecuritySchemeOAuth2Flow;
|
|
200
|
+
clientCredentials?: SecuritySchemeOAuth2Flow;
|
|
201
|
+
authorizationCode?: SecuritySchemeOAuth2Flow;
|
|
202
|
+
};
|
|
203
|
+
description?: string;
|
|
204
|
+
};
|
|
205
|
+
type SecuritySchemeOpenIdConnect = {
|
|
206
|
+
type: "openIdConnect";
|
|
207
|
+
openIdConnectUrl: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
};
|
|
210
|
+
type SecurityScheme = SecuritySchemeApiKey | SecuritySchemeHttp | SecuritySchemeOAuth2 | SecuritySchemeOpenIdConnect;
|
|
211
|
+
type OpenApiOptions = {
|
|
212
|
+
version: string;
|
|
213
|
+
title: string;
|
|
214
|
+
description?: string;
|
|
215
|
+
servers?: Array<{
|
|
216
|
+
url: string;
|
|
217
|
+
description?: string;
|
|
218
|
+
}>;
|
|
219
|
+
securitySchemes?: Record<string, SecurityScheme>;
|
|
220
|
+
};
|
|
221
|
+
type Context<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = {
|
|
222
|
+
raw: Request;
|
|
223
|
+
req: {
|
|
224
|
+
body: InferOutput<TReq["body"]>;
|
|
225
|
+
query: InferOutput<TReq["query"]>;
|
|
226
|
+
headers: InferOutput<TReq["headers"]>;
|
|
227
|
+
cookies: InferOutput<TReq["cookies"]>;
|
|
228
|
+
params: InferOutput<TReq["params"]>;
|
|
229
|
+
};
|
|
230
|
+
json: <S extends ExtractStatusCodesOrAny<TRes>>(status: S, data: TRes extends ResponseSchema ? InferOutput<TRes[S]> : unknown) => Response;
|
|
231
|
+
text: (status: number, text: string) => Response;
|
|
232
|
+
html: (status: number, html: string) => Response;
|
|
233
|
+
redirect: (status: number, url: string) => Response;
|
|
234
|
+
get: <K extends keyof TExt>(key: K) => TExt[K];
|
|
235
|
+
};
|
|
236
|
+
type RouteHandler<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = (c: Context<TReq, TRes, TExt>) => Response | Promise<Response>;
|
|
237
|
+
type RouteConfig<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TGlobalMiddlewares extends readonly Middleware[] = readonly [], TRouteMiddlewares extends readonly Middleware[] = readonly []> = {
|
|
238
|
+
path: string;
|
|
239
|
+
method: Bun.Serve.HTTPMethod;
|
|
240
|
+
request?: TReq;
|
|
241
|
+
response?: TRes;
|
|
242
|
+
middlewares?: TRouteMiddlewares;
|
|
243
|
+
handler: RouteHandler<TReq, TRes, MergeMiddlewareExtensions<TGlobalMiddlewares> & MergeMiddlewareExtensions<TRouteMiddlewares>>;
|
|
244
|
+
summary?: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
operationId?: string;
|
|
247
|
+
tags?: string[];
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/lib/api/middleware/index.d.ts
|
|
251
|
+
declare class Middleware<TRequest extends RequestSchema = RequestSchema, TResponse extends ResponseSchema = ResponseSchema, TExtension extends Record<string, unknown> = Record<string, unknown>> {
|
|
252
|
+
options: MiddlewareOptions<TRequest, TResponse, TExtension>;
|
|
253
|
+
constructor(options: MiddlewareOptions<TRequest, TResponse, TExtension>);
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/lib/api/core/index.d.ts
|
|
257
|
+
declare class Api<TMiddlewares extends readonly Middleware[] = readonly []> {
|
|
258
|
+
private options;
|
|
259
|
+
private routes;
|
|
260
|
+
constructor(options?: ApiOptions<TMiddlewares>);
|
|
261
|
+
private getFullPath;
|
|
262
|
+
private validateRequestSchema;
|
|
263
|
+
private createContext;
|
|
264
|
+
private validateResponseBody;
|
|
265
|
+
private buildBunRoutes;
|
|
266
|
+
defineRoute<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema = ResponseSchema, TRouteMiddlewares extends readonly Middleware[] = readonly []>(config: RouteConfig<TReq, TRes, TMiddlewares, TRouteMiddlewares>): void;
|
|
267
|
+
getOpenApiSpec(): Promise<OpenApiSpec>;
|
|
268
|
+
serve(port: number, callback?: (server: Bun.Server<unknown>) => void): void;
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
5
271
|
export { Api, type ApiOptions, type Context, type ExtractStatusCodes, type InferInput, type InferMiddlewareExtension, type InferOutput, type MergeMiddlewareExtensions, Middleware, type MiddlewareHandler, type MiddlewareOptions, type OpenApiOptions, type RequestSchema, type ResponseSchema, type RouteConfig, type RouteHandler, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeHttp, type SecuritySchemeOAuth2, type SecuritySchemeOAuth2Flow, type SecuritySchemeOpenIdConnect };
|
package/dist/lib/api/index.d.mts
CHANGED
|
@@ -1,5 +1,271 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
//#region src/lib/api/openapi/types.d.ts
|
|
2
|
+
type OpenApiSpec = {
|
|
3
|
+
openapi: string;
|
|
4
|
+
info: {
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
servers?: Array<{
|
|
10
|
+
url: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}>;
|
|
13
|
+
paths: Record<string, OpenApiPath>;
|
|
14
|
+
components?: {
|
|
15
|
+
schemas?: Record<string, unknown>;
|
|
16
|
+
responses?: Record<string, unknown>;
|
|
17
|
+
parameters?: Record<string, unknown>;
|
|
18
|
+
requestBodies?: Record<string, unknown>;
|
|
19
|
+
securitySchemes?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type OpenApiPath = {
|
|
23
|
+
[method: string]: OpenApiOperation;
|
|
24
|
+
};
|
|
25
|
+
type OpenApiOperation = {
|
|
26
|
+
summary?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
operationId?: string;
|
|
29
|
+
tags?: string[];
|
|
30
|
+
parameters?: OpenApiParameter[];
|
|
31
|
+
requestBody?: OpenApiRequestBody;
|
|
32
|
+
responses: Record<string, OpenApiResponse>;
|
|
33
|
+
security?: Array<Record<string, string[]>>;
|
|
34
|
+
};
|
|
35
|
+
type OpenApiParameter = {
|
|
36
|
+
name: string;
|
|
37
|
+
in: "path" | "query" | "header" | "cookie";
|
|
38
|
+
required?: boolean;
|
|
39
|
+
schema: unknown;
|
|
40
|
+
description?: string;
|
|
41
|
+
};
|
|
42
|
+
type OpenApiRequestBody = {
|
|
43
|
+
required?: boolean;
|
|
44
|
+
content: {
|
|
45
|
+
[mediaType: string]: {
|
|
46
|
+
schema: unknown;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
type OpenApiResponse = {
|
|
51
|
+
description: string;
|
|
52
|
+
content?: {
|
|
53
|
+
[mediaType: string]: {
|
|
54
|
+
schema: unknown;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region node_modules/@standard-schema/spec/dist/index.d.ts
|
|
60
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
61
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
62
|
+
/** The Standard properties. */
|
|
63
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
64
|
+
}
|
|
65
|
+
declare namespace StandardTypedV1 {
|
|
66
|
+
/** The Standard Typed properties interface. */
|
|
67
|
+
interface Props<Input = unknown, Output = Input> {
|
|
68
|
+
/** The version number of the standard. */
|
|
69
|
+
readonly version: 1;
|
|
70
|
+
/** The vendor name of the schema library. */
|
|
71
|
+
readonly vendor: string;
|
|
72
|
+
/** Inferred types associated with the schema. */
|
|
73
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
74
|
+
}
|
|
75
|
+
/** The Standard Typed types interface. */
|
|
76
|
+
interface Types<Input = unknown, Output = Input> {
|
|
77
|
+
/** The input type of the schema. */
|
|
78
|
+
readonly input: Input;
|
|
79
|
+
/** The output type of the schema. */
|
|
80
|
+
readonly output: Output;
|
|
81
|
+
}
|
|
82
|
+
/** Infers the input type of a Standard Typed. */
|
|
83
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
84
|
+
/** Infers the output type of a Standard Typed. */
|
|
85
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
86
|
+
}
|
|
87
|
+
/** The Standard Schema interface. */
|
|
88
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
89
|
+
/** The Standard Schema properties. */
|
|
90
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
91
|
+
}
|
|
92
|
+
declare namespace StandardSchemaV1 {
|
|
93
|
+
/** The Standard Schema properties interface. */
|
|
94
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
95
|
+
/** Validates unknown input values. */
|
|
96
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
97
|
+
}
|
|
98
|
+
/** The result interface of the validate function. */
|
|
99
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
100
|
+
/** The result interface if validation succeeds. */
|
|
101
|
+
interface SuccessResult<Output> {
|
|
102
|
+
/** The typed output value. */
|
|
103
|
+
readonly value: Output;
|
|
104
|
+
/** A falsy value for `issues` indicates success. */
|
|
105
|
+
readonly issues?: undefined;
|
|
106
|
+
}
|
|
107
|
+
interface Options {
|
|
108
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
109
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
110
|
+
}
|
|
111
|
+
/** The result interface if validation fails. */
|
|
112
|
+
interface FailureResult {
|
|
113
|
+
/** The issues of failed validation. */
|
|
114
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
115
|
+
}
|
|
116
|
+
/** The issue interface of the failure output. */
|
|
117
|
+
interface Issue {
|
|
118
|
+
/** The error message of the issue. */
|
|
119
|
+
readonly message: string;
|
|
120
|
+
/** The path of the issue, if any. */
|
|
121
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
122
|
+
}
|
|
123
|
+
/** The path segment interface of the issue. */
|
|
124
|
+
interface PathSegment {
|
|
125
|
+
/** The key representing a path segment. */
|
|
126
|
+
readonly key: PropertyKey;
|
|
127
|
+
}
|
|
128
|
+
/** The Standard types interface. */
|
|
129
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
130
|
+
/** Infers the input type of a Standard. */
|
|
131
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
132
|
+
/** Infers the output type of a Standard. */
|
|
133
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
134
|
+
}
|
|
135
|
+
/** The Standard JSON Schema interface. */
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/lib/api/middleware/types.d.ts
|
|
138
|
+
type MiddlewareHandler<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<never, never>> = (c: Context<TReq, TRes>) => Response | TExt | undefined | Promise<Response | TExt | undefined> | Promise<void> | void;
|
|
139
|
+
type MiddlewareOptions<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = {
|
|
140
|
+
request?: TReq;
|
|
141
|
+
response?: TRes;
|
|
142
|
+
handler: MiddlewareHandler<TReq, TRes, TExt>;
|
|
143
|
+
};
|
|
144
|
+
type InferMiddlewareExtension<T> = T extends {
|
|
145
|
+
options: MiddlewareOptions<infer _TReq, infer _TRes, infer E>;
|
|
146
|
+
} ? E : never;
|
|
147
|
+
type MergeMiddlewareExtensions<T extends readonly unknown[]> = T extends readonly [infer First, ...infer Rest] ? InferMiddlewareExtension<First> & MergeMiddlewareExtensions<Rest> : {};
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/lib/api/core/types.d.ts
|
|
150
|
+
type ResponseSchema = {
|
|
151
|
+
[status: number]: StandardSchemaV1;
|
|
152
|
+
};
|
|
153
|
+
type RequestSchema = {
|
|
154
|
+
params?: StandardSchemaV1;
|
|
155
|
+
body?: StandardSchemaV1;
|
|
156
|
+
query?: StandardSchemaV1;
|
|
157
|
+
headers?: StandardSchemaV1;
|
|
158
|
+
cookies?: StandardSchemaV1;
|
|
159
|
+
};
|
|
160
|
+
type SafeTypeAccess<T, K extends "input" | "output"> = T extends StandardSchemaV1 ? T["~standard"] extends {
|
|
161
|
+
types?: infer U;
|
|
162
|
+
} ? U extends Record<K, infer V> ? V : never : never : undefined;
|
|
163
|
+
type InferOutput<T extends StandardSchemaV1 | undefined> = SafeTypeAccess<T, "output">;
|
|
164
|
+
type InferInput<T extends StandardSchemaV1 | undefined> = SafeTypeAccess<T, "input">;
|
|
165
|
+
type ExtractStatusCodes<T extends ResponseSchema> = keyof T & number;
|
|
166
|
+
type ExtractStatusCodesOrAny<T extends ResponseSchema | undefined> = T extends ResponseSchema ? ExtractStatusCodes<T> : number;
|
|
167
|
+
type ValidationOptions = boolean | {
|
|
168
|
+
input?: boolean;
|
|
169
|
+
output?: boolean;
|
|
170
|
+
};
|
|
171
|
+
type ApiOptions<TMiddlewares extends readonly Middleware[] = readonly []> = {
|
|
172
|
+
prefix?: string;
|
|
173
|
+
openapi?: OpenApiOptions;
|
|
174
|
+
middlewares?: TMiddlewares;
|
|
175
|
+
validation?: ValidationOptions;
|
|
176
|
+
};
|
|
177
|
+
type SecuritySchemeApiKey = {
|
|
178
|
+
type: "apiKey";
|
|
179
|
+
name: string;
|
|
180
|
+
in: "query" | "header" | "cookie";
|
|
181
|
+
description?: string;
|
|
182
|
+
};
|
|
183
|
+
type SecuritySchemeHttp = {
|
|
184
|
+
type: "http";
|
|
185
|
+
scheme: string;
|
|
186
|
+
bearerFormat?: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
};
|
|
189
|
+
type SecuritySchemeOAuth2Flow = {
|
|
190
|
+
authorizationUrl?: string;
|
|
191
|
+
tokenUrl?: string;
|
|
192
|
+
refreshUrl?: string;
|
|
193
|
+
scopes: Record<string, string>;
|
|
194
|
+
};
|
|
195
|
+
type SecuritySchemeOAuth2 = {
|
|
196
|
+
type: "oauth2";
|
|
197
|
+
flows: {
|
|
198
|
+
implicit?: SecuritySchemeOAuth2Flow;
|
|
199
|
+
password?: SecuritySchemeOAuth2Flow;
|
|
200
|
+
clientCredentials?: SecuritySchemeOAuth2Flow;
|
|
201
|
+
authorizationCode?: SecuritySchemeOAuth2Flow;
|
|
202
|
+
};
|
|
203
|
+
description?: string;
|
|
204
|
+
};
|
|
205
|
+
type SecuritySchemeOpenIdConnect = {
|
|
206
|
+
type: "openIdConnect";
|
|
207
|
+
openIdConnectUrl: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
};
|
|
210
|
+
type SecurityScheme = SecuritySchemeApiKey | SecuritySchemeHttp | SecuritySchemeOAuth2 | SecuritySchemeOpenIdConnect;
|
|
211
|
+
type OpenApiOptions = {
|
|
212
|
+
version: string;
|
|
213
|
+
title: string;
|
|
214
|
+
description?: string;
|
|
215
|
+
servers?: Array<{
|
|
216
|
+
url: string;
|
|
217
|
+
description?: string;
|
|
218
|
+
}>;
|
|
219
|
+
securitySchemes?: Record<string, SecurityScheme>;
|
|
220
|
+
};
|
|
221
|
+
type Context<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = {
|
|
222
|
+
raw: Request;
|
|
223
|
+
req: {
|
|
224
|
+
body: InferOutput<TReq["body"]>;
|
|
225
|
+
query: InferOutput<TReq["query"]>;
|
|
226
|
+
headers: InferOutput<TReq["headers"]>;
|
|
227
|
+
cookies: InferOutput<TReq["cookies"]>;
|
|
228
|
+
params: InferOutput<TReq["params"]>;
|
|
229
|
+
};
|
|
230
|
+
json: <S extends ExtractStatusCodesOrAny<TRes>>(status: S, data: TRes extends ResponseSchema ? InferOutput<TRes[S]> : unknown) => Response;
|
|
231
|
+
text: (status: number, text: string) => Response;
|
|
232
|
+
html: (status: number, html: string) => Response;
|
|
233
|
+
redirect: (status: number, url: string) => Response;
|
|
234
|
+
get: <K extends keyof TExt>(key: K) => TExt[K];
|
|
235
|
+
};
|
|
236
|
+
type RouteHandler<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TExt extends Record<string, unknown> = Record<string, unknown>> = (c: Context<TReq, TRes, TExt>) => Response | Promise<Response>;
|
|
237
|
+
type RouteConfig<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema | undefined = undefined, TGlobalMiddlewares extends readonly Middleware[] = readonly [], TRouteMiddlewares extends readonly Middleware[] = readonly []> = {
|
|
238
|
+
path: string;
|
|
239
|
+
method: Bun.Serve.HTTPMethod;
|
|
240
|
+
request?: TReq;
|
|
241
|
+
response?: TRes;
|
|
242
|
+
middlewares?: TRouteMiddlewares;
|
|
243
|
+
handler: RouteHandler<TReq, TRes, MergeMiddlewareExtensions<TGlobalMiddlewares> & MergeMiddlewareExtensions<TRouteMiddlewares>>;
|
|
244
|
+
summary?: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
operationId?: string;
|
|
247
|
+
tags?: string[];
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/lib/api/middleware/index.d.ts
|
|
251
|
+
declare class Middleware<TRequest extends RequestSchema = RequestSchema, TResponse extends ResponseSchema = ResponseSchema, TExtension extends Record<string, unknown> = Record<string, unknown>> {
|
|
252
|
+
options: MiddlewareOptions<TRequest, TResponse, TExtension>;
|
|
253
|
+
constructor(options: MiddlewareOptions<TRequest, TResponse, TExtension>);
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/lib/api/core/index.d.ts
|
|
257
|
+
declare class Api<TMiddlewares extends readonly Middleware[] = readonly []> {
|
|
258
|
+
private options;
|
|
259
|
+
private routes;
|
|
260
|
+
constructor(options?: ApiOptions<TMiddlewares>);
|
|
261
|
+
private getFullPath;
|
|
262
|
+
private validateRequestSchema;
|
|
263
|
+
private createContext;
|
|
264
|
+
private validateResponseBody;
|
|
265
|
+
private buildBunRoutes;
|
|
266
|
+
defineRoute<TReq extends RequestSchema = RequestSchema, TRes extends ResponseSchema = ResponseSchema, TRouteMiddlewares extends readonly Middleware[] = readonly []>(config: RouteConfig<TReq, TRes, TMiddlewares, TRouteMiddlewares>): void;
|
|
267
|
+
getOpenApiSpec(): Promise<OpenApiSpec>;
|
|
268
|
+
serve(port: number, callback?: (server: Bun.Server<unknown>) => void): void;
|
|
269
|
+
}
|
|
270
|
+
//#endregion
|
|
5
271
|
export { Api, type ApiOptions, type Context, type ExtractStatusCodes, type InferInput, type InferMiddlewareExtension, type InferOutput, type MergeMiddlewareExtensions, Middleware, type MiddlewareHandler, type MiddlewareOptions, type OpenApiOptions, type RequestSchema, type ResponseSchema, type RouteConfig, type RouteHandler, type SecurityScheme, type SecuritySchemeApiKey, type SecuritySchemeHttp, type SecuritySchemeOAuth2, type SecuritySchemeOAuth2Flow, type SecuritySchemeOpenIdConnect };
|