@nixxie-cms/core 1.0.3 → 2.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 (203) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/CHANGES-1.1.md +134 -0
  3. package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
  4. package/context/dist/nixxie-cms-core-context.esm.js +3 -2
  5. package/dist/declarations/src/access.d.ts +2 -2
  6. package/dist/declarations/src/access.d.ts.map +1 -1
  7. package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
  8. package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
  9. package/dist/declarations/src/admin-ui/context.d.ts +6 -6
  10. package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
  11. package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
  12. package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
  13. package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
  14. package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
  15. package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
  16. package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
  17. package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
  18. package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
  19. package/dist/declarations/src/context.d.ts +1 -1
  20. package/dist/declarations/src/context.d.ts.map +1 -1
  21. package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
  22. package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
  23. package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
  24. package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
  25. package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
  26. package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
  27. package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
  28. package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
  29. package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
  30. package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
  31. package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
  32. package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
  33. package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
  34. package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
  35. package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
  36. package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
  37. package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
  38. package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
  39. package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
  40. package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
  41. package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
  42. package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
  43. package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
  44. package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
  45. package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
  46. package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
  47. package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
  48. package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
  49. package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
  50. package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
  51. package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
  52. package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
  53. package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
  54. package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
  55. package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
  56. package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
  57. package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
  58. package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
  59. package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
  60. package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
  61. package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
  62. package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
  63. package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
  64. package/dist/declarations/src/helpers.d.ts +249 -13
  65. package/dist/declarations/src/helpers.d.ts.map +1 -1
  66. package/dist/declarations/src/index.d.ts +9 -4
  67. package/dist/declarations/src/index.d.ts.map +1 -1
  68. package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
  69. package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
  70. package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
  71. package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
  72. package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
  73. package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
  74. package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
  75. package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
  76. package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
  77. package/dist/declarations/src/lib/env.d.ts +9 -0
  78. package/dist/declarations/src/lib/env.d.ts.map +1 -0
  79. package/dist/declarations/src/lib/system.d.ts +1 -1
  80. package/dist/declarations/src/lib/system.d.ts.map +1 -1
  81. package/dist/declarations/src/list-features.d.ts +162 -0
  82. package/dist/declarations/src/list-features.d.ts.map +1 -0
  83. package/dist/declarations/src/schema.d.ts +24 -23
  84. package/dist/declarations/src/schema.d.ts.map +1 -1
  85. package/dist/declarations/src/session.d.ts +75 -0
  86. package/dist/declarations/src/session.d.ts.map +1 -1
  87. package/dist/declarations/src/types/admin-meta.d.ts +11 -11
  88. package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
  89. package/dist/declarations/src/types/config/access-control.d.ts +42 -42
  90. package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
  91. package/dist/declarations/src/types/config/fields.d.ts +19 -19
  92. package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
  93. package/dist/declarations/src/types/config/hooks.d.ts +131 -131
  94. package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
  95. package/dist/declarations/src/types/config/index.d.ts +190 -8
  96. package/dist/declarations/src/types/config/index.d.ts.map +1 -1
  97. package/dist/declarations/src/types/config/lists.d.ts +146 -108
  98. package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
  99. package/dist/declarations/src/types/context.d.ts +507 -47
  100. package/dist/declarations/src/types/context.d.ts.map +1 -1
  101. package/dist/declarations/src/types/next-fields.d.ts +28 -28
  102. package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
  103. package/dist/declarations/src/types/type-info.d.ts +3 -3
  104. package/dist/declarations/src/types/type-info.d.ts.map +1 -1
  105. package/dist/{express-455ae20c.cjs.js → express-84d534c2.cjs.js} +6 -6
  106. package/dist/{express-7559ca2d.esm.js → express-d0a4ce99.esm.js} +6 -6
  107. package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
  108. package/dist/index-6055753b.cjs.js +393 -0
  109. package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
  110. package/dist/index-f1703b7b.esm.js +386 -0
  111. package/dist/nixxie-cms-core.cjs.js +1388 -30
  112. package/dist/nixxie-cms-core.esm.js +1362 -24
  113. package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
  114. package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
  115. package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
  116. package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
  117. package/dist/{system-a321642d.cjs.js → system-6b37a5f8.cjs.js} +33 -7
  118. package/dist/{system-03e49e4f.esm.js → system-e591d821.esm.js} +33 -7
  119. package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
  120. package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
  121. package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
  122. package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
  123. package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
  124. package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
  125. package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
  126. package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
  127. package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
  128. package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
  129. package/package.json +4 -4
  130. package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
  131. package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
  132. package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
  133. package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
  134. package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
  135. package/session/dist/nixxie-cms-core-session.esm.js +279 -1
  136. package/src/access.ts +25 -25
  137. package/src/admin-ui/admin-meta-graphql.ts +5 -5
  138. package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
  139. package/src/admin-ui/components/Navigation.tsx +3 -3
  140. package/src/admin-ui/context.tsx +6 -6
  141. package/src/admin-ui/utils/Fields.tsx +241 -241
  142. package/src/admin-ui/utils/actionData.ts +36 -36
  143. package/src/admin-ui/utils/filters.ts +148 -148
  144. package/src/admin-ui/utils/useCreateItem.ts +171 -171
  145. package/src/admin-ui/utils/utils.tsx +127 -127
  146. package/src/context.ts +1 -1
  147. package/src/fields/non-null-graphql.ts +115 -115
  148. package/src/fields/types/bigInt/index.ts +6 -6
  149. package/src/fields/types/bytes/index.ts +6 -6
  150. package/src/fields/types/calendarDay/index.ts +18 -19
  151. package/src/fields/types/checkbox/index.ts +6 -6
  152. package/src/fields/types/decimal/index.ts +6 -6
  153. package/src/fields/types/file/index.ts +8 -8
  154. package/src/fields/types/float/index.ts +6 -6
  155. package/src/fields/types/image/index.ts +8 -8
  156. package/src/fields/types/integer/index.ts +6 -6
  157. package/src/fields/types/json/index.ts +5 -5
  158. package/src/fields/types/multiselect/index.ts +7 -7
  159. package/src/fields/types/multiselect/views/index.tsx +149 -151
  160. package/src/fields/types/password/index.ts +6 -6
  161. package/src/fields/types/relationship/index.ts +13 -13
  162. package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
  163. package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
  164. package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
  165. package/src/fields/types/relationship/views/index.tsx +492 -492
  166. package/src/fields/types/relationship/views/types.ts +46 -46
  167. package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
  168. package/src/fields/types/relationship/views/useFilter.tsx +109 -109
  169. package/src/fields/types/select/index.ts +6 -6
  170. package/src/fields/types/text/index.ts +6 -6
  171. package/src/fields/types/timestamp/index.ts +23 -21
  172. package/src/fields/types/virtual/index.ts +11 -11
  173. package/src/helpers.ts +773 -42
  174. package/src/index.ts +66 -24
  175. package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
  176. package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
  177. package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
  178. package/src/lib/admin-meta.ts +369 -369
  179. package/src/lib/context/createContext.ts +6 -0
  180. package/src/lib/core/access-control.ts +434 -434
  181. package/src/lib/core/cascade.ts +236 -0
  182. package/src/lib/core/initialise-lists.ts +49 -33
  183. package/src/lib/core/mutations/index.ts +7 -0
  184. package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
  185. package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
  186. package/src/lib/core/queries/output-field.ts +178 -178
  187. package/src/lib/env.ts +50 -0
  188. package/src/lib/id-field.ts +2 -2
  189. package/src/lib/system.ts +221 -207
  190. package/src/lib/typescript-schema-printer.ts +227 -227
  191. package/src/list-features.ts +476 -0
  192. package/src/schema.ts +92 -22
  193. package/src/session.ts +225 -0
  194. package/src/types/admin-meta.ts +218 -218
  195. package/src/types/config/access-control.ts +186 -186
  196. package/src/types/config/fields.ts +96 -96
  197. package/src/types/config/hooks.ts +529 -529
  198. package/src/types/config/index.ts +206 -7
  199. package/src/types/config/lists.ts +606 -565
  200. package/src/types/context.ts +592 -55
  201. package/src/types/next-fields.ts +31 -31
  202. package/src/types/type-info.ts +38 -38
  203. package/src/types/type-tests.ts +21 -21
@@ -101,12 +101,7 @@ const Cell = ({
101
101
  type: 'conjunction'
102
102
  });
103
103
  const labels = value.map(x => field.valuesToOptionsWithStringValues[x].label);
104
- let cellContent = null;
105
- if (value.length > 3) {
106
- cellContent = listFormatter.format([labels[0], `${value.length - 1} more`]);
107
- } else {
108
- cellContent = listFormatter.format(labels);
109
- }
104
+ const cellContent = value.length > 3 ? listFormatter.format([labels[0], `${value.length - 1} more`]) : listFormatter.format(labels);
110
105
  return /*#__PURE__*/jsxRuntime.jsx(typography.Text, {
111
106
  children: cellContent
112
107
  });
@@ -97,12 +97,7 @@ const Cell = ({
97
97
  type: 'conjunction'
98
98
  });
99
99
  const labels = value.map(x => field.valuesToOptionsWithStringValues[x].label);
100
- let cellContent = null;
101
- if (value.length > 3) {
102
- cellContent = listFormatter.format([labels[0], `${value.length - 1} more`]);
103
- } else {
104
- cellContent = listFormatter.format(labels);
105
- }
100
+ const cellContent = value.length > 3 ? listFormatter.format([labels[0], `${value.length - 1} more`]) : listFormatter.format(labels);
106
101
  return /*#__PURE__*/jsx(Text, {
107
102
  children: cellContent
108
103
  });
@@ -4,14 +4,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var bcryptjs = require('bcryptjs');
6
6
  var dumbPasswords = require('dumb-passwords');
7
- var resolveHooks = require('../../../../dist/resolve-hooks-165a9ce2.cjs.js');
7
+ var resolveHooks = require('../../../../dist/resolve-hooks-10a5f84c.cjs.js');
8
8
  require('pluralize');
9
9
  var nextFields = require('../../../../dist/next-fields-49c025ef.cjs.js');
10
- var nonNullGraphql = require('../../../../dist/non-null-graphql-add6bb3d.cjs.js');
10
+ require('node:crypto');
11
+ var nonNullGraphql = require('../../../../dist/non-null-graphql-4a44c122.cjs.js');
11
12
  require('node:path');
12
13
  require('@graphql-ts/schema');
13
14
  require('@graphql-ts/extend');
14
15
  var graphql = require('graphql');
16
+ require('node:async_hooks');
15
17
  require('decimal.js');
16
18
  require('graphql-upload/GraphQLUpload.js');
17
19
 
@@ -1,13 +1,15 @@
1
1
  import bcryptjs from 'bcryptjs';
2
2
  import dumbPasswords from 'dumb-passwords';
3
- import { u as userInputError } from '../../../../dist/resolve-hooks-6813a045.esm.js';
3
+ import { u as userInputError } from '../../../../dist/resolve-hooks-9e676794.esm.js';
4
4
  import 'pluralize';
5
5
  import { g, f as fieldType } from '../../../../dist/next-fields-9bf04ed8.esm.js';
6
- import { m as makeValidateHook, d as defaultIsRequired } from '../../../../dist/non-null-graphql-a84ed64d.esm.js';
6
+ import 'node:crypto';
7
+ import { m as makeValidateHook, d as defaultIsRequired } from '../../../../dist/non-null-graphql-8c5feaae.esm.js';
7
8
  import 'node:path';
8
9
  import '@graphql-ts/schema';
9
10
  import '@graphql-ts/extend';
10
11
  import { isObjectType } from 'graphql';
12
+ import 'node:async_hooks';
11
13
  import 'decimal.js';
12
14
  import 'graphql-upload/GraphQLUpload.js';
13
15
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var express = require('../../../dist/express-455ae20c.cjs.js');
5
+ var express = require('../../../dist/express-84d534c2.cjs.js');
6
6
  var migrations = require('../../../dist/migrations-ab2e0fd4.cjs.js');
7
- var system = require('../../../dist/system-a321642d.cjs.js');
7
+ var system = require('../../../dist/system-6b37a5f8.cjs.js');
8
8
  require('node:fs/promises');
9
9
  require('node:path');
10
10
  require('@prisma/internals');
@@ -24,12 +24,13 @@ require('@prisma/migrate');
24
24
  require('node:crypto');
25
25
  require('../../../dist/admin-meta-18d0c276.cjs.js');
26
26
  require('@graphql-ts/schema');
27
- require('../../../dist/resolve-hooks-165a9ce2.cjs.js');
27
+ require('../../../dist/resolve-hooks-10a5f84c.cjs.js');
28
28
  require('pluralize');
29
29
  require('../../../dist/next-fields-49c025ef.cjs.js');
30
30
  require('decimal.js');
31
31
  require('@graphql-ts/extend');
32
32
  require('graphql-upload/GraphQLUpload.js');
33
+ require('node:async_hooks');
33
34
  require('../../../dist/utils-e74e3527.cjs.js');
34
35
  require('../../../dist/utils-1b632a8f.cjs.js');
35
36
  require('../../../access/dist/nixxie-cms-core-access.cjs.js');
@@ -1,6 +1,6 @@
1
- export { E as ExitError, e as buildArtifacts, c as createExpressServer, g as generateArtifacts } from '../../../dist/express-7559ca2d.esm.js';
1
+ export { E as ExitError, e as buildArtifacts, c as createExpressServer, g as generateArtifacts } from '../../../dist/express-d0a4ce99.esm.js';
2
2
  export { w as withMigrate } from '../../../dist/migrations-996e66a0.esm.js';
3
- export { c as createSystem } from '../../../dist/system-03e49e4f.esm.js';
3
+ export { a as createSystem } from '../../../dist/system-e591d821.esm.js';
4
4
  import 'node:fs/promises';
5
5
  import 'node:path';
6
6
  import '@prisma/internals';
@@ -20,12 +20,13 @@ import '@prisma/migrate';
20
20
  import 'node:crypto';
21
21
  import '../../../dist/admin-meta-14c60fec.esm.js';
22
22
  import '@graphql-ts/schema';
23
- import '../../../dist/resolve-hooks-6813a045.esm.js';
23
+ import '../../../dist/resolve-hooks-9e676794.esm.js';
24
24
  import 'pluralize';
25
25
  import '../../../dist/next-fields-9bf04ed8.esm.js';
26
26
  import 'decimal.js';
27
27
  import '@graphql-ts/extend';
28
28
  import 'graphql-upload/GraphQLUpload.js';
29
+ import 'node:async_hooks';
29
30
  import '../../../dist/utils-ef2cd0f4.esm.js';
30
31
  import '../../../dist/utils-0cc426c8.esm.js';
31
32
  import '../../../access/dist/nixxie-cms-core-access.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixxie-cms/core",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nixxiecms/nixxie/tree/main/packages/core"
@@ -266,12 +266,14 @@
266
266
  "clipboard-copy": "^4.0.1",
267
267
  "conf": "^10.2.0",
268
268
  "cookie": "^1.0.0",
269
+ "@types/cors": "^2.8.13",
269
270
  "cors": "^2.8.5",
270
271
  "dataloader": "^2.1.0",
271
272
  "date-fns": "^4.0.0",
272
273
  "decimal.js": "^10.4.1",
273
274
  "dumb-passwords": "^0.2.1",
274
275
  "esbuild": "^0.28.0",
276
+ "@types/express": "^4.17.14",
275
277
  "express": "^4.19.2",
276
278
  "fast-deep-equal": "^3.1.3",
277
279
  "fs-extra": "^11.0.0",
@@ -293,8 +295,6 @@
293
295
  "@types/apollo-upload-client": "19.0.0",
294
296
  "@types/body-parser": "^1.19.2",
295
297
  "@types/bytes": "^3.1.1",
296
- "@types/cors": "^2.8.13",
297
- "@types/express": "^4.17.14",
298
298
  "@types/fs-extra": "^11.0.0",
299
299
  "@types/pluralize": "^0.0.33",
300
300
  "@types/prompts": "^2.0.14",
@@ -302,7 +302,7 @@
302
302
  "@types/react-dom": "^19.2.3",
303
303
  "@types/resolve": "^1.20.2",
304
304
  "@types/uuid": "^11.0.0",
305
- "@nixxie-cms/core": "^1.0.3"
305
+ "@nixxie-cms/core": "^2.0.0"
306
306
  },
307
307
  "preconstruct": {
308
308
  "entrypoints": [
@@ -10,8 +10,8 @@ var fs = require('node:fs/promises');
10
10
  var path = require('node:path');
11
11
  var node_util = require('node:util');
12
12
  var resolve = require('resolve');
13
- var system = require('../../../dist/system-a321642d.cjs.js');
14
- var express = require('../../../dist/express-455ae20c.cjs.js');
13
+ var system = require('../../../dist/system-6b37a5f8.cjs.js');
14
+ var express = require('../../../dist/express-84d534c2.cjs.js');
15
15
  var node_module = require('node:module');
16
16
  var node_http = require('node:http');
17
17
  var internals = require('@prisma/internals');
@@ -30,12 +30,13 @@ var node_child_process = require('node:child_process');
30
30
  var node_crypto = require('node:crypto');
31
31
  require('../../../dist/admin-meta-18d0c276.cjs.js');
32
32
  require('@graphql-ts/schema');
33
- require('../../../dist/resolve-hooks-165a9ce2.cjs.js');
33
+ require('../../../dist/resolve-hooks-10a5f84c.cjs.js');
34
34
  require('pluralize');
35
35
  require('../../../dist/next-fields-49c025ef.cjs.js');
36
36
  require('decimal.js');
37
37
  require('@graphql-ts/extend');
38
38
  require('graphql-upload/GraphQLUpload.js');
39
+ require('node:async_hooks');
39
40
  require('../../../dist/utils-e74e3527.cjs.js');
40
41
  require('../../../dist/utils-1b632a8f.cjs.js');
41
42
  require('../../../access/dist/nixxie-cms-core-access.cjs.js');
@@ -6,8 +6,8 @@ import fs from 'node:fs/promises';
6
6
  import path, { join } from 'node:path';
7
7
  import { promisify } from 'node:util';
8
8
  import resolve from 'resolve';
9
- import { w as withSpan, c as createSystem } from '../../../dist/system-03e49e4f.esm.js';
10
- import { i as importBuiltNixxieConfiguration, v as validateArtifacts, g as generateArtifacts, a as generateTypes, b as generatePrismaClient, E as ExitError, c as createExpressServer, p as printPrismaSchema, d as getFormattedGraphQLSchema } from '../../../dist/express-7559ca2d.esm.js';
9
+ import { w as withSpan, a as createSystem } from '../../../dist/system-e591d821.esm.js';
10
+ import { i as importBuiltNixxieConfiguration, v as validateArtifacts, g as generateArtifacts, a as generateTypes, b as generatePrismaClient, E as ExitError, c as createExpressServer, p as printPrismaSchema, d as getFormattedGraphQLSchema } from '../../../dist/express-d0a4ce99.esm.js';
11
11
  import { createRequire } from 'node:module';
12
12
  import { createServer } from 'node:http';
13
13
  import { createDatabase, dropDatabase } from '@prisma/internals';
@@ -26,12 +26,13 @@ import { spawn } from 'node:child_process';
26
26
  import { randomBytes } from 'node:crypto';
27
27
  import '../../../dist/admin-meta-14c60fec.esm.js';
28
28
  import '@graphql-ts/schema';
29
- import '../../../dist/resolve-hooks-6813a045.esm.js';
29
+ import '../../../dist/resolve-hooks-9e676794.esm.js';
30
30
  import 'pluralize';
31
31
  import '../../../dist/next-fields-9bf04ed8.esm.js';
32
32
  import 'decimal.js';
33
33
  import '@graphql-ts/extend';
34
34
  import 'graphql-upload/GraphQLUpload.js';
35
+ import 'node:async_hooks';
35
36
  import '../../../dist/utils-ef2cd0f4.esm.js';
36
37
  import '../../../dist/utils-0cc426c8.esm.js';
37
38
  import '../../../access/dist/nixxie-cms-core-access.esm.js';
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var scripts_cli_dist_nixxieCmsCoreScriptsCli = require('../cli/dist/nixxie-cms-core-scripts-cli.cjs.js');
4
- var express = require('../../dist/express-455ae20c.cjs.js');
4
+ var express = require('../../dist/express-84d534c2.cjs.js');
5
5
  require('meow');
6
6
  require('esbuild');
7
7
  require('@nodelib/fs.walk');
@@ -10,17 +10,18 @@ require('node:fs/promises');
10
10
  require('node:path');
11
11
  require('node:util');
12
12
  require('resolve');
13
- require('../../dist/system-a321642d.cjs.js');
13
+ require('../../dist/system-6b37a5f8.cjs.js');
14
14
  require('node:crypto');
15
15
  require('../../dist/admin-meta-18d0c276.cjs.js');
16
16
  require('graphql');
17
17
  require('@graphql-ts/schema');
18
- require('../../dist/resolve-hooks-165a9ce2.cjs.js');
18
+ require('../../dist/resolve-hooks-10a5f84c.cjs.js');
19
19
  require('pluralize');
20
20
  require('../../dist/next-fields-49c025ef.cjs.js');
21
21
  require('decimal.js');
22
22
  require('@graphql-ts/extend');
23
23
  require('graphql-upload/GraphQLUpload.js');
24
+ require('node:async_hooks');
24
25
  require('../../dist/utils-e74e3527.cjs.js');
25
26
  require('../../dist/utils-1b632a8f.cjs.js');
26
27
  require('../../access/dist/nixxie-cms-core-access.cjs.js');
@@ -1,5 +1,5 @@
1
1
  import { cli } from '../cli/dist/nixxie-cms-core-scripts-cli.esm.js';
2
- import { E as ExitError } from '../../dist/express-7559ca2d.esm.js';
2
+ import { E as ExitError } from '../../dist/express-d0a4ce99.esm.js';
3
3
  import 'meow';
4
4
  import 'esbuild';
5
5
  import '@nodelib/fs.walk';
@@ -8,17 +8,18 @@ import 'node:fs/promises';
8
8
  import 'node:path';
9
9
  import 'node:util';
10
10
  import 'resolve';
11
- import '../../dist/system-03e49e4f.esm.js';
11
+ import '../../dist/system-e591d821.esm.js';
12
12
  import 'node:crypto';
13
13
  import '../../dist/admin-meta-14c60fec.esm.js';
14
14
  import 'graphql';
15
15
  import '@graphql-ts/schema';
16
- import '../../dist/resolve-hooks-6813a045.esm.js';
16
+ import '../../dist/resolve-hooks-9e676794.esm.js';
17
17
  import 'pluralize';
18
18
  import '../../dist/next-fields-9bf04ed8.esm.js';
19
19
  import 'decimal.js';
20
20
  import '@graphql-ts/extend';
21
21
  import 'graphql-upload/GraphQLUpload.js';
22
+ import 'node:async_hooks';
22
23
  import '../../dist/utils-ef2cd0f4.esm.js';
23
24
  import '../../dist/utils-0cc426c8.esm.js';
24
25
  import '../../access/dist/nixxie-cms-core-access.esm.js';
@@ -5,6 +5,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var node_crypto = require('node:crypto');
6
6
  var cookie = require('cookie');
7
7
  var Iron = require('@hapi/iron');
8
+ var index = require('../../dist/index-6055753b.cjs.js');
9
+ require('pluralize');
10
+ require('../../dist/next-fields-49c025ef.cjs.js');
11
+ require('decimal.js');
12
+ require('@graphql-ts/schema');
13
+ require('@graphql-ts/extend');
14
+ require('graphql-upload/GraphQLUpload.js');
15
+ require('graphql');
16
+ require('../../dist/resolve-hooks-10a5f84c.cjs.js');
17
+ require('node:async_hooks');
18
+ require('../../dist/non-null-graphql-4a44c122.cjs.js');
19
+ require('node:path');
8
20
 
9
21
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
22
 
@@ -104,6 +116,224 @@ function statelessSessions({
104
116
  }
105
117
  };
106
118
  }
119
+ function sessionModel(context, collection) {
120
+ var _context$prisma;
121
+ const delegate = (_context$prisma = context.prisma) === null || _context$prisma === void 0 ? void 0 : _context$prisma[collection[0].toLowerCase() + collection.slice(1)];
122
+ if (!delegate) {
123
+ throw new Error(`persistentSessions: collection "${collection}" was not found in the Prisma client. ` + `Add it to your config (e.g. \`collections: { ${collection}: sessionCollection() }\`) and run a migration.`);
124
+ }
125
+ return delegate;
126
+ }
127
+
128
+ /**
129
+ * Database-backed sessions: the cookie carries only an opaque token; the session itself
130
+ * lives in a collection, so sessions survive restarts, can be listed per user, and can be
131
+ * revoked server-side (see `listSessions` / `revokeSession` / `revokeUserSessions`).
132
+ *
133
+ * Tracks `lastSeenAt` (refreshed at most once a minute), `userAgent` and `ip` per session.
134
+ * Pair with a scheduled `pruneSessions()` job to clear expired/revoked rows.
135
+ */
136
+ function persistentSessions({
137
+ collection = 'UserSession',
138
+ maxAge = 60 * 60 * 8,
139
+ // 8 hours
140
+ ...statelessSessionsOptions
141
+ } = {}) {
142
+ const stateless = statelessSessions({
143
+ ...statelessSessionsOptions,
144
+ maxAge
145
+ });
146
+ return {
147
+ async get({
148
+ context
149
+ }) {
150
+ const token = await stateless.get({
151
+ context
152
+ });
153
+ if (!token) return;
154
+ const row = await sessionModel(context, collection).findUnique({
155
+ where: {
156
+ token
157
+ }
158
+ });
159
+ if (!row || row.revokedAt) return;
160
+ if (row.expiresAt && row.expiresAt.getTime() < Date.now()) return;
161
+
162
+ // Refresh activity tracking at most once a minute; never block the request on it.
163
+ if (!row.lastSeenAt || Date.now() - row.lastSeenAt.getTime() > 60000) {
164
+ void sessionModel(context, collection).update({
165
+ where: {
166
+ token
167
+ },
168
+ data: {
169
+ lastSeenAt: new Date()
170
+ }
171
+ }).catch(() => {});
172
+ }
173
+ return row.data;
174
+ },
175
+ async start({
176
+ context,
177
+ data
178
+ }) {
179
+ var _ref, _ref2, _ref3, _forwarded$split$, _req$socket;
180
+ const token = node_crypto.randomBytes(24).toString('base64url'); // 192-bit
181
+ const req = context.req;
182
+ const forwarded = req === null || req === void 0 ? void 0 : req.headers['x-forwarded-for'];
183
+ await sessionModel(context, collection).create({
184
+ data: {
185
+ token,
186
+ data: data,
187
+ itemId: (data === null || data === void 0 ? void 0 : data.itemId) != null ? String(data.itemId) : null,
188
+ expiresAt: new Date(Date.now() + maxAge * 1000),
189
+ createdAt: new Date(),
190
+ lastSeenAt: new Date(),
191
+ userAgent: (_ref = req === null || req === void 0 ? void 0 : req.headers['user-agent']) !== null && _ref !== void 0 ? _ref : null,
192
+ ip: (_ref2 = (_ref3 = typeof forwarded === 'string' ? (_forwarded$split$ = forwarded.split(',')[0]) === null || _forwarded$split$ === void 0 ? void 0 : _forwarded$split$.trim() : forwarded === null || forwarded === void 0 ? void 0 : forwarded[0]) !== null && _ref3 !== void 0 ? _ref3 : req === null || req === void 0 || (_req$socket = req.socket) === null || _req$socket === void 0 ? void 0 : _req$socket.remoteAddress) !== null && _ref2 !== void 0 ? _ref2 : null
193
+ }
194
+ });
195
+ return (await stateless.start({
196
+ context,
197
+ data: token
198
+ })) || '';
199
+ },
200
+ async end({
201
+ context
202
+ }) {
203
+ const token = await stateless.get({
204
+ context
205
+ });
206
+ if (token) {
207
+ await sessionModel(context, collection).deleteMany({
208
+ where: {
209
+ token
210
+ }
211
+ });
212
+ }
213
+ await stateless.end({
214
+ context
215
+ });
216
+ }
217
+ };
218
+ }
219
+ const stripToken = row => {
220
+ var _row$itemId, _row$lastSeenAt, _row$expiresAt, _row$revokedAt, _row$userAgent, _row$ip;
221
+ return {
222
+ id: row.id,
223
+ itemId: (_row$itemId = row.itemId) !== null && _row$itemId !== void 0 ? _row$itemId : null,
224
+ createdAt: row.createdAt,
225
+ lastSeenAt: (_row$lastSeenAt = row.lastSeenAt) !== null && _row$lastSeenAt !== void 0 ? _row$lastSeenAt : null,
226
+ expiresAt: (_row$expiresAt = row.expiresAt) !== null && _row$expiresAt !== void 0 ? _row$expiresAt : null,
227
+ revokedAt: (_row$revokedAt = row.revokedAt) !== null && _row$revokedAt !== void 0 ? _row$revokedAt : null,
228
+ userAgent: (_row$userAgent = row.userAgent) !== null && _row$userAgent !== void 0 ? _row$userAgent : null,
229
+ ip: (_row$ip = row.ip) !== null && _row$ip !== void 0 ? _row$ip : null
230
+ };
231
+ };
232
+
233
+ /** Active (non-revoked, non-expired) sessions for a user, without their tokens. */
234
+ async function listSessions(context, itemId, {
235
+ collection = 'UserSession'
236
+ } = {}) {
237
+ const rows = await sessionModel(context, collection).findMany({
238
+ where: {
239
+ itemId: String(itemId),
240
+ revokedAt: null,
241
+ expiresAt: {
242
+ gte: new Date()
243
+ }
244
+ },
245
+ orderBy: {
246
+ lastSeenAt: 'desc'
247
+ }
248
+ });
249
+ return rows.map(stripToken);
250
+ }
251
+
252
+ /** Revoke a single session by its row id. The next request with its cookie is signed out. */
253
+ async function revokeSession(context, sessionId, {
254
+ collection = 'UserSession'
255
+ } = {}) {
256
+ await sessionModel(context, collection).updateMany({
257
+ where: {
258
+ id: sessionId
259
+ },
260
+ data: {
261
+ revokedAt: new Date()
262
+ }
263
+ });
264
+ }
265
+
266
+ /** Revoke every session belonging to a user (e.g. after a password change). */
267
+ async function revokeUserSessions(context, itemId, {
268
+ collection = 'UserSession'
269
+ } = {}) {
270
+ const result = await sessionModel(context, collection).updateMany({
271
+ where: {
272
+ itemId: String(itemId),
273
+ revokedAt: null
274
+ },
275
+ data: {
276
+ revokedAt: new Date()
277
+ }
278
+ });
279
+ return result.count;
280
+ }
281
+
282
+ /** Delete expired and revoked session rows. Run from a scheduled job. */
283
+ async function pruneSessions(context, {
284
+ collection = 'UserSession'
285
+ } = {}) {
286
+ const result = await sessionModel(context, collection).deleteMany({
287
+ where: {
288
+ OR: [{
289
+ expiresAt: {
290
+ lt: new Date()
291
+ }
292
+ }, {
293
+ revokedAt: {
294
+ not: null
295
+ }
296
+ }]
297
+ }
298
+ });
299
+ return result.count;
300
+ }
301
+
302
+ /**
303
+ * Sign the current user in as another user, recording who is impersonating in the
304
+ * session (`impersonatedBy`). Works with any session strategy. The caller is
305
+ * responsible for authorising the action (e.g. an admin-only check).
306
+ */
307
+ async function startImpersonation(context, itemId) {
308
+ if (!context.sessionStrategy) throw new Error('startImpersonation: no session strategy configured');
309
+ const current = context.session;
310
+ if (!(current !== null && current !== void 0 && current.itemId)) throw new Error('startImpersonation: there is no signed-in session');
311
+ if (current.impersonatedBy != null) {
312
+ throw new Error('startImpersonation: already impersonating — end the current impersonation first');
313
+ }
314
+ await context.sessionStrategy.start({
315
+ context,
316
+ data: {
317
+ itemId,
318
+ impersonatedBy: current.itemId
319
+ }
320
+ });
321
+ }
322
+
323
+ /** Return from an impersonated session to the original user's session. */
324
+ async function endImpersonation(context) {
325
+ if (!context.sessionStrategy) throw new Error('endImpersonation: no session strategy configured');
326
+ const current = context.session;
327
+ if ((current === null || current === void 0 ? void 0 : current.impersonatedBy) == null) {
328
+ throw new Error('endImpersonation: the current session is not impersonating anyone');
329
+ }
330
+ await context.sessionStrategy.start({
331
+ context,
332
+ data: {
333
+ itemId: current.impersonatedBy
334
+ }
335
+ });
336
+ }
107
337
  function storedSessions({
108
338
  store: storeFn,
109
339
  maxAge = 60 * 60 * 8,
@@ -153,5 +383,61 @@ function storedSessions({
153
383
  };
154
384
  }
155
385
 
386
+ /**
387
+ * Ready-made collection definition backing `persistentSessions()`.
388
+ *
389
+ * @example
390
+ * config({
391
+ * collections: {
392
+ * UserSession: sessionCollection(),
393
+ * ...collections,
394
+ * },
395
+ * session: persistentSessions({ collection: 'UserSession' }),
396
+ * })
397
+ */
398
+ function sessionCollection() {
399
+ return {
400
+ fields: {
401
+ token: index.text({
402
+ validation: {
403
+ isRequired: true
404
+ },
405
+ isIndexed: 'unique'
406
+ }),
407
+ data: index.json(),
408
+ itemId: index.text({
409
+ isIndexed: true
410
+ }),
411
+ expiresAt: index.timestamp(),
412
+ createdAt: index.timestamp({
413
+ defaultValue: {
414
+ kind: 'now'
415
+ },
416
+ db: {
417
+ isNullable: false
418
+ }
419
+ }),
420
+ lastSeenAt: index.timestamp(),
421
+ revokedAt: index.timestamp(),
422
+ userAgent: index.text(),
423
+ ip: index.text()
424
+ },
425
+ graphql: {
426
+ omit: true
427
+ },
428
+ ui: {
429
+ hideNavigation: true
430
+ }
431
+ };
432
+ }
433
+
434
+ exports.endImpersonation = endImpersonation;
435
+ exports.listSessions = listSessions;
436
+ exports.persistentSessions = persistentSessions;
437
+ exports.pruneSessions = pruneSessions;
438
+ exports.revokeSession = revokeSession;
439
+ exports.revokeUserSessions = revokeUserSessions;
440
+ exports.sessionCollection = sessionCollection;
441
+ exports.startImpersonation = startImpersonation;
156
442
  exports.statelessSessions = statelessSessions;
157
443
  exports.storedSessions = storedSessions;