@nixxie-cms/auth 1.0.1 → 1.1.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # @nixxie/auth
2
-
3
- Nixxie-6 is the latest version of Nixxie.
4
- To get help with this package join the conversation in [Slack](https://community.nixxieinternational.com/), or [Github](https://github.com/nixxiecms/nixxie/).
5
-
6
- Visit <https://nixxieinternational.com/> for docs, and [follow @nixxiecms on Twitter](https://twitter.com/nixxiecms) for the latest updates.
1
+ # @nixxie/auth
2
+
3
+ Nixxie-6 is the latest version of Nixxie.
4
+ To get help with this package join the conversation in [Slack](https://community.nixxieinternational.com/), or [Github](https://github.com/nixxiecms/nixxie/).
5
+
6
+ Visit <https://nixxieinternational.com/> for docs, and [follow @nixxiecms on Twitter](https://twitter.com/nixxiecms) for the latest updates.
@@ -1,4 +1,4 @@
1
- {
2
- "main": "dist/nixxie-cms-auth-components-Navigation.cjs.js",
3
- "module": "dist/nixxie-cms-auth-components-Navigation.esm.js"
4
- }
1
+ {
2
+ "main": "dist/nixxie-cms-auth-components-Navigation.cjs.js",
3
+ "module": "dist/nixxie-cms-auth-components-Navigation.esm.js"
4
+ }
@@ -1,4 +1,4 @@
1
- import type { BaseListTypeInfo, BaseNixxieTypeInfo, NixxieConfig } from '@nixxie-cms/core/types';
1
+ import type { BaseCollectionTypeInfo, BaseNixxieTypeInfo, NixxieConfig } from '@nixxie-cms/core/types';
2
2
  import type { AuthConfig } from "./types.js";
3
3
  export type AuthSession = {
4
4
  itemId: string | number;
@@ -9,7 +9,7 @@ export type AuthSession = {
9
9
  *
10
10
  * Generates config for Nixxie to implement standard auth features.
11
11
  */
12
- export declare function createAuth<ListTypeInfo extends BaseListTypeInfo>({ listKey, secretField, initFirstItem, identityField, sessionData, }: AuthConfig<ListTypeInfo>): {
12
+ export declare function createAuth<CollectionTypeInfo extends BaseCollectionTypeInfo>({ listKey, secretField, initFirstItem, identityField, sessionData, }: AuthConfig<CollectionTypeInfo>): {
13
13
  withAuth: <TypeInfo extends BaseNixxieTypeInfo>(config: NixxieConfig<TypeInfo>) => NixxieConfig<TypeInfo>;
14
14
  };
15
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAGhB,kBAAkB,EAClB,YAAY,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAgB,mBAAe;AAOvD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAmBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,YAAY,SAAS,gBAAgB,EAAE,EAChE,OAAO,EACP,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAkB,GACnB,EAAE,UAAU,CAAC,YAAY,CAAC;eAkKP,QAAQ,SAAS,kBAAkB,UAC3C,YAAY,CAAC,QAAQ,CAAC,KAC7B,YAAY,CAAC,QAAQ,CAAC;EA8E1B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EAGtB,kBAAkB,EAClB,YAAY,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAgB,mBAAe;AAOvD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AAmBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,kBAAkB,SAAS,sBAAsB,EAAE,EAC5E,OAAO,EACP,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAkB,GACnB,EAAE,UAAU,CAAC,kBAAkB,CAAC;eAkKb,QAAQ,SAAS,kBAAkB,UAC3C,YAAY,CAAC,QAAQ,CAAC,KAC7B,YAAY,CAAC,QAAQ,CAAC;EA8E1B"}
@@ -1,4 +1,4 @@
1
- import type { BaseListTypeInfo, NixxieContext } from '@nixxie-cms/core/types';
1
+ import type { BaseCollectionTypeInfo, NixxieContext } from '@nixxie-cms/core/types';
2
2
  export type AuthGqlNames = {
3
3
  itemQueryName: string;
4
4
  whereUniqueInputName: string;
@@ -21,25 +21,25 @@ export type AuthTokenTypeConfig = {
21
21
  /** How long do tokens stay valid for from time of issue, in minutes **/
22
22
  tokensValidForMins?: number;
23
23
  };
24
- export type AuthConfig<ListTypeInfo extends BaseListTypeInfo> = {
24
+ export type AuthConfig<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
25
25
  /** The key of the list to authenticate users with */
26
- listKey: ListTypeInfo['key'];
26
+ listKey: CollectionTypeInfo['key'];
27
27
  /** The path of the field the identity is stored in; must be text-ish */
28
- identityField: ListTypeInfo['fields'];
28
+ identityField: CollectionTypeInfo['fields'];
29
29
  /** The path of the field the secret is stored in; must be password-ish */
30
- secretField: ListTypeInfo['fields'];
30
+ secretField: CollectionTypeInfo['fields'];
31
31
  /** The initial user/db seeding functionality */
32
- initFirstItem?: InitFirstItemConfig<ListTypeInfo>;
32
+ initFirstItem?: InitFirstItemConfig<CollectionTypeInfo>;
33
33
  /** Session data population */
34
34
  sessionData?: string;
35
35
  };
36
- export type InitFirstItemConfig<ListTypeInfo extends BaseListTypeInfo> = {
36
+ export type InitFirstItemConfig<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
37
37
  /** Array of fields to collect, e.g ['name', 'email', 'password'] */
38
- fields: readonly ListTypeInfo['fields'][];
38
+ fields: readonly CollectionTypeInfo['fields'][];
39
39
  /** Suppresses the second screen where we ask people to subscribe and follow Nixxie */
40
40
  skipNixxieWelcome?: boolean;
41
41
  /** Extra input to add for the create mutation */
42
- itemData?: Partial<ListTypeInfo['inputs']['create']>;
42
+ itemData?: Partial<CollectionTypeInfo['inputs']['create']>;
43
43
  };
44
44
  export type AuthTokenRedemptionErrorCode = 'FAILURE' | 'TOKEN_EXPIRED' | 'TOKEN_REDEEMED';
45
45
  export type SecretFieldImpl = {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"../../../src","sources":["types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE7E,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAA;IACrB,oBAAoB,EAAE,MAAM,CAAA;IAE5B,4BAA4B,EAAE,MAAM,CAAA;IACpC,oCAAoC,EAAE,MAAM,CAAA;IAC5C,qCAAqC,EAAE,MAAM,CAAA;IAC7C,qCAAqC,EAAE,MAAM,CAAA;IAE7C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE;IAC/B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,aAAa,CAAA;CACvB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAE1B,MAAM,MAAM,mBAAmB,GAAG;IAChC,8EAA8E;IAC9E,SAAS,EAAE,WAAW,CAAA;IACtB,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,UAAU,CAAC,YAAY,SAAS,gBAAgB,IAAI;IAC9D,qDAAqD;IACrD,OAAO,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAC5B,wEAAwE;IACxE,aAAa,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;IACrC,0EAA0E;IAC1E,WAAW,EAAE,YAAY,CAAC,QAAQ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AAC,MAAM,CAAC,CAAA;IACjD,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5D,CAAA"}
@@ -220,7 +220,9 @@ const getSchemaExtension = ({
220
220
  try {
221
221
  ast = graphql.parse(query);
222
222
  } catch (err) {
223
- throw new Error(`The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`);
223
+ throw new Error(`The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`, {
224
+ cause: err
225
+ });
224
226
  }
225
227
  const errors = graphql.validate(base.schema, ast);
226
228
  if (errors.length) {
@@ -294,10 +296,10 @@ function getAuthGqlNames(singular) {
294
296
  }
295
297
 
296
298
  // TODO: use TypeInfo and listKey for types
297
- /**
298
- * createAuth function
299
- *
300
- * Generates config for Nixxie to implement standard auth features.
299
+ /**
300
+ * createAuth function
301
+ *
302
+ * Generates config for Nixxie to implement standard auth features.
301
303
  */
302
304
  function createAuth({
303
305
  listKey,
@@ -306,13 +308,13 @@ function createAuth({
306
308
  identityField,
307
309
  sessionData = 'id'
308
310
  }) {
309
- /**
310
- * getAdditionalFiles
311
- *
312
- * This function adds files to be generated into the Admin UI build. Must be added to the
313
- * ui.getAdditionalFiles config.
314
- *
315
- * The signin page is always included, and the init page is included when initFirstItem is set
311
+ /**
312
+ * getAdditionalFiles
313
+ *
314
+ * This function adds files to be generated into the Admin UI build. Must be added to the
315
+ * ui.getAdditionalFiles config.
316
+ *
317
+ * The signin page is always included, and the init page is included when initFirstItem is set
316
318
  */
317
319
  const authGetAdditionalFiles = config => {
318
320
  var _listConfig$ui$labelF, _listConfig$ui, _listConfig$graphql$s, _listConfig$graphql;
@@ -465,10 +467,10 @@ function createAuth({
465
467
  return schema;
466
468
  }
467
469
 
468
- /**
469
- * withAuth
470
- *
471
- * Automatically extends your configuration with a prescriptive implementation.
470
+ /**
471
+ * withAuth
472
+ *
473
+ * Automatically extends your configuration with a prescriptive implementation.
472
474
  */
473
475
  function withAuth(config) {
474
476
  var _ui, _listConfig$graphql$s2, _listConfig$graphql2;
@@ -509,10 +511,10 @@ function createAuth({
509
511
  } = graphql !== null && graphql !== void 0 ? graphql : {};
510
512
  const listConfig = config.lists[listKey];
511
513
 
512
- /**
513
- * extendGraphqlSchema
514
- *
515
- * Must be added to the extendGraphqlSchema config. Can be composed.
514
+ /**
515
+ * extendGraphqlSchema
516
+ *
517
+ * Must be added to the extendGraphqlSchema config. Can be composed.
516
518
  */
517
519
  const authGqlNames = getAuthGqlNames((_listConfig$graphql$s2 = (_listConfig$graphql2 = listConfig.graphql) === null || _listConfig$graphql2 === void 0 ? void 0 : _listConfig$graphql2.singular) !== null && _listConfig$graphql$s2 !== void 0 ? _listConfig$graphql$s2 : listKey);
518
520
  const authExtendGraphqlSchema = getSchemaExtension({
@@ -216,7 +216,9 @@ const getSchemaExtension = ({
216
216
  try {
217
217
  ast = parse(query);
218
218
  } catch (err) {
219
- throw new Error(`The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`);
219
+ throw new Error(`The query to get session data has a syntax error, the sessionData option in your createAuth usage is likely incorrect\n${err}`, {
220
+ cause: err
221
+ });
220
222
  }
221
223
  const errors = validate(base.schema, ast);
222
224
  if (errors.length) {
@@ -290,10 +292,10 @@ function getAuthGqlNames(singular) {
290
292
  }
291
293
 
292
294
  // TODO: use TypeInfo and listKey for types
293
- /**
294
- * createAuth function
295
- *
296
- * Generates config for Nixxie to implement standard auth features.
295
+ /**
296
+ * createAuth function
297
+ *
298
+ * Generates config for Nixxie to implement standard auth features.
297
299
  */
298
300
  function createAuth({
299
301
  listKey,
@@ -302,13 +304,13 @@ function createAuth({
302
304
  identityField,
303
305
  sessionData = 'id'
304
306
  }) {
305
- /**
306
- * getAdditionalFiles
307
- *
308
- * This function adds files to be generated into the Admin UI build. Must be added to the
309
- * ui.getAdditionalFiles config.
310
- *
311
- * The signin page is always included, and the init page is included when initFirstItem is set
307
+ /**
308
+ * getAdditionalFiles
309
+ *
310
+ * This function adds files to be generated into the Admin UI build. Must be added to the
311
+ * ui.getAdditionalFiles config.
312
+ *
313
+ * The signin page is always included, and the init page is included when initFirstItem is set
312
314
  */
313
315
  const authGetAdditionalFiles = config => {
314
316
  var _listConfig$ui$labelF, _listConfig$ui, _listConfig$graphql$s, _listConfig$graphql;
@@ -461,10 +463,10 @@ function createAuth({
461
463
  return schema;
462
464
  }
463
465
 
464
- /**
465
- * withAuth
466
- *
467
- * Automatically extends your configuration with a prescriptive implementation.
466
+ /**
467
+ * withAuth
468
+ *
469
+ * Automatically extends your configuration with a prescriptive implementation.
468
470
  */
469
471
  function withAuth(config) {
470
472
  var _ui, _listConfig$graphql$s2, _listConfig$graphql2;
@@ -505,10 +507,10 @@ function createAuth({
505
507
  } = graphql !== null && graphql !== void 0 ? graphql : {};
506
508
  const listConfig = config.lists[listKey];
507
509
 
508
- /**
509
- * extendGraphqlSchema
510
- *
511
- * Must be added to the extendGraphqlSchema config. Can be composed.
510
+ /**
511
+ * extendGraphqlSchema
512
+ *
513
+ * Must be added to the extendGraphqlSchema config. Can be composed.
512
514
  */
513
515
  const authGqlNames = getAuthGqlNames((_listConfig$graphql$s2 = (_listConfig$graphql2 = listConfig.graphql) === null || _listConfig$graphql2 === void 0 ? void 0 : _listConfig$graphql2.singular) !== null && _listConfig$graphql$s2 !== void 0 ? _listConfig$graphql$s2 : listKey);
514
516
  const authExtendGraphqlSchema = getSchemaExtension({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nixxie-cms/auth",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/nixxie-cms-auth.cjs.js",
6
6
  "module": "dist/nixxie-cms-auth.esm.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "react": "^19.2.4",
39
- "@nixxie-cms/core": "^1.0.1"
39
+ "@nixxie-cms/core": "^1.1.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@nixxie-cms/core": "^1.0.1",
@@ -9,7 +9,7 @@ var components = require('@nixxie-cms/core/admin-ui/components');
9
9
  var context = require('@nixxie-cms/core/admin-ui/context');
10
10
  var router = require('@nixxie-cms/core/admin-ui/router');
11
11
  var utils = require('@nixxie-cms/core/admin-ui/utils');
12
- var useFromRedirect = require('../../../dist/useFromRedirect-2de239a9.cjs.js');
12
+ var useFromRedirect = require('../../../dist/useFromRedirect-80f27dbb.cjs.js');
13
13
  var jsxRuntime = require('react/jsx-runtime');
14
14
  require('react');
15
15
 
@@ -5,7 +5,7 @@ import { GraphQLErrorNotice } from '@nixxie-cms/core/admin-ui/components';
5
5
  import { useList } from '@nixxie-cms/core/admin-ui/context';
6
6
  import { useRouter } from '@nixxie-cms/core/admin-ui/router';
7
7
  import { useBuildItem, Fields } from '@nixxie-cms/core/admin-ui/utils';
8
- import { u as useRedirect } from '../../../dist/useFromRedirect-b3deee00.esm.js';
8
+ import { u as useRedirect } from '../../../dist/useFromRedirect-e80750d8.esm.js';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
  import 'react';
11
11
 
@@ -1,4 +1,4 @@
1
- {
2
- "main": "dist/nixxie-cms-auth-pages-InitPage.cjs.js",
3
- "module": "dist/nixxie-cms-auth-pages-InitPage.esm.js"
4
- }
1
+ {
2
+ "main": "dist/nixxie-cms-auth-pages-InitPage.cjs.js",
3
+ "module": "dist/nixxie-cms-auth-pages-InitPage.esm.js"
4
+ }
@@ -13,7 +13,7 @@ var typography = require('@keystar/ui/typography');
13
13
  var apollo = require('@nixxie-cms/core/admin-ui/apollo');
14
14
  var components = require('@nixxie-cms/core/admin-ui/components');
15
15
  var router = require('@nixxie-cms/core/admin-ui/router');
16
- var useFromRedirect = require('../../../dist/useFromRedirect-2de239a9.cjs.js');
16
+ var useFromRedirect = require('../../../dist/useFromRedirect-80f27dbb.cjs.js');
17
17
  var jsxRuntime = require('react/jsx-runtime');
18
18
 
19
19
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -9,7 +9,7 @@ import { Text } from '@keystar/ui/typography';
9
9
  import { useMutation, gql } from '@nixxie-cms/core/admin-ui/apollo';
10
10
  import { GraphQLErrorNotice } from '@nixxie-cms/core/admin-ui/components';
11
11
  import { useRouter } from '@nixxie-cms/core/admin-ui/router';
12
- import { u as useRedirect } from '../../../dist/useFromRedirect-b3deee00.esm.js';
12
+ import { u as useRedirect } from '../../../dist/useFromRedirect-e80750d8.esm.js';
13
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
14
 
15
15
  var SigninPage = props => () => /*#__PURE__*/jsx(SigninPage$1, {
@@ -1,4 +1,4 @@
1
- {
2
- "main": "dist/nixxie-cms-auth-pages-SigninPage.cjs.js",
3
- "module": "dist/nixxie-cms-auth-pages-SigninPage.esm.js"
4
- }
1
+ {
2
+ "main": "dist/nixxie-cms-auth-pages-SigninPage.cjs.js",
3
+ "module": "dist/nixxie-cms-auth-pages-SigninPage.esm.js"
4
+ }
@@ -1,87 +1,87 @@
1
- import type { BaseItem, NixxieContext } from '@nixxie-cms/core/types'
2
- import { g } from '@nixxie-cms/core'
3
- import { assertInputObjectType, GraphQLInputObjectType, type GraphQLSchema } from 'graphql'
4
- import { type AuthGqlNames, type InitFirstItemConfig } from '../types'
5
- import type { Extension } from '@nixxie-cms/core/graphql-ts'
6
-
7
- const AUTHENTICATION_FAILURE = 'Authentication failed.' as const
8
-
9
- export function getInitFirstItemSchema({
10
- authGqlNames,
11
- listKey,
12
- fields,
13
- defaultItemData,
14
- graphQLSchema,
15
- ItemAuthenticationWithPasswordSuccess,
16
- }: {
17
- authGqlNames: AuthGqlNames
18
- listKey: string
19
- fields: InitFirstItemConfig<any>['fields']
20
- defaultItemData: InitFirstItemConfig<any>['itemData']
21
- graphQLSchema: GraphQLSchema
22
- ItemAuthenticationWithPasswordSuccess: g<
23
- typeof g.object<{
24
- item: BaseItem
25
- sessionToken: string
26
- }>
27
- >
28
- // TODO: return type required by pnpm :(
29
- }): Extension {
30
- const createInputConfig = assertInputObjectType(
31
- graphQLSchema.getType(`${listKey}CreateInput`)
32
- ).toConfig()
33
- const fieldsSet = new Set(fields)
34
- const initialCreateInput = new GraphQLInputObjectType({
35
- ...createInputConfig,
36
- fields: Object.fromEntries(
37
- Object.entries(createInputConfig.fields).filter(([fieldKey]) => fieldsSet.has(fieldKey))
38
- ),
39
- name: authGqlNames.CreateInitialInput,
40
- })
41
-
42
- return {
43
- mutation: {
44
- [authGqlNames.createInitialItem]: g.field({
45
- type: g.nonNull(ItemAuthenticationWithPasswordSuccess),
46
- args: { data: g.arg({ type: g.nonNull(initialCreateInput) }) },
47
- async resolve(rootVal, { data }, context: NixxieContext) {
48
- if (!context.sessionStrategy) throw new Error('No session strategy on context')
49
-
50
- const sudoContext = context.sudo()
51
-
52
- // should approximate hasInitFirstItemConditions
53
- const count = await sudoContext.db[listKey].count()
54
- if (count !== 0) throw AUTHENTICATION_FAILURE
55
-
56
- // Update system state
57
- // this is strictly speaking incorrect. the db API will do GraphQL coercion on a value which has already been coerced
58
- // (this is also mostly fine, the chance that people are using things where
59
- // the input value can't round-trip like the Upload scalar here is quite low)
60
- const item = await sudoContext.db[listKey].createOne({
61
- data: {
62
- ...defaultItemData,
63
- ...data,
64
- },
65
- })
66
-
67
- const sessionToken = await context.sessionStrategy.start({
68
- data: {
69
- listKey,
70
- itemId: item.id,
71
- },
72
- context,
73
- })
74
-
75
- if (typeof sessionToken !== 'string' || sessionToken.length === 0) {
76
- throw AUTHENTICATION_FAILURE
77
- }
78
-
79
- return {
80
- sessionToken,
81
- item,
82
- }
83
- },
84
- }),
85
- },
86
- }
87
- }
1
+ import type { BaseItem, NixxieContext } from '@nixxie-cms/core/types'
2
+ import { g } from '@nixxie-cms/core'
3
+ import { assertInputObjectType, GraphQLInputObjectType, type GraphQLSchema } from 'graphql'
4
+ import { type AuthGqlNames, type InitFirstItemConfig } from '../types'
5
+ import type { Extension } from '@nixxie-cms/core/graphql-ts'
6
+
7
+ const AUTHENTICATION_FAILURE = 'Authentication failed.' as const
8
+
9
+ export function getInitFirstItemSchema({
10
+ authGqlNames,
11
+ listKey,
12
+ fields,
13
+ defaultItemData,
14
+ graphQLSchema,
15
+ ItemAuthenticationWithPasswordSuccess,
16
+ }: {
17
+ authGqlNames: AuthGqlNames
18
+ listKey: string
19
+ fields: InitFirstItemConfig<any>['fields']
20
+ defaultItemData: InitFirstItemConfig<any>['itemData']
21
+ graphQLSchema: GraphQLSchema
22
+ ItemAuthenticationWithPasswordSuccess: g<
23
+ typeof g.object<{
24
+ item: BaseItem
25
+ sessionToken: string
26
+ }>
27
+ >
28
+ // TODO: return type required by pnpm :(
29
+ }): Extension {
30
+ const createInputConfig = assertInputObjectType(
31
+ graphQLSchema.getType(`${listKey}CreateInput`)
32
+ ).toConfig()
33
+ const fieldsSet = new Set(fields)
34
+ const initialCreateInput = new GraphQLInputObjectType({
35
+ ...createInputConfig,
36
+ fields: Object.fromEntries(
37
+ Object.entries(createInputConfig.fields).filter(([fieldKey]) => fieldsSet.has(fieldKey))
38
+ ),
39
+ name: authGqlNames.CreateInitialInput,
40
+ })
41
+
42
+ return {
43
+ mutation: {
44
+ [authGqlNames.createInitialItem]: g.field({
45
+ type: g.nonNull(ItemAuthenticationWithPasswordSuccess),
46
+ args: { data: g.arg({ type: g.nonNull(initialCreateInput) }) },
47
+ async resolve(rootVal, { data }, context: NixxieContext) {
48
+ if (!context.sessionStrategy) throw new Error('No session strategy on context')
49
+
50
+ const sudoContext = context.sudo()
51
+
52
+ // should approximate hasInitFirstItemConditions
53
+ const count = await sudoContext.db[listKey].count()
54
+ if (count !== 0) throw AUTHENTICATION_FAILURE
55
+
56
+ // Update system state
57
+ // this is strictly speaking incorrect. the db API will do GraphQL coercion on a value which has already been coerced
58
+ // (this is also mostly fine, the chance that people are using things where
59
+ // the input value can't round-trip like the Upload scalar here is quite low)
60
+ const item = await sudoContext.db[listKey].createOne({
61
+ data: {
62
+ ...defaultItemData,
63
+ ...data,
64
+ },
65
+ })
66
+
67
+ const sessionToken = await context.sessionStrategy.start({
68
+ data: {
69
+ listKey,
70
+ itemId: item.id,
71
+ },
72
+ context,
73
+ })
74
+
75
+ if (typeof sessionToken !== 'string' || sessionToken.length === 0) {
76
+ throw AUTHENTICATION_FAILURE
77
+ }
78
+
79
+ return {
80
+ sessionToken,
81
+ item,
82
+ }
83
+ },
84
+ }),
85
+ },
86
+ }
87
+ }