lumen-framework 3.0.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.
- package/LICENSE +26 -0
- package/README.md +164 -0
- package/bin/lumen +275 -0
- package/dist/cli.cjs +3002 -0
- package/dist/cli.cjs.map +7 -0
- package/dist/index.js +6515 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +6480 -0
- package/dist/index.mjs.map +7 -0
- package/dist/types/constants.d.ts +7 -0
- package/dist/types/errors/controller-missing-error.d.ts +7 -0
- package/dist/types/errors/serializer-missing-error.d.ts +7 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/interfaces.d.ts +12 -0
- package/dist/types/packages/application/index.d.ts +97 -0
- package/dist/types/packages/application/initialize.d.ts +6 -0
- package/dist/types/packages/application/interfaces.d.ts +16 -0
- package/dist/types/packages/application/utils/create-controller.d.ts +12 -0
- package/dist/types/packages/application/utils/create-serializer.d.ts +4 -0
- package/dist/types/packages/application/utils/normalize-port.d.ts +4 -0
- package/dist/types/packages/cli/commands/build.d.ts +1 -0
- package/dist/types/packages/cli/commands/create.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbcreate.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbdrop.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbmigrate.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbrollback.d.ts +4 -0
- package/dist/types/packages/cli/commands/dbseed.d.ts +4 -0
- package/dist/types/packages/cli/commands/destroy.d.ts +11 -0
- package/dist/types/packages/cli/commands/generate.d.ts +10 -0
- package/dist/types/packages/cli/commands/index.d.ts +12 -0
- package/dist/types/packages/cli/commands/repl.d.ts +1 -0
- package/dist/types/packages/cli/commands/serve.d.ts +8 -0
- package/dist/types/packages/cli/commands/test.d.ts +4 -0
- package/dist/types/packages/cli/constants.d.ts +2 -0
- package/dist/types/packages/cli/errors/database-config-missing.d.ts +4 -0
- package/dist/types/packages/cli/generator/constants.d.ts +5 -0
- package/dist/types/packages/cli/generator/index.d.ts +11 -0
- package/dist/types/packages/cli/generator/interfaces.d.ts +9 -0
- package/dist/types/packages/cli/generator/utils/create-generator.d.ts +9 -0
- package/dist/types/packages/cli/generator/utils/generate-type.d.ts +33 -0
- package/dist/types/packages/cli/generator/utils/generator-for.d.ts +2 -0
- package/dist/types/packages/cli/generator/utils/log.d.ts +4 -0
- package/dist/types/packages/cli/generator/utils/migration-conflict.d.ts +6 -0
- package/dist/types/packages/cli/templates/application.d.ts +5 -0
- package/dist/types/packages/cli/templates/config.d.ts +5 -0
- package/dist/types/packages/cli/templates/controller.d.ts +5 -0
- package/dist/types/packages/cli/templates/database.d.ts +5 -0
- package/dist/types/packages/cli/templates/empty-migration.d.ts +5 -0
- package/dist/types/packages/cli/templates/eslint-config.d.ts +5 -0
- package/dist/types/packages/cli/templates/gitignore.d.ts +5 -0
- package/dist/types/packages/cli/templates/license.d.ts +5 -0
- package/dist/types/packages/cli/templates/middleware.d.ts +5 -0
- package/dist/types/packages/cli/templates/model-migration.d.ts +5 -0
- package/dist/types/packages/cli/templates/model.d.ts +5 -0
- package/dist/types/packages/cli/templates/package-json.d.ts +5 -0
- package/dist/types/packages/cli/templates/readme.d.ts +5 -0
- package/dist/types/packages/cli/templates/routes.d.ts +5 -0
- package/dist/types/packages/cli/templates/seed.d.ts +5 -0
- package/dist/types/packages/cli/templates/serializer.d.ts +5 -0
- package/dist/types/packages/cli/templates/util.d.ts +5 -0
- package/dist/types/packages/cli/utils/create-prompt.d.ts +4 -0
- package/dist/types/packages/cli/utils/driver-for.d.ts +1 -0
- package/dist/types/packages/cli/utils/indent.d.ts +1 -0
- package/dist/types/packages/compiler/index.d.ts +11 -0
- package/dist/types/packages/compiler/interfaces.d.ts +1 -0
- package/dist/types/packages/compiler/utils/create-boot-script.d.ts +6 -0
- package/dist/types/packages/compiler/utils/create-manifest.d.ts +6 -0
- package/dist/types/packages/compiler/utils/format-name.d.ts +5 -0
- package/dist/types/packages/config/index.d.ts +3 -0
- package/dist/types/packages/config/interfaces.d.ts +6 -0
- package/dist/types/packages/controller/constants.d.ts +2 -0
- package/dist/types/packages/controller/index.d.ts +591 -0
- package/dist/types/packages/controller/interfaces.d.ts +13 -0
- package/dist/types/packages/controller/utils/find-many.d.ts +6 -0
- package/dist/types/packages/controller/utils/find-one.d.ts +6 -0
- package/dist/types/packages/controller/utils/params-to-query.d.ts +16 -0
- package/dist/types/packages/controller/utils/resolve-relationships.d.ts +5 -0
- package/dist/types/packages/database/attribute/index.d.ts +6 -0
- package/dist/types/packages/database/attribute/interfaces.d.ts +6 -0
- package/dist/types/packages/database/attribute/utils/create-attribute.d.ts +5 -0
- package/dist/types/packages/database/attribute/utils/create-getter.d.ts +3 -0
- package/dist/types/packages/database/attribute/utils/create-normalizer.d.ts +1 -0
- package/dist/types/packages/database/attribute/utils/create-setter.d.ts +8 -0
- package/dist/types/packages/database/change-set/index.d.ts +10 -0
- package/dist/types/packages/database/constants.d.ts +3 -0
- package/dist/types/packages/database/errors/config-missing-error.d.ts +4 -0
- package/dist/types/packages/database/errors/index.d.ts +5 -0
- package/dist/types/packages/database/errors/invalid-driver-error.d.ts +7 -0
- package/dist/types/packages/database/errors/migrations-pending-error.d.ts +7 -0
- package/dist/types/packages/database/errors/model-missing-error.d.ts +7 -0
- package/dist/types/packages/database/errors/unique-constraint-error.d.ts +4 -0
- package/dist/types/packages/database/index.d.ts +26 -0
- package/dist/types/packages/database/initialize.d.ts +6 -0
- package/dist/types/packages/database/interfaces.d.ts +85 -0
- package/dist/types/packages/database/migration/index.d.ts +12 -0
- package/dist/types/packages/database/migration/interfaces.d.ts +4 -0
- package/dist/types/packages/database/migration/utils/generate-timestamp.d.ts +2 -0
- package/dist/types/packages/database/model/index.d.ts +1046 -0
- package/dist/types/packages/database/model/initialize-class.d.ts +10 -0
- package/dist/types/packages/database/model/interfaces.d.ts +14 -0
- package/dist/types/packages/database/model/utils/get-columns.d.ts +5 -0
- package/dist/types/packages/database/model/utils/persistence.d.ts +18 -0
- package/dist/types/packages/database/model/utils/process-write-error.d.ts +4 -0
- package/dist/types/packages/database/model/utils/run-hooks.d.ts +6 -0
- package/dist/types/packages/database/model/utils/validate.d.ts +5 -0
- package/dist/types/packages/database/query/errors/index.d.ts +1 -0
- package/dist/types/packages/database/query/errors/record-not-found-error.d.ts +6 -0
- package/dist/types/packages/database/query/index.d.ts +38 -0
- package/dist/types/packages/database/query/runner/constants.d.ts +2 -0
- package/dist/types/packages/database/query/runner/index.d.ts +9 -0
- package/dist/types/packages/database/query/runner/utils/build-results.d.ts +10 -0
- package/dist/types/packages/database/query/runner/utils/get-find-param.d.ts +2 -0
- package/dist/types/packages/database/query/utils/format-select.d.ts +5 -0
- package/dist/types/packages/database/query/utils/scopes-for.d.ts +2 -0
- package/dist/types/packages/database/relationship/index.d.ts +11 -0
- package/dist/types/packages/database/relationship/interfaces.d.ts +12 -0
- package/dist/types/packages/database/relationship/utils/getters.d.ts +14 -0
- package/dist/types/packages/database/relationship/utils/inverse-setters.d.ts +15 -0
- package/dist/types/packages/database/relationship/utils/setters.d.ts +14 -0
- package/dist/types/packages/database/relationship/utils/unassociate.d.ts +5 -0
- package/dist/types/packages/database/relationship/utils/update-relationship.d.ts +5 -0
- package/dist/types/packages/database/relationship/utils/validate-type.d.ts +2 -0
- package/dist/types/packages/database/transaction/index.d.ts +16 -0
- package/dist/types/packages/database/transaction/interfaces.d.ts +5 -0
- package/dist/types/packages/database/utils/connect.d.ts +6 -0
- package/dist/types/packages/database/utils/create-migrations.d.ts +5 -0
- package/dist/types/packages/database/utils/normalize-model-name.d.ts +5 -0
- package/dist/types/packages/database/utils/pending-migrations.d.ts +4 -0
- package/dist/types/packages/database/utils/type-for-column.d.ts +5 -0
- package/dist/types/packages/database/validation/errors/index.d.ts +1 -0
- package/dist/types/packages/database/validation/errors/validation-error.d.ts +7 -0
- package/dist/types/packages/database/validation/index.d.ts +13 -0
- package/dist/types/packages/database/validation/interfaces.d.ts +5 -0
- package/dist/types/packages/freezeable/constants.d.ts +1 -0
- package/dist/types/packages/freezeable/index.d.ts +3 -0
- package/dist/types/packages/freezeable/map/index.d.ts +11 -0
- package/dist/types/packages/freezeable/set/index.d.ts +11 -0
- package/dist/types/packages/freezeable/utils/freeze.d.ts +20 -0
- package/dist/types/packages/freezeable/utils/is-frozen.d.ts +4 -0
- package/dist/types/packages/fs/index.d.ts +52 -0
- package/dist/types/packages/fs/interfaces.d.ts +19 -0
- package/dist/types/packages/fs/utils/create-path-remover.d.ts +5 -0
- package/dist/types/packages/fs/utils/create-resolver.d.ts +4 -0
- package/dist/types/packages/fs/utils/exists.d.ts +4 -0
- package/dist/types/packages/fs/utils/is-js-file.d.ts +4 -0
- package/dist/types/packages/fs/utils/parse-path.d.ts +5 -0
- package/dist/types/packages/fs/utils/rmrf.d.ts +5 -0
- package/dist/types/packages/fs/watcher/index.d.ts +13 -0
- package/dist/types/packages/fs/watcher/initialize.d.ts +5 -0
- package/dist/types/packages/fs/watcher/interfaces.d.ts +3 -0
- package/dist/types/packages/jsonapi/constants.d.ts +2 -0
- package/dist/types/packages/jsonapi/errors/index.d.ts +3 -0
- package/dist/types/packages/jsonapi/errors/invalid-content-type-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/errors/not-acceptable-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/errors/unsupported-media-type-error.d.ts +8 -0
- package/dist/types/packages/jsonapi/index.d.ts +5 -0
- package/dist/types/packages/jsonapi/interfaces.d.ts +66 -0
- package/dist/types/packages/jsonapi/utils/has-media-type.d.ts +4 -0
- package/dist/types/packages/jsonapi/utils/is-jsonapi.d.ts +4 -0
- package/dist/types/packages/loader/builder/index.d.ts +6 -0
- package/dist/types/packages/loader/builder/interfaces.d.ts +10 -0
- package/dist/types/packages/loader/builder/utils/create-children-builder.d.ts +2 -0
- package/dist/types/packages/loader/builder/utils/create-parent-builder.d.ts +2 -0
- package/dist/types/packages/loader/builder/utils/sort-by-namespace.d.ts +5 -0
- package/dist/types/packages/loader/index.d.ts +8 -0
- package/dist/types/packages/loader/interfaces.d.ts +4 -0
- package/dist/types/packages/loader/resolver/index.d.ts +7 -0
- package/dist/types/packages/loader/resolver/utils/closest-ancestor.d.ts +2 -0
- package/dist/types/packages/loader/resolver/utils/closest-child.d.ts +2 -0
- package/dist/types/packages/loader/utils/bundle-for.d.ts +5 -0
- package/dist/types/packages/loader/utils/format-key.d.ts +4 -0
- package/dist/types/packages/logger/constants.d.ts +8 -0
- package/dist/types/packages/logger/index.d.ts +182 -0
- package/dist/types/packages/logger/interfaces.d.ts +17 -0
- package/dist/types/packages/logger/request-logger/index.d.ts +6 -0
- package/dist/types/packages/logger/request-logger/interfaces.d.ts +25 -0
- package/dist/types/packages/logger/request-logger/templates.d.ts +9 -0
- package/dist/types/packages/logger/request-logger/utils/filter-params.d.ts +4 -0
- package/dist/types/packages/logger/request-logger/utils/log-json.d.ts +10 -0
- package/dist/types/packages/logger/request-logger/utils/log-text.d.ts +10 -0
- package/dist/types/packages/logger/utils/line.d.ts +4 -0
- package/dist/types/packages/logger/utils/sql.d.ts +4 -0
- package/dist/types/packages/logger/writer/constants.d.ts +3 -0
- package/dist/types/packages/logger/writer/index.d.ts +6 -0
- package/dist/types/packages/logger/writer/interfaces.d.ts +2 -0
- package/dist/types/packages/logger/writer/utils/format-message.d.ts +9 -0
- package/dist/types/packages/lumenify/index.d.ts +11 -0
- package/dist/types/packages/lumenify/utils/create-response-proxy.d.ts +8 -0
- package/dist/types/packages/pm/cluster/index.d.ts +21 -0
- package/dist/types/packages/pm/cluster/interfaces.d.ts +7 -0
- package/dist/types/packages/pm/index.d.ts +6 -0
- package/dist/types/packages/router/definitions/context/index.d.ts +11 -0
- package/dist/types/packages/router/definitions/context/utils/create-definition-group.d.ts +7 -0
- package/dist/types/packages/router/definitions/context/utils/create-definition.d.ts +10 -0
- package/dist/types/packages/router/definitions/context/utils/normalize-resource-args.d.ts +12 -0
- package/dist/types/packages/router/definitions/index.d.ts +10 -0
- package/dist/types/packages/router/definitions/interfaces.d.ts +7 -0
- package/dist/types/packages/router/index.d.ts +18 -0
- package/dist/types/packages/router/interfaces.d.ts +18 -0
- package/dist/types/packages/router/namespace/index.d.ts +20 -0
- package/dist/types/packages/router/namespace/interfaces.d.ts +9 -0
- package/dist/types/packages/router/namespace/utils/normalize-name.d.ts +4 -0
- package/dist/types/packages/router/namespace/utils/normalize-path.d.ts +4 -0
- package/dist/types/packages/router/resource/index.d.ts +13 -0
- package/dist/types/packages/router/resource/interfaces.d.ts +5 -0
- package/dist/types/packages/router/resource/utils/normalize-only.d.ts +5 -0
- package/dist/types/packages/router/route/action/constants.d.ts +1 -0
- package/dist/types/packages/router/route/action/enhancers/resource.d.ts +5 -0
- package/dist/types/packages/router/route/action/enhancers/track-perf.d.ts +5 -0
- package/dist/types/packages/router/route/action/index.d.ts +9 -0
- package/dist/types/packages/router/route/action/interfaces.d.ts +2 -0
- package/dist/types/packages/router/route/action/utils/create-page-links.d.ts +12 -0
- package/dist/types/packages/router/route/action/utils/get-action-name.d.ts +5 -0
- package/dist/types/packages/router/route/action/utils/get-controller-name.d.ts +5 -0
- package/dist/types/packages/router/route/constants.d.ts +1 -0
- package/dist/types/packages/router/route/index.d.ts +28 -0
- package/dist/types/packages/router/route/interfaces.d.ts +10 -0
- package/dist/types/packages/router/route/params/errors/index.d.ts +5 -0
- package/dist/types/packages/router/route/params/errors/invalid-parameter-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/errors/parameter-not-nullable-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/parameter-required-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/errors/parameter-type-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/parameter-value-error.d.ts +9 -0
- package/dist/types/packages/router/route/params/errors/resource-mismatch-error.d.ts +8 -0
- package/dist/types/packages/router/route/params/index.d.ts +18 -0
- package/dist/types/packages/router/route/params/interfaces.d.ts +25 -0
- package/dist/types/packages/router/route/params/parameter/index.d.ts +14 -0
- package/dist/types/packages/router/route/params/parameter/interfaces.d.ts +4 -0
- package/dist/types/packages/router/route/params/parameter/utils/validate-value.d.ts +5 -0
- package/dist/types/packages/router/route/params/parameter-group/index.d.ts +14 -0
- package/dist/types/packages/router/route/params/parameter-group/utils/has-required-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/get-data-params.d.ts +6 -0
- package/dist/types/packages/router/route/params/utils/get-default-collection-params.d.ts +6 -0
- package/dist/types/packages/router/route/params/utils/get-default-member-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/get-query-params.d.ts +14 -0
- package/dist/types/packages/router/route/params/utils/get-url-params.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/validate-resource-id.d.ts +5 -0
- package/dist/types/packages/router/route/params/utils/validate-type.d.ts +5 -0
- package/dist/types/packages/router/route/utils/get-dynamic-segments.d.ts +4 -0
- package/dist/types/packages/router/route/utils/get-static-path.d.ts +4 -0
- package/dist/types/packages/router/utils/create-replacer.d.ts +5 -0
- package/dist/types/packages/serializer/index.d.ts +521 -0
- package/dist/types/packages/serializer/interfaces.d.ts +7 -0
- package/dist/types/packages/server/constants.d.ts +2 -0
- package/dist/types/packages/server/index.d.ts +27 -0
- package/dist/types/packages/server/interfaces.d.ts +18 -0
- package/dist/types/packages/server/request/constants.d.ts +2 -0
- package/dist/types/packages/server/request/index.d.ts +8 -0
- package/dist/types/packages/server/request/interfaces.d.ts +63 -0
- package/dist/types/packages/server/request/parser/constants.d.ts +6 -0
- package/dist/types/packages/server/request/parser/errors/index.d.ts +1 -0
- package/dist/types/packages/server/request/parser/errors/malformed-request-error.d.ts +8 -0
- package/dist/types/packages/server/request/parser/index.d.ts +5 -0
- package/dist/types/packages/server/request/parser/utils/format.d.ts +17 -0
- package/dist/types/packages/server/request/parser/utils/parse-nested-object.d.ts +4 -0
- package/dist/types/packages/server/request/parser/utils/parse-read.d.ts +5 -0
- package/dist/types/packages/server/request/parser/utils/parse-write.d.ts +5 -0
- package/dist/types/packages/server/request/utils/get-domain.d.ts +5 -0
- package/dist/types/packages/server/responder/index.d.ts +5 -0
- package/dist/types/packages/server/responder/utils/data-for.d.ts +5 -0
- package/dist/types/packages/server/responder/utils/has-content-type.d.ts +2 -0
- package/dist/types/packages/server/responder/utils/normalize.d.ts +7 -0
- package/dist/types/packages/server/response/index.d.ts +5 -0
- package/dist/types/packages/server/response/interfaces.d.ts +22 -0
- package/dist/types/packages/server/utils/create-server-error.d.ts +7 -0
- package/dist/types/packages/server/utils/set-cors-headers.d.ts +3 -0
- package/dist/types/packages/server/utils/validate-accept.d.ts +4 -0
- package/dist/types/packages/server/utils/validate-content-type.d.ts +4 -0
- package/dist/types/packages/template/index.d.ts +8 -0
- package/dist/types/packages/template/utils/insert-values.d.ts +4 -0
- package/dist/types/utils/chain.d.ts +5 -0
- package/dist/types/utils/compact.d.ts +11 -0
- package/dist/types/utils/compose.d.ts +19 -0
- package/dist/types/utils/create-query-string.d.ts +6 -0
- package/dist/types/utils/diff.d.ts +4 -0
- package/dist/types/utils/entries.d.ts +4 -0
- package/dist/types/utils/env.d.ts +3 -0
- package/dist/types/utils/exec.d.ts +5 -0
- package/dist/types/utils/github.d.ts +9 -0
- package/dist/types/utils/has-own-property.d.ts +1 -0
- package/dist/types/utils/insert.d.ts +4 -0
- package/dist/types/utils/is-buffer.d.ts +4 -0
- package/dist/types/utils/is-null.d.ts +4 -0
- package/dist/types/utils/is-object.d.ts +17 -0
- package/dist/types/utils/is-undefined.d.ts +4 -0
- package/dist/types/utils/k.d.ts +10 -0
- package/dist/types/utils/map-to-object.d.ts +1 -0
- package/dist/types/utils/merge.d.ts +4 -0
- package/dist/types/utils/omit.d.ts +9 -0
- package/dist/types/utils/pick.d.ts +11 -0
- package/dist/types/utils/present.d.ts +4 -0
- package/dist/types/utils/promise-hash.d.ts +9 -0
- package/dist/types/utils/proxy.d.ts +6 -0
- package/dist/types/utils/range.d.ts +4 -0
- package/dist/types/utils/set-type.d.ts +11 -0
- package/dist/types/utils/sleep.d.ts +4 -0
- package/dist/types/utils/stringify.d.ts +4 -0
- package/dist/types/utils/transform-keys.d.ts +29 -0
- package/dist/types/utils/try-catch.d.ts +55 -0
- package/dist/types/utils/underscore.d.ts +4 -0
- package/dist/types/utils/uniq.d.ts +4 -0
- package/package.json +87 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Writable } from 'stream';
|
|
2
|
+
import type Logger from '../../logger';
|
|
3
|
+
type Response$stat = {
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
duration: number;
|
|
7
|
+
controller: string;
|
|
8
|
+
};
|
|
9
|
+
export type Response$opts = {
|
|
10
|
+
logger: Logger;
|
|
11
|
+
};
|
|
12
|
+
export interface Response extends Writable {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
stats: Array<Response$stat>;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
statusCode: number;
|
|
17
|
+
statusMessage: string;
|
|
18
|
+
getHeader(name: string): string | void;
|
|
19
|
+
setHeader(name: string, value: string): void;
|
|
20
|
+
removeHeader(name: string): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Server$Error } from '../interfaces';
|
|
2
|
+
type Constructor<T> = new (...args: Array<any>) => T;
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
export default function createServerError<T extends object>(Target: Constructor<T>, statusCode: number): Constructor<T & Server$Error>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used as a template tag, so `strings` arrives as a TemplateStringsArray —
|
|
3
|
+
* typed as `readonly string[]`, which also accepts a plain array.
|
|
4
|
+
*
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export default function template(strings: readonly string[], ...values: unknown[]): string;
|
|
8
|
+
export { default as insertValues } from './utils/insert-values';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes null/undefined entries from an array or object.
|
|
3
|
+
*
|
|
4
|
+
* Overloaded because the two inputs behave differently: an array keeps its
|
|
5
|
+
* element type, while an object may lose keys — hence `Partial<T>` rather than
|
|
6
|
+
* Flow's `T`.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export default function compact<T>(source: T[]): T[];
|
|
11
|
+
export default function compact<T extends object>(source: T): Partial<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single stage of a composed pipeline.
|
|
3
|
+
*
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
type Stage = (value: any) => any;
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export declare function tap<T>(input: T): T;
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
export declare function compose<T, U>(main: (input: any) => U, ...etc: Stage[]): (input: T) => U;
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export declare function composeAsync<T, U>(main: (input: any) => Promise<U>, ...etc: Stage[]): (input: T | Promise<T>) => Promise<U>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hasOwnProperty(target: object, key: string): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine wether or not a value is an Object.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* const a = null;
|
|
6
|
+
* const b = [];
|
|
7
|
+
* const c = {};
|
|
8
|
+
*
|
|
9
|
+
* console.log(typeof a, typeof b, typeof c);
|
|
10
|
+
* // => 'object', 'object', 'object' 👎
|
|
11
|
+
*
|
|
12
|
+
* console.log(isObject(a), isObject(b), isObject(c));
|
|
13
|
+
* // => false, false, true 👍
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
export default function isObject(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility function that always returns `this` based on it's current
|
|
3
|
+
* context.
|
|
4
|
+
*
|
|
5
|
+
* A common use case for the K function is a default parameter for optional
|
|
6
|
+
* callback functions or general function arguments.
|
|
7
|
+
*
|
|
8
|
+
* @private
|
|
9
|
+
*/
|
|
10
|
+
export default function K(this: unknown): unknown;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function mapToObject<T>(source: Map<string, T>): Record<string, T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a copy of `src` without `omitted` keys.
|
|
3
|
+
*
|
|
4
|
+
* Typed as `Partial<T>` rather than Flow's `T`, since the omitted keys are by
|
|
5
|
+
* definition absent from the result.
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
*/
|
|
9
|
+
export default function omit<T extends object>(src: T, ...omitted: string[]): Partial<T>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a copy of `src` containing only `keys` whose values are defined.
|
|
3
|
+
*
|
|
4
|
+
* The result is `Partial<T>` rather than Flow's `T`: keys may be dropped, both
|
|
5
|
+
* because the caller asked for a subset and because undefined values are
|
|
6
|
+
* filtered out. The cast is confined to the return, where the dynamic key
|
|
7
|
+
* access makes the shape unknowable to the compiler.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export default function pick<T extends object>(src: T, ...keys: string[]): Partial<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves every value of an object, returning an object of the same shape with
|
|
3
|
+
* each promise unwrapped.
|
|
4
|
+
*
|
|
5
|
+
* @private
|
|
6
|
+
*/
|
|
7
|
+
export default function promiseHash<T extends Record<string, unknown>>(promises: T): Promise<{
|
|
8
|
+
[K in keyof T]: Awaited<T[K]>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escape hatch that existed to coerce Flow into accepting the return type of a
|
|
3
|
+
* polymorphic higher-order function.
|
|
4
|
+
*
|
|
5
|
+
* NOTE: this util is a Flow-era crutch. TypeScript's generics express the same
|
|
6
|
+
* intent directly, so calls to `setType` should be removed as their callers are
|
|
7
|
+
* converted — at which point this file can go away entirely.
|
|
8
|
+
*
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export default function setType<T>(fn: () => T): T;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Transformer = (key: string) => string;
|
|
2
|
+
/**
|
|
3
|
+
* Rewrites an object's keys with `transformer`.
|
|
4
|
+
*
|
|
5
|
+
* Overloaded rather than Flow's `T -> T`, which was inaccurate: transforming
|
|
6
|
+
* keys produces a differently-shaped object, so the object form returns
|
|
7
|
+
* `Record<string, unknown>`. Arrays are passed through as a shallow copy (their
|
|
8
|
+
* keys are not transformed), so they keep their element type.
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
export declare function transformKeys<T>(source: T[], transformer: Transformer, deep?: boolean): T[];
|
|
13
|
+
export declare function transformKeys(source: object, transformer: Transformer, deep?: boolean): Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
export declare function camelizeKeys<T>(source: T[], deep?: boolean): T[];
|
|
18
|
+
export declare function camelizeKeys(source: object, deep?: boolean): Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
export declare function dasherizeKeys<T>(source: T[], deep?: boolean): T[];
|
|
23
|
+
export declare function dasherizeKeys(source: object, deep?: boolean): Record<string, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
*/
|
|
27
|
+
export declare function underscoreKeys<T>(source: T[], deep?: boolean): T[];
|
|
28
|
+
export declare function underscoreKeys(source: object, deep?: boolean): Record<string, unknown>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility function used for wrapping async code that would otherwise need a
|
|
3
|
+
* try-catch block.
|
|
4
|
+
*
|
|
5
|
+
* V8 deoptimizes functions when running into try-catch catch due to the
|
|
6
|
+
* unpredictable nature of the code. The `tryCatch` utility function is a way
|
|
7
|
+
* to "have your cake and eat it too". Since the inner function (`fn`) will not
|
|
8
|
+
* become deoptimized by V8 for including a standard try-catch block, we don't
|
|
9
|
+
* have to sacrifice as much perf for error handling expensive computations.
|
|
10
|
+
*
|
|
11
|
+
* The `tryCatch` utility is also very useful when you want to perform a noop
|
|
12
|
+
* when an error is thrown as the catch argument (`rescue`) is optional unlike
|
|
13
|
+
* a traditional try-catch block.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* tryCatch(() => {
|
|
17
|
+
* const n = Math.floor(Math.random() * 6);
|
|
18
|
+
*
|
|
19
|
+
* if (n >= 4) {
|
|
20
|
+
* throw new Error('You lose!');
|
|
21
|
+
* } else {
|
|
22
|
+
* return Promise.resolve(n);
|
|
23
|
+
* }
|
|
24
|
+
* }, err => {
|
|
25
|
+
* console.error(err);
|
|
26
|
+
* }).then(luckyNumber => {
|
|
27
|
+
* console.log(`Your lucky number is ${luckyNumber}.`);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
export default function tryCatch<T>(fn: () => Promise<T>, rescue?: (err: unknown) => unknown): Promise<T | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* A syncronous implementation of the `tryCatch` utility.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const luckyNumber = tryCatchSync(() => {
|
|
38
|
+
* const n = Math.floor(Math.random() * 6);
|
|
39
|
+
*
|
|
40
|
+
* if (n >= 4) {
|
|
41
|
+
* throw new Error('You lose!');
|
|
42
|
+
* } else {
|
|
43
|
+
* return n;
|
|
44
|
+
* }
|
|
45
|
+
* }, err => {
|
|
46
|
+
* console.error(err);
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* if (luckyNumber) {
|
|
50
|
+
* console.log(`Your lucky number is ${luckyNumber}.`);
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
export declare function tryCatchSync<T>(fn: () => T, rescue?: (err: unknown) => unknown): T | undefined;
|
package/package.json
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lumen-framework",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Build scalable, Node.js-powered REST APIs with almost no code.",
|
|
5
|
+
"repository": "github:nickschot/lux",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mvc",
|
|
8
|
+
"api",
|
|
9
|
+
"lux",
|
|
10
|
+
"lumen",
|
|
11
|
+
"jsonapi",
|
|
12
|
+
"json-api",
|
|
13
|
+
"rest",
|
|
14
|
+
"framework"
|
|
15
|
+
],
|
|
16
|
+
"main": "dist/index.js",
|
|
17
|
+
"module": "dist/index.mjs",
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"bin": {
|
|
20
|
+
"lumen": "bin/lumen"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"bin",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "node build.mjs",
|
|
30
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
31
|
+
"prepack": "pnpm run build && pnpm run build:types",
|
|
32
|
+
"clean": "shx rm -rf coverage dist test/test-app/dist",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"format": "prettier --write .",
|
|
36
|
+
"format:check": "prettier --check .",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"debugger": "node --enable-source-maps test/utils/debugger/dist/debug.js",
|
|
39
|
+
"build:debugger": "node test/utils/debugger/build.mjs"
|
|
40
|
+
},
|
|
41
|
+
"author": "Nick Schot <nickschot@gmail.com>",
|
|
42
|
+
"contributors": [
|
|
43
|
+
{
|
|
44
|
+
"name": "Zachary Golba",
|
|
45
|
+
"url": "https://github.com/zacharygolba"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"bugs": {
|
|
50
|
+
"url": "https://github.com/nickschot/lux/issues"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">= 20"
|
|
54
|
+
},
|
|
55
|
+
"packageManager": "pnpm@10.34.5",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"ansi-regex": "^5.0.1",
|
|
58
|
+
"chalk": "^4.1.2",
|
|
59
|
+
"commander": "^2.20.3",
|
|
60
|
+
"esbuild": "^0.28.1",
|
|
61
|
+
"fb-watchman": "^2.0.2",
|
|
62
|
+
"inflection": "^1.13.4",
|
|
63
|
+
"knex": "^3.3.0",
|
|
64
|
+
"ora": "^5.4.1"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@eslint/js": "^9.39.5",
|
|
68
|
+
"@types/inflection": "1.13.2",
|
|
69
|
+
"@types/node": "^20.19.43",
|
|
70
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
71
|
+
"eslint": "^9.39.5",
|
|
72
|
+
"eslint-config-prettier": "^10.1.8",
|
|
73
|
+
"faker": "4.1.0",
|
|
74
|
+
"globals": "^17.7.0",
|
|
75
|
+
"lumen-framework": "link:.",
|
|
76
|
+
"node-fetch": "^2.7.0",
|
|
77
|
+
"prettier": "^3.9.5",
|
|
78
|
+
"shx": "^0.3.4",
|
|
79
|
+
"sinon": "2.2.0",
|
|
80
|
+
"typescript": "^6.0.3",
|
|
81
|
+
"typescript-eslint": "^8.64.0",
|
|
82
|
+
"vitest": "^4.1.10"
|
|
83
|
+
},
|
|
84
|
+
"volta": {
|
|
85
|
+
"node": "20.20.2"
|
|
86
|
+
}
|
|
87
|
+
}
|