@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.
- package/CHANGELOG.md +36 -0
- package/CHANGES-1.1.md +134 -0
- package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
- package/context/dist/nixxie-cms-core-context.esm.js +3 -2
- package/dist/declarations/src/access.d.ts +2 -2
- package/dist/declarations/src/access.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/context.d.ts +6 -6
- package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
- package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
- package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
- package/dist/declarations/src/context.d.ts +1 -1
- package/dist/declarations/src/context.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
- package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
- package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
- package/dist/declarations/src/helpers.d.ts +249 -13
- package/dist/declarations/src/helpers.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +9 -4
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
- package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
- package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
- package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
- package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
- package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
- package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
- package/dist/declarations/src/lib/env.d.ts +9 -0
- package/dist/declarations/src/lib/env.d.ts.map +1 -0
- package/dist/declarations/src/lib/system.d.ts +1 -1
- package/dist/declarations/src/lib/system.d.ts.map +1 -1
- package/dist/declarations/src/list-features.d.ts +162 -0
- package/dist/declarations/src/list-features.d.ts.map +1 -0
- package/dist/declarations/src/schema.d.ts +24 -23
- package/dist/declarations/src/schema.d.ts.map +1 -1
- package/dist/declarations/src/session.d.ts +75 -0
- package/dist/declarations/src/session.d.ts.map +1 -1
- package/dist/declarations/src/types/admin-meta.d.ts +11 -11
- package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/types/config/access-control.d.ts +42 -42
- package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
- package/dist/declarations/src/types/config/fields.d.ts +19 -19
- package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
- package/dist/declarations/src/types/config/hooks.d.ts +131 -131
- package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
- package/dist/declarations/src/types/config/index.d.ts +190 -8
- package/dist/declarations/src/types/config/index.d.ts.map +1 -1
- package/dist/declarations/src/types/config/lists.d.ts +146 -108
- package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
- package/dist/declarations/src/types/context.d.ts +507 -47
- package/dist/declarations/src/types/context.d.ts.map +1 -1
- package/dist/declarations/src/types/next-fields.d.ts +28 -28
- package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
- package/dist/declarations/src/types/type-info.d.ts +3 -3
- package/dist/declarations/src/types/type-info.d.ts.map +1 -1
- package/dist/{express-455ae20c.cjs.js → express-84d534c2.cjs.js} +6 -6
- package/dist/{express-7559ca2d.esm.js → express-d0a4ce99.esm.js} +6 -6
- package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
- package/dist/index-6055753b.cjs.js +393 -0
- package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
- package/dist/index-f1703b7b.esm.js +386 -0
- package/dist/nixxie-cms-core.cjs.js +1388 -30
- package/dist/nixxie-cms-core.esm.js +1362 -24
- package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
- package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
- package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
- package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
- package/dist/{system-a321642d.cjs.js → system-6b37a5f8.cjs.js} +33 -7
- package/dist/{system-03e49e4f.esm.js → system-e591d821.esm.js} +33 -7
- package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
- package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
- package/package.json +4 -4
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
- package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
- package/session/dist/nixxie-cms-core-session.esm.js +279 -1
- package/src/access.ts +25 -25
- package/src/admin-ui/admin-meta-graphql.ts +5 -5
- package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
- package/src/admin-ui/components/Navigation.tsx +3 -3
- package/src/admin-ui/context.tsx +6 -6
- package/src/admin-ui/utils/Fields.tsx +241 -241
- package/src/admin-ui/utils/actionData.ts +36 -36
- package/src/admin-ui/utils/filters.ts +148 -148
- package/src/admin-ui/utils/useCreateItem.ts +171 -171
- package/src/admin-ui/utils/utils.tsx +127 -127
- package/src/context.ts +1 -1
- package/src/fields/non-null-graphql.ts +115 -115
- package/src/fields/types/bigInt/index.ts +6 -6
- package/src/fields/types/bytes/index.ts +6 -6
- package/src/fields/types/calendarDay/index.ts +18 -19
- package/src/fields/types/checkbox/index.ts +6 -6
- package/src/fields/types/decimal/index.ts +6 -6
- package/src/fields/types/file/index.ts +8 -8
- package/src/fields/types/float/index.ts +6 -6
- package/src/fields/types/image/index.ts +8 -8
- package/src/fields/types/integer/index.ts +6 -6
- package/src/fields/types/json/index.ts +5 -5
- package/src/fields/types/multiselect/index.ts +7 -7
- package/src/fields/types/multiselect/views/index.tsx +149 -151
- package/src/fields/types/password/index.ts +6 -6
- package/src/fields/types/relationship/index.ts +13 -13
- package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
- package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
- package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
- package/src/fields/types/relationship/views/index.tsx +492 -492
- package/src/fields/types/relationship/views/types.ts +46 -46
- package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
- package/src/fields/types/relationship/views/useFilter.tsx +109 -109
- package/src/fields/types/select/index.ts +6 -6
- package/src/fields/types/text/index.ts +6 -6
- package/src/fields/types/timestamp/index.ts +23 -21
- package/src/fields/types/virtual/index.ts +11 -11
- package/src/helpers.ts +773 -42
- package/src/index.ts +66 -24
- package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
- package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
- package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
- package/src/lib/admin-meta.ts +369 -369
- package/src/lib/context/createContext.ts +6 -0
- package/src/lib/core/access-control.ts +434 -434
- package/src/lib/core/cascade.ts +236 -0
- package/src/lib/core/initialise-lists.ts +49 -33
- package/src/lib/core/mutations/index.ts +7 -0
- package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
- package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
- package/src/lib/core/queries/output-field.ts +178 -178
- package/src/lib/env.ts +50 -0
- package/src/lib/id-field.ts +2 -2
- package/src/lib/system.ts +221 -207
- package/src/lib/typescript-schema-printer.ts +227 -227
- package/src/list-features.ts +476 -0
- package/src/schema.ts +92 -22
- package/src/session.ts +225 -0
- package/src/types/admin-meta.ts +218 -218
- package/src/types/config/access-control.ts +186 -186
- package/src/types/config/fields.ts +96 -96
- package/src/types/config/hooks.ts +529 -529
- package/src/types/config/index.ts +206 -7
- package/src/types/config/lists.ts +606 -565
- package/src/types/context.ts +592 -55
- package/src/types/next-fields.ts +31 -31
- package/src/types/type-info.ts +38 -38
- package/src/types/type-tests.ts +21 -21
package/src/types/next-fields.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal from 'decimal.js'
|
|
2
2
|
import { g } from '../types/schema'
|
|
3
|
-
import type {
|
|
3
|
+
import type { BaseCollectionTypeInfo } from './type-info'
|
|
4
4
|
import type { BaseFieldTypeInfo, CommonFieldConfig } from './config'
|
|
5
5
|
import type { DatabaseProvider } from './core'
|
|
6
6
|
import type {
|
|
@@ -24,16 +24,16 @@ export { Decimal }
|
|
|
24
24
|
|
|
25
25
|
export type BaseItem = { id: { toString(): string }; [key: string]: unknown }
|
|
26
26
|
|
|
27
|
-
export type
|
|
28
|
-
types:
|
|
27
|
+
export type CollectionGraphQLTypes<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
28
|
+
types: GraphQLTypesForCollection<CollectionTypeInfo>
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export type FieldData<
|
|
31
|
+
export type FieldData<CollectionTypeInfo extends BaseCollectionTypeInfo = BaseCollectionTypeInfo> = {
|
|
32
32
|
lists: {
|
|
33
|
-
[Key in keyof
|
|
33
|
+
[Key in keyof CollectionTypeInfo['all']['lists']]: CollectionGraphQLTypes<CollectionTypeInfo['all']['lists'][Key]>
|
|
34
34
|
}
|
|
35
35
|
provider: DatabaseProvider
|
|
36
|
-
listKey:
|
|
36
|
+
listKey: CollectionTypeInfo['key']
|
|
37
37
|
fieldKey: string
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -62,8 +62,8 @@ export type SimpleFieldTypeInfo<Scalar extends ScalarNames> = {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export type FieldTypeFunc<
|
|
66
|
-
data: FieldData<
|
|
65
|
+
export type FieldTypeFunc<CollectionTypeInfo extends BaseCollectionTypeInfo> = (
|
|
66
|
+
data: FieldData<CollectionTypeInfo>
|
|
67
67
|
) => NextFieldType<
|
|
68
68
|
DBField,
|
|
69
69
|
GArg<GInputType> | undefined,
|
|
@@ -71,7 +71,7 @@ export type FieldTypeFunc<ListTypeInfo extends BaseListTypeInfo> = (
|
|
|
71
71
|
GArg<GNullableInputType, false>,
|
|
72
72
|
GArg<GNullableInputType, false>,
|
|
73
73
|
GArg<GNullableInputType, false>,
|
|
74
|
-
|
|
74
|
+
CollectionTypeInfo
|
|
75
75
|
>
|
|
76
76
|
|
|
77
77
|
export type NextFieldType<
|
|
@@ -81,7 +81,7 @@ export type NextFieldType<
|
|
|
81
81
|
UniqueWhereArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
82
82
|
OrderByArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
83
83
|
FilterArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
84
|
-
|
|
84
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo = BaseCollectionTypeInfo,
|
|
85
85
|
> = {
|
|
86
86
|
dbField: TDBField
|
|
87
87
|
} & FieldTypeWithoutDBField<
|
|
@@ -91,7 +91,7 @@ export type NextFieldType<
|
|
|
91
91
|
UniqueWhereArg,
|
|
92
92
|
OrderByArg,
|
|
93
93
|
FilterArg,
|
|
94
|
-
|
|
94
|
+
CollectionTypeInfo
|
|
95
95
|
>
|
|
96
96
|
|
|
97
97
|
export type ScalarPrismaTypes = {
|
|
@@ -391,7 +391,7 @@ export type FieldTypeWithoutDBField<
|
|
|
391
391
|
UniqueWhereArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
392
392
|
OrderByArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
393
393
|
FilterArg extends GArg<GNullableInputType, false> = GArg<GNullableInputType, false>,
|
|
394
|
-
|
|
394
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo = BaseCollectionTypeInfo,
|
|
395
395
|
FieldTypeInfo extends BaseFieldTypeInfo = BaseFieldTypeInfo,
|
|
396
396
|
> = {
|
|
397
397
|
input?: {
|
|
@@ -407,11 +407,11 @@ export type FieldTypeWithoutDBField<
|
|
|
407
407
|
getAdminMeta?: () => JSONValue
|
|
408
408
|
unreferencedConcreteInterfaceImplementations?: readonly g<typeof g.object<any>>[]
|
|
409
409
|
__nxTelemetryFieldTypeName?: string
|
|
410
|
-
} & CommonFieldConfig<
|
|
410
|
+
} & CommonFieldConfig<CollectionTypeInfo, FieldTypeInfo>
|
|
411
411
|
|
|
412
412
|
type AnyInputObj = GInputObjectType<Record<string, GArg<GInputType>>>
|
|
413
413
|
|
|
414
|
-
export type
|
|
414
|
+
export type GraphQLTypesForCollection<CollectionTypeInfo extends BaseCollectionTypeInfo = BaseCollectionTypeInfo> = {
|
|
415
415
|
create: AnyInputObj | typeof g.Empty
|
|
416
416
|
update: AnyInputObj | typeof g.Empty
|
|
417
417
|
uniqueWhere: GInputObjectType<{
|
|
@@ -420,17 +420,17 @@ export type GraphQLTypesForList<ListTypeInfo extends BaseListTypeInfo = BaseList
|
|
|
420
420
|
}>
|
|
421
421
|
where: AnyInputObj
|
|
422
422
|
orderBy: AnyInputObj
|
|
423
|
-
output: GObjectType<
|
|
423
|
+
output: GObjectType<CollectionTypeInfo['item'], NixxieContext<CollectionTypeInfo['all']>>
|
|
424
424
|
findManyArgs: FindManyArgs
|
|
425
425
|
relateTo: {
|
|
426
426
|
one: {
|
|
427
427
|
create: GInputObjectType<{
|
|
428
|
-
create?: GArg<
|
|
429
|
-
connect: GArg<
|
|
428
|
+
create?: GArg<GraphQLTypesForCollection<CollectionTypeInfo>['create']>
|
|
429
|
+
connect: GArg<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>
|
|
430
430
|
}>
|
|
431
431
|
update: GInputObjectType<{
|
|
432
|
-
create?: GArg<
|
|
433
|
-
connect: GArg<
|
|
432
|
+
create?: GArg<GraphQLTypesForCollection<CollectionTypeInfo>['create']>
|
|
433
|
+
connect: GArg<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>
|
|
434
434
|
disconnect: GArg<typeof g.Boolean>
|
|
435
435
|
}>
|
|
436
436
|
}
|
|
@@ -441,32 +441,32 @@ export type GraphQLTypesForList<ListTypeInfo extends BaseListTypeInfo = BaseList
|
|
|
441
441
|
none: GArg<AnyInputObj>
|
|
442
442
|
}>
|
|
443
443
|
create: GInputObjectType<{
|
|
444
|
-
create?: GArg<GList<GNonNull<
|
|
445
|
-
connect: GArg<GList<GNonNull<
|
|
446
|
-
set: GArg<GList<GNonNull<
|
|
444
|
+
create?: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['create']>>>
|
|
445
|
+
connect: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>>>
|
|
446
|
+
set: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>>>
|
|
447
447
|
}>
|
|
448
448
|
update: GInputObjectType<{
|
|
449
|
-
create?: GArg<GList<GNonNull<
|
|
450
|
-
connect: GArg<GList<GNonNull<
|
|
451
|
-
disconnect: GArg<GList<GNonNull<
|
|
452
|
-
set: GArg<GList<GNonNull<
|
|
449
|
+
create?: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['create']>>>
|
|
450
|
+
connect: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>>>
|
|
451
|
+
disconnect: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>>>
|
|
452
|
+
set: GArg<GList<GNonNull<GraphQLTypesForCollection<CollectionTypeInfo>['uniqueWhere']>>>
|
|
453
453
|
}>
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
export type FindManyArgs = {
|
|
459
|
-
where: GArg<GNonNull<
|
|
460
|
-
orderBy: GArg<GNonNull<GList<GNonNull<
|
|
459
|
+
where: GArg<GNonNull<GraphQLTypesForCollection['where']>, true>
|
|
460
|
+
orderBy: GArg<GNonNull<GList<GNonNull<GraphQLTypesForCollection['orderBy']>>>, true>
|
|
461
461
|
take: GArg<typeof g.Int>
|
|
462
462
|
skip: GArg<GNonNull<typeof g.Int>, true>
|
|
463
|
-
cursor: GArg<
|
|
463
|
+
cursor: GArg<GraphQLTypesForCollection['uniqueWhere']>
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
export type FindManyArgsValue = InferValueFromArgs<FindManyArgs>
|
|
467
467
|
|
|
468
468
|
// fieldType(dbField)(fieldInfo) => { ...fieldInfo, dbField };
|
|
469
|
-
export function fieldType<TDBField extends DBField,
|
|
469
|
+
export function fieldType<TDBField extends DBField, CollectionTypeInfo extends BaseCollectionTypeInfo>(
|
|
470
470
|
dbField: TDBField
|
|
471
471
|
) {
|
|
472
472
|
return function fieldTypeWrapper<
|
|
@@ -483,7 +483,7 @@ export function fieldType<TDBField extends DBField, ListTypeInfo extends BaseLis
|
|
|
483
483
|
UniqueWhereArg,
|
|
484
484
|
OrderByArg,
|
|
485
485
|
FilterArg,
|
|
486
|
-
|
|
486
|
+
CollectionTypeInfo
|
|
487
487
|
>
|
|
488
488
|
): NextFieldType<
|
|
489
489
|
DBField,
|
package/src/types/type-info.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { BaseItem } from './next-fields'
|
|
2
|
-
import type { NixxieContext } from '../types'
|
|
3
|
-
|
|
4
|
-
type GraphQLInput = Record<string, any>
|
|
5
|
-
|
|
6
|
-
export type
|
|
7
|
-
key: string
|
|
8
|
-
fields: string
|
|
9
|
-
actions: string
|
|
10
|
-
item: BaseItem
|
|
11
|
-
inputs: {
|
|
12
|
-
create: GraphQLInput
|
|
13
|
-
update: GraphQLInput
|
|
14
|
-
where: GraphQLInput
|
|
15
|
-
uniqueWhere: { readonly id?: string | number | null } & GraphQLInput
|
|
16
|
-
orderBy: Record<string, 'asc' | 'desc' | null>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* WARNING: may change in patch
|
|
21
|
-
*/
|
|
22
|
-
prisma: {
|
|
23
|
-
create: Record<string, any>
|
|
24
|
-
update: Record<string, any>
|
|
25
|
-
}
|
|
26
|
-
all: BaseNixxieTypeInfo<Session>
|
|
27
|
-
|
|
28
|
-
isSingleton: boolean
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export type
|
|
32
|
-
NixxieContext<
|
|
33
|
-
|
|
34
|
-
export type BaseNixxieTypeInfo<Session = any> = {
|
|
35
|
-
lists: Record<string,
|
|
36
|
-
prisma: any
|
|
37
|
-
session: Session
|
|
38
|
-
}
|
|
1
|
+
import type { BaseItem } from './next-fields'
|
|
2
|
+
import type { NixxieContext } from '../types'
|
|
3
|
+
|
|
4
|
+
type GraphQLInput = Record<string, any>
|
|
5
|
+
|
|
6
|
+
export type BaseCollectionTypeInfo<Session = any> = {
|
|
7
|
+
key: string
|
|
8
|
+
fields: string
|
|
9
|
+
actions: string
|
|
10
|
+
item: BaseItem
|
|
11
|
+
inputs: {
|
|
12
|
+
create: GraphQLInput
|
|
13
|
+
update: GraphQLInput
|
|
14
|
+
where: GraphQLInput
|
|
15
|
+
uniqueWhere: { readonly id?: string | number | null } & GraphQLInput
|
|
16
|
+
orderBy: Record<string, 'asc' | 'desc' | null>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* WARNING: may change in patch
|
|
21
|
+
*/
|
|
22
|
+
prisma: {
|
|
23
|
+
create: Record<string, any>
|
|
24
|
+
update: Record<string, any>
|
|
25
|
+
}
|
|
26
|
+
all: BaseNixxieTypeInfo<Session>
|
|
27
|
+
|
|
28
|
+
isSingleton: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type NixxieContextFromCollectionTypeInfo<CollectionTypeInfo extends BaseCollectionTypeInfo> =
|
|
32
|
+
NixxieContext<CollectionTypeInfo['all']>
|
|
33
|
+
|
|
34
|
+
export type BaseNixxieTypeInfo<Session = any> = {
|
|
35
|
+
lists: Record<string, BaseCollectionTypeInfo<Session>>
|
|
36
|
+
prisma: any
|
|
37
|
+
session: Session
|
|
38
|
+
}
|
package/src/types/type-tests.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { NixxieContext } from './context'
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
const someContext: NixxieContext<{
|
|
5
|
-
lists: {
|
|
6
|
-
Singleton:
|
|
7
|
-
List:
|
|
8
|
-
ListOrSingleton:
|
|
9
|
-
}
|
|
10
|
-
prisma: any
|
|
11
|
-
session: any
|
|
12
|
-
}> = undefined!
|
|
13
|
-
|
|
14
|
-
someContext.query.Singleton.findOne({})
|
|
15
|
-
someContext.query.Singleton.findOne({ where: { id: '1' } })
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
someContext.query.List.findOne({})
|
|
18
|
-
someContext.query.List.findOne({ where: { id: '1' } })
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
someContext.query.ListOrSingleton.findOne({})
|
|
21
|
-
someContext.query.ListOrSingleton.findOne({ where: { id: '1' } })
|
|
1
|
+
import type { NixxieContext } from './context'
|
|
2
|
+
import type { BaseCollectionTypeInfo } from './type-info'
|
|
3
|
+
|
|
4
|
+
const someContext: NixxieContext<{
|
|
5
|
+
lists: {
|
|
6
|
+
Singleton: BaseCollectionTypeInfo & { isSingleton: true }
|
|
7
|
+
List: BaseCollectionTypeInfo & { isSingleton: false }
|
|
8
|
+
ListOrSingleton: BaseCollectionTypeInfo
|
|
9
|
+
}
|
|
10
|
+
prisma: any
|
|
11
|
+
session: any
|
|
12
|
+
}> = undefined!
|
|
13
|
+
|
|
14
|
+
someContext.query.Singleton.findOne({})
|
|
15
|
+
someContext.query.Singleton.findOne({ where: { id: '1' } })
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
someContext.query.List.findOne({})
|
|
18
|
+
someContext.query.List.findOne({ where: { id: '1' } })
|
|
19
|
+
// @ts-expect-error
|
|
20
|
+
someContext.query.ListOrSingleton.findOne({})
|
|
21
|
+
someContext.query.ListOrSingleton.findOne({ where: { id: '1' } })
|