@byline/core 0.9.3

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 (283) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +17 -0
  3. package/dist/@types/admin-types.d.ts +275 -0
  4. package/dist/@types/admin-types.d.ts.map +1 -0
  5. package/dist/@types/admin-types.js +18 -0
  6. package/dist/@types/admin-types.js.map +1 -0
  7. package/dist/@types/collection-types.d.ts +816 -0
  8. package/dist/@types/collection-types.d.ts.map +1 -0
  9. package/dist/@types/collection-types.js +217 -0
  10. package/dist/@types/collection-types.js.map +1 -0
  11. package/dist/@types/db-types.d.ts +463 -0
  12. package/dist/@types/db-types.d.ts.map +1 -0
  13. package/dist/@types/db-types.js +2 -0
  14. package/dist/@types/db-types.js.map +1 -0
  15. package/dist/@types/field-data-types.d.ts +147 -0
  16. package/dist/@types/field-data-types.d.ts.map +1 -0
  17. package/dist/@types/field-data-types.js +38 -0
  18. package/dist/@types/field-data-types.js.map +1 -0
  19. package/dist/@types/field-types.d.ts +579 -0
  20. package/dist/@types/field-types.d.ts.map +1 -0
  21. package/dist/@types/field-types.js +32 -0
  22. package/dist/@types/field-types.js.map +1 -0
  23. package/dist/@types/index.d.ts +18 -0
  24. package/dist/@types/index.d.ts.map +1 -0
  25. package/dist/@types/index.js +18 -0
  26. package/dist/@types/index.js.map +1 -0
  27. package/dist/@types/populate-types.d.ts +54 -0
  28. package/dist/@types/populate-types.d.ts.map +1 -0
  29. package/dist/@types/populate-types.js +9 -0
  30. package/dist/@types/populate-types.js.map +1 -0
  31. package/dist/@types/query-predicate.d.ts +74 -0
  32. package/dist/@types/query-predicate.d.ts.map +1 -0
  33. package/dist/@types/query-predicate.js +9 -0
  34. package/dist/@types/query-predicate.js.map +1 -0
  35. package/dist/@types/site-config.d.ts +212 -0
  36. package/dist/@types/site-config.d.ts.map +1 -0
  37. package/dist/@types/site-config.js +9 -0
  38. package/dist/@types/site-config.js.map +1 -0
  39. package/dist/@types/storage-types.d.ts +86 -0
  40. package/dist/@types/storage-types.d.ts.map +1 -0
  41. package/dist/@types/storage-types.js +9 -0
  42. package/dist/@types/storage-types.js.map +1 -0
  43. package/dist/@types/store-types.d.ts +134 -0
  44. package/dist/@types/store-types.d.ts.map +1 -0
  45. package/dist/@types/store-types.js +24 -0
  46. package/dist/@types/store-types.js.map +1 -0
  47. package/dist/@types/type-utils.d.ts +17 -0
  48. package/dist/@types/type-utils.d.ts.map +1 -0
  49. package/dist/@types/type-utils.js +9 -0
  50. package/dist/@types/type-utils.js.map +1 -0
  51. package/dist/auth/apply-before-read.d.ts +36 -0
  52. package/dist/auth/apply-before-read.d.ts.map +1 -0
  53. package/dist/auth/apply-before-read.js +68 -0
  54. package/dist/auth/apply-before-read.js.map +1 -0
  55. package/dist/auth/apply-before-read.test.node.d.ts +9 -0
  56. package/dist/auth/apply-before-read.test.node.d.ts.map +1 -0
  57. package/dist/auth/apply-before-read.test.node.js +144 -0
  58. package/dist/auth/apply-before-read.test.node.js.map +1 -0
  59. package/dist/auth/assert-actor-can-perform.d.ts +39 -0
  60. package/dist/auth/assert-actor-can-perform.d.ts.map +1 -0
  61. package/dist/auth/assert-actor-can-perform.js +64 -0
  62. package/dist/auth/assert-actor-can-perform.js.map +1 -0
  63. package/dist/auth/assert-actor-can-perform.test.node.d.ts +9 -0
  64. package/dist/auth/assert-actor-can-perform.test.node.d.ts.map +1 -0
  65. package/dist/auth/assert-actor-can-perform.test.node.js +119 -0
  66. package/dist/auth/assert-actor-can-perform.test.node.js.map +1 -0
  67. package/dist/auth/index.d.ts +11 -0
  68. package/dist/auth/index.d.ts.map +1 -0
  69. package/dist/auth/index.js +11 -0
  70. package/dist/auth/index.js.map +1 -0
  71. package/dist/auth/register-collection-abilities.d.ts +40 -0
  72. package/dist/auth/register-collection-abilities.d.ts.map +1 -0
  73. package/dist/auth/register-collection-abilities.js +87 -0
  74. package/dist/auth/register-collection-abilities.js.map +1 -0
  75. package/dist/auth/register-collection-abilities.test.node.d.ts +9 -0
  76. package/dist/auth/register-collection-abilities.test.node.d.ts.map +1 -0
  77. package/dist/auth/register-collection-abilities.test.node.js +124 -0
  78. package/dist/auth/register-collection-abilities.test.node.js.map +1 -0
  79. package/dist/config/config.d.ts +10 -0
  80. package/dist/config/config.d.ts.map +1 -0
  81. package/dist/config/config.js +108 -0
  82. package/dist/config/config.js.map +1 -0
  83. package/dist/config/routes.d.ts +16 -0
  84. package/dist/config/routes.d.ts.map +1 -0
  85. package/dist/config/routes.js +26 -0
  86. package/dist/config/routes.js.map +1 -0
  87. package/dist/config/validate-admin-configs.d.ts +33 -0
  88. package/dist/config/validate-admin-configs.d.ts.map +1 -0
  89. package/dist/config/validate-admin-configs.js +250 -0
  90. package/dist/config/validate-admin-configs.js.map +1 -0
  91. package/dist/config/validate-admin-configs.test.node.d.ts +9 -0
  92. package/dist/config/validate-admin-configs.test.node.d.ts.map +1 -0
  93. package/dist/config/validate-admin-configs.test.node.js +224 -0
  94. package/dist/config/validate-admin-configs.test.node.js.map +1 -0
  95. package/dist/config/validate-collections.d.ts +33 -0
  96. package/dist/config/validate-collections.d.ts.map +1 -0
  97. package/dist/config/validate-collections.js +70 -0
  98. package/dist/config/validate-collections.js.map +1 -0
  99. package/dist/config/validate-collections.test.node.d.ts +9 -0
  100. package/dist/config/validate-collections.test.node.d.ts.map +1 -0
  101. package/dist/config/validate-collections.test.node.js +149 -0
  102. package/dist/config/validate-collections.test.node.js.map +1 -0
  103. package/dist/core.d.ts +89 -0
  104. package/dist/core.d.ts.map +1 -0
  105. package/dist/core.js +99 -0
  106. package/dist/core.js.map +1 -0
  107. package/dist/defaults/default-values.d.ts +13 -0
  108. package/dist/defaults/default-values.d.ts.map +1 -0
  109. package/dist/defaults/default-values.js +60 -0
  110. package/dist/defaults/default-values.js.map +1 -0
  111. package/dist/index.d.ts +20 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +36 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/lib/errors.d.ts +98 -0
  116. package/dist/lib/errors.d.ts.map +1 -0
  117. package/dist/lib/errors.js +134 -0
  118. package/dist/lib/errors.js.map +1 -0
  119. package/dist/lib/logger.d.ts +62 -0
  120. package/dist/lib/logger.d.ts.map +1 -0
  121. package/dist/lib/logger.js +120 -0
  122. package/dist/lib/logger.js.map +1 -0
  123. package/dist/lib/registry.d.ts +65 -0
  124. package/dist/lib/registry.d.ts.map +1 -0
  125. package/dist/lib/registry.js +133 -0
  126. package/dist/lib/registry.js.map +1 -0
  127. package/dist/logger/index.d.ts +3 -0
  128. package/dist/logger/index.d.ts.map +1 -0
  129. package/dist/logger/index.js +3 -0
  130. package/dist/logger/index.js.map +1 -0
  131. package/dist/patches/apply-patches.d.ts +21 -0
  132. package/dist/patches/apply-patches.d.ts.map +1 -0
  133. package/dist/patches/apply-patches.js +357 -0
  134. package/dist/patches/apply-patches.js.map +1 -0
  135. package/dist/patches/index.d.ts +3 -0
  136. package/dist/patches/index.d.ts.map +1 -0
  137. package/dist/patches/index.js +4 -0
  138. package/dist/patches/index.js.map +1 -0
  139. package/dist/patches/patch-types.d.ts +82 -0
  140. package/dist/patches/patch-types.d.ts.map +1 -0
  141. package/dist/patches/patch-types.js +3 -0
  142. package/dist/patches/patch-types.js.map +1 -0
  143. package/dist/patches/patch.test.node.d.ts +2 -0
  144. package/dist/patches/patch.test.node.d.ts.map +1 -0
  145. package/dist/patches/patch.test.node.js +193 -0
  146. package/dist/patches/patch.test.node.js.map +1 -0
  147. package/dist/query/parse-where.d.ts +100 -0
  148. package/dist/query/parse-where.d.ts.map +1 -0
  149. package/dist/query/parse-where.js +352 -0
  150. package/dist/query/parse-where.js.map +1 -0
  151. package/dist/query/parse-where.test.node.d.ts +9 -0
  152. package/dist/query/parse-where.test.node.d.ts.map +1 -0
  153. package/dist/query/parse-where.test.node.js +581 -0
  154. package/dist/query/parse-where.test.node.js.map +1 -0
  155. package/dist/schemas/zod/builder.d.ts +466 -0
  156. package/dist/schemas/zod/builder.d.ts.map +1 -0
  157. package/dist/schemas/zod/builder.js +276 -0
  158. package/dist/schemas/zod/builder.js.map +1 -0
  159. package/dist/schemas/zod/cache.d.ts +14 -0
  160. package/dist/schemas/zod/cache.d.ts.map +1 -0
  161. package/dist/schemas/zod/cache.js +40 -0
  162. package/dist/schemas/zod/cache.js.map +1 -0
  163. package/dist/schemas/zod/index.d.ts +4 -0
  164. package/dist/schemas/zod/index.d.ts.map +1 -0
  165. package/dist/schemas/zod/index.js +4 -0
  166. package/dist/schemas/zod/index.js.map +1 -0
  167. package/dist/schemas/zod/types.d.ts +13 -0
  168. package/dist/schemas/zod/types.d.ts.map +1 -0
  169. package/dist/schemas/zod/types.js +2 -0
  170. package/dist/schemas/zod/types.js.map +1 -0
  171. package/dist/services/collection-bootstrap.d.ts +46 -0
  172. package/dist/services/collection-bootstrap.d.ts.map +1 -0
  173. package/dist/services/collection-bootstrap.js +108 -0
  174. package/dist/services/collection-bootstrap.js.map +1 -0
  175. package/dist/services/collection-bootstrap.test.node.d.ts +9 -0
  176. package/dist/services/collection-bootstrap.test.node.d.ts.map +1 -0
  177. package/dist/services/collection-bootstrap.test.node.js +208 -0
  178. package/dist/services/collection-bootstrap.test.node.js.map +1 -0
  179. package/dist/services/document-lifecycle.d.ts +245 -0
  180. package/dist/services/document-lifecycle.d.ts.map +1 -0
  181. package/dist/services/document-lifecycle.js +481 -0
  182. package/dist/services/document-lifecycle.js.map +1 -0
  183. package/dist/services/document-lifecycle.test.node.d.ts +9 -0
  184. package/dist/services/document-lifecycle.test.node.d.ts.map +1 -0
  185. package/dist/services/document-lifecycle.test.node.js +781 -0
  186. package/dist/services/document-lifecycle.test.node.js.map +1 -0
  187. package/dist/services/document-read.d.ts +26 -0
  188. package/dist/services/document-read.d.ts.map +1 -0
  189. package/dist/services/document-read.js +60 -0
  190. package/dist/services/document-read.js.map +1 -0
  191. package/dist/services/field-upload.d.ts +100 -0
  192. package/dist/services/field-upload.d.ts.map +1 -0
  193. package/dist/services/field-upload.js +328 -0
  194. package/dist/services/field-upload.js.map +1 -0
  195. package/dist/services/field-upload.test.node.d.ts +9 -0
  196. package/dist/services/field-upload.test.node.d.ts.map +1 -0
  197. package/dist/services/field-upload.test.node.js +337 -0
  198. package/dist/services/field-upload.test.node.js.map +1 -0
  199. package/dist/services/index.d.ts +10 -0
  200. package/dist/services/index.d.ts.map +1 -0
  201. package/dist/services/index.js +11 -0
  202. package/dist/services/index.js.map +1 -0
  203. package/dist/services/populate.d.ts +299 -0
  204. package/dist/services/populate.d.ts.map +1 -0
  205. package/dist/services/populate.js +484 -0
  206. package/dist/services/populate.js.map +1 -0
  207. package/dist/services/populate.test.node.d.ts +9 -0
  208. package/dist/services/populate.test.node.d.ts.map +1 -0
  209. package/dist/services/populate.test.node.js +910 -0
  210. package/dist/services/populate.test.node.js.map +1 -0
  211. package/dist/services/relation-projection.d.ts +52 -0
  212. package/dist/services/relation-projection.d.ts.map +1 -0
  213. package/dist/services/relation-projection.js +81 -0
  214. package/dist/services/relation-projection.js.map +1 -0
  215. package/dist/services/richtext-populate.d.ts +87 -0
  216. package/dist/services/richtext-populate.d.ts.map +1 -0
  217. package/dist/services/richtext-populate.js +189 -0
  218. package/dist/services/richtext-populate.js.map +1 -0
  219. package/dist/services/richtext-populate.test.node.d.ts +9 -0
  220. package/dist/services/richtext-populate.test.node.d.ts.map +1 -0
  221. package/dist/services/richtext-populate.test.node.js +197 -0
  222. package/dist/services/richtext-populate.test.node.js.map +1 -0
  223. package/dist/storage/collection-fingerprint.d.ts +21 -0
  224. package/dist/storage/collection-fingerprint.d.ts.map +1 -0
  225. package/dist/storage/collection-fingerprint.js +172 -0
  226. package/dist/storage/collection-fingerprint.js.map +1 -0
  227. package/dist/storage/collection-fingerprint.test.node.d.ts +9 -0
  228. package/dist/storage/collection-fingerprint.test.node.d.ts.map +1 -0
  229. package/dist/storage/collection-fingerprint.test.node.js +256 -0
  230. package/dist/storage/collection-fingerprint.test.node.js.map +1 -0
  231. package/dist/storage/field-store-map.d.ts +59 -0
  232. package/dist/storage/field-store-map.d.ts.map +1 -0
  233. package/dist/storage/field-store-map.js +75 -0
  234. package/dist/storage/field-store-map.js.map +1 -0
  235. package/dist/storage/field-store-map.test.node.d.ts +9 -0
  236. package/dist/storage/field-store-map.test.node.d.ts.map +1 -0
  237. package/dist/storage/field-store-map.test.node.js +117 -0
  238. package/dist/storage/field-store-map.test.node.js.map +1 -0
  239. package/dist/storage/index.d.ts +10 -0
  240. package/dist/storage/index.d.ts.map +1 -0
  241. package/dist/storage/index.js +10 -0
  242. package/dist/storage/index.js.map +1 -0
  243. package/dist/utils/normalise-dates.d.ts +15 -0
  244. package/dist/utils/normalise-dates.d.ts.map +1 -0
  245. package/dist/utils/normalise-dates.js +22 -0
  246. package/dist/utils/normalise-dates.js.map +1 -0
  247. package/dist/utils/slugify.d.ts +56 -0
  248. package/dist/utils/slugify.d.ts.map +1 -0
  249. package/dist/utils/slugify.js +91 -0
  250. package/dist/utils/slugify.js.map +1 -0
  251. package/dist/utils/slugify.test.node.d.ts +9 -0
  252. package/dist/utils/slugify.test.node.d.ts.map +1 -0
  253. package/dist/utils/slugify.test.node.js +86 -0
  254. package/dist/utils/slugify.test.node.js.map +1 -0
  255. package/dist/utils/storage-utils.d.ts +36 -0
  256. package/dist/utils/storage-utils.d.ts.map +1 -0
  257. package/dist/utils/storage-utils.js +38 -0
  258. package/dist/utils/storage-utils.js.map +1 -0
  259. package/dist/utils/utils.general.d.ts +64 -0
  260. package/dist/utils/utils.general.d.ts.map +1 -0
  261. package/dist/utils/utils.general.js +219 -0
  262. package/dist/utils/utils.general.js.map +1 -0
  263. package/dist/validation/index.d.ts +9 -0
  264. package/dist/validation/index.d.ts.map +1 -0
  265. package/dist/validation/index.js +9 -0
  266. package/dist/validation/index.js.map +1 -0
  267. package/dist/validation/shared.d.ts +36 -0
  268. package/dist/validation/shared.d.ts.map +1 -0
  269. package/dist/validation/shared.js +42 -0
  270. package/dist/validation/shared.js.map +1 -0
  271. package/dist/workflow/index.d.ts +2 -0
  272. package/dist/workflow/index.d.ts.map +1 -0
  273. package/dist/workflow/index.js +3 -0
  274. package/dist/workflow/index.js.map +1 -0
  275. package/dist/workflow/workflow.d.ts +40 -0
  276. package/dist/workflow/workflow.d.ts.map +1 -0
  277. package/dist/workflow/workflow.js +96 -0
  278. package/dist/workflow/workflow.js.map +1 -0
  279. package/dist/workflow/workflow.test.node.d.ts +2 -0
  280. package/dist/workflow/workflow.test.node.d.ts.map +1 -0
  281. package/dist/workflow/workflow.test.node.js +198 -0
  282. package/dist/workflow/workflow.test.node.js.map +1 -0
  283. package/package.json +88 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ /**
9
+ * Field names that cannot be declared in a collection schema because they
10
+ * collide with system-managed attributes on `documentVersions`. Exported
11
+ * so storage-layer reconstruction can skip orphan rows that may exist in
12
+ * store tables from installations whose schemas declared these names as
13
+ * user fields before they were promoted to system attributes.
14
+ */
15
+ export const RESERVED_FIELD_NAMES = new Set(['path']);
16
+ const USE_AS_PATH_SOURCE_TYPES = new Set([
17
+ 'text',
18
+ 'textArea',
19
+ 'select',
20
+ 'date',
21
+ 'datetime',
22
+ 'time',
23
+ ]);
24
+ function walkFields(fields, visit) {
25
+ for (const field of fields) {
26
+ visit(field);
27
+ if (field.type === 'group' || field.type === 'array') {
28
+ walkFields(field.fields, visit);
29
+ }
30
+ else if (field.type === 'blocks') {
31
+ for (const block of field.blocks) {
32
+ walkFields(block.fields, visit);
33
+ }
34
+ }
35
+ }
36
+ }
37
+ /**
38
+ * Validate every collection in a configuration.
39
+ *
40
+ * Enforced rules:
41
+ * - No field (at any nesting depth) may be named `path`. The `path`
42
+ * column on `documentVersions` is system-managed; collections opt
43
+ * into derived paths via `useAsPath`.
44
+ * - When `useAsPath` is set, the referenced field must exist at the
45
+ * top level of the collection and be of a type the slugifier can
46
+ * sensibly consume (text-like or date-like).
47
+ *
48
+ * Throws a plain `Error` (not a `BylineError`) because configuration
49
+ * validation runs at startup, before the logger and error registry are
50
+ * necessarily wired up.
51
+ */
52
+ export function validateCollections(collections) {
53
+ for (const collection of collections) {
54
+ walkFields(collection.fields, (field) => {
55
+ if ('name' in field && RESERVED_FIELD_NAMES.has(field.name)) {
56
+ throw new Error(`Collection "${collection.path}" declares a field named "${field.name}", which is a reserved system attribute. Use \`useAsPath: '<sourceField>'\` on the collection definition instead.`);
57
+ }
58
+ });
59
+ if (collection.useAsPath != null) {
60
+ const source = collection.fields.find((f) => 'name' in f && f.name === collection.useAsPath);
61
+ if (source == null) {
62
+ throw new Error(`Collection "${collection.path}" sets \`useAsPath: '${collection.useAsPath}'\` but no top-level field with that name exists.`);
63
+ }
64
+ if (!USE_AS_PATH_SOURCE_TYPES.has(source.type)) {
65
+ throw new Error(`Collection "${collection.path}" sets \`useAsPath: '${collection.useAsPath}'\` but field "${collection.useAsPath}" has type "${source.type}". Supported source types: ${[...USE_AS_PATH_SOURCE_TYPES].join(', ')}.`);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ //# sourceMappingURL=validate-collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-collections.js","sourceRoot":"","sources":["../../src/config/validate-collections.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAE1E,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAY;IAClD,MAAM;IACN,UAAU;IACV,QAAQ;IACR,MAAM;IACN,UAAU;IACV,MAAM;CACP,CAAC,CAAA;AAEF,SAAS,UAAU,CAAC,MAAwB,EAAE,KAA6B;IACzE,KAAK,MAAM,KAAK,IAAI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C;YACD,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/C,MAAM,IAAI,KAAK,CACb,eAAe,UAAU,CAAC,IAAI,wBAAwB,UAAU,CAAC,SAAS,kBAAkB,UAAU,CAAC,SAAS,eAAe,MAAM,CAAC,IAAI,8BAA8B,CAAC,GAAG,wBAAwB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACpN,CAAA;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=validate-collections.test.node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-collections.test.node.d.ts","sourceRoot":"","sources":["../../src/config/validate-collections.test.node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { describe, expect, it } from 'vitest';
9
+ import { validateCollections } from './validate-collections.js';
10
+ const baseCollection = {
11
+ path: 'pages',
12
+ labels: { singular: 'Page', plural: 'Pages' },
13
+ fields: [{ name: 'title', label: 'Title', type: 'text' }],
14
+ };
15
+ describe('validateCollections', () => {
16
+ it('accepts a collection with no reserved names and no useAsPath', () => {
17
+ expect(() => validateCollections([baseCollection])).not.toThrow();
18
+ });
19
+ it('rejects a top-level field named "path"', () => {
20
+ const collection = {
21
+ ...baseCollection,
22
+ fields: [
23
+ { name: 'title', label: 'Title', type: 'text' },
24
+ { name: 'path', label: 'Path', type: 'text' },
25
+ ],
26
+ };
27
+ expect(() => validateCollections([collection])).toThrow(/reserved system attribute/);
28
+ });
29
+ it('rejects a nested "path" field inside a group', () => {
30
+ const collection = {
31
+ ...baseCollection,
32
+ fields: [
33
+ {
34
+ name: 'meta',
35
+ label: 'Meta',
36
+ type: 'group',
37
+ fields: [{ name: 'path', label: 'Path', type: 'text' }],
38
+ },
39
+ ],
40
+ };
41
+ expect(() => validateCollections([collection])).toThrow(/reserved system attribute/);
42
+ });
43
+ it('rejects a "path" field nested inside a block', () => {
44
+ const collection = {
45
+ ...baseCollection,
46
+ fields: [
47
+ {
48
+ name: 'content',
49
+ label: 'Content',
50
+ type: 'blocks',
51
+ blocks: [
52
+ {
53
+ blockType: 'photoBlock',
54
+ fields: [{ name: 'path', label: 'Path', type: 'text' }],
55
+ },
56
+ ],
57
+ },
58
+ ],
59
+ };
60
+ expect(() => validateCollections([collection])).toThrow(/reserved system attribute/);
61
+ });
62
+ it('accepts a valid useAsPath pointing at a text field', () => {
63
+ expect(() => validateCollections([{ ...baseCollection, useAsPath: 'title' }])).not.toThrow();
64
+ });
65
+ it('rejects a useAsPath pointing at a missing field', () => {
66
+ expect(() => validateCollections([{ ...baseCollection, useAsPath: 'nonexistent' }])).toThrow(/no top-level field with that name/);
67
+ });
68
+ it('rejects a useAsPath pointing at an unsupported field type', () => {
69
+ const collection = {
70
+ ...baseCollection,
71
+ fields: [
72
+ { name: 'title', label: 'Title', type: 'text' },
73
+ { name: 'photo', label: 'Photo', type: 'image' },
74
+ ],
75
+ useAsPath: 'photo',
76
+ };
77
+ expect(() => validateCollections([collection])).toThrow(/Supported source types/);
78
+ });
79
+ it('accepts useAsPath pointing at a datetime field', () => {
80
+ const collection = {
81
+ ...baseCollection,
82
+ fields: [
83
+ { name: 'title', label: 'Title', type: 'text' },
84
+ { name: 'publishedOn', label: 'Published On', type: 'datetime', mode: 'datetime' },
85
+ ],
86
+ useAsPath: 'publishedOn',
87
+ };
88
+ expect(() => validateCollections([collection])).not.toThrow();
89
+ });
90
+ // useAsPath deliberately resolves against top-level fields only. A
91
+ // nested source (inside a group, array, or block) isn't addressable
92
+ // in the derivation cascade — path is a singular identity anchor, not
93
+ // a per-item or per-locale derivation — so the validator rejects it
94
+ // at startup rather than silently falling through to a UUID.
95
+ it('rejects useAsPath pointing at a field nested inside a group', () => {
96
+ const collection = {
97
+ ...baseCollection,
98
+ fields: [
99
+ { name: 'title', label: 'Title', type: 'text' },
100
+ {
101
+ name: 'meta',
102
+ label: 'Meta',
103
+ type: 'group',
104
+ fields: [{ name: 'slugSource', label: 'Slug source', type: 'text' }],
105
+ },
106
+ ],
107
+ useAsPath: 'slugSource',
108
+ };
109
+ expect(() => validateCollections([collection])).toThrow(/no top-level field with that name/);
110
+ });
111
+ it('rejects useAsPath pointing at a field nested inside an array', () => {
112
+ const collection = {
113
+ ...baseCollection,
114
+ fields: [
115
+ { name: 'title', label: 'Title', type: 'text' },
116
+ {
117
+ name: 'variants',
118
+ label: 'Variants',
119
+ type: 'array',
120
+ fields: [{ name: 'slugSource', label: 'Slug source', type: 'text' }],
121
+ },
122
+ ],
123
+ useAsPath: 'slugSource',
124
+ };
125
+ expect(() => validateCollections([collection])).toThrow(/no top-level field with that name/);
126
+ });
127
+ it('rejects useAsPath pointing at a field nested inside a block', () => {
128
+ const collection = {
129
+ ...baseCollection,
130
+ fields: [
131
+ { name: 'title', label: 'Title', type: 'text' },
132
+ {
133
+ name: 'content',
134
+ label: 'Content',
135
+ type: 'blocks',
136
+ blocks: [
137
+ {
138
+ blockType: 'hero',
139
+ fields: [{ name: 'slugSource', label: 'Slug source', type: 'text' }],
140
+ },
141
+ ],
142
+ },
143
+ ],
144
+ useAsPath: 'slugSource',
145
+ };
146
+ expect(() => validateCollections([collection])).toThrow(/no top-level field with that name/);
147
+ });
148
+ });
149
+ //# sourceMappingURL=validate-collections.test.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-collections.test.node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,SAAS;oBACf,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ;oBACd,MAAM,EAAE;wBACN;4BACE,SAAS,EAAE,MAAM;4BACjB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yBACrE;qBACF;iBACF;aACF;YACD,SAAS,EAAE,YAAY;SACxB,CAAA;QACD,MAAM,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;IAC9F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
package/dist/core.d.ts ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { type AbilityDescriptor, AbilityRegistry, type SessionProvider } from '@byline/auth';
9
+ import { type Logger as PinoLogger } from 'pino';
10
+ import { type BylineLogger } from './lib/logger.js';
11
+ import { type CollectionRecord } from './services/collection-bootstrap.js';
12
+ import type { CollectionDefinition, IDbAdapter, IStorageProvider, ServerConfig } from './@types/index.js';
13
+ export interface BylineCore<TAdminStore = unknown> {
14
+ config: ServerConfig<TAdminStore>;
15
+ collections: CollectionDefinition[];
16
+ db: IDbAdapter;
17
+ storage: IStorageProvider | undefined;
18
+ logger: BylineLogger;
19
+ /**
20
+ * Registered collections, keyed by `path`, with their current DB row id,
21
+ * schema version, and fingerprint. Populated by `ensureCollections()` at
22
+ * startup. Prefer `getCollectionRecord(path)` for lookups.
23
+ */
24
+ collectionRecords: Map<string, CollectionRecord>;
25
+ /**
26
+ * Throwing lookup for a collection's registration record. Use this
27
+ * wherever you need `(collectionId, collectionVersion)` — callers that
28
+ * hit this accessor do not need a DB round-trip.
29
+ */
30
+ getCollectionRecord: (path: string) => CollectionRecord;
31
+ /**
32
+ * Ability registry. Populated at init time with the CRUD + workflow
33
+ * abilities contributed by each declared collection
34
+ * (`collections.<path>.{read,create,update,delete,publish,changeStatus}`).
35
+ *
36
+ * Plugins and future subsystems contribute their own abilities via
37
+ * `registerAbility()` — or directly against `core.abilities` — typically
38
+ * during server bootstrap and before any admin UI renders.
39
+ *
40
+ * Consumed at runtime by `AdminAuth.assertAbility()` (Phase 4) and at
41
+ * design time by the admin role-editor UI (Phase 6). See
42
+ * docs/analysis/AUTHN-AUTHZ-ANALYSIS.md §3.
43
+ */
44
+ abilities: AbilityRegistry;
45
+ /** Convenience wrapper around `abilities.register()`. */
46
+ registerAbility: (descriptor: AbilityDescriptor) => void;
47
+ /** Convenience wrapper around `abilities.list()`. */
48
+ listAbilities: () => AbilityDescriptor[];
49
+ /** Convenience wrapper around `abilities.byGroup()`. */
50
+ getAbilitiesByGroup: () => Map<string, AbilityDescriptor[]>;
51
+ /**
52
+ * Configured session provider. Phase 3 leaves this optional — the admin
53
+ * server-fn middleware wired in Phase 5 will tighten the contract where
54
+ * authentication is required.
55
+ */
56
+ sessionProvider: SessionProvider | undefined;
57
+ /**
58
+ * Adapter-built admin store bundle (users / roles / permissions /
59
+ * refresh tokens). Passed through from `ServerConfig.adminStore` so
60
+ * consumers (server fns, seeds, admin commands) have a single
61
+ * adapter-agnostic handle instead of reconstructing the store or
62
+ * casting `db` to the concrete adapter type.
63
+ *
64
+ * Undefined when the installation does not configure admin.
65
+ */
66
+ adminStore: TAdminStore | undefined;
67
+ }
68
+ /**
69
+ * Initialize Byline CMS core services via the typed registry.
70
+ *
71
+ * This is the recommended server-side entry point. It composes the
72
+ * dependency graph and populates the global config singleton for
73
+ * backward compatibility with `getServerConfig()`.
74
+ *
75
+ * @param config - Server configuration (collections, db, storage, i18n).
76
+ * @param pinoLogger - Optional raw Pino instance. Defaults to `pino({ level: 'info' })`.
77
+ */
78
+ export declare const initBylineCore: <TAdminStore = unknown>(config: ServerConfig<TAdminStore>, pinoLogger?: PinoLogger) => Promise<BylineCore<TAdminStore>>;
79
+ /**
80
+ * Typed accessor for the composed `BylineCore` registered by
81
+ * `initBylineCore`. Throws if init has not run yet.
82
+ *
83
+ * The generic `TAdminStore` parameter mirrors `BylineCore<TAdminStore>` —
84
+ * callers that consume `core.adminStore` should pass the concrete admin
85
+ * store type (e.g. `getBylineCore<AdminStore>()`); callers that don't
86
+ * touch `adminStore` can omit it.
87
+ */
88
+ export declare function getBylineCore<TAdminStore = unknown>(): BylineCore<TAdminStore>;
89
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAA;AAC5F,OAAO,EAAE,KAAK,MAAM,IAAI,UAAU,EAAQ,MAAM,MAAM,CAAA;AAItD,OAAO,EAAE,KAAK,YAAY,EAAoC,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,oCAAoC,CAAA;AAE7F,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,YAAY,EACb,MAAM,mBAAmB,CAAA;AAE1B,MAAM,WAAW,UAAU,CAAC,WAAW,GAAG,OAAO;IAC/C,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;IACjC,WAAW,EAAE,oBAAoB,EAAE,CAAA;IACnC,EAAE,EAAE,UAAU,CAAA;IACd,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACrC,MAAM,EAAE,YAAY,CAAA;IACpB;;;;OAIG;IACH,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAChD;;;;OAIG;IACH,mBAAmB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,CAAA;IACvD;;;;;;;;;;;;OAYG;IACH,SAAS,EAAE,eAAe,CAAA;IAC1B,yDAAyD;IACzD,eAAe,EAAE,CAAC,UAAU,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACxD,qDAAqD;IACrD,aAAa,EAAE,MAAM,iBAAiB,EAAE,CAAA;IACxC,wDAAwD;IACxD,mBAAmB,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAA;IAC3D;;;;OAIG;IACH,eAAe,EAAE,eAAe,GAAG,SAAS,CAAA;IAC5C;;;;;;;;OAQG;IACH,UAAU,EAAE,WAAW,GAAG,SAAS,CAAA;CACpC;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GAAU,WAAW,GAAG,OAAO,EACxD,QAAQ,YAAY,CAAC,WAAW,CAAC,EACjC,aAAY,UAAoC,KAC/C,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAuEjC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAG,OAAO,KAAK,UAAU,CAAC,WAAW,CAAC,CAE9E"}
package/dist/core.js ADDED
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This Source Code is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5
+ *
6
+ * Copyright (c) Infonomic Company Limited
7
+ */
8
+ import { AbilityRegistry } from '@byline/auth';
9
+ import { pino } from 'pino';
10
+ import { registerCollectionAbilities } from './auth/register-collection-abilities.js';
11
+ import { defineBylineCore, defineServerConfig, getBylineCoreUnsafe } from './config/config.js';
12
+ import { createBylineLogger, defineLogger } from './lib/logger.js';
13
+ import { Registry } from './lib/registry.js';
14
+ import { ensureCollections } from './services/collection-bootstrap.js';
15
+ import { validateRichTextFieldFlags } from './services/richtext-populate.js';
16
+ /**
17
+ * Initialize Byline CMS core services via the typed registry.
18
+ *
19
+ * This is the recommended server-side entry point. It composes the
20
+ * dependency graph and populates the global config singleton for
21
+ * backward compatibility with `getServerConfig()`.
22
+ *
23
+ * @param config - Server configuration (collections, db, storage, i18n).
24
+ * @param pinoLogger - Optional raw Pino instance. Defaults to `pino({ level: 'info' })`.
25
+ */
26
+ export const initBylineCore = async (config, pinoLogger = pino({ level: 'info' })) => {
27
+ const registry = new Registry()
28
+ .addValue('config', config)
29
+ .addValue('collections', config.collections)
30
+ .addValue('db', config.db)
31
+ .addValue('storage', config.storage)
32
+ .addFactory('logger', createBylineLogger);
33
+ const composed = registry.compose({ pinoLogger });
34
+ // Validate richText field flags against the registered server adapter
35
+ // before any DB work. Fail-fast surfaces unrenderable configurations
36
+ // (both flags off) and missing-adapter cases at boot rather than at
37
+ // request time.
38
+ validateRichTextFieldFlags(composed.collections, config.fields?.richText?.populate != null);
39
+ // Backward compat: populate globalThis singletons
40
+ defineServerConfig(config);
41
+ defineLogger(composed.logger);
42
+ // Reconcile collection definitions with the database: insert new rows,
43
+ // bump schema versions when the fingerprint has drifted, and build the
44
+ // in-memory record cache used by the lifecycle/upload/client paths.
45
+ const collectionRecords = await ensureCollections({
46
+ definitions: composed.collections,
47
+ db: composed.db,
48
+ logger: composed.logger,
49
+ });
50
+ const getCollectionRecord = (path) => {
51
+ const record = collectionRecords.get(path);
52
+ if (!record) {
53
+ throw new Error(`BylineCore.getCollectionRecord: no record for collection '${path}'. ` +
54
+ `Known paths: ${Array.from(collectionRecords.keys()).join(', ') || '(none)'}`);
55
+ }
56
+ return record;
57
+ };
58
+ // Ability registry — populated with each collection's CRUD + workflow
59
+ // abilities. Plugins and subsystems add their own via
60
+ // `core.registerAbility()` or `core.abilities.register()`.
61
+ const abilities = new AbilityRegistry();
62
+ for (const definition of composed.collections) {
63
+ registerCollectionAbilities(abilities, definition);
64
+ }
65
+ const core = {
66
+ config: composed.config,
67
+ collections: composed.collections,
68
+ db: composed.db,
69
+ storage: composed.storage,
70
+ logger: composed.logger,
71
+ collectionRecords,
72
+ getCollectionRecord,
73
+ abilities,
74
+ registerAbility: (descriptor) => abilities.register(descriptor),
75
+ listAbilities: () => abilities.list(),
76
+ getAbilitiesByGroup: () => abilities.byGroup(),
77
+ sessionProvider: composed.config.sessionProvider,
78
+ adminStore: composed.config.adminStore,
79
+ };
80
+ // Register on the global singleton so server-side packages
81
+ // (`@byline/host-tanstack-start/server-fns/*`, future hosts) can read
82
+ // post-init state via `getBylineCore()` instead of importing the
83
+ // host's server config module directly.
84
+ defineBylineCore(core);
85
+ return core;
86
+ };
87
+ /**
88
+ * Typed accessor for the composed `BylineCore` registered by
89
+ * `initBylineCore`. Throws if init has not run yet.
90
+ *
91
+ * The generic `TAdminStore` parameter mirrors `BylineCore<TAdminStore>` —
92
+ * callers that consume `core.adminStore` should pass the concrete admin
93
+ * store type (e.g. `getBylineCore<AdminStore>()`); callers that don't
94
+ * touch `adminStore` can omit it.
95
+ */
96
+ export function getBylineCore() {
97
+ return getBylineCoreUnsafe();
98
+ }
99
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA0B,eAAe,EAAwB,MAAM,cAAc,CAAA;AAC5F,OAAO,EAA6B,IAAI,EAAE,MAAM,MAAM,CAAA;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAA;AACrF,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,OAAO,EAAqB,kBAAkB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAyB,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CA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,13 @@
1
+ import type { DefaultValue, DefaultValueContext, FieldSet } from '../@types/field-types.js';
2
+ export declare function resolveDefaultValue<T>(defaultValue: DefaultValue<T> | undefined, ctx?: Partial<DefaultValueContext>): Promise<T | undefined>;
3
+ export declare function resolveFieldDefaultValue(field: {
4
+ defaultValue?: DefaultValue;
5
+ } & Record<string, any>, ctx?: Partial<DefaultValueContext>): Promise<unknown | undefined>;
6
+ /**
7
+ * Build initial document data from a field list.
8
+ *
9
+ * This is intentionally conservative: it only sets values that are explicitly defaulted
10
+ * (either via `defaultValue` or via nested structure fields that have child defaults).
11
+ */
12
+ export declare function buildInitialDataFromFields(fields: FieldSet, ctx?: Partial<DefaultValueContext>): Promise<Record<string, any>>;
13
+ //# sourceMappingURL=default-values.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-values.d.ts","sourceRoot":"","sources":["../../src/defaults/default-values.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAW3F,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,EACzC,GAAG,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACjC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAYxB;AAED,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE;IAAE,YAAY,CAAC,EAAE,YAAY,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5D,GAAG,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACjC,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAE9B;AAED;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,QAAQ,EAChB,GAAG,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAoC9B"}
@@ -0,0 +1,60 @@
1
+ import { isStructureField } from '../@types/field-types.js';
2
+ function normalizeCtx(ctx) {
3
+ return {
4
+ data: ctx?.data ?? {},
5
+ locale: ctx?.locale,
6
+ now: ctx?.now ?? (() => new Date()),
7
+ uuid: ctx?.uuid,
8
+ };
9
+ }
10
+ export async function resolveDefaultValue(defaultValue, ctx) {
11
+ if (defaultValue === undefined) {
12
+ return undefined;
13
+ }
14
+ const normalized = normalizeCtx(ctx);
15
+ if (typeof defaultValue === 'function') {
16
+ return defaultValue(normalized);
17
+ }
18
+ return defaultValue;
19
+ }
20
+ export async function resolveFieldDefaultValue(field, ctx) {
21
+ return resolveDefaultValue(field.defaultValue, ctx);
22
+ }
23
+ /**
24
+ * Build initial document data from a field list.
25
+ *
26
+ * This is intentionally conservative: it only sets values that are explicitly defaulted
27
+ * (either via `defaultValue` or via nested structure fields that have child defaults).
28
+ */
29
+ export async function buildInitialDataFromFields(fields, ctx) {
30
+ const normalized = normalizeCtx(ctx);
31
+ const out = {};
32
+ for (const field of fields) {
33
+ const currentData = { ...normalized.data, ...out };
34
+ const explicit = await resolveFieldDefaultValue(field, {
35
+ ...normalized,
36
+ data: currentData,
37
+ });
38
+ if (explicit !== undefined) {
39
+ out[field.name] = explicit;
40
+ continue;
41
+ }
42
+ if (!isStructureField(field)) {
43
+ continue;
44
+ }
45
+ // If this is a structure field with child defaults, build a nested default.
46
+ // For arrays we avoid guessing a default shape.
47
+ if (field.type === 'group') {
48
+ // Group fields are represented as a plain object keyed by child field names.
49
+ const nested = await buildInitialDataFromFields(field.fields, {
50
+ ...normalized,
51
+ data: currentData,
52
+ });
53
+ if (Object.keys(nested).length > 0) {
54
+ out[field.name] = nested;
55
+ }
56
+ }
57
+ }
58
+ return out;
59
+ }
60
+ //# sourceMappingURL=default-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-values.js","sourceRoot":"","sources":["../../src/defaults/default-values.ts"],"names":[],"mappings":"AA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A;QAEF,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAA;YAC1B,SAAQ;QACV,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,SAAQ;QACV,CAAC;QAED,4EAA4E;QAC5E,gDAAgD;QAChD,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,6EAA6E;YAC7E,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,KAAK,CAAC,MAAM,EAAE;gBAC5D,GAAG,UAAU;gBACb,IAAI,EAAE,WAAW;aAClB,CAAC,CAAA;YACF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACnC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;YAC1B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,20 @@
1
+ export * from './@types/index.js';
2
+ export { applyBeforeRead, assertActorCanPerform, COLLECTION_ABILITY_VERBS, type CollectionAbilityVerb, collectionAbilityKey, registerCollectionAbilities, } from './auth/index.js';
3
+ export { defineClientConfig, defineServerConfig, getClientConfig, getCollectionAdminConfig, getCollectionDefinition, getServerConfig, } from './config/config.js';
4
+ export { resolveRoutes } from './config/routes.js';
5
+ export { validateAdminConfigs } from './config/validate-admin-configs.js';
6
+ export { RESERVED_FIELD_NAMES } from './config/validate-collections.js';
7
+ export { type BylineCore, getBylineCore, initBylineCore } from './core.js';
8
+ export * from './defaults/default-values.js';
9
+ export { BylineError, ERR_DATABASE, ERR_NOT_FOUND, ERR_READ_BUDGET_EXCEEDED, ERR_STORAGE, ERR_UNHANDLED, ERR_VALIDATION, ErrorCodes, type ErrorReport, } from './lib/errors.js';
10
+ export { type BylineLogger, getLogger } from './lib/logger.js';
11
+ export { AsyncRegistry, type RegisteredServices, Registry } from './lib/registry.js';
12
+ export * from './patches/index.js';
13
+ export { mergePredicates, type ParseContext, type ParsedSort, type ParsedWhere, parseSort, parseWhere, } from './query/parse-where.js';
14
+ export { getCollectionSchemasForPath } from './schemas/zod/cache.js';
15
+ export * from './services/index.js';
16
+ export * from './storage/index.js';
17
+ export { formatTextValue, looksLikeISODate, type SlugifierFn, type SlugifyContext, slugify, } from './utils/slugify.js';
18
+ export { getUploadFields, hasUploadField, isUploadField } from './utils/storage-utils.js';
19
+ export * from './workflow/index.js';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,cAAc,mBAAmB,CAAA;AACjC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,EAAE,KAAK,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1E,cAAc,8BAA8B,CAAA;AAC5C,OAAO,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,cAAc,EACd,UAAU,EACV,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACpF,cAAc,oBAAoB,CAAA;AAClC,OAAO,EACL,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,SAAS,EACT,UAAU,GACX,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AACpE,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,OAAO,GACR,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACzF,cAAc,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @byline/core public surface.
3
+ //
4
+ // Subpath exports (see `package.json`):
5
+ // - `.` — main entry (this file); published
6
+ // - `./zod-schemas`, `./logger`, `./package.json` — published
7
+ // - `./patches`, `./workflow`, `./services` — NOT published
8
+ //
9
+ // The three unpublished subpaths are in-monorepo boundaries used by
10
+ // the admin server fns and the `@byline/client` SDK. They are
11
+ // registered in the main `exports` map (so workspace consumers and
12
+ // `tsc` can resolve them) but deliberately omitted from
13
+ // `publishConfig.exports` — they are not stable surface and should
14
+ // not be imported by external npm consumers. External access goes
15
+ // through this main entry or `@byline/client`.
16
+ // ---------------------------------------------------------------------------
17
+ export * from './@types/index.js';
18
+ export { applyBeforeRead, assertActorCanPerform, COLLECTION_ABILITY_VERBS, collectionAbilityKey, registerCollectionAbilities, } from './auth/index.js';
19
+ export { defineClientConfig, defineServerConfig, getClientConfig, getCollectionAdminConfig, getCollectionDefinition, getServerConfig, } from './config/config.js';
20
+ export { resolveRoutes } from './config/routes.js';
21
+ export { validateAdminConfigs } from './config/validate-admin-configs.js';
22
+ export { RESERVED_FIELD_NAMES } from './config/validate-collections.js';
23
+ export { getBylineCore, initBylineCore } from './core.js';
24
+ export * from './defaults/default-values.js';
25
+ export { BylineError, ERR_DATABASE, ERR_NOT_FOUND, ERR_READ_BUDGET_EXCEEDED, ERR_STORAGE, ERR_UNHANDLED, ERR_VALIDATION, ErrorCodes, } from './lib/errors.js';
26
+ export { getLogger } from './lib/logger.js';
27
+ export { AsyncRegistry, Registry } from './lib/registry.js';
28
+ export * from './patches/index.js';
29
+ export { mergePredicates, parseSort, parseWhere, } from './query/parse-where.js';
30
+ export { getCollectionSchemasForPath } from './schemas/zod/cache.js';
31
+ export * from './services/index.js';
32
+ export * from './storage/index.js';
33
+ export { formatTextValue, looksLikeISODate, slugify, } from './utils/slugify.js';
34
+ export { getUploadFields, hasUploadField, isUploadField } from './utils/storage-utils.js';
35
+ export * from './workflow/index.js';
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+BAA+B;AAC/B,EAAE;AACF,wCAAwC;AACxC,0DAA0D;AAC1D,gEAAgE;AAChE,8DAA8D;AAC9D,EAAE;AACF,oEAAoE;AACpE,8DAA8D;AAC9D,mEAAmE;AACnE,wDAAwD;AACxD,mEAAmE;AACnE,kEAAkE;AAClE,+CAA+C;AAC/C,8EAA8E;AAE9E,cAAc,mBAAmB,CAAA;AACjC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EAExB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,wBAAwB,EACxB,uBAAuB,EACvB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,oBAAoB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