lumen-framework 3.1.0 → 4.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.
Files changed (258) hide show
  1. package/README.md +75 -109
  2. package/bin/lumen +23 -41
  3. package/dist/cli.cjs +856 -479
  4. package/dist/cli.cjs.map +4 -4
  5. package/dist/index.js +3284 -1720
  6. package/dist/index.js.map +4 -4
  7. package/dist/index.mjs +3263 -1699
  8. package/dist/index.mjs.map +4 -4
  9. package/dist/testing.js +280 -0
  10. package/dist/testing.js.map +7 -0
  11. package/dist/testing.mjs +252 -0
  12. package/dist/testing.mjs.map +7 -0
  13. package/dist/types/errors/links-only-error.d.ts +13 -0
  14. package/dist/types/errors/reserved-field-name-error.d.ts +13 -0
  15. package/dist/types/errors/unknown-attribute-error.d.ts +13 -0
  16. package/dist/types/index.d.ts +14 -0
  17. package/dist/types/interfaces.d.ts +1 -1
  18. package/dist/types/packages/application/index.d.ts +38 -45
  19. package/dist/types/packages/application/initialize.d.ts +3 -5
  20. package/dist/types/packages/application/interfaces.d.ts +13 -5
  21. package/dist/types/packages/application/utils/create-controller.d.ts +14 -4
  22. package/dist/types/packages/application/utils/create-serializer.d.ts +2 -2
  23. package/dist/types/packages/application/utils/normalize-port.d.ts +1 -3
  24. package/dist/types/packages/application/utils/resolve-visibility.d.ts +15 -0
  25. package/dist/types/packages/application/utils/restrict-open-namespaces.d.ts +19 -0
  26. package/dist/types/packages/application/utils/validate-attributes.d.ts +17 -0
  27. package/dist/types/packages/application/utils/validate-links-only.d.ts +19 -0
  28. package/dist/types/packages/application/utils/validate-namespaced-serializers.d.ts +3 -3
  29. package/dist/types/packages/application/utils/validate-reserved-names.d.ts +12 -0
  30. package/dist/types/packages/application/utils/warn-query-param-names.d.ts +10 -0
  31. package/dist/types/packages/cli/commands/dbcreate.d.ts +1 -1
  32. package/dist/types/packages/cli/commands/dbdrop.d.ts +1 -1
  33. package/dist/types/packages/cli/commands/destroy.d.ts +3 -2
  34. package/dist/types/packages/cli/commands/generate.d.ts +5 -5
  35. package/dist/types/packages/cli/commands/index.d.ts +0 -1
  36. package/dist/types/packages/cli/generator/index.d.ts +6 -6
  37. package/dist/types/packages/cli/generator/interfaces.d.ts +3 -3
  38. package/dist/types/packages/cli/generator/utils/create-generator.d.ts +2 -2
  39. package/dist/types/packages/cli/generator/utils/generate-type.d.ts +9 -9
  40. package/dist/types/packages/cli/generator/utils/migration-conflict.d.ts +4 -4
  41. package/dist/types/packages/cli/templates/pnpm-workspace.d.ts +15 -0
  42. package/dist/types/packages/cli/utils/create-spinner.d.ts +14 -0
  43. package/dist/types/packages/cli/utils/print-statements.d.ts +12 -0
  44. package/dist/types/packages/cli/utils/server-database.d.ts +27 -0
  45. package/dist/types/packages/compiler/interfaces.d.ts +1 -1
  46. package/dist/types/packages/config/interfaces.d.ts +10 -4
  47. package/dist/types/packages/controller/constants.d.ts +7 -2
  48. package/dist/types/packages/controller/errors/related-record-not-found-error.d.ts +4 -4
  49. package/dist/types/packages/controller/index.d.ts +364 -473
  50. package/dist/types/packages/controller/interfaces.d.ts +21 -6
  51. package/dist/types/packages/controller/utils/find-many.d.ts +2 -5
  52. package/dist/types/packages/controller/utils/find-one.d.ts +2 -5
  53. package/dist/types/packages/controller/utils/params-to-query.d.ts +8 -10
  54. package/dist/types/packages/controller/utils/resolve-relationships.d.ts +1 -3
  55. package/dist/types/packages/controller/utils/validate-relationships.d.ts +5 -3
  56. package/dist/types/packages/controller/visibility/errors.d.ts +21 -0
  57. package/dist/types/packages/controller/visibility/index.d.ts +51 -0
  58. package/dist/types/packages/database/attribute/index.d.ts +4 -6
  59. package/dist/types/packages/database/attribute/interfaces.d.ts +1 -1
  60. package/dist/types/packages/database/attribute/utils/create-attribute.d.ts +3 -5
  61. package/dist/types/packages/database/attribute/utils/create-getter.d.ts +2 -2
  62. package/dist/types/packages/database/attribute/utils/create-setter.d.ts +3 -5
  63. package/dist/types/packages/database/constants.d.ts +1 -0
  64. package/dist/types/packages/database/errors/index.d.ts +1 -0
  65. package/dist/types/packages/database/errors/invalid-driver-error.d.ts +1 -3
  66. package/dist/types/packages/database/errors/migrations-pending-error.d.ts +1 -3
  67. package/dist/types/packages/database/errors/model-missing-error.d.ts +1 -3
  68. package/dist/types/packages/database/errors/relationship-config-error.d.ts +10 -0
  69. package/dist/types/packages/database/errors/unique-constraint-error.d.ts +1 -1
  70. package/dist/types/packages/database/index.d.ts +9 -6
  71. package/dist/types/packages/database/initialize.d.ts +3 -5
  72. package/dist/types/packages/database/interfaces.d.ts +115 -25
  73. package/dist/types/packages/database/migration/index.d.ts +5 -7
  74. package/dist/types/packages/database/migration/interfaces.d.ts +2 -4
  75. package/dist/types/packages/database/migration/utils/generate-timestamp.d.ts +9 -1
  76. package/dist/types/packages/database/model/index.d.ts +348 -759
  77. package/dist/types/packages/database/model/initialize-class.d.ts +7 -1
  78. package/dist/types/packages/database/model/interfaces.d.ts +30 -12
  79. package/dist/types/packages/database/model/utils/attribute.d.ts +14 -0
  80. package/dist/types/packages/database/model/utils/get-columns.d.ts +1 -3
  81. package/dist/types/packages/database/model/utils/persistence.d.ts +5 -14
  82. package/dist/types/packages/database/model/utils/process-write-error.d.ts +2 -2
  83. package/dist/types/packages/database/model/utils/run-hooks.d.ts +7 -3
  84. package/dist/types/packages/database/model/utils/validate.d.ts +4 -1
  85. package/dist/types/packages/database/query/errors/record-not-found-error.d.ts +1 -1
  86. package/dist/types/packages/database/query/index.d.ts +179 -3
  87. package/dist/types/packages/database/query/runner/index.d.ts +1 -3
  88. package/dist/types/packages/database/query/runner/utils/build-results.d.ts +3 -4
  89. package/dist/types/packages/database/query/utils/format-select.d.ts +1 -3
  90. package/dist/types/packages/database/relationship/index.d.ts +7 -6
  91. package/dist/types/packages/database/relationship/interfaces.d.ts +16 -3
  92. package/dist/types/packages/database/relationship/utils/getters.d.ts +7 -13
  93. package/dist/types/packages/database/relationship/utils/inverse-setters.d.ts +5 -9
  94. package/dist/types/packages/database/relationship/utils/setters.d.ts +7 -13
  95. package/dist/types/packages/database/relationship/utils/unassociate.d.ts +1 -3
  96. package/dist/types/packages/database/relationship/utils/update-relationship.d.ts +6 -2
  97. package/dist/types/packages/database/transaction/index.d.ts +9 -10
  98. package/dist/types/packages/database/transaction/interfaces.d.ts +7 -1
  99. package/dist/types/packages/database/utils/connect.d.ts +16 -3
  100. package/dist/types/packages/database/utils/create-migrations.d.ts +1 -3
  101. package/dist/types/packages/database/utils/normalize-model-name.d.ts +1 -3
  102. package/dist/types/packages/database/utils/pending-migrations.d.ts +1 -3
  103. package/dist/types/packages/database/utils/primary-key-type.d.ts +10 -0
  104. package/dist/types/packages/database/utils/type-for-column.d.ts +3 -5
  105. package/dist/types/packages/database/utils/validate-relationships.d.ts +13 -0
  106. package/dist/types/packages/database/validation/errors/validation-error.d.ts +4 -4
  107. package/dist/types/packages/database/validation/index.d.ts +3 -5
  108. package/dist/types/packages/database/validation/interfaces.d.ts +1 -1
  109. package/dist/types/packages/freezeable/map/index.d.ts +1 -3
  110. package/dist/types/packages/freezeable/set/index.d.ts +1 -3
  111. package/dist/types/packages/freezeable/utils/freeze.d.ts +5 -15
  112. package/dist/types/packages/freezeable/utils/is-frozen.d.ts +1 -3
  113. package/dist/types/packages/fs/index.d.ts +7 -7
  114. package/dist/types/packages/fs/interfaces.d.ts +4 -4
  115. package/dist/types/packages/fs/utils/parse-path.d.ts +2 -2
  116. package/dist/types/packages/fs/watcher/interfaces.d.ts +1 -1
  117. package/dist/types/packages/jsonapi/errors/invalid-content-type-error.d.ts +3 -5
  118. package/dist/types/packages/jsonapi/errors/not-acceptable-error.d.ts +2 -4
  119. package/dist/types/packages/jsonapi/errors/unsupported-media-type-error.d.ts +2 -4
  120. package/dist/types/packages/jsonapi/index.d.ts +1 -1
  121. package/dist/types/packages/jsonapi/interfaces.d.ts +47 -36
  122. package/dist/types/packages/jsonapi/utils/has-media-type-params.d.ts +1 -1
  123. package/dist/types/packages/jsonapi/utils/is-jsonapi.d.ts +1 -1
  124. package/dist/types/packages/jsonapi/utils/media-type.d.ts +2 -2
  125. package/dist/types/packages/loader/builder/index.d.ts +3 -3
  126. package/dist/types/packages/loader/builder/interfaces.d.ts +7 -7
  127. package/dist/types/packages/loader/builder/utils/create-children-builder.d.ts +2 -2
  128. package/dist/types/packages/loader/builder/utils/create-parent-builder.d.ts +9 -2
  129. package/dist/types/packages/loader/builder/utils/sort-by-namespace.d.ts +2 -2
  130. package/dist/types/packages/loader/index.d.ts +1 -1
  131. package/dist/types/packages/loader/interfaces.d.ts +2 -2
  132. package/dist/types/packages/loader/resolver/index.d.ts +2 -2
  133. package/dist/types/packages/loader/resolver/utils/closest-ancestor.d.ts +2 -2
  134. package/dist/types/packages/loader/resolver/utils/closest-child.d.ts +2 -2
  135. package/dist/types/packages/logger/constants.d.ts +3 -3
  136. package/dist/types/packages/logger/errors/invalid-config-error.d.ts +5 -0
  137. package/dist/types/packages/logger/index.d.ts +65 -142
  138. package/dist/types/packages/logger/interfaces.d.ts +52 -10
  139. package/dist/types/packages/logger/request-logger/index.d.ts +3 -5
  140. package/dist/types/packages/logger/request-logger/interfaces.d.ts +5 -5
  141. package/dist/types/packages/logger/request-logger/templates.d.ts +5 -9
  142. package/dist/types/packages/logger/request-logger/utils/filter-params.d.ts +6 -1
  143. package/dist/types/packages/logger/request-logger/utils/log-json.d.ts +2 -4
  144. package/dist/types/packages/logger/request-logger/utils/log-text.d.ts +1 -3
  145. package/dist/types/packages/logger/request-logger/utils/params-for.d.ts +9 -0
  146. package/dist/types/packages/logger/utils/error-name.d.ts +7 -0
  147. package/dist/types/packages/logger/utils/line.d.ts +1 -3
  148. package/dist/types/packages/logger/writer/constants.d.ts +0 -1
  149. package/dist/types/packages/logger/writer/index.d.ts +6 -6
  150. package/dist/types/packages/logger/writer/interfaces.d.ts +2 -2
  151. package/dist/types/packages/logger/writer/utils/format-message.d.ts +2 -2
  152. package/dist/types/packages/lumenify/index.d.ts +20 -5
  153. package/dist/types/packages/lumenify/utils/create-response-proxy.d.ts +1 -1
  154. package/dist/types/packages/pm/cluster/index.d.ts +56 -7
  155. package/dist/types/packages/pm/cluster/interfaces.d.ts +2 -1
  156. package/dist/types/packages/pm/index.d.ts +2 -2
  157. package/dist/types/packages/router/definitions/context/index.d.ts +5 -7
  158. package/dist/types/packages/router/definitions/context/utils/create-definition-group.d.ts +3 -5
  159. package/dist/types/packages/router/definitions/context/utils/create-definition.d.ts +11 -6
  160. package/dist/types/packages/router/definitions/context/utils/normalize-resource-args.d.ts +4 -5
  161. package/dist/types/packages/router/definitions/index.d.ts +5 -9
  162. package/dist/types/packages/router/definitions/interfaces.d.ts +4 -4
  163. package/dist/types/packages/router/index.d.ts +23 -11
  164. package/dist/types/packages/router/interfaces.d.ts +4 -4
  165. package/dist/types/packages/router/namespace/index.d.ts +7 -9
  166. package/dist/types/packages/router/namespace/interfaces.d.ts +3 -3
  167. package/dist/types/packages/router/namespace/utils/normalize-name.d.ts +1 -3
  168. package/dist/types/packages/router/namespace/utils/normalize-path.d.ts +1 -3
  169. package/dist/types/packages/router/resource/index.d.ts +7 -8
  170. package/dist/types/packages/router/resource/interfaces.d.ts +12 -4
  171. package/dist/types/packages/router/resource/utils/normalize-only.d.ts +3 -5
  172. package/dist/types/packages/router/route/action/enhancers/resource.d.ts +1 -3
  173. package/dist/types/packages/router/route/action/enhancers/track-perf.d.ts +1 -3
  174. package/dist/types/packages/router/route/action/index.d.ts +7 -2
  175. package/dist/types/packages/router/route/action/interfaces.d.ts +4 -0
  176. package/dist/types/packages/router/route/action/utils/create-page-links.d.ts +21 -5
  177. package/dist/types/packages/router/route/action/utils/get-action-name.d.ts +1 -3
  178. package/dist/types/packages/router/route/action/utils/get-controller-name.d.ts +1 -3
  179. package/dist/types/packages/router/route/index.d.ts +13 -9
  180. package/dist/types/packages/router/route/interfaces.d.ts +7 -5
  181. package/dist/types/packages/router/route/params/errors/client-generated-id-error.d.ts +4 -4
  182. package/dist/types/packages/router/route/params/errors/forbidden-parameter-error.d.ts +4 -4
  183. package/dist/types/packages/router/route/params/errors/index.d.ts +1 -0
  184. package/dist/types/packages/router/route/params/errors/invalid-parameter-error.d.ts +4 -6
  185. package/dist/types/packages/router/route/params/errors/parameter-not-nullable-error.d.ts +4 -6
  186. package/dist/types/packages/router/route/params/errors/parameter-range-error.d.ts +9 -0
  187. package/dist/types/packages/router/route/params/errors/parameter-required-error.d.ts +4 -6
  188. package/dist/types/packages/router/route/params/errors/parameter-type-error.d.ts +4 -6
  189. package/dist/types/packages/router/route/params/errors/parameter-value-error.d.ts +4 -6
  190. package/dist/types/packages/router/route/params/errors/resource-mismatch-error.d.ts +4 -6
  191. package/dist/types/packages/router/route/params/index.d.ts +5 -9
  192. package/dist/types/packages/router/route/params/interfaces.d.ts +12 -8
  193. package/dist/types/packages/router/route/params/parameter/forbidden-parameter.d.ts +1 -1
  194. package/dist/types/packages/router/route/params/parameter/ignored-parameter.d.ts +14 -0
  195. package/dist/types/packages/router/route/params/parameter/index.d.ts +21 -5
  196. package/dist/types/packages/router/route/params/parameter/interfaces.d.ts +2 -2
  197. package/dist/types/packages/router/route/params/parameter/utils/validate-range.d.ts +3 -0
  198. package/dist/types/packages/router/route/params/parameter/utils/validate-value.d.ts +1 -3
  199. package/dist/types/packages/router/route/params/parameter-group/index.d.ts +3 -5
  200. package/dist/types/packages/router/route/params/parameter-group/utils/missing-params.d.ts +8 -0
  201. package/dist/types/packages/router/route/params/utils/get-data-params.d.ts +5 -1
  202. package/dist/types/packages/router/route/params/utils/get-default-collection-params.d.ts +1 -3
  203. package/dist/types/packages/router/route/params/utils/get-default-member-params.d.ts +5 -2
  204. package/dist/types/packages/router/route/params/utils/get-query-params.d.ts +3 -9
  205. package/dist/types/packages/router/route/params/utils/get-url-params.d.ts +1 -3
  206. package/dist/types/packages/router/route/params/utils/parse-column-value.d.ts +16 -0
  207. package/dist/types/packages/router/route/params/utils/validate-client-id.d.ts +1 -1
  208. package/dist/types/packages/router/route/params/utils/validate-resource-id.d.ts +1 -3
  209. package/dist/types/packages/router/route/params/utils/validate-type.d.ts +3 -5
  210. package/dist/types/packages/router/route/utils/get-dynamic-segments.d.ts +1 -3
  211. package/dist/types/packages/router/route/utils/get-static-path.d.ts +6 -2
  212. package/dist/types/packages/router/utils/create-replacer.d.ts +10 -2
  213. package/dist/types/packages/serializer/index.d.ts +243 -434
  214. package/dist/types/packages/serializer/interfaces.d.ts +19 -1
  215. package/dist/types/packages/serializer/utils/include-tree.d.ts +12 -3
  216. package/dist/types/packages/serializer/utils/load-linkage.d.ts +9 -3
  217. package/dist/types/packages/server/errors/error-list.d.ts +25 -0
  218. package/dist/types/packages/server/errors/method-not-allowed-error.d.ts +11 -0
  219. package/dist/types/packages/server/index.d.ts +9 -9
  220. package/dist/types/packages/server/interfaces.d.ts +59 -7
  221. package/dist/types/packages/server/request/constants.d.ts +2 -2
  222. package/dist/types/packages/server/request/index.d.ts +3 -5
  223. package/dist/types/packages/server/request/interfaces.d.ts +72 -8
  224. package/dist/types/packages/server/request/parser/errors/malformed-request-error.d.ts +3 -5
  225. package/dist/types/packages/server/request/parser/index.d.ts +6 -1
  226. package/dist/types/packages/server/request/parser/utils/format.d.ts +13 -11
  227. package/dist/types/packages/server/request/parser/utils/normalize-document.d.ts +13 -0
  228. package/dist/types/packages/server/request/parser/utils/parse-nested-object.d.ts +1 -3
  229. package/dist/types/packages/server/request/parser/utils/parse-read.d.ts +2 -4
  230. package/dist/types/packages/server/request/parser/utils/parse-write.d.ts +17 -1
  231. package/dist/types/packages/server/request/utils/get-domain.d.ts +1 -3
  232. package/dist/types/packages/server/responder/index.d.ts +1 -3
  233. package/dist/types/packages/server/responder/utils/content-type-for.d.ts +8 -0
  234. package/dist/types/packages/server/responder/utils/data-for.d.ts +3 -5
  235. package/dist/types/packages/server/responder/utils/normalize.d.ts +2 -3
  236. package/dist/types/packages/server/response/index.d.ts +3 -5
  237. package/dist/types/packages/server/response/interfaces.d.ts +14 -3
  238. package/dist/types/packages/server/utils/client-ip-for.d.ts +10 -0
  239. package/dist/types/packages/server/utils/create-server-error.d.ts +11 -3
  240. package/dist/types/packages/server/utils/request-id-for.d.ts +9 -0
  241. package/dist/types/packages/server/utils/set-cors-headers.d.ts +2 -2
  242. package/dist/types/packages/server/utils/source-for.d.ts +19 -3
  243. package/dist/types/packages/server/utils/status-for-error.d.ts +6 -0
  244. package/dist/types/packages/server/utils/validate-accept.d.ts +1 -1
  245. package/dist/types/packages/server/utils/validate-content-type.d.ts +8 -3
  246. package/dist/types/packages/testing/audit-visibility.d.ts +189 -0
  247. package/dist/types/packages/testing/index.d.ts +4 -0
  248. package/dist/types/packages/testing/start-app.d.ts +52 -0
  249. package/dist/types/packages/testing/utils/identifiers-in.d.ts +14 -0
  250. package/dist/types/testing.d.ts +9 -0
  251. package/dist/types/utils/chalk.d.ts +16 -0
  252. package/dist/types/utils/pick.d.ts +2 -2
  253. package/package.json +54 -26
  254. package/dist/types/packages/cli/commands/test.d.ts +0 -4
  255. package/dist/types/packages/logger/utils/sql.d.ts +0 -4
  256. package/dist/types/packages/router/route/params/parameter-group/utils/has-required-params.d.ts +0 -5
  257. package/dist/types/utils/create-query-string.d.ts +0 -6
  258. package/dist/types/utils/has-own-property.d.ts +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/packages/testing/utils/identifiers-in.ts", "../src/packages/testing/audit-visibility.ts", "../src/packages/testing/start-app.ts"],
4
+ "sourcesContent": ["/** A resource's `type` and `id`. */\nexport type Identifier = { type: string; id: string };\n\ntype Linkage = Identifier | Array<Identifier> | null | undefined;\n\ntype Resource = Identifier & {\n relationships?: Record<string, { data?: Linkage }>;\n};\n\nconst isIdentifier = (value: unknown): value is Identifier =>\n typeof value === 'object' &&\n value !== null &&\n 'type' in value &&\n 'id' in value;\n\n/**\n * Every resource a JSON:API document names: its primary data, its `included`\n * resources, and the linkage of each one's relationships. A relationship\n * endpoint's primary data is linkage itself, so it is covered the same way.\n * Ids are strings, as JSON:API sends them.\n *\n * @internal\n */\nexport default function identifiersIn(document: unknown): Array<Identifier> {\n const found: Array<Identifier> = [];\n\n const add = (value: unknown) => {\n if (isIdentifier(value)) {\n found.push({ type: value.type, id: String(value.id) });\n }\n };\n\n const addLinkage = (linkage: Linkage) => {\n (Array.isArray(linkage) ? linkage : [linkage]).forEach(add);\n };\n\n const addResource = (resource: unknown) => {\n add(resource);\n\n if (isIdentifier(resource)) {\n Object.values((resource as Resource).relationships ?? {}).forEach(\n relationship => addLinkage(relationship?.data)\n );\n }\n };\n\n if (typeof document !== 'object' || document === null) {\n return found;\n }\n\n const { data, included } = document as {\n data?: unknown;\n included?: Array<unknown>;\n };\n\n (Array.isArray(data) ? data : [data]).forEach(addResource);\n (included ?? []).forEach(addResource);\n\n return found;\n}\n", "import type { AddressInfo } from 'net';\n\nimport type Application from '../application';\nimport type { Model } from '../database';\nimport type Route from '../router/route';\n\nimport identifiersIn from './utils/identifiers-in';\nimport type { Identifier } from './utils/identifiers-in';\n\n/**\n * Which records of one type a request may see, for {@link auditVisibility}:\n * every one (`true`), the ids listed, or the ids a function accepts.\n */\nexport type VisibleRecords =\n true | ReadonlyArray<string | number> | ((id: string) => boolean);\n\n/** The options of {@link auditVisibility}. */\nexport type AuditVisibilityOptions = {\n /**\n * The namespace to audit: `''` (the default) for the root, `'admin'` for\n * `/admin`. Nested namespaces are audited on their own.\n */\n namespace?: string;\n\n /**\n * What the request may see, keyed by type. Written by hand, independently\n * of the app's visibility rules: it is what they are checked against. A\n * type left out may not appear at all.\n */\n visible: Record<string, VisibleRecords>;\n\n /**\n * Headers sent with every request, such as the `Authorization` of the user\n * the audit is for.\n */\n headers?: Record<string, string>;\n\n /**\n * The ids to request each type's routes with (`GET /posts/:id`,\n * `/posts/:id/comments`, \u2026), keyed by type: visible and hidden ones\n * alike. A type left out is requested with every id in the database, so\n * keep the database small or list the ids.\n */\n ids?: Record<string, ReadonlyArray<string | number>>;\n\n /**\n * Query parameters a read requires, keyed by the type it serves: they are\n * sent with that type's list, its records by id, and every related\n * endpoint that serves it (`/posts/:id/comments` serves `comments`, and\n * takes the parameters of the comments' controller). Relationship\n * endpoints take none.\n *\n * ```javascript\n * query: { comments: { fromDate: '2026-01-01' } }\n * ```\n */\n query?: Record<string, Record<string, string>>;\n\n /**\n * Where the application is served, when not by `app` itself: a server\n * started as a separate process (`lumen serve`), such as\n * `'http://localhost:4000'`. `app` still provides the routes, the\n * include paths and the ids, so it must be booted in the test, but need\n * not listen.\n */\n origin?: string;\n\n /**\n * Called with each document a read answers with, for checks beyond which\n * records appear, such as the fields a request may see of each. Return a\n * message, or several, for each problem found: each is reported as a\n * violation of that request. May be async.\n *\n * ```javascript\n * onDocument({ document }) {\n * return document.included\n * ?.filter(({ type, attributes }) => type === 'users' && attributes.email)\n * .map(({ id }) => `users ${id} shows its email`);\n * }\n * ```\n */\n onDocument?: (\n response: AuditedDocument\n ) => DocumentCheckResult | Promise<DocumentCheckResult>;\n};\n\n/**\n * The read a request was made to, as the route defines it: so a check need\n * not parse the URL to know which record it is about.\n */\nexport type AuditedRoute = {\n /** The action, as hooks see it. */\n action: 'index' | 'show' | 'showRelationship' | 'showRelated';\n /**\n * The route's resource type: for a relationship or related endpoint, the\n * owner's (`posts` for `/posts/3/comments`).\n */\n type: string;\n /**\n * The id in the URL: the record of a `show`, the owner of a relationship\n * or related endpoint. None for a list.\n */\n id?: string;\n /** The relationship of a relationship or related endpoint (`comments`). */\n relationship?: string;\n};\n\n/** A document a read answered with, for `onDocument`. */\nexport type AuditedDocument = {\n /** The request, as a path and query string. */\n url: string;\n /** Its status. */\n status: number;\n /** The read the request was made to. */\n route: AuditedRoute;\n /** The parsed JSON:API document. */\n document: Record<string, unknown>;\n};\n\n/**\n * What `onDocument` returns: a message for each problem found, or nothing\n * when there is none.\n */\nexport type DocumentCheckResult =\n string | ReadonlyArray<string> | null | undefined | void;\n\n/**\n * A record a response contained that the audit's `visible` does not allow; a\n * relationship or related endpoint that answered for an owner `visible` does\n * not allow; a request that failed with an error other than `401`, `403` or\n * `404`, so that what it serves could not be checked; or a problem\n * `onDocument` found.\n */\nexport type VisibilityViolation = {\n /** The request, as a path and query string. */\n url: string;\n /** Its status. */\n status: number;\n /**\n * The record's type, if the violation is a record: one the response named,\n * or the hidden owner an endpoint answered for.\n */\n type?: string;\n /** The record's id, if the violation is a record. */\n id?: string;\n /**\n * What is wrong, for a hidden owner an endpoint answered for and for what\n * `onDocument` found.\n */\n message?: string;\n};\n\n/** What {@link auditVisibility} found. */\nexport type VisibilityAudit = {\n /** Every request made, as a path and query string. */\n requests: Array<string>;\n /** What should not have been in a response, in request order. */\n violations: Array<VisibilityViolation>;\n /**\n * Every record the responses named, keyed by type: as primary data,\n * included or as linkage, allowed or not, each id once. Compare it with\n * what the request should see to check that the audit reached it all.\n */\n seen: Record<string, Array<string>>;\n};\n\n// The built-in reads; custom routes take parameters the audit cannot know.\nconst READS = new Set(['index', 'show', 'showRelationship', 'showRelated']);\n\n// Statuses that reveal nothing: the request may not read, or there is nothing\n// it may see. Any other error means the read went unchecked.\nconst DENIED = new Set([401, 403, 404]);\n\n// Bounds the `links.next` chain of a single list, should one never end.\nconst MAX_PAGES = 1000;\n\n/** Where `app` itself is listening, if it is. */\nfunction originOf(app: Application): string {\n const address = app.server.instance.address() as AddressInfo | null;\n\n if (!address) {\n throw new Error(\n 'auditVisibility: the application is not listening. Start it ' +\n '(`startApp()`), or pass the `origin` of the server to audit.'\n );\n }\n\n return `http://localhost:${address.port}`;\n}\n\nfunction allows(visible: VisibleRecords | undefined, id: string): boolean {\n if (visible === true) {\n return true;\n }\n\n if (typeof visible === 'function') {\n return visible(id);\n }\n\n return Boolean(visible?.some(allowed => String(allowed) === id));\n}\n\n/**\n * The `include` values to request a route with: none, and every path it\n * accepts at once. A compound document holds what each path reaches, so one\n * request covers them all; a path that leads on to a longer one\n * (`comments` to `comments.user`) adds nothing and is left out. A\n * relationship endpoint (linkage only) accepts none.\n */\nfunction includesOf(route: Route): Array<string | undefined> {\n const include = route.params.get('include') as Set<string> | undefined;\n const paths = include ? Array.from(include) : [];\n const longest = paths.filter(\n path => !paths.some(other => other.startsWith(`${path}.`))\n );\n\n return longest.length ? [undefined, longest.join(',')] : [undefined];\n}\n\n/**\n * Request every read a namespace serves \u2014 each list, each record by id, each\n * relationship and related endpoint, without `include` and with every path\n * it accepts, following every page \u2014 and report each record in a response that\n * `visible` does not allow: in `data`, in `included`, or in any\n * relationship's linkage. A relationship or related endpoint that answers\n * for an owner `visible` does not allow is reported too, whatever it\n * answers with: that it answers reveals the owner. A `401`, `403` or `404`\n * (for a hidden record) reveals nothing and passes; any other error is\n * reported, since the read it answers went unchecked.\n *\n * Visibility rules apply to every one of these paths, but scoping in an\n * `index` or `show` override, or in a hook keyed on the action, does not.\n * This checks the result rather than the mechanism, against a list written\n * by hand:\n *\n * ```javascript\n * import { auditVisibility } from 'lumen-framework/testing';\n *\n * it('shows a member only public posts and their comments', async () => {\n * const { violations } = await auditVisibility(app, {\n * namespace: 'members',\n * headers: { Authorization: `Bearer ${memberToken}` },\n * visible: {\n * posts: [publicPost.id],\n * comments: [commentOnPublicPost.id],\n * users: true\n * }\n * });\n *\n * expect(violations).toEqual([]);\n * });\n * ```\n *\n * Requests are made one at a time, to `app` itself (which must then be\n * listening, as {@link startApp} leaves it) or to `origin`. Custom routes are\n * not requested. Each route is requested once per\n * id (and per page), so run it against a small fixture database, or narrow\n * the ids with `ids`.\n *\n * @param app - The application, listening.\n * @param options - What to audit, and what the request may see.\n * @returns Every request made, every violation found, and every record\n * seen.\n * @throws When the namespace serves no reads, so a mistyped namespace cannot\n * pass by checking nothing.\n */\nexport default async function auditVisibility(\n app: Application,\n {\n namespace = '',\n visible,\n headers = {},\n ids = {},\n query: required = {},\n origin = originOf(app),\n onDocument\n }: AuditVisibilityOptions\n): Promise<VisibilityAudit> {\n const audit: VisibilityAudit = { requests: [], violations: [], seen: {} };\n const seen = new Map<string, Set<string>>();\n\n const routes = Array.from(app.router.values()).filter(\n route =>\n route.method === 'GET' &&\n READS.has(route.action) &&\n route.controller.namespace === namespace\n );\n\n if (!routes.length) {\n throw new Error(\n `auditVisibility: namespace '/${namespace}' serves no index, show, ` +\n 'relationship or related routes.'\n );\n }\n\n // A link as a path and query string, which the audit reports.\n const relative = (link: string) => {\n const { pathname, search } = new URL(link, origin);\n\n return pathname + search;\n };\n\n const idsCache = new Map<string, Array<string>>();\n\n const idsOf = async (route: Route): Promise<Array<string>> => {\n const { model } = route.controller;\n const type = model.resourceName;\n let list = idsCache.get(type);\n\n if (!list) {\n const given = ids[type];\n\n list = given\n ? given.map(String)\n : (\n (await model.select(model.primaryKey)) as unknown as Array<Model>\n ).map(record => String(record.getPrimaryKey()));\n\n idsCache.set(type, list);\n }\n\n return list;\n };\n\n const check = (url: string, status: number, found: Array<Identifier>) => {\n found.forEach(({ type, id }) => {\n if (!seen.has(type)) {\n seen.set(type, new Set());\n }\n\n seen.get(type)?.add(id);\n\n if (!allows(visible[type], id)) {\n audit.violations.push({ url, status, type, id });\n }\n });\n };\n\n // One request, and the pages after it.\n const read = async (first: string, route: AuditedRoute) => {\n let url: string | undefined = first;\n\n // A relationship or related endpoint whose owner the request may not\n // see. Answering at all, whatever it answers with, tells the client the\n // owner exists, and what it is linked to: the owner is in the URL, not\n // in the response, so `check()` cannot catch it.\n const hiddenOwner =\n route.action.startsWith('showRel') &&\n route.id !== undefined &&\n !allows(visible[route.type], route.id);\n\n for (let page = 0; url && page < MAX_PAGES; page += 1) {\n audit.requests.push(url);\n\n const res: globalThis.Response = await fetch(origin + url, {\n headers: { Accept: 'application/vnd.api+json', ...headers }\n });\n\n if (!res.ok && !DENIED.has(res.status)) {\n audit.violations.push({ url, status: res.status });\n await res.body?.cancel();\n return;\n }\n\n if (res.ok && hiddenOwner && page === 0) {\n audit.violations.push({\n url,\n status: res.status,\n type: route.type,\n id: route.id,\n message:\n `answered for ${route.type} ${route.id}, which the request ` +\n 'may not see'\n });\n }\n\n // An override may answer with something other than a document (a\n // string is `text/plain`); only a JSON body can name records.\n if (!res.ok || !res.headers.get('content-type')?.includes('json')) {\n await res.body?.cancel();\n return;\n }\n\n const document = (await res.json()) as {\n links?: { next?: unknown };\n } | null;\n\n check(url, res.status, identifiersIn(document));\n\n if (onDocument && document) {\n const found = await onDocument({\n url,\n status: res.status,\n route,\n document: document as Record<string, unknown>\n });\n const messages =\n typeof found === 'string' ? [found] : Array.from(found ?? []);\n\n const at = { url, status: res.status };\n\n messages.forEach(message => {\n audit.violations.push({ ...at, message });\n });\n }\n\n const next: unknown = document?.links?.next;\n\n url = typeof next === 'string' ? relative(next) : undefined;\n }\n };\n\n for (const route of routes) {\n const paged = route.params.get('page')\n ? (route.related ?? route.controller).maxPerPage\n : undefined;\n\n // The type the route's records are of: none for a relationship\n // endpoint, which answers with linkage and takes no parameters.\n const served =\n route.type === 'relationship'\n ? undefined\n : (route.related ?? route.controller).model.resourceName;\n\n const query = (include: string | undefined) => {\n const params = new URLSearchParams(served ? required[served] : {});\n\n if (include) {\n params.set('include', include);\n }\n\n if (paged) {\n params.set('page[size]', String(paged));\n }\n\n const search = params.toString();\n\n return search ? `?${search}` : '';\n };\n\n const about = {\n action: route.action as AuditedRoute['action'],\n type: route.controller.model.resourceName,\n ...(route.relationship ? { relationship: route.relationship } : {})\n };\n\n const targets: Array<[string, AuditedRoute]> = route.dynamicSegments.length\n ? (await idsOf(route)).map(id => [\n route.path.replace(':id', encodeURIComponent(id)),\n { ...about, id }\n ])\n : [[route.path, about]];\n\n for (const [path, target] of targets) {\n for (const include of includesOf(route)) {\n await read(path + query(include), target);\n }\n }\n }\n\n seen.forEach((list, type) => {\n audit.seen[type] = Array.from(list);\n });\n\n return audit;\n}\n", "import { once } from 'events';\nimport { createRequire } from 'module';\nimport { resolve as resolvePath, join as joinPath } from 'path';\nimport type { AddressInfo } from 'net';\n\nimport type Application from '../application';\n\n/** The options of {@link startApp}. */\nexport type StartAppOptions = {\n /**\n * The environment to boot in: which `config/environments/*.js` and which\n * entry of `config/database.js` apply. Sets `NODE_ENV` when given, and\n * defaults it to `'test'` when unset, until `close()` restores it.\n */\n env?: string;\n\n /** The port to listen on. `0`, the default, takes a free one. */\n port?: number;\n};\n\n/** An application {@link startApp} booted. */\nexport type StartedApp = {\n /** The application, for {@link auditVisibility} and the models. */\n app: Application;\n /** Where it listens, such as `'http://localhost:53017'`. */\n origin: string;\n /**\n * Stops the server, closes the database connections, and restores\n * `NODE_ENV` to what it was before `startApp()`.\n */\n close: () => Promise<void>;\n};\n\ntype Bundle = {\n Application: new (options: Record<string, unknown>) => Promise<Application>;\n config: Record<string, unknown>;\n database: Record<string, unknown>;\n};\n\n// The bundles booting or booted in this process. Booting sets up an app's\n// model classes, which happens once per process: a second boot of the same\n// bundle fails. A failed boot is removed again, so a retry reports its own\n// error rather than \"already started\".\nconst started = new Set<string>();\n\n// The first error each bundle failed to boot with: a failed boot can leave the\n// app half set up, so a retry may fail on that rather than on the cause.\nconst failed = new Map<string, unknown>();\n\nconst messageOf = (error: unknown) =>\n error instanceof Error ? error.message : String(error);\n\n/**\n * Boot the app at `path` in the test's own process, from its compiled\n * bundle (`dist/bundle.js`), and listen on a free port.\n *\n * ```javascript\n * import { startApp } from 'lumen-framework/testing';\n *\n * let app, origin, close;\n *\n * beforeAll(async () => {\n * ({ app, origin, close } = await startApp(process.cwd()));\n * });\n *\n * afterAll(() => close());\n * ```\n *\n * The bundle must be compiled for the environment first, as `lumen build`\n * and the `lumen db:*` commands do. Its model classes are set up once per\n * process, so start an app once and share it between test files; starting\n * the same one again throws. `NODE_ENV` holds the app's environment until\n * `close()`.\n *\n * @param path - The app's root directory.\n * @param options - The environment and port.\n * @returns The application, where it listens, and how to stop it.\n * @throws When the app at `path` was already started in this process.\n */\nexport default async function startApp(\n path: string,\n { env, port = 0 }: StartAppOptions = {}\n): Promise<StartedApp> {\n const root = resolvePath(path);\n const bundlePath = joinPath(root, 'dist', 'bundle.js');\n\n if (started.has(bundlePath)) {\n throw new Error(\n `startApp: ${root} was already started in this process. Its models ` +\n 'are set up once per process: start it once and share it.'\n );\n }\n\n // Read when the bundle loads, which is why it is set first. It stays set\n // while the app runs: the app reads it again per request (whether a 500\n // shows its message).\n const previous = process.env.NODE_ENV;\n const restoreEnv = () => {\n if (previous === undefined) {\n delete process.env.NODE_ENV;\n } else {\n process.env.NODE_ENV = previous;\n }\n };\n\n process.env.NODE_ENV = env ?? previous ?? 'test';\n started.add(bundlePath);\n\n let app: Application;\n\n try {\n // The app's bundle, resolved at runtime: not a module of the framework.\n const {\n Application: App,\n config,\n database\n } = createRequire(bundlePath)(bundlePath) as Bundle;\n\n app = await new App({ ...config, database, path: root, port });\n\n if (!app.server.instance.listening) {\n await once(app.server.instance, 'listening');\n }\n } catch (error) {\n started.delete(bundlePath);\n restoreEnv();\n\n const earlier = failed.get(bundlePath);\n\n if (failed.has(bundlePath)) {\n throw new Error(\n `startApp: booting ${root} failed: ${messageOf(error)}. An earlier ` +\n `attempt in this process failed first, with: ${messageOf(earlier)}. ` +\n 'A failed boot can leave the app half set up: fix that one first.',\n { cause: error }\n );\n }\n\n failed.set(bundlePath, error);\n throw error;\n }\n\n const { port: listening } = app.server.instance.address() as AddressInfo;\n\n return {\n app,\n origin: `http://localhost:${listening}`,\n close: async () => {\n try {\n await app.close();\n } finally {\n restoreEnv();\n }\n }\n };\n}\n"],
5
+ "mappings": ";AASA,IAAM,eAAe,CAAC,UACpB,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,QAAQ;AAUK,SAAR,cAA+B,UAAsC;AAC1E,QAAM,QAA2B,CAAC;AAElC,QAAM,MAAM,CAAC,UAAmB;AAC9B,QAAI,aAAa,KAAK,GAAG;AACvB,YAAM,KAAK,EAAE,MAAM,MAAM,MAAM,IAAI,OAAO,MAAM,EAAE,EAAE,CAAC;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,aAAa,CAAC,YAAqB;AACvC,KAAC,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,GAAG,QAAQ,GA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Y;AAC1C,UAAQ,IAAI,UAAU;AAEtB,MAAI;AAEJ,MAAI;AAEF,UAAM;AAAA,MACJ,aAAa;AAAA,MACb;AAAA,MACA;AAAA,IACF,IAAI,cAAc,UAAU,EAAE,UAAU;AAExC,UAAM,MAAM,IAAI,IAAI,EAAE,GAAG,QAAQ,UAAU,MAAM,MAAM,KAAK,CAAC;AAE7D,QAAI,CAAC,IAAI,OAAO,SAAS,WAAW;AAClC,YAAM,KAAK,IAAI,OAAO,UAAU,WAAW;AAAA,IAC7C;AAAA,EACF,SAAS,OAAO;AACd,YAAQ,OAAO,UAAU;AACzB,eAAW;AAEX,UAAM,UAAU,OAAO,IAAI,UAAU;AAErC,QAAI,OAAO,IAAI,UAAU,GAAG;AAC1B,YAAM,IAAI;AAAA,QACR,qBAAqB,IAAI,YAAY,UAAU,KAAK,CAAC,4DACJ,UAAU,OAAO,CAAC;AAAA,QAEnE,EAAE,OAAO,MAAM;AAAA,MACjB;AAAA,IACF;AAEA,WAAO,IAAI,YAAY,KAAK;AAC5B,UAAM;AAAA,EACR;AAEA,QAAM,EAAE,MAAM,UAAU,IAAI,IAAI,OAAO,SAAS,QAAQ;AAExD,SAAO;AAAA,IACL;AAAA,IACA,QAAQ,oBAAoB,SAAS;AAAA,IACrC,OAAO,YAAY;AACjB,UAAI;AACF,cAAM,IAAI,MAAM;AAAA,MAClB,UAAE;AACA,mBAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Thrown at boot when a Serializer's `linksOnly` names a relationship it
3
+ * cannot serialize as links only.
4
+ *
5
+ * @private
6
+ */
7
+ declare class LinksOnlyError extends TypeError {
8
+ /**
9
+ * @param problems - One line per relationship, saying what is wrong.
10
+ */
11
+ constructor(problems: Array<string>);
12
+ }
13
+ export default LinksOnlyError;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Thrown at boot when a serializer lists a field named `type` or `id`, which
3
+ * JSON:API forbids, without `allowReservedNames`.
4
+ *
5
+ * @internal
6
+ */
7
+ declare class ReservedFieldNameError extends TypeError {
8
+ /**
9
+ * @param problems - One line per name, saying where it is listed.
10
+ */
11
+ constructor(problems: Array<string>);
12
+ }
13
+ export default ReservedFieldNameError;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Thrown at boot when a serializer's `attributes`, or a controller's `sort`
3
+ * or `filter`, names something that is not a column of the model's table.
4
+ *
5
+ * @internal
6
+ */
7
+ declare class UnknownAttributeError extends TypeError {
8
+ /**
9
+ * @param problems - One line per name, saying where it is listed.
10
+ */
11
+ constructor(problems: Array<string>);
12
+ }
13
+ export default UnknownAttributeError;
@@ -1,6 +1,20 @@
1
+ /**
2
+ * The framework: what an app's models, controllers, serializers and
3
+ * application extend. Test helpers live in `lumen-framework/testing`.
4
+ *
5
+ * @module lumen-framework
6
+ */
1
7
  export { Model } from './packages/database';
2
8
  export { default as Logger } from './packages/logger';
3
9
  export { default as Controller } from './packages/controller';
4
10
  export { default as Serializer } from './packages/serializer';
5
11
  export { default as Application } from './packages/application';
6
12
  export { default as lumenify } from './packages/lumenify';
13
+ export type { ApplicationOptions } from './packages/application';
14
+ export type { Config } from './packages/config';
15
+ export type { AfterAction, BeforeAction, ControllerOptions, Visibility } from './packages/controller';
16
+ export type { DatabaseConfig, DatabaseEnvironmentConfig, DatabasePoolConfig, ModelClass, ModelHook, ModelHooks, Query, RelationshipOptions, TransactionResult } from './packages/database';
17
+ export type { LogFilter, LogFormat, LogFunction, LoggerConfig, LogLevel } from './packages/logger';
18
+ export type { Action } from './packages/router';
19
+ export type { SerializerOptions } from './packages/serializer';
20
+ export type { CorsConfig, Request, RequestMethod, RequestParams, Response, ServerConfig } from './packages/server';
@@ -1,4 +1,4 @@
1
- export interface Lumen$Collection<T> {
1
+ export interface LumenCollection<T> {
2
2
  size: number;
3
3
  has(key: T): boolean;
4
4
  clear(): void;
@@ -6,92 +6,85 @@ import type Serializer from '../serializer';
6
6
  import type Database from '../database';
7
7
  import type { Model, ModelClass } from '../database';
8
8
  import type { FreezeableMap } from '../freezeable';
9
- import type { Application$opts } from './interfaces';
9
+ import type { ApplicationOptions } from './interfaces';
10
10
  /**
11
- * @class Application
12
- * @public
11
+ * A running Lumen app: its models, controllers, serializers, routes and HTTP
12
+ * server. `app/index.js` exports a subclass, usually empty:
13
+ *
14
+ * ```javascript
15
+ * import { Application } from 'lumen-framework';
16
+ *
17
+ * class Blog extends Application {}
18
+ *
19
+ * export default Blog;
20
+ * ```
21
+ *
22
+ * `lumen serve` builds the app and constructs it; constructing one resolves
23
+ * once the database is connected, every module is loaded and the server is
24
+ * listening.
13
25
  */
14
26
  declare class Application {
15
- /**
16
- * The path of `Application` instance.
17
- *
18
- * @property path
19
- * @type {String}
20
- * @public
21
- */
27
+ /** The app's root directory. */
22
28
  path: string;
23
- /**
24
- * The port that an `Application` instance is listening for incomming HTTP
25
- * requests.
26
- *
27
- * @property port
28
- * @type {Number}
29
- * @public
30
- */
29
+ /** The port the app listens on. */
31
30
  port: number;
32
31
  /**
33
32
  * A reference to the `Database` instance.
34
33
  *
35
- * @property store
36
- * @type {Database}
37
- * @private
34
+ * @internal
38
35
  */
39
36
  store: Database;
40
37
  /**
41
38
  * A reference to the `Logger` instance.
42
39
  *
43
- * @property logger
44
- * @type {Logger}
45
- * @private
40
+ * @internal
46
41
  */
47
42
  logger: Logger;
48
43
  /**
49
44
  * A reference to the `Router` instance.
50
45
  *
51
- * @property router
52
- * @type {Router}
53
- * @private
46
+ * @internal
54
47
  */
55
48
  router: Router;
56
49
  /**
57
50
  * A reference to the `Server` instance.
58
51
  *
59
- * @property server
60
- * @type {Server}
61
- * @private
52
+ * @internal
62
53
  */
63
54
  server: Server;
64
55
  /**
65
56
  * A map containing each `Model` class.
66
57
  *
67
- * @property models
68
- * @type {Map}
69
- * @private
58
+ * @internal
70
59
  */
71
60
  models: FreezeableMap<string, ModelClass>;
72
61
  /**
73
62
  * A map containing each `Controller` instance.
74
63
  *
75
- * @property controllers
76
- * @type {Map}
77
- * @private
64
+ * @internal
78
65
  */
79
66
  controllers: FreezeableMap<string, Controller>;
80
67
  /**
81
68
  * A map containing each `Serializer` instance.
82
69
  *
83
- * @property serializers
84
- * @type {Map}
85
- * @private
70
+ * @internal
86
71
  */
87
72
  serializers: FreezeableMap<string, Serializer<Model>>;
88
73
  /**
89
- * @method constructor
90
- * @param {Object} config
91
- * @return {Promise}
92
- * @public
74
+ * Boot the app. Resolves with the ready instance, though TypeScript types
75
+ * it as the instance itself; `await` it.
76
+ */
77
+ constructor(opts: ApplicationOptions);
78
+ /**
79
+ * Stop the application gracefully: the server stops accepting connections
80
+ * and closes idle ones, the requests in flight finish, and then the
81
+ * database connections close. Resolves once all of that is done.
82
+ *
83
+ * `lumen serve` calls it in each worker when the process is asked to stop
84
+ * (`SIGTERM`, `SIGINT`); call it yourself when you construct an
85
+ * application in a script or a test.
93
86
  */
94
- constructor(opts: Application$opts);
87
+ close(): Promise<void>;
95
88
  }
96
89
  export default Application;
97
- export type { Application$opts, Application$Class, Application$factoryOpts } from './interfaces';
90
+ export type { ApplicationOptions, ApplicationClass, ApplicationFactoryOptions } from './interfaces';
@@ -1,6 +1,4 @@
1
1
  import type Application from './index';
2
- import type { Application$opts } from './index';
3
- /**
4
- * @private
5
- */
6
- export default function initialize<T extends Application>(app: T, { path, port, logging, database, server: serverConfig }: Application$opts): Promise<T>;
2
+ import type { ApplicationOptions } from './index';
3
+ /** @internal */
4
+ export default function initialize<T extends Application>(app: T, { path, port, logging, database, server: serverConfig }: ApplicationOptions): Promise<T>;
@@ -1,15 +1,23 @@
1
1
  import type { Config } from '../config';
2
2
  import type Database from '../database';
3
- import type { Database$config, Model } from '../database';
3
+ import type { DatabaseConfig, Model } from '../database';
4
4
  import type Controller from '../controller';
5
5
  import type Serializer from '../serializer';
6
- export type Application$opts = Config & {
6
+ /**
7
+ * What an {@link Application} is constructed with: the environment's
8
+ * {@link Config}, plus where the app is and how to reach its database. The
9
+ * app's generated boot code passes these; apps don't build them by hand.
10
+ */
11
+ export type ApplicationOptions = Config & {
12
+ /** The app's root directory. */
7
13
  path: string;
14
+ /** The port to listen on. */
8
15
  port: string | number;
9
- database: Database$config;
16
+ /** The contents of `config/database.js`. */
17
+ database: DatabaseConfig;
10
18
  };
11
- export type Application$Class<T> = new (...args: Array<any>) => T;
12
- export type Application$factoryOpts<T extends Controller | Serializer<Model>> = {
19
+ export type ApplicationClass<T> = new (...args: Array<any>) => T;
20
+ export type ApplicationFactoryOptions<T extends Controller | Serializer<Model>> = {
13
21
  key: string;
14
22
  store: Database;
15
23
  parent?: T | null;
@@ -1,12 +1,22 @@
1
1
  import type Database from '../../database';
2
2
  import type { Model } from '../../database';
3
+ import { NAMESPACE_SETTINGS } from '../../controller';
3
4
  import type Controller from '../../controller';
4
5
  import type Serializer from '../../serializer';
5
- import type { Bundle$Namespace } from '../../loader';
6
- import type { Application$Class } from '../index';
7
- export default function createController<T extends Controller>(constructor: Application$Class<T>, opts: {
6
+ import type { BundleNamespace } from '../../loader';
7
+ import type { ApplicationClass } from '../index';
8
+ type NamespaceSetting = (typeof NAMESPACE_SETTINGS)[number];
9
+ /**
10
+ * Whether `controller`, or the `ApplicationController` of a namespace it is
11
+ * in, sets `setting` itself rather than leaving it at the default.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare function setsItself(controller: Controller, setting: NamespaceSetting): boolean;
16
+ export default function createController<T extends Controller>(constructor: ApplicationClass<T>, opts: {
8
17
  key: string;
9
18
  store: Database;
10
19
  parent?: Controller | null;
11
- serializers: Bundle$Namespace<Serializer<Model>>;
20
+ serializers: BundleNamespace<Serializer<Model>>;
12
21
  }): T;
22
+ export {};
@@ -1,4 +1,4 @@
1
1
  import type Serializer from '../../serializer';
2
2
  import type { Model } from '../../database';
3
- import type { Application$Class, Application$factoryOpts } from '../index';
4
- export default function createSerializer<T extends Serializer<Model>>(constructor: Application$Class<T>, opts: Application$factoryOpts<T>): T;
3
+ import type { ApplicationClass, ApplicationFactoryOptions } from '../index';
4
+ export default function createSerializer<T extends Serializer<Model>>(constructor: ApplicationClass<T>, opts: ApplicationFactoryOptions<T>): T;
@@ -1,4 +1,2 @@
1
- /**
2
- * @private
3
- */
1
+ /** @internal */
4
2
  export default function normalizePort(port?: string | number): number;
@@ -0,0 +1,15 @@
1
+ import Controller from '../../controller';
2
+ import type { ModelClass } from '../../database';
3
+ import type { BundleNamespace } from '../../loader';
4
+ /**
5
+ * Give every controller the visibility rules of its namespace — the
6
+ * `static visibility` of the namespace's `ApplicationController`, or, when it
7
+ * has none or declares none, the closest ancestor namespace's — and whether
8
+ * any were declared (`hasVisibilityRules`), and refuse to boot on rules that
9
+ * cannot be applied: rules declared on any other controller (a rule must hold for the
10
+ * whole namespace, since types are included across controllers), rules for a
11
+ * type that has no model, and rules that are not functions.
12
+ *
13
+ * @internal
14
+ */
15
+ export default function resolveVisibility(controllers: BundleNamespace<Controller> | Map<string, Controller>, models: Iterable<ModelClass>): void;
@@ -0,0 +1,19 @@
1
+ import type Logger from '../../logger';
2
+ import type Controller from '../../controller';
3
+ /**
4
+ * Give the controllers of a namespace without visibility rules — neither its
5
+ * own nor an ancestor's, run after `resolveVisibility()` — conservative
6
+ * defaults, and warn once per such namespace that serves records.
7
+ *
8
+ * Without rules, nothing scopes what a request reaches beyond its primary
9
+ * data: an `index` or `show` override, or a hook checking `request.action`,
10
+ * does not apply to included resources or to the relationship and related
11
+ * endpoints. So unless a controller (or its namespace) sets
12
+ * `maxIncludeDepth`, `?include=` is turned off (`0`); the router serves
13
+ * relationship endpoints only where a resource's `relationships` option asks
14
+ * for them. Declaring rules — `static visibility = {}` for a namespace that
15
+ * may see everything — lifts both.
16
+ *
17
+ * @internal
18
+ */
19
+ export default function restrictOpenNamespaces(controllers: Map<string, Controller>, logger: Logger): void;
@@ -0,0 +1,17 @@
1
+ import type Controller from '../../controller';
2
+ import type Serializer from '../../serializer';
3
+ import type { Model } from '../../database';
4
+ import type { BundleNamespace } from '../../loader';
5
+ /**
6
+ * Check that every serializer's `attributes`, and every controller's `sort`
7
+ * and `filter`, name columns of their model. Anything else used to be
8
+ * accepted and then silently ignored: missing from responses, and a `sort`
9
+ * or `filter` that did nothing. Throws listing every problem.
10
+ *
11
+ * A controller's `sort` and `filter` default to its serializer's
12
+ * `attributes`, so only names its serializer does not list are reported for
13
+ * the controller.
14
+ *
15
+ * @internal
16
+ */
17
+ export default function validateAttributes(controllers: BundleNamespace<Controller> | Map<string, Controller>, serializers: BundleNamespace<Serializer<Model>> | Map<string, Serializer<Model>>): void;
@@ -0,0 +1,19 @@
1
+ import type Router from '../../router';
2
+ import type Serializer from '../../serializer';
3
+ import type { Model } from '../../database';
4
+ import type { BundleNamespace } from '../../loader';
5
+ /**
6
+ * Check every Serializer's `linksOnly` against the built `router`: each
7
+ * relationship must be one of its `hasMany`, and have a related endpoint
8
+ * (`/posts/:id/comments`) in at least one namespace where the Serializer
9
+ * formats its type — else it could never be left without its linkage.
10
+ * Throws listing every problem.
11
+ *
12
+ * Whatever removes a related endpoint counts: no controller for the related
13
+ * type in the namespace, a related resource without `index`, an owning
14
+ * resource without `show` (or without the relationship in its
15
+ * `relationships`), or a custom route at that path.
16
+ *
17
+ * @internal
18
+ */
19
+ export default function validateLinksOnly(router: Router, serializers: BundleNamespace<Serializer<Model>> | Map<string, Serializer<Model>>): void;
@@ -1,7 +1,7 @@
1
1
  import type Controller from '../../controller';
2
2
  import type Serializer from '../../serializer';
3
3
  import type { Model } from '../../database';
4
- import type { Bundle$Namespace } from '../../loader';
4
+ import type { BundleNamespace } from '../../loader';
5
5
  /**
6
6
  * Enforce `serializerFallback = false`: for every namespace whose
7
7
  * ApplicationController sets it, each type its controllers can serialize — the
@@ -10,6 +10,6 @@ import type { Bundle$Namespace } from '../../loader';
10
10
  * Serializer in exactly that namespace. Throws listing every gap, so a missing
11
11
  * serializer fails the boot instead of silently falling back to the root one.
12
12
  *
13
- * @private
13
+ * @internal
14
14
  */
15
- export default function validateNamespacedSerializers(controllers: Bundle$Namespace<Controller> | Map<string, Controller>, serializers: Bundle$Namespace<Serializer<Model>> | Map<string, Serializer<Model>>): void;
15
+ export default function validateNamespacedSerializers(controllers: BundleNamespace<Controller> | Map<string, Controller>, serializers: BundleNamespace<Serializer<Model>> | Map<string, Serializer<Model>>): void;
@@ -0,0 +1,12 @@
1
+ import type Logger from '../../logger';
2
+ import type Serializer from '../../serializer';
3
+ import type { Model } from '../../database';
4
+ import type { BundleNamespace } from '../../loader';
5
+ /**
6
+ * Refuse to boot when a serializer's `attributes`, `hasOne` or `hasMany`
7
+ * names `type` or `id`, listing every one; warn instead for a serializer that
8
+ * sets `allowReservedNames`.
9
+ *
10
+ * @internal
11
+ */
12
+ export default function validateReservedNames(serializers: BundleNamespace<Serializer<Model>> | Map<string, Serializer<Model>>, logger: Logger): void;
@@ -0,0 +1,10 @@
1
+ import type Logger from '../../logger';
2
+ import type Controller from '../../controller';
3
+ /**
4
+ * Warn at boot about custom `query` parameters whose names the spec reserves
5
+ * for itself (all lowercase a-z, e.g. `search`). They keep working; a
6
+ * spec-aware client or a future version of the spec may not agree.
7
+ *
8
+ * @internal
9
+ */
10
+ export default function warnQueryParamNames(controllers: Map<string, Controller>, logger: Logger): void;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @private
3
3
  */
4
- export declare function dbcreate(): Promise<unknown>;
4
+ export declare function dbcreate(): Promise<void>;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @private
3
3
  */
4
- export declare function dbdrop(): Promise<unknown>;
4
+ export declare function dbdrop(): Promise<void> | Promise<boolean>;
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @private
3
3
  */
4
- export declare function destroyType(type: string, name: string): Promise<void>;
4
+ export declare function destroyType(type: string, name: string, cwd?: string): Promise<void>;
5
5
  /**
6
6
  * @private
7
7
  */
8
- export declare function destroy({ type, name }: {
8
+ export declare function destroy({ type, name, cwd }: {
9
9
  type: string;
10
10
  name: string;
11
+ cwd?: string;
11
12
  }): Promise<void>;
@@ -1,10 +1,10 @@
1
- import type { Generator$opts } from '../generator';
1
+ import type { GeneratorOptions } from '../generator';
2
2
  /**
3
3
  * @private
4
4
  */
5
5
  export declare function generate({ cwd, name, type, attrs }: {
6
- cwd?: Generator$opts['cwd'];
7
- name: Generator$opts['name'];
8
- type: Generator$opts['type'];
9
- attrs?: Generator$opts['attrs'];
6
+ cwd?: GeneratorOptions['cwd'];
7
+ name: GeneratorOptions['name'];
8
+ type: GeneratorOptions['type'];
9
+ attrs?: GeneratorOptions['attrs'];
10
10
  }): Promise<void>;
@@ -9,4 +9,3 @@ export { destroy } from './destroy';
9
9
  export { generate } from './generate';
10
10
  export { repl } from './repl';
11
11
  export { serve } from './serve';
12
- export { test } from './test';
@@ -1,11 +1,11 @@
1
- import type { Generator$opts } from './interfaces';
1
+ import type { GeneratorOptions } from './interfaces';
2
2
  /**
3
3
  * @private
4
4
  */
5
5
  export declare function runGenerator({ cwd, type, name, attrs }: {
6
- cwd: Generator$opts['cwd'];
7
- type: Generator$opts['type'];
8
- name: Generator$opts['name'];
9
- attrs: Generator$opts['attrs'];
6
+ cwd: GeneratorOptions['cwd'];
7
+ type: GeneratorOptions['type'];
8
+ name: GeneratorOptions['name'];
9
+ attrs: GeneratorOptions['attrs'];
10
10
  }): Promise<void>;
11
- export type { Generator, Generator$opts, Generator$template } from './interfaces';
11
+ export type { Generator, GeneratorOptions, GeneratorTemplate } from './interfaces';
@@ -1,9 +1,9 @@
1
- export type Generator$opts = {
1
+ export type GeneratorOptions = {
2
2
  cwd: string;
3
3
  type: string;
4
4
  name: string;
5
5
  attrs: Array<string>;
6
6
  onConflict(text: string): Promise<string | boolean>;
7
7
  };
8
- export type Generator = (opts: Generator$opts) => Promise<void>;
9
- export type Generator$template = (name: string, attrs: Array<string>) => string;
8
+ export type Generator = (opts: GeneratorOptions) => Promise<void>;
9
+ export type GeneratorTemplate = (name: string, attrs: Array<string>) => string;
@@ -1,9 +1,9 @@
1
- import type { Generator, Generator$template } from '../index';
1
+ import type { Generator, GeneratorTemplate } from '../index';
2
2
  /**
3
3
  * @private
4
4
  */
5
5
  export default function createGenerator({ dir, template, hasConflict }: {
6
6
  dir: string;
7
- template: Generator$template;
7
+ template: GeneratorTemplate;
8
8
  hasConflict?: (path: string) => Promise<boolean>;
9
9
  }): Generator;
@@ -1,33 +1,33 @@
1
- import type { Generator$opts } from '../index';
1
+ import type { GeneratorOptions } from '../index';
2
2
  /**
3
3
  * @private
4
4
  */
5
- export declare function controller(opts: Generator$opts): Promise<void>;
5
+ export declare function controller(opts: GeneratorOptions): Promise<void>;
6
6
  /**
7
7
  * @private
8
8
  */
9
- export declare function serializer(opts: Generator$opts): Promise<void>;
9
+ export declare function serializer(opts: GeneratorOptions): Promise<void>;
10
10
  /**
11
11
  * @private
12
12
  */
13
- export declare function migration(opts: Generator$opts): Promise<void>;
13
+ export declare function migration(opts: GeneratorOptions): Promise<void>;
14
14
  /**
15
15
  * @private
16
16
  */
17
- export declare function modelMigration(opts: Generator$opts): Promise<void>;
17
+ export declare function modelMigration(opts: GeneratorOptions): Promise<void>;
18
18
  /**
19
19
  * @private
20
20
  */
21
- export declare function model(opts: Generator$opts): Promise<void>;
21
+ export declare function model(opts: GeneratorOptions): Promise<void>;
22
22
  /**
23
23
  * @private
24
24
  */
25
- export declare function middleware(opts: Generator$opts): Promise<void>;
25
+ export declare function middleware(opts: GeneratorOptions): Promise<void>;
26
26
  /**
27
27
  * @private
28
28
  */
29
- export declare function util(opts: Generator$opts): Promise<void>;
29
+ export declare function util(opts: GeneratorOptions): Promise<void>;
30
30
  /**
31
31
  * @private
32
32
  */
33
- export declare function resource(opts: Generator$opts): Promise<void>;
33
+ export declare function resource(opts: GeneratorOptions): Promise<void>;