nucleus-core-ts 0.9.887 → 0.9.889

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/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.9.887
1
+ 0.9.889
@@ -69,7 +69,7 @@ export function ForgotPasswordForm({ labels, forgotPasswordAction, onBackToLogin
69
69
  store.setStep('success');
70
70
  },
71
71
  onErrorHandle: (err)=>{
72
- const errorMessage = err instanceof Error ? err.message : 'Failed to send reset email. Please try again.';
72
+ const errorMessage = err instanceof Error ? err.message : say.sendFailed;
73
73
  store.setError(errorMessage);
74
74
  shakeForm();
75
75
  }
@@ -19,5 +19,7 @@ export type ForgotPasswordLabels = {
19
19
  submit: string;
20
20
  /** Said when the box is empty. */
21
21
  emailRequired: string;
22
+ /** What a failed submit says — the only sentence a person sees when it goes wrong. */
23
+ sendFailed: string;
22
24
  };
23
25
  export declare const DEFAULT_FORGOT_PASSWORD_LABELS: ForgotPasswordLabels;
@@ -14,5 +14,6 @@
14
14
  backToLogin: 'Back to login',
15
15
  pageLabel: 'Forgot password page',
16
16
  submit: 'Send Reset Link',
17
- emailRequired: 'Please enter your email address'
17
+ emailRequired: 'Please enter your email address',
18
+ sendFailed: 'Failed to send reset email. Please try again.'
18
19
  };
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useLabels } from '../text/context';
4
4
  import { integrationsPageTheme } from '../theme';
5
- import { AUTH_TYPE_OPTIONS, authTypeHint, toAuthType } from './authOptions';
5
+ import { authTypeHint, authTypeOptions, toAuthType } from './authOptions';
6
6
  import { ConnectionOauthFields } from './ConnectionOauthFields';
7
7
  import { usesHeaderName, usesQueryParam } from './connectionDraft';
8
8
  import { describedBy } from './formSupport';
@@ -18,13 +18,14 @@ import { Field } from './Primitives';
18
18
  */ const theme = integrationsPageTheme;
19
19
  export function ConnectionAuthFields(props) {
20
20
  const labels = useLabels();
21
+ const authTypes = authTypeOptions(labels.auth);
21
22
  const { draft, disabled, onChange } = props;
22
23
  return /*#__PURE__*/ _jsxs("section", {
23
24
  "aria-label": labels.auth.sectionLabel,
24
25
  className: "flex flex-col gap-3",
25
26
  children: [
26
27
  /*#__PURE__*/ _jsx(Field, {
27
- hint: authTypeHint(draft.authType),
28
+ hint: authTypeHint(draft.authType, labels.auth),
28
29
  htmlFor: "connection-auth-type",
29
30
  label: labels.auth.type,
30
31
  children: /*#__PURE__*/ _jsx("select", {
@@ -39,7 +40,7 @@ export function ConnectionAuthFields(props) {
39
40
  });
40
41
  },
41
42
  value: draft.authType,
42
- children: AUTH_TYPE_OPTIONS.map((option)=>/*#__PURE__*/ _jsx("option", {
43
+ children: authTypes.map((option)=>/*#__PURE__*/ _jsx("option", {
43
44
  value: option.value,
44
45
  children: option.label
45
46
  }, option.value))
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useLabels } from '../text/context';
4
4
  import { integrationsPageTheme } from '../theme';
5
- import { CLIENT_AUTH_OPTIONS, GRANT_TYPE_OPTIONS, toClientAuth, toGrantType } from './authOptions';
5
+ import { clientAuthOptions, grantTypeOptions, toClientAuth, toGrantType } from './authOptions';
6
6
  import { usesOauth } from './connectionDraft';
7
7
  import { describedBy } from './formSupport';
8
8
  import { Field } from './Primitives';
@@ -15,6 +15,8 @@ import { Field } from './Primitives';
15
15
  */ const theme = integrationsPageTheme;
16
16
  export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
17
17
  const labels = useLabels();
18
+ const grantTypes = grantTypeOptions(labels.auth);
19
+ const clientAuths = clientAuthOptions(labels.auth);
18
20
  if (!usesOauth(draft.authType)) return null;
19
21
  return /*#__PURE__*/ _jsxs(_Fragment, {
20
22
  children: [
@@ -52,7 +54,7 @@ export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
52
54
  });
53
55
  },
54
56
  value: draft.oauthGrantType,
55
- children: GRANT_TYPE_OPTIONS.map((option)=>/*#__PURE__*/ _jsx("option", {
57
+ children: grantTypes.map((option)=>/*#__PURE__*/ _jsx("option", {
56
58
  value: option.value,
57
59
  children: option.label
58
60
  }, option.value))
@@ -122,7 +124,7 @@ export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
122
124
  });
123
125
  },
124
126
  value: draft.oauthClientAuth,
125
- children: CLIENT_AUTH_OPTIONS.map((option)=>/*#__PURE__*/ _jsx("option", {
127
+ children: clientAuths.map((option)=>/*#__PURE__*/ _jsx("option", {
126
128
  value: option.value,
127
129
  children: option.label
128
130
  }, option.value))
@@ -1,3 +1,4 @@
1
+ import type { IntegrationsLabels } from '../text';
1
2
  import type { IntegrationAuthType } from '../types';
2
3
  /**
3
4
  * The three closed choices in the auth section, and the only way a `<select>`
@@ -12,18 +13,27 @@ export type AuthTypeOption = {
12
13
  label: string;
13
14
  hint: string;
14
15
  };
15
- export declare const AUTH_TYPE_OPTIONS: AuthTypeOption[];
16
+ type AuthText = IntegrationsLabels['auth'];
17
+ /** Every scheme there is, in the order the select offers them. */
18
+ export declare const AUTH_TYPE_VALUES: IntegrationAuthType[];
19
+ /**
20
+ * The scheme names are protocol words — `Bearer token`, `Basic`, `OAuth 2` are
21
+ * what the specifications call them and what the service's own documentation
22
+ * will say — so they are not label material. The sentence under each one is.
23
+ */
24
+ export declare const authTypeOptions: (t: AuthText) => AuthTypeOption[];
16
25
  export type GrantTypeValue = 'password' | 'client_credentials';
17
26
  export type ClientAuthValue = 'basic' | 'body';
18
- export declare const GRANT_TYPE_OPTIONS: {
27
+ export declare const grantTypeOptions: (t: AuthText) => {
19
28
  value: GrantTypeValue;
20
29
  label: string;
21
30
  }[];
22
- export declare const CLIENT_AUTH_OPTIONS: {
31
+ export declare const clientAuthOptions: (t: AuthText) => {
23
32
  value: ClientAuthValue;
24
33
  label: string;
25
34
  }[];
26
35
  export declare function toAuthType(value: string): IntegrationAuthType | null;
27
36
  export declare function toGrantType(value: string): GrantTypeValue | null;
28
37
  export declare function toClientAuth(value: string): ClientAuthValue | null;
29
- export declare function authTypeHint(authType: IntegrationAuthType): string;
38
+ export declare function authTypeHint(authType: IntegrationAuthType, t: AuthText): string;
39
+ export {};
@@ -1,70 +1,75 @@
1
- export const AUTH_TYPE_OPTIONS = [
2
- {
3
- value: 'none',
4
- label: 'None',
5
- hint: 'The service is called with no credential of any kind.'
6
- },
7
- {
8
- value: 'bearer',
9
- label: 'Bearer token',
10
- hint: 'A token is sent on every request, by default as Authorization: Bearer …'
11
- },
12
- {
13
- value: 'api_key',
14
- label: 'API key',
15
- hint: 'A key is sent in a header or as a query parameter. Say which below.'
16
- },
17
- {
18
- value: 'basic',
19
- label: 'Basic',
20
- hint: 'A user name and password pair, sent as HTTP basic authentication.'
21
- },
22
- {
23
- value: 'oauth2',
24
- label: 'OAuth 2',
25
- hint: 'A token is fetched from the token endpoint before each batch of calls and refreshed when it expires.'
26
- }
27
- ];
28
- export const GRANT_TYPE_OPTIONS = [
29
- {
30
- value: 'client_credentials',
31
- label: 'Client credentials'
32
- },
33
- {
34
- value: 'password',
35
- label: 'Password'
36
- }
37
- ];
38
- export const CLIENT_AUTH_OPTIONS = [
39
- {
40
- value: 'basic',
41
- label: 'Authorization header (basic)'
42
- },
43
- {
44
- value: 'body',
45
- label: 'Request body'
46
- }
1
+ /** Every scheme there is, in the order the select offers them. */ export const AUTH_TYPE_VALUES = [
2
+ 'none',
3
+ 'bearer',
4
+ 'api_key',
5
+ 'basic',
6
+ 'oauth2'
47
7
  ];
8
+ /**
9
+ * The scheme names are protocol words — `Bearer token`, `Basic`, `OAuth 2` are
10
+ * what the specifications call them and what the service's own documentation
11
+ * will say — so they are not label material. The sentence under each one is.
12
+ */ export const authTypeOptions = (t)=>[
13
+ {
14
+ value: 'none',
15
+ label: t.typeNone,
16
+ hint: t.typeNoneHint
17
+ },
18
+ {
19
+ value: 'bearer',
20
+ label: 'Bearer token',
21
+ hint: t.typeBearerHint
22
+ },
23
+ {
24
+ value: 'api_key',
25
+ label: 'API key',
26
+ hint: t.typeApiKeyHint
27
+ },
28
+ {
29
+ value: 'basic',
30
+ label: 'Basic',
31
+ hint: t.typeBasicHint
32
+ },
33
+ {
34
+ value: 'oauth2',
35
+ label: 'OAuth 2',
36
+ hint: t.typeOauth2Hint
37
+ }
38
+ ];
39
+ export const grantTypeOptions = (t)=>[
40
+ {
41
+ value: 'client_credentials',
42
+ label: t.grantClientCredentials
43
+ },
44
+ {
45
+ value: 'password',
46
+ label: t.grantPassword
47
+ }
48
+ ];
49
+ export const clientAuthOptions = (t)=>[
50
+ {
51
+ value: 'basic',
52
+ label: t.clientAuthHeader
53
+ },
54
+ {
55
+ value: 'body',
56
+ label: t.clientAuthBody
57
+ }
58
+ ];
48
59
  export function toAuthType(value) {
49
- for (const option of AUTH_TYPE_OPTIONS){
50
- if (option.value === value) return option.value;
60
+ for (const known of AUTH_TYPE_VALUES){
61
+ if (known === value) return known;
51
62
  }
52
63
  return null;
53
64
  }
54
65
  export function toGrantType(value) {
55
- for (const option of GRANT_TYPE_OPTIONS){
56
- if (option.value === value) return option.value;
57
- }
58
- return null;
66
+ return value === 'password' || value === 'client_credentials' ? value : null;
59
67
  }
60
68
  export function toClientAuth(value) {
61
- for (const option of CLIENT_AUTH_OPTIONS){
62
- if (option.value === value) return option.value;
63
- }
64
- return null;
69
+ return value === 'basic' || value === 'body' ? value : null;
65
70
  }
66
- export function authTypeHint(authType) {
67
- for (const option of AUTH_TYPE_OPTIONS){
71
+ export function authTypeHint(authType, t) {
72
+ for (const option of authTypeOptions(t)){
68
73
  if (option.value === authType) return option.hint;
69
74
  }
70
75
  return '';
@@ -242,6 +242,20 @@ export type IntegrationsLabels = {
242
242
  auth: {
243
243
  sectionLabel: string;
244
244
  type: string;
245
+ /**
246
+ * The closed choices. The scheme NAMES are protocol words and stay as they
247
+ * are; what each one does is a sentence, and that is read.
248
+ */
249
+ typeNone: string;
250
+ typeNoneHint: string;
251
+ typeBearerHint: string;
252
+ typeApiKeyHint: string;
253
+ typeBasicHint: string;
254
+ typeOauth2Hint: string;
255
+ grantClientCredentials: string;
256
+ grantPassword: string;
257
+ clientAuthHeader: string;
258
+ clientAuthBody: string;
245
259
  headerName: string;
246
260
  headerNameHint: string;
247
261
  headerNamePlaceholder: string;
@@ -231,6 +231,16 @@
231
231
  auth: {
232
232
  sectionLabel: 'Authentication',
233
233
  type: 'How we prove who we are',
234
+ typeNone: 'None',
235
+ typeNoneHint: 'The service is called with no credential of any kind.',
236
+ typeBearerHint: 'A token is sent on every request, by default as Authorization: Bearer …',
237
+ typeApiKeyHint: 'A key is sent in a header or as a query parameter. Say which below.',
238
+ typeBasicHint: 'A user name and password pair, sent as HTTP basic authentication.',
239
+ typeOauth2Hint: 'A token is fetched from the token endpoint before each batch of calls and refreshed when it expires.',
240
+ grantClientCredentials: 'Client credentials',
241
+ grantPassword: 'Password',
242
+ clientAuthHeader: 'Authorization header (basic)',
243
+ clientAuthBody: 'Request body',
234
244
  headerName: 'Header name',
235
245
  headerNameHint: 'Empty means Authorization. Set it when the service reads the credential from a header of its own.',
236
246
  headerNamePlaceholder: 'X-Api-Key',
@@ -165,7 +165,7 @@ export function ResetPasswordForm({ labels, token, resetPasswordAction, onBackTo
165
165
  store.setStep('success');
166
166
  },
167
167
  onErrorHandle: (err)=>{
168
- const errorMessage = err instanceof Error ? err.message : 'Failed to reset password. Please try again.';
168
+ const errorMessage = err instanceof Error ? err.message : say.resetFailed;
169
169
  store.setError(errorMessage);
170
170
  shakeForm();
171
171
  }
@@ -19,5 +19,7 @@ export type ResetPasswordLabels = {
19
19
  fillAllFields: string;
20
20
  passwordsDoNotMatch: string;
21
21
  requirementsNotMet: string;
22
+ /** What a failed submit says — the only sentence a person sees when it goes wrong. */
23
+ resetFailed: string;
22
24
  };
23
25
  export declare const DEFAULT_RESET_PASSWORD_LABELS: ResetPasswordLabels;
@@ -15,5 +15,6 @@
15
15
  ruleSpecial: 'One special character',
16
16
  fillAllFields: 'Please fill in all fields',
17
17
  passwordsDoNotMatch: 'Passwords do not match',
18
- requirementsNotMet: 'Password does not meet all requirements'
18
+ requirementsNotMet: 'Password does not meet all requirements',
19
+ resetFailed: 'Failed to reset password. Please try again.'
19
20
  };
@@ -23,7 +23,7 @@ export function SetPasswordPage({ logo, title = 'Set Password', subtitle = 'Ente
23
23
  const verifyToken = useEffectEvent((tokenValue)=>{
24
24
  if (!tokenValue) {
25
25
  store.setStep('error');
26
- store.setError('Invalid or missing token');
26
+ store.setError(say.invalidToken);
27
27
  return;
28
28
  }
29
29
  magicLinkVerifyAction.start({
@@ -142,7 +142,7 @@ export function SetPasswordPage({ logo, title = 'Set Password', subtitle = 'Ente
142
142
  }),
143
143
  /*#__PURE__*/ _jsx("p", {
144
144
  className: theme.states.error.subtitle,
145
- children: isInvite ? 'This invitation link is invalid or has expired.' : 'This link is invalid or has expired.'
145
+ children: isInvite ? say.invalidInviteBody : say.invalidLinkBody
146
146
  }),
147
147
  store.error && store.error !== 'Token verification failed' && /*#__PURE__*/ _jsx("p", {
148
148
  className: theme.states.error.errorMessage,
@@ -150,19 +150,19 @@ export function SetPasswordPage({ logo, title = 'Set Password', subtitle = 'Ente
150
150
  }),
151
151
  /*#__PURE__*/ _jsx("p", {
152
152
  className: theme.states.error.helpText,
153
- children: isInvite ? 'Please contact your administrator to request a new invitation.' : 'Please request a new link or contact support.'
153
+ children: isInvite ? say.invalidInviteHelp : say.invalidLinkHelp
154
154
  }),
155
155
  /*#__PURE__*/ _jsx("div", {
156
156
  className: theme.layout.buttonGroup,
157
157
  children: backToLoginHref ? /*#__PURE__*/ _jsx("a", {
158
158
  href: backToLoginHref,
159
159
  className: theme.states.error.buttonPrimary,
160
- children: "Go to Login"
160
+ children: say.goToLogin
161
161
  }) : /*#__PURE__*/ _jsx("button", {
162
162
  type: "button",
163
163
  onClick: onBackToLogin,
164
164
  className: theme.states.error.buttonPrimary,
165
- children: "Go to Login"
165
+ children: say.goToLogin
166
166
  })
167
167
  })
168
168
  ]
@@ -21,6 +21,18 @@ export type SetPasswordLabels = {
21
21
  passwordStrength: string;
22
22
  passwordRequirements: string;
23
23
  pageLabel: string;
24
+ /**
25
+ * The invalid-link screen. Its heading was translatable and the three
26
+ * sentences under it were not, so an invited employee whose link had expired
27
+ * met a Turkish title over an English explanation — on the one screen where
28
+ * they cannot do anything but read it and act.
29
+ */
30
+ invalidInviteBody: string;
31
+ invalidLinkBody: string;
32
+ invalidInviteHelp: string;
33
+ invalidLinkHelp: string;
34
+ goToLogin: string;
35
+ invalidToken: string;
24
36
  /** Said when something is wrong, at the moment it is wrong. */
25
37
  passwordRequired: string;
26
38
  passwordNeedsNumber: string;
@@ -20,6 +20,12 @@
20
20
  passwordStrength: 'Password strength',
21
21
  passwordRequirements: 'Password requirements',
22
22
  pageLabel: 'Set password page',
23
+ invalidInviteBody: 'This invitation link is invalid or has expired.',
24
+ invalidLinkBody: 'This link is invalid or has expired.',
25
+ invalidInviteHelp: 'Please contact your administrator to request a new invitation.',
26
+ invalidLinkHelp: 'Please request a new link or contact support.',
27
+ goToLogin: 'Go to Login',
28
+ invalidToken: 'Invalid or missing token',
23
29
  passwordRequired: 'Password is required',
24
30
  passwordNeedsNumber: 'Password must contain at least one number',
25
31
  confirmRequired: 'Please confirm your password',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.9.887",
3
+ "version": "0.9.889",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",