@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
@@ -2,16 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var resolveHooks = require('../../dist/resolve-hooks-165a9ce2.cjs.js');
5
+ var resolveHooks = require('../../dist/resolve-hooks-10a5f84c.cjs.js');
6
6
  require('pluralize');
7
7
  var nextFields = require('../../dist/next-fields-49c025ef.cjs.js');
8
- var index = require('../../dist/index-42045902.cjs.js');
9
- var nonNullGraphql = require('../../dist/non-null-graphql-add6bb3d.cjs.js');
8
+ var node_crypto = require('node:crypto');
9
+ var index$1 = require('../../dist/index-6055753b.cjs.js');
10
+ var nonNullGraphql = require('../../dist/non-null-graphql-4a44c122.cjs.js');
10
11
  require('node:path');
11
12
  var schema = require('@graphql-ts/schema');
12
13
  require('@graphql-ts/extend');
13
14
  var Decimal = require('decimal.js');
14
- var node_crypto = require('node:crypto');
15
+ var index = require('../../dist/index-ac29f382.cjs.js');
15
16
  var fields_types_image_utils_dist_nixxieCmsCoreFieldsTypesImageUtils = require('../types/image/utils/dist/nixxie-cms-core-fields-types-image-utils.cjs.js');
16
17
  var jpg = require('image-size/types/jpg');
17
18
  var png = require('image-size/types/png');
@@ -19,9 +20,10 @@ var webp = require('image-size/types/webp');
19
20
  var gif = require('image-size/types/gif');
20
21
  var node_stream = require('node:stream');
21
22
  var fields_types_password_dist_nixxieCmsCoreFieldsTypesPassword = require('../types/password/dist/nixxie-cms-core-fields-types-password.cjs.js');
22
- var utils = require('../../dist/utils-1b632a8f.cjs.js');
23
23
  var graphql = require('graphql');
24
+ var utils = require('../../dist/utils-1b632a8f.cjs.js');
24
25
  var fields_types_bytes_dist_nixxieCmsCoreFieldsTypesBytes = require('../types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js');
26
+ require('node:async_hooks');
25
27
  require('graphql-upload/GraphQLUpload.js');
26
28
  require('../../dist/admin-meta-18d0c276.cjs.js');
27
29
  require('bcryptjs');
@@ -57,7 +59,7 @@ function checkbox(config = {}) {
57
59
  input: {
58
60
  where: {
59
61
  arg: nextFields.g.arg({
60
- type: index.filters[meta.provider].Boolean.required
62
+ type: index$1.filters[meta.provider].Boolean.required
61
63
  })
62
64
  },
63
65
  create: {
@@ -196,9 +198,9 @@ function decimal(config = {}) {
196
198
  } : undefined,
197
199
  where: {
198
200
  arg: nextFields.g.arg({
199
- type: index.filters[meta.provider].Decimal[mode]
201
+ type: index$1.filters[meta.provider].Decimal[mode]
200
202
  }),
201
- resolve: mode === 'optional' ? index.resolveCommon : undefined
203
+ resolve: mode === 'optional' ? index$1.resolveCommon : undefined
202
204
  },
203
205
  create: {
204
206
  arg: nextFields.g.arg({
@@ -460,9 +462,9 @@ function float(config = {}) {
460
462
  } : undefined,
461
463
  where: {
462
464
  arg: nextFields.g.arg({
463
- type: index.filters[meta.provider].Float[mode]
465
+ type: index$1.filters[meta.provider].Float[mode]
464
466
  }),
465
- resolve: mode === 'optional' ? index.resolveCommon : undefined
467
+ resolve: mode === 'optional' ? index$1.resolveCommon : undefined
466
468
  },
467
469
  create: {
468
470
  arg: nextFields.g.arg({
@@ -503,139 +505,9 @@ function float(config = {}) {
503
505
  };
504
506
  }
505
507
 
506
- // for a signed 32-bit integer
507
- const MAX_INT$3 = 0x7fffffff;
508
- const MIN_INT$3 = -0x80000000;
509
- function integer(config = {}) {
510
- var _defaultValue_$kind;
511
- const {
512
- defaultValue: defaultValue_,
513
- isIndexed,
514
- validation = {}
515
- } = config;
516
- const {
517
- isRequired = false,
518
- min,
519
- max
520
- } = validation;
521
- const defaultValue = typeof defaultValue_ === 'number' ? defaultValue_ : (_defaultValue_$kind = defaultValue_ === null || defaultValue_ === void 0 ? void 0 : defaultValue_.kind) !== null && _defaultValue_$kind !== void 0 ? _defaultValue_$kind : null;
522
- return meta => {
523
- var _config$db, _config$db2;
524
- if (typeof defaultValue === 'number' && !Number.isInteger(defaultValue)) {
525
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies a default value of: ${defaultValue} but it must be a valid finite number`);
526
- }
527
- if (min !== undefined && !Number.isInteger(min)) {
528
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.min: ${min} but it must be an integer`);
529
- }
530
- if (max !== undefined && !Number.isInteger(max)) {
531
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.max: ${max} but it must be an integer`);
532
- }
533
- if (min !== undefined && (min > MAX_INT$3 || min < MIN_INT$3)) {
534
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.min: ${min} which is outside of the range of a 32-bit signed integer`);
535
- }
536
- if (max !== undefined && (max > MAX_INT$3 || max < MIN_INT$3)) {
537
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.max: ${max} which is outside of the range of a 32-bit signed integer`);
538
- }
539
- if (min !== undefined && max !== undefined && min > max) {
540
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies a validation.max that is less than the validation.min, and therefore has no valid options`);
541
- }
542
- const hasAdditionalValidation = min !== undefined || max !== undefined;
543
- const {
544
- mode,
545
- validate
546
- } = nonNullGraphql.makeValidateHook(meta, config, hasAdditionalValidation ? ({
547
- resolvedData,
548
- operation,
549
- addValidationError
550
- }) => {
551
- if (operation === 'delete') return;
552
- const value = resolvedData[meta.fieldKey];
553
- if (typeof value === 'number') {
554
- if (min !== undefined && value < min) {
555
- addValidationError(`value must be greater than or equal to ${min}`);
556
- }
557
- if (max !== undefined && value > max) {
558
- addValidationError(`value must be less than or equal to ${max}`);
559
- }
560
- }
561
- } : undefined, defaultValue !== null);
562
- return nextFields.fieldType({
563
- kind: 'scalar',
564
- mode,
565
- scalar: 'Int',
566
- index: isIndexed === true ? 'index' : isIndexed || undefined,
567
- default: typeof defaultValue === 'number' ? {
568
- kind: 'literal',
569
- value: defaultValue
570
- } : defaultValue === 'autoincrement' ? {
571
- kind: 'autoincrement'
572
- } : undefined,
573
- map: (_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.map,
574
- extendPrismaSchema: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.extendPrismaSchema
575
- })({
576
- ...config,
577
- ...nonNullGraphql.defaultIsRequired(config, isRequired),
578
- hooks: {
579
- ...config.hooks,
580
- validate
581
- },
582
- input: {
583
- uniqueWhere: isIndexed === 'unique' ? {
584
- arg: nextFields.g.arg({
585
- type: nextFields.g.Int
586
- })
587
- } : undefined,
588
- where: {
589
- arg: nextFields.g.arg({
590
- type: index.filters[meta.provider].Int[mode]
591
- }),
592
- resolve: mode === 'optional' ? index.resolveCommon : undefined
593
- },
594
- create: {
595
- arg: nextFields.g.arg({
596
- type: nextFields.g.Int,
597
- defaultValue: typeof defaultValue === 'number' ? defaultValue : undefined
598
- }),
599
- resolve(value) {
600
- if (value === undefined) {
601
- if (defaultValue === 'autoincrement') return undefined;
602
- return defaultValue;
603
- }
604
- return value;
605
- }
606
- },
607
- update: {
608
- arg: nextFields.g.arg({
609
- type: nextFields.g.Int
610
- })
611
- },
612
- orderBy: {
613
- arg: nextFields.g.arg({
614
- type: nextFields.orderDirectionEnum
615
- })
616
- }
617
- },
618
- output: nextFields.g.field({
619
- type: nextFields.g.Int
620
- }),
621
- __nxTelemetryFieldTypeName: '@nixxie-cms/integer',
622
- views: '@nixxie-cms/core/fields/types/integer/views',
623
- getAdminMeta() {
624
- return {
625
- validation: {
626
- min: min !== null && min !== void 0 ? min : MIN_INT$3,
627
- max: max !== null && max !== void 0 ? max : MAX_INT$3
628
- },
629
- defaultValue
630
- };
631
- }
632
- });
633
- };
634
- }
635
-
636
508
  // for a signed 64-bit integer
637
- const MAX_INT$2 = 9223372036854775807n;
638
- const MIN_INT$2 = -9223372036854775808n;
509
+ const MAX_INT$1 = 9223372036854775807n;
510
+ const MIN_INT$1 = -9223372036854775808n;
639
511
 
640
512
  // TODO: https://github.com/Nixxie/keystatic/blob/main/design-system/pkg/src/number-field/NumberField.tsx
641
513
  function bigInt(config = {}) {
@@ -676,10 +548,10 @@ function bigInt(config = {}) {
676
548
  if (max !== undefined && !Number.isInteger(max)) {
677
549
  throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.max: ${max} but it must be an integer`);
678
550
  }
679
- if (min !== undefined && (min > MAX_INT$2 || min < MIN_INT$2)) {
551
+ if (min !== undefined && (min > MAX_INT$1 || min < MIN_INT$1)) {
680
552
  throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.min: ${min} which is outside of the range of a 64-bit signed integer`);
681
553
  }
682
- if (max !== undefined && (max > MAX_INT$2 || max < MIN_INT$2)) {
554
+ if (max !== undefined && (max > MAX_INT$1 || max < MIN_INT$1)) {
683
555
  throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.max: ${max} which is outside of the range of a 64-bit signed integer`);
684
556
  }
685
557
  if (min !== undefined && max !== undefined && min > max) {
@@ -733,9 +605,9 @@ function bigInt(config = {}) {
733
605
  } : undefined,
734
606
  where: {
735
607
  arg: nextFields.g.arg({
736
- type: index.filters[meta.provider].BigInt[mode]
608
+ type: index$1.filters[meta.provider].BigInt[mode]
737
609
  }),
738
- resolve: mode === 'optional' ? index.resolveCommon : undefined
610
+ resolve: mode === 'optional' ? index$1.resolveCommon : undefined
739
611
  },
740
612
  create: {
741
613
  arg: nextFields.g.arg({
@@ -770,8 +642,8 @@ function bigInt(config = {}) {
770
642
  var _min$toString, _max$toString;
771
643
  return {
772
644
  validation: {
773
- min: (_min$toString = min === null || min === void 0 ? void 0 : min.toString()) !== null && _min$toString !== void 0 ? _min$toString : `${MIN_INT$2}`,
774
- max: (_max$toString = max === null || max === void 0 ? void 0 : max.toString()) !== null && _max$toString !== void 0 ? _max$toString : `${MAX_INT$2}`
645
+ min: (_min$toString = min === null || min === void 0 ? void 0 : min.toString()) !== null && _min$toString !== void 0 ? _min$toString : `${MIN_INT$1}`,
646
+ max: (_max$toString = max === null || max === void 0 ? void 0 : max.toString()) !== null && _max$toString !== void 0 ? _max$toString : `${MAX_INT$1}`
775
647
  },
776
648
  defaultValue: typeof defaultValue === 'bigint' ? defaultValue.toString() : defaultValue
777
649
  };
@@ -1022,427 +894,6 @@ function defaultTransformName(_) {
1022
894
  return node_crypto.randomBytes(16).toString('base64url');
1023
895
  }
1024
896
 
1025
- function json({
1026
- defaultValue = null,
1027
- ...config
1028
- } = {}) {
1029
- return meta => {
1030
- var _config$db, _config$db2;
1031
- if (config.isIndexed === 'unique') {
1032
- throw Error("isIndexed: 'unique' is not a supported option for field type json");
1033
- }
1034
- return nextFields.fieldType({
1035
- kind: 'scalar',
1036
- mode: 'optional',
1037
- scalar: 'Json',
1038
- default: defaultValue === null ? undefined : meta.provider === 'sqlite' ? undefined : {
1039
- kind: 'literal',
1040
- // TODO: waiting on https://github.com/prisma/prisma/issues/26571
1041
- // input.create manages defaultValues anyway
1042
- value: JSON.stringify(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null)
1043
- },
1044
- map: (_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.map,
1045
- extendPrismaSchema: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.extendPrismaSchema
1046
- })({
1047
- ...config,
1048
- __nxTelemetryFieldTypeName: '@nixxie-cms/json',
1049
- input: {
1050
- create: {
1051
- arg: nextFields.g.arg({
1052
- type: nextFields.g.JSON
1053
- }),
1054
- resolve(val) {
1055
- // TODO: redundant when https://github.com/prisma/prisma/issues/26571 is resolved
1056
- return val === undefined ? defaultValue : val;
1057
- }
1058
- },
1059
- update: {
1060
- arg: nextFields.g.arg({
1061
- type: nextFields.g.JSON
1062
- })
1063
- }
1064
- },
1065
- output: nextFields.g.field({
1066
- type: nextFields.g.JSON
1067
- }),
1068
- views: '@nixxie-cms/core/fields/types/json/views',
1069
- getAdminMeta: () => ({
1070
- defaultValue
1071
- })
1072
- });
1073
- };
1074
- }
1075
-
1076
- // these are the lowest and highest values for a signed 32-bit integer
1077
- const MAX_INT$1 = 2147483647;
1078
- const MIN_INT$1 = -2147483648;
1079
- function select(config) {
1080
- const {
1081
- isIndexed,
1082
- ui: {
1083
- displayMode = 'select',
1084
- ...ui
1085
- } = {},
1086
- defaultValue,
1087
- validation
1088
- } = config;
1089
- return meta => {
1090
- var _validation$isRequire, _config$db, _config$db2;
1091
- const options = config.options.map(option => {
1092
- if (typeof option === 'string') {
1093
- return {
1094
- label: utils.humanize(option),
1095
- value: option
1096
- };
1097
- }
1098
- return option;
1099
- });
1100
- const accepted = new Set(options.map(x => x.value));
1101
- if (accepted.size !== options.length) {
1102
- throw new Error(`${meta.listKey}.${meta.fieldKey}: duplicate options, this is not allowed`);
1103
- }
1104
- const {
1105
- mode,
1106
- validate
1107
- } = nonNullGraphql.makeValidateHook(meta, config, ({
1108
- resolvedData,
1109
- operation,
1110
- addValidationError
1111
- }) => {
1112
- if (operation === 'delete') return;
1113
- const value = resolvedData[meta.fieldKey];
1114
- if (value != null && !accepted.has(value)) {
1115
- addValidationError(`value is not an accepted option`);
1116
- }
1117
- });
1118
- const commonConfig = {
1119
- ...config,
1120
- mode,
1121
- ...nonNullGraphql.defaultIsRequired({
1122
- ui
1123
- }, (_validation$isRequire = validation === null || validation === void 0 ? void 0 : validation.isRequired) !== null && _validation$isRequire !== void 0 ? _validation$isRequire : false),
1124
- hooks: {
1125
- ...config.hooks,
1126
- validate
1127
- },
1128
- __nxTelemetryFieldTypeName: '@nixxie-cms/select',
1129
- views: '@nixxie-cms/core/fields/types/select/views',
1130
- getAdminMeta: () => {
1131
- var _config$type;
1132
- return {
1133
- options,
1134
- type: (_config$type = config.type) !== null && _config$type !== void 0 ? _config$type : 'string',
1135
- displayMode: displayMode,
1136
- defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : null
1137
- };
1138
- }
1139
- };
1140
- const commonDbFieldConfig = {
1141
- mode,
1142
- index: isIndexed === true ? 'index' : isIndexed || undefined,
1143
- default: defaultValue === undefined ? undefined : {
1144
- kind: 'literal',
1145
- value: defaultValue
1146
- },
1147
- map: (_config$db = config.db) === null || _config$db === void 0 ? void 0 : _config$db.map,
1148
- extendPrismaSchema: (_config$db2 = config.db) === null || _config$db2 === void 0 ? void 0 : _config$db2.extendPrismaSchema
1149
- };
1150
- const resolveCreate = val => {
1151
- if (val === undefined) {
1152
- var _ref;
1153
- return (_ref = defaultValue) !== null && _ref !== void 0 ? _ref : null;
1154
- }
1155
- return val;
1156
- };
1157
- if (config.type === 'integer') {
1158
- if (config.options.some(({
1159
- value
1160
- }) => !Number.isInteger(value) || value > MAX_INT$1 || value < MIN_INT$1)) {
1161
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies integer values that are outside the range of a 32-bit signed integer`);
1162
- }
1163
- return nextFields.fieldType({
1164
- kind: 'scalar',
1165
- scalar: 'Int',
1166
- ...commonDbFieldConfig
1167
- })({
1168
- ...commonConfig,
1169
- input: {
1170
- uniqueWhere: isIndexed === 'unique' ? {
1171
- arg: nextFields.g.arg({
1172
- type: nextFields.g.Int
1173
- })
1174
- } : undefined,
1175
- where: {
1176
- arg: nextFields.g.arg({
1177
- type: index.filters[meta.provider].Int[mode]
1178
- }),
1179
- resolve: mode === 'required' ? undefined : index.resolveCommon
1180
- },
1181
- create: {
1182
- arg: nextFields.g.arg({
1183
- type: nextFields.g.Int,
1184
- defaultValue: typeof defaultValue === 'number' ? defaultValue : undefined
1185
- }),
1186
- resolve: resolveCreate
1187
- },
1188
- update: {
1189
- arg: nextFields.g.arg({
1190
- type: nextFields.g.Int
1191
- })
1192
- },
1193
- orderBy: {
1194
- arg: nextFields.g.arg({
1195
- type: nextFields.orderDirectionEnum
1196
- })
1197
- }
1198
- },
1199
- output: nextFields.g.field({
1200
- type: nextFields.g.Int
1201
- })
1202
- });
1203
- }
1204
- if (config.type === 'enum') {
1205
- const enumName = `${meta.listKey}${utils.humanize(meta.fieldKey).replace(/ /g, '')}Type`;
1206
- const enumValues = options.map(x => `${x.value}`);
1207
- const graphQLType = nextFields.g.enum({
1208
- name: enumName,
1209
- values: nextFields.g.enumValues(enumValues)
1210
- });
1211
- return nextFields.fieldType(meta.provider === 'sqlite' ? {
1212
- kind: 'scalar',
1213
- scalar: 'String',
1214
- ...commonDbFieldConfig
1215
- } : {
1216
- kind: 'enum',
1217
- values: enumValues,
1218
- name: enumName,
1219
- ...commonDbFieldConfig
1220
- })({
1221
- ...commonConfig,
1222
- input: {
1223
- uniqueWhere: isIndexed === 'unique' ? {
1224
- arg: nextFields.g.arg({
1225
- type: graphQLType
1226
- })
1227
- } : undefined,
1228
- where: {
1229
- arg: nextFields.g.arg({
1230
- type: index.filters[meta.provider].enum(graphQLType).optional
1231
- }),
1232
- resolve: mode === 'required' ? undefined : index.resolveCommon
1233
- },
1234
- create: {
1235
- arg: nextFields.g.arg({
1236
- type: graphQLType,
1237
- defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined
1238
- }),
1239
- resolve: resolveCreate
1240
- },
1241
- update: {
1242
- arg: nextFields.g.arg({
1243
- type: graphQLType
1244
- })
1245
- },
1246
- orderBy: {
1247
- arg: nextFields.g.arg({
1248
- type: nextFields.orderDirectionEnum
1249
- })
1250
- }
1251
- },
1252
- output: nextFields.g.field({
1253
- type: graphQLType
1254
- })
1255
- });
1256
- }
1257
- return nextFields.fieldType({
1258
- kind: 'scalar',
1259
- scalar: 'String',
1260
- ...commonDbFieldConfig
1261
- })({
1262
- ...commonConfig,
1263
- input: {
1264
- uniqueWhere: isIndexed === 'unique' ? {
1265
- arg: nextFields.g.arg({
1266
- type: nextFields.g.String
1267
- })
1268
- } : undefined,
1269
- where: {
1270
- arg: nextFields.g.arg({
1271
- type: index.filters[meta.provider].String[mode]
1272
- }),
1273
- resolve: mode === 'required' ? undefined : index.resolveString
1274
- },
1275
- create: {
1276
- arg: nextFields.g.arg({
1277
- type: nextFields.g.String,
1278
- defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined
1279
- }),
1280
- resolve: resolveCreate
1281
- },
1282
- update: {
1283
- arg: nextFields.g.arg({
1284
- type: nextFields.g.String
1285
- })
1286
- },
1287
- orderBy: {
1288
- arg: nextFields.g.arg({
1289
- type: nextFields.orderDirectionEnum
1290
- })
1291
- }
1292
- },
1293
- output: nextFields.g.field({
1294
- type: nextFields.g.String
1295
- })
1296
- });
1297
- };
1298
- }
1299
-
1300
- function text(config = {}) {
1301
- var _config$db, _config$db2, _config$db2$isNullabl, _validation$isRequire, _validation$length$mi, _validation$length, _validation$length2, _validation$length3;
1302
- const {
1303
- defaultValue: defaultValue_,
1304
- isIndexed,
1305
- validation = {}
1306
- } = config;
1307
- (_config$db = config.db) !== null && _config$db !== void 0 ? _config$db : config.db = {};
1308
- (_config$db2$isNullabl = (_config$db2 = config.db).isNullable) !== null && _config$db2$isNullabl !== void 0 ? _config$db2$isNullabl : _config$db2.isNullable = false; // TODO: sigh, remove in breaking change?
1309
-
1310
- const isRequired = (_validation$isRequire = validation.isRequired) !== null && _validation$isRequire !== void 0 ? _validation$isRequire : false;
1311
- const match = validation.match;
1312
- const min = validation.isRequired ? (_validation$length$mi = (_validation$length = validation.length) === null || _validation$length === void 0 ? void 0 : _validation$length.min) !== null && _validation$length$mi !== void 0 ? _validation$length$mi : 1 : (_validation$length2 = validation.length) === null || _validation$length2 === void 0 ? void 0 : _validation$length2.min;
1313
- const max = (_validation$length3 = validation.length) === null || _validation$length3 === void 0 ? void 0 : _validation$length3.max;
1314
- return meta => {
1315
- var _config$db$isNullable, _config$db3, _config$db4, _config$db5, _config$db6;
1316
- if (min !== undefined && (!Number.isInteger(min) || min < 0)) {
1317
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.length.min: ${min} but it must be a positive integer`);
1318
- }
1319
- if (max !== undefined && (!Number.isInteger(max) || max < 0)) {
1320
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.length.max: ${max} but it must be a positive integer`);
1321
- }
1322
- if (isRequired && min !== undefined && min === 0) {
1323
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.isRequired: true and validation.length.min: 0, this is not allowed because validation.isRequired implies at least a min length of 1`);
1324
- }
1325
- if (isRequired && max !== undefined && max === 0) {
1326
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies validation.isRequired: true and validation.length.max: 0, this is not allowed because validation.isRequired implies at least a max length of 1`);
1327
- }
1328
- if (min !== undefined && max !== undefined && min > max) {
1329
- throw new Error(`${meta.listKey}.${meta.fieldKey} specifies a validation.length.max that is less than the validation.length.min, and therefore has no valid options`);
1330
- }
1331
-
1332
- // defaulted to false as a zero length string is preferred to null
1333
- const isNullable = (_config$db$isNullable = (_config$db3 = config.db) === null || _config$db3 === void 0 ? void 0 : _config$db3.isNullable) !== null && _config$db$isNullable !== void 0 ? _config$db$isNullable : false;
1334
- const defaultValue = isNullable ? defaultValue_ !== null && defaultValue_ !== void 0 ? defaultValue_ : null : defaultValue_ !== null && defaultValue_ !== void 0 ? defaultValue_ : '';
1335
- const hasAdditionalValidation = match || min !== undefined || max !== undefined;
1336
- const {
1337
- mode,
1338
- validate
1339
- } = nonNullGraphql.makeValidateHook(meta, config, hasAdditionalValidation ? ({
1340
- resolvedData,
1341
- operation,
1342
- addValidationError
1343
- }) => {
1344
- if (operation === 'delete') return;
1345
- const value = resolvedData[meta.fieldKey];
1346
- if (value != null) {
1347
- if (min !== undefined && value.length < min) {
1348
- if (min === 1) {
1349
- addValidationError(`value must not be empty`);
1350
- } else {
1351
- addValidationError(`value must be at least ${min} characters long`);
1352
- }
1353
- }
1354
- if (max !== undefined && value.length > max) {
1355
- addValidationError(`value must be no longer than ${max} characters`);
1356
- }
1357
- if (match && !match.regex.test(value)) {
1358
- var _match$explanation;
1359
- addValidationError((_match$explanation = match.explanation) !== null && _match$explanation !== void 0 ? _match$explanation : `value must match ${match.regex}`);
1360
- }
1361
- }
1362
- } : undefined);
1363
- return nextFields.fieldType({
1364
- kind: 'scalar',
1365
- mode,
1366
- scalar: 'String',
1367
- default: defaultValue === null ? undefined : {
1368
- kind: 'literal',
1369
- value: defaultValue
1370
- },
1371
- index: isIndexed === true ? 'index' : isIndexed || undefined,
1372
- map: (_config$db4 = config.db) === null || _config$db4 === void 0 ? void 0 : _config$db4.map,
1373
- nativeType: (_config$db5 = config.db) === null || _config$db5 === void 0 ? void 0 : _config$db5.nativeType,
1374
- extendPrismaSchema: (_config$db6 = config.db) === null || _config$db6 === void 0 ? void 0 : _config$db6.extendPrismaSchema
1375
- })({
1376
- ...config,
1377
- ...nonNullGraphql.defaultIsRequired(config, isRequired),
1378
- hooks: {
1379
- ...config.hooks,
1380
- validate
1381
- },
1382
- input: {
1383
- uniqueWhere: isIndexed === 'unique' ? {
1384
- arg: nextFields.g.arg({
1385
- type: nextFields.g.String
1386
- })
1387
- } : undefined,
1388
- where: {
1389
- arg: nextFields.g.arg({
1390
- type: index.filters[meta.provider].String[mode]
1391
- }),
1392
- resolve: mode === 'required' ? undefined : index.resolveString
1393
- },
1394
- create: {
1395
- arg: nextFields.g.arg({
1396
- type: nextFields.g.String,
1397
- defaultValue: typeof defaultValue === 'string' ? defaultValue : undefined
1398
- }),
1399
- resolve(val) {
1400
- if (val !== undefined) return val;
1401
- return defaultValue !== null && defaultValue !== void 0 ? defaultValue : null;
1402
- }
1403
- },
1404
- update: {
1405
- arg: nextFields.g.arg({
1406
- type: nextFields.g.String
1407
- })
1408
- },
1409
- orderBy: {
1410
- arg: nextFields.g.arg({
1411
- type: nextFields.orderDirectionEnum
1412
- })
1413
- }
1414
- },
1415
- output: nextFields.g.field({
1416
- type: nextFields.g.String
1417
- }),
1418
- __nxTelemetryFieldTypeName: '@nixxie-cms/text',
1419
- views: '@nixxie-cms/core/fields/types/text/views',
1420
- getAdminMeta() {
1421
- var _config$ui$displayMod, _config$ui, _match$explanation2;
1422
- return {
1423
- displayMode: (_config$ui$displayMod = (_config$ui = config.ui) === null || _config$ui === void 0 ? void 0 : _config$ui.displayMode) !== null && _config$ui$displayMod !== void 0 ? _config$ui$displayMod : 'input',
1424
- shouldUseModeInsensitive: meta.provider === 'postgresql',
1425
- validation: {
1426
- match: match ? {
1427
- regex: {
1428
- source: match.regex.source,
1429
- flags: match.regex.flags
1430
- },
1431
- explanation: (_match$explanation2 = match.explanation) !== null && _match$explanation2 !== void 0 ? _match$explanation2 : `value must match ${match.regex}`
1432
- } : null,
1433
- length: {
1434
- max: max !== null && max !== void 0 ? max : null,
1435
- min: min !== null && min !== void 0 ? min : null
1436
- }
1437
- },
1438
- defaultValue: defaultValue !== null && defaultValue !== void 0 ? defaultValue : isNullable ? null : '',
1439
- isNullable
1440
- };
1441
- }
1442
- });
1443
- };
1444
- }
1445
-
1446
897
  function virtual({
1447
898
  field,
1448
899
  ...config
@@ -1491,7 +942,9 @@ function calendarDay(config = {}) {
1491
942
  try {
1492
943
  nextFields.g.CalendarDay.parseValue(defaultValue);
1493
944
  } catch (err) {
1494
- throw new Error(`The calendarDay field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: ${defaultValue} but values must be provided as a full-date ISO8601 string such as 1970-01-01`);
945
+ throw new Error(`The calendarDay field at ${meta.listKey}.${meta.fieldKey} specifies defaultValue: ${defaultValue} but values must be provided as a full-date ISO8601 string such as 1970-01-01`, {
946
+ cause: err
947
+ });
1495
948
  }
1496
949
  }
1497
950
  const usesNativeDateType = meta.provider === 'postgresql' || meta.provider === 'mysql';
@@ -1505,7 +958,7 @@ function calendarDay(config = {}) {
1505
958
  mode,
1506
959
  validate
1507
960
  } = nonNullGraphql.makeValidateHook(meta, config);
1508
- const commonResolveFilter = mode === 'optional' ? index.resolveCommon : x => x;
961
+ const commonResolveFilter = mode === 'optional' ? index$1.resolveCommon : x => x;
1509
962
  return nextFields.fieldType({
1510
963
  kind: 'scalar',
1511
964
  mode,
@@ -1789,8 +1242,12 @@ function configToOptionsAndGraphQLType(config, meta) {
1789
1242
  };
1790
1243
  }
1791
1244
 
1245
+ exports.json = index$1.json;
1246
+ exports.text = index$1.text;
1247
+ exports.timestamp = index$1.timestamp;
1248
+ exports.integer = index.integer;
1792
1249
  exports.relationship = index.relationship;
1793
- exports.timestamp = index.timestamp;
1250
+ exports.select = index.select;
1794
1251
  exports.password = fields_types_password_dist_nixxieCmsCoreFieldsTypesPassword.password;
1795
1252
  exports.bytes = fields_types_bytes_dist_nixxieCmsCoreFieldsTypesBytes.bytes;
1796
1253
  exports.bigInt = bigInt;
@@ -1800,9 +1257,5 @@ exports.decimal = decimal;
1800
1257
  exports.file = file;
1801
1258
  exports.float = float;
1802
1259
  exports.image = image;
1803
- exports.integer = integer;
1804
- exports.json = json;
1805
1260
  exports.multiselect = multiselect;
1806
- exports.select = select;
1807
- exports.text = text;
1808
1261
  exports.virtual = virtual;