@shipfox/client-runners 0.2.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 (120) hide show
  1. package/.storybook/main.ts +1 -0
  2. package/.storybook/preview.css +4 -0
  3. package/.storybook/preview.tsx +64 -0
  4. package/.turbo/turbo-build.log +2 -0
  5. package/.turbo/turbo-type$colon$emit.log +1 -0
  6. package/.turbo/turbo-type.log +1 -0
  7. package/CHANGELOG.md +112 -0
  8. package/LICENSE +21 -0
  9. package/dist/components/create-manual-registration-token-form.d.ts +10 -0
  10. package/dist/components/create-manual-registration-token-form.d.ts.map +1 -0
  11. package/dist/components/create-manual-registration-token-form.js +206 -0
  12. package/dist/components/create-manual-registration-token-form.js.map +1 -0
  13. package/dist/components/create-provisioner-token-form.d.ts +10 -0
  14. package/dist/components/create-provisioner-token-form.d.ts.map +1 -0
  15. package/dist/components/create-provisioner-token-form.js +206 -0
  16. package/dist/components/create-provisioner-token-form.js.map +1 -0
  17. package/dist/components/form-errors.d.ts +6 -0
  18. package/dist/components/form-errors.d.ts.map +1 -0
  19. package/dist/components/form-errors.js +9 -0
  20. package/dist/components/form-errors.js.map +1 -0
  21. package/dist/components/manual-registration-token-errors.d.ts +2 -0
  22. package/dist/components/manual-registration-token-errors.d.ts.map +1 -0
  23. package/dist/components/manual-registration-token-errors.js +14 -0
  24. package/dist/components/manual-registration-token-errors.js.map +1 -0
  25. package/dist/components/manual-registration-token-format.d.ts +5 -0
  26. package/dist/components/manual-registration-token-format.d.ts.map +1 -0
  27. package/dist/components/manual-registration-token-format.js +14 -0
  28. package/dist/components/manual-registration-token-format.js.map +1 -0
  29. package/dist/components/manual-registration-token-list.d.ts +8 -0
  30. package/dist/components/manual-registration-token-list.d.ts.map +1 -0
  31. package/dist/components/manual-registration-token-list.js +293 -0
  32. package/dist/components/manual-registration-token-list.js.map +1 -0
  33. package/dist/components/manual-registration-tokens-settings-section.d.ts +4 -0
  34. package/dist/components/manual-registration-tokens-settings-section.d.ts.map +1 -0
  35. package/dist/components/manual-registration-tokens-settings-section.js +109 -0
  36. package/dist/components/manual-registration-tokens-settings-section.js.map +1 -0
  37. package/dist/components/provisioner-token-errors.d.ts +2 -0
  38. package/dist/components/provisioner-token-errors.d.ts.map +1 -0
  39. package/dist/components/provisioner-token-errors.js +13 -0
  40. package/dist/components/provisioner-token-errors.js.map +1 -0
  41. package/dist/components/provisioner-token-form-errors.d.ts +6 -0
  42. package/dist/components/provisioner-token-form-errors.d.ts.map +1 -0
  43. package/dist/components/provisioner-token-form-errors.js +9 -0
  44. package/dist/components/provisioner-token-form-errors.js.map +1 -0
  45. package/dist/components/provisioner-token-format.d.ts +21 -0
  46. package/dist/components/provisioner-token-format.d.ts.map +1 -0
  47. package/dist/components/provisioner-token-format.js +36 -0
  48. package/dist/components/provisioner-token-format.js.map +1 -0
  49. package/dist/components/provisioner-token-list.d.ts +9 -0
  50. package/dist/components/provisioner-token-list.d.ts.map +1 -0
  51. package/dist/components/provisioner-token-list.js +344 -0
  52. package/dist/components/provisioner-token-list.js.map +1 -0
  53. package/dist/components/provisioner-tokens-settings-section.d.ts +4 -0
  54. package/dist/components/provisioner-tokens-settings-section.d.ts.map +1 -0
  55. package/dist/components/provisioner-tokens-settings-section.js +117 -0
  56. package/dist/components/provisioner-tokens-settings-section.js.map +1 -0
  57. package/dist/components/token-date.d.ts +6 -0
  58. package/dist/components/token-date.d.ts.map +1 -0
  59. package/dist/components/token-date.js +27 -0
  60. package/dist/components/token-date.js.map +1 -0
  61. package/dist/components/token-expiration-select.d.ts +11 -0
  62. package/dist/components/token-expiration-select.d.ts.map +1 -0
  63. package/dist/components/token-expiration-select.js +68 -0
  64. package/dist/components/token-expiration-select.js.map +1 -0
  65. package/dist/components/token-name.d.ts +4 -0
  66. package/dist/components/token-name.d.ts.map +1 -0
  67. package/dist/components/token-name.js +24 -0
  68. package/dist/components/token-name.js.map +1 -0
  69. package/dist/components/token-settings-sections.stories.d.ts +26 -0
  70. package/dist/components/token-settings-sections.stories.d.ts.map +1 -0
  71. package/dist/components/token-settings-sections.stories.js +370 -0
  72. package/dist/components/token-settings-sections.stories.js.map +1 -0
  73. package/dist/hooks/api/manual-registration-tokens.d.ts +83 -0
  74. package/dist/hooks/api/manual-registration-tokens.d.ts.map +1 -0
  75. package/dist/hooks/api/manual-registration-tokens.js +53 -0
  76. package/dist/hooks/api/manual-registration-tokens.js.map +1 -0
  77. package/dist/hooks/api/provisioner-tokens.d.ts +125 -0
  78. package/dist/hooks/api/provisioner-tokens.d.ts.map +1 -0
  79. package/dist/hooks/api/provisioner-tokens.js +81 -0
  80. package/dist/hooks/api/provisioner-tokens.js.map +1 -0
  81. package/dist/index.d.ts +5 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +6 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/tsconfig.test.tsbuildinfo +1 -0
  86. package/package.json +88 -0
  87. package/src/components/create-manual-registration-token-form.tsx +197 -0
  88. package/src/components/create-provisioner-token-form.tsx +193 -0
  89. package/src/components/form-errors.test.ts +24 -0
  90. package/src/components/form-errors.ts +9 -0
  91. package/src/components/manual-registration-token-errors.ts +13 -0
  92. package/src/components/manual-registration-token-format.test.ts +48 -0
  93. package/src/components/manual-registration-token-format.ts +18 -0
  94. package/src/components/manual-registration-token-list.tsx +246 -0
  95. package/src/components/manual-registration-tokens-settings-section.test.tsx +251 -0
  96. package/src/components/manual-registration-tokens-settings-section.tsx +110 -0
  97. package/src/components/provisioner-token-errors.ts +12 -0
  98. package/src/components/provisioner-token-form-errors.test.ts +35 -0
  99. package/src/components/provisioner-token-form-errors.ts +9 -0
  100. package/src/components/provisioner-token-format.test.ts +96 -0
  101. package/src/components/provisioner-token-format.ts +40 -0
  102. package/src/components/provisioner-token-list.tsx +280 -0
  103. package/src/components/provisioner-tokens-settings-section.test.tsx +362 -0
  104. package/src/components/provisioner-tokens-settings-section.tsx +114 -0
  105. package/src/components/token-date.tsx +27 -0
  106. package/src/components/token-expiration-select.tsx +64 -0
  107. package/src/components/token-name.tsx +19 -0
  108. package/src/components/token-settings-sections.stories.tsx +360 -0
  109. package/src/hooks/api/manual-registration-tokens.test.ts +87 -0
  110. package/src/hooks/api/manual-registration-tokens.ts +71 -0
  111. package/src/hooks/api/provisioner-tokens.test.ts +127 -0
  112. package/src/hooks/api/provisioner-tokens.ts +102 -0
  113. package/src/index.ts +4 -0
  114. package/test/setup.ts +3 -0
  115. package/tsconfig.build.json +9 -0
  116. package/tsconfig.build.tsbuildinfo +1 -0
  117. package/tsconfig.json +3 -0
  118. package/tsconfig.test.json +8 -0
  119. package/vercel.json +8 -0
  120. package/vitest.config.ts +74 -0
@@ -0,0 +1 @@
1
+ export {default} from '../../.storybook/main.ts';
@@ -0,0 +1,4 @@
1
+ @import "@shipfox/react-ui/index.css";
2
+
3
+ @source "../src";
4
+ @source "../../../shared/react/ui/src";
@@ -0,0 +1,64 @@
1
+ import './preview.css';
2
+ import {ThemeProvider} from '@shipfox/react-ui/theme';
3
+ import type {Decorator, Preview} from '@storybook/react';
4
+
5
+ if (typeof document !== 'undefined' && document.fonts) {
6
+ void Promise.all([
7
+ document.fonts.load("16px 'Inter'"),
8
+ document.fonts.load("italic 16px 'Inter'"),
9
+ document.fonts.load("16px 'Commit Mono'"),
10
+ document.fonts.load("bold 16px 'Commit Mono'"),
11
+ ]);
12
+ }
13
+
14
+ const STORYBOOK_NOW_MS = Date.parse('2026-06-26T12:00:00.000Z');
15
+
16
+ Object.defineProperty(Date, 'now', {
17
+ configurable: true,
18
+ writable: true,
19
+ value: () => STORYBOOK_NOW_MS,
20
+ });
21
+
22
+ const withTheme: Decorator = (Story, context) => {
23
+ const theme = context.globals.theme;
24
+ return (
25
+ <ThemeProvider key={theme} defaultTheme={theme} storageKey={`shipfox-theme-${theme}`}>
26
+ <Story />
27
+ </ThemeProvider>
28
+ );
29
+ };
30
+
31
+ const preview: Preview = {
32
+ decorators: [withTheme],
33
+ parameters: {
34
+ argos: {
35
+ // Dual-theme coverage lives in @shipfox/react-ui (the theming source of truth);
36
+ // feature packages capture only the primary dark theme to limit Argos spend.
37
+ modes: {
38
+ dark: {theme: 'dark'},
39
+ },
40
+ fitToContent: false,
41
+ },
42
+ options: {
43
+ storySort: {method: 'alphabetical'},
44
+ },
45
+ },
46
+ globalTypes: {
47
+ theme: {
48
+ name: 'Theme',
49
+ description: 'Global theme for components',
50
+ defaultValue: 'dark',
51
+ toolbar: {
52
+ icon: 'sun',
53
+ items: [
54
+ {value: 'light', icon: 'sun', title: 'Light'},
55
+ {value: 'dark', icon: 'moon', title: 'Dark'},
56
+ {value: 'system', icon: 'info', title: 'System'},
57
+ ],
58
+ showName: true,
59
+ },
60
+ },
61
+ },
62
+ };
63
+
64
+ export default preview;
@@ -0,0 +1,2 @@
1
+ $ shipfox-swc
2
+ Successfully compiled: 19 files with swc (65.66ms)
@@ -0,0 +1 @@
1
+ $ shipfox-tsc-emit
@@ -0,0 +1 @@
1
+ $ shipfox-tsc-check
package/CHANGELOG.md ADDED
@@ -0,0 +1,112 @@
1
+ # @shipfox/client-runners
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3d064b8: Publishes the client runtime closure with shell, feature, route, Vite, and testing contracts.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [3d064b8]
12
+ - @shipfox/client-api@0.2.0
13
+ - @shipfox/client-ui@0.2.0
14
+
15
+ ## 0.0.5
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [c18d624]
20
+ - @shipfox/react-ui@0.3.1
21
+ - @shipfox/client-ui@0.1.2
22
+
23
+ ## 0.0.4
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [1b0d344]
28
+ - @shipfox/api-runners-dto@2.0.0
29
+ - @shipfox/client-ui@0.1.1
30
+ - @shipfox/client-api@0.0.1
31
+ - @shipfox/react-ui@0.3.0
32
+
33
+ ## 0.0.3
34
+
35
+ ### Patch Changes
36
+
37
+ - 048fc29: Adds Runner Provisioners settings with provisioner token management and connection status.
38
+ - 6181819: Adds runner registration sessions with bounded label contracts, session-token auth, and lease-token heartbeat ownership.
39
+ - Updated dependencies [43d7996]
40
+ - Updated dependencies [14e0bea]
41
+ - Updated dependencies [8100b48]
42
+ - Updated dependencies [7a9943d]
43
+ - Updated dependencies [2325d76]
44
+ - Updated dependencies [9018f0b]
45
+ - Updated dependencies [7fdfd72]
46
+ - Updated dependencies [c0a883c]
47
+ - Updated dependencies [2a3193f]
48
+ - Updated dependencies [f104ff2]
49
+ - Updated dependencies [7341569]
50
+ - Updated dependencies [c47be09]
51
+ - Updated dependencies [f9f059e]
52
+ - Updated dependencies [e4c6abf]
53
+ - Updated dependencies [5d0676a]
54
+ - Updated dependencies [3afb7e3]
55
+ - Updated dependencies [a35c2dc]
56
+ - Updated dependencies [58f7aef]
57
+ - Updated dependencies [5264a22]
58
+ - Updated dependencies [247cbd6]
59
+ - Updated dependencies [9674879]
60
+ - Updated dependencies [225c9a5]
61
+ - Updated dependencies [fb64f13]
62
+ - Updated dependencies [62720ea]
63
+ - Updated dependencies [24f131b]
64
+ - Updated dependencies [bb2a7bc]
65
+ - Updated dependencies [5eb06d0]
66
+ - Updated dependencies [4e13e5f]
67
+ - Updated dependencies [e92150d]
68
+ - Updated dependencies [8037501]
69
+ - Updated dependencies [0fb6018]
70
+ - Updated dependencies [c27a1ed]
71
+ - Updated dependencies [b8e49ff]
72
+ - Updated dependencies [8037501]
73
+ - Updated dependencies [6c0da64]
74
+ - Updated dependencies [07f8ff8]
75
+ - Updated dependencies [e457582]
76
+ - Updated dependencies [8b5c905]
77
+ - Updated dependencies [f849131]
78
+ - Updated dependencies [88b9793]
79
+ - Updated dependencies [94bdcc5]
80
+ - Updated dependencies [a34c8ea]
81
+ - Updated dependencies [27770eb]
82
+ - Updated dependencies [2933c33]
83
+ - Updated dependencies [8ac4bf4]
84
+ - Updated dependencies [03d9eae]
85
+ - Updated dependencies [a5c7562]
86
+ - Updated dependencies [6181819]
87
+ - Updated dependencies [3a0be6b]
88
+ - Updated dependencies [d42baf4]
89
+ - Updated dependencies [8037501]
90
+ - Updated dependencies [54bb8a3]
91
+ - Updated dependencies [f711e18]
92
+ - Updated dependencies [8ecc121]
93
+ - @shipfox/react-ui@0.3.0
94
+ - @shipfox/api-runners-dto@0.1.0
95
+ - @shipfox/client-api@0.0.1
96
+ - @shipfox/client-ui@0.1.0
97
+
98
+ ## 0.0.2
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies [5c1e777]
103
+ - @shipfox/react-ui@0.2.0
104
+
105
+ ## 0.0.1
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies [2311e15]
110
+ - @shipfox/react-ui@0.1.1
111
+ - @shipfox/api-runners-dto@0.0.0
112
+ - @shipfox/client-api@0.0.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shipfox
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ import type { CreateManualRegistrationTokenResponseDto } from '@shipfox/api-runners-dto';
2
+ export declare const CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID = "create-manual-registration-token-form";
3
+ export declare function CreateManualRegistrationTokenForm({ workspaceId, onCreated, }: {
4
+ workspaceId: string;
5
+ onCreated: (token: CreateManualRegistrationTokenResponseDto) => void;
6
+ }): import("react").JSX.Element;
7
+ export declare function CreatedManualRegistrationTokenPanel({ token, }: {
8
+ token: CreateManualRegistrationTokenResponseDto;
9
+ }): import("react").JSX.Element;
10
+ //# sourceMappingURL=create-manual-registration-token-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-manual-registration-token-form.d.ts","sourceRoot":"","sources":["../../src/components/create-manual-registration-token-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,wCAAwC,EAAC,MAAM,0BAA0B,CAAC;AAqBvF,eAAO,MAAM,wCAAwC,0CAA0C,CAAC;AAEhG,wBAAgB,iCAAiC,CAAC,EAChD,WAAW,EACX,SAAS,GACV,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,KAAK,EAAE,wCAAwC,KAAK,IAAI,CAAC;CACtE,+BAgHA;AAED,wBAAgB,mCAAmC,CAAC,EAClD,KAAK,GACN,EAAE;IACD,KAAK,EAAE,wCAAwC,CAAC;CACjD,+BAiDA"}
@@ -0,0 +1,206 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Button } from '@shipfox/react-ui/button';
3
+ import { Callout, CalloutContent, CalloutDescription, CalloutTitle } from '@shipfox/react-ui/callout';
4
+ import { FormField, FormFieldInput, fieldError } from '@shipfox/react-ui/form-field';
5
+ import { useCopyToClipboard } from '@shipfox/react-ui/hooks';
6
+ import { ModalBody, ModalFooter } from '@shipfox/react-ui/modal';
7
+ import { Code, Text } from '@shipfox/react-ui/typography';
8
+ import { useForm } from '@tanstack/react-form';
9
+ import { useQueryClient } from '@tanstack/react-query';
10
+ import { useState } from 'react';
11
+ import { manualRegistrationTokenQueryKeys, useCreateManualRegistrationTokenMutation } from '#hooks/api/manual-registration-tokens.js';
12
+ import { manualRegistrationTokenCreateErrorToFormError } from './form-errors.js';
13
+ import { ExpirationSelect, expirationHint } from './token-expiration-select.js';
14
+ export const CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID = 'create-manual-registration-token-form';
15
+ export function CreateManualRegistrationTokenForm({ workspaceId, onCreated }) {
16
+ const queryClient = useQueryClient();
17
+ const createToken = useCreateManualRegistrationTokenMutation();
18
+ const [formError, setFormError] = useState();
19
+ const form = useForm({
20
+ defaultValues: {
21
+ name: '',
22
+ expiration: '86400'
23
+ },
24
+ onSubmit: async ({ value })=>{
25
+ setFormError(undefined);
26
+ const trimmedName = value.name.trim();
27
+ const body = {
28
+ ...trimmedName ? {
29
+ name: trimmedName
30
+ } : {},
31
+ ...value.expiration === 'never' ? {} : {
32
+ ttl_seconds: Number(value.expiration)
33
+ }
34
+ };
35
+ try {
36
+ const token = await createToken.mutateAsync({
37
+ workspaceId,
38
+ body
39
+ });
40
+ await queryClient.invalidateQueries({
41
+ queryKey: manualRegistrationTokenQueryKeys.list(workspaceId)
42
+ });
43
+ onCreated(token);
44
+ } catch (error) {
45
+ const mapped = manualRegistrationTokenCreateErrorToFormError(error);
46
+ setFormError(mapped.message);
47
+ }
48
+ }
49
+ });
50
+ return /*#__PURE__*/ _jsxs(_Fragment, {
51
+ children: [
52
+ /*#__PURE__*/ _jsxs(ModalBody, {
53
+ className: "gap-16",
54
+ children: [
55
+ /*#__PURE__*/ _jsxs("form", {
56
+ id: CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID,
57
+ className: "flex w-full flex-col gap-8",
58
+ noValidate: true,
59
+ onSubmit: (event)=>{
60
+ event.preventDefault();
61
+ event.stopPropagation();
62
+ void form.handleSubmit();
63
+ },
64
+ children: [
65
+ /*#__PURE__*/ _jsxs("div", {
66
+ className: "flex w-full items-end gap-16 max-[640px]:flex-col max-[640px]:items-stretch",
67
+ children: [
68
+ /*#__PURE__*/ _jsx(form.Field, {
69
+ name: "name",
70
+ validators: {
71
+ onBlur: ({ value })=>value.length <= 80 ? undefined : 'Token name must be 80 characters or fewer.'
72
+ },
73
+ children: (field)=>/*#__PURE__*/ _jsx(FormField, {
74
+ className: "flex-1",
75
+ label: "Token name",
76
+ id: "manual-registration-token-name",
77
+ error: fieldError(field),
78
+ children: /*#__PURE__*/ _jsx(FormFieldInput, {
79
+ placeholder: "Local runner",
80
+ maxLength: 80,
81
+ value: field.state.value,
82
+ onChange: (event)=>field.handleChange(event.target.value),
83
+ onBlur: field.handleBlur
84
+ })
85
+ })
86
+ }),
87
+ /*#__PURE__*/ _jsx(form.Field, {
88
+ name: "expiration",
89
+ children: (field)=>/*#__PURE__*/ _jsx(FormField, {
90
+ className: "flex-1",
91
+ label: "Expires",
92
+ id: "manual-registration-token-expiration",
93
+ error: fieldError(field),
94
+ children: /*#__PURE__*/ _jsx(ExpirationSelect, {
95
+ value: field.state.value,
96
+ onValueChange: (next)=>field.handleChange(next)
97
+ })
98
+ })
99
+ })
100
+ ]
101
+ }),
102
+ /*#__PURE__*/ _jsx(form.Subscribe, {
103
+ selector: (state)=>state.values.expiration,
104
+ children: (expiration)=>/*#__PURE__*/ _jsx(Text, {
105
+ size: "sm",
106
+ className: "text-foreground-neutral-muted",
107
+ children: expirationHint(expiration)
108
+ })
109
+ })
110
+ ]
111
+ }),
112
+ formError ? /*#__PURE__*/ _jsx(Callout, {
113
+ role: "alert",
114
+ type: "error",
115
+ children: /*#__PURE__*/ _jsxs("div", {
116
+ className: "flex flex-col gap-8",
117
+ children: [
118
+ /*#__PURE__*/ _jsx(Text, {
119
+ size: "sm",
120
+ bold: true,
121
+ children: "Could not create token"
122
+ }),
123
+ /*#__PURE__*/ _jsx(Text, {
124
+ size: "sm",
125
+ children: formError
126
+ })
127
+ ]
128
+ })
129
+ }) : null
130
+ ]
131
+ }),
132
+ /*#__PURE__*/ _jsx(ModalFooter, {
133
+ children: /*#__PURE__*/ _jsx(Button, {
134
+ type: "submit",
135
+ form: CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID,
136
+ isLoading: createToken.isPending,
137
+ children: "Create token"
138
+ })
139
+ })
140
+ ]
141
+ });
142
+ }
143
+ export function CreatedManualRegistrationTokenPanel({ token }) {
144
+ const [copyState, setCopyState] = useState('idle');
145
+ const { copy } = useCopyToClipboard({
146
+ text: token.raw_token,
147
+ onCopy: ()=>{
148
+ setCopyState('copied');
149
+ window.setTimeout(()=>setCopyState('idle'), 1500);
150
+ }
151
+ });
152
+ async function handleCopy() {
153
+ try {
154
+ await copy();
155
+ } catch {
156
+ setCopyState('failed');
157
+ window.setTimeout(()=>setCopyState('idle'), 2500);
158
+ }
159
+ }
160
+ return /*#__PURE__*/ _jsx(Callout, {
161
+ type: "success",
162
+ variant: "secondary",
163
+ icon: null,
164
+ children: /*#__PURE__*/ _jsxs(CalloutContent, {
165
+ className: "flex flex-col gap-12",
166
+ children: [
167
+ /*#__PURE__*/ _jsxs("div", {
168
+ className: "flex flex-col gap-2",
169
+ children: [
170
+ /*#__PURE__*/ _jsx(CalloutTitle, {
171
+ className: "mb-0",
172
+ children: "Token created"
173
+ }),
174
+ /*#__PURE__*/ _jsx(CalloutDescription, {
175
+ children: "Copy this registration token now. It will not be shown again."
176
+ })
177
+ ]
178
+ }),
179
+ /*#__PURE__*/ _jsxs("div", {
180
+ className: "flex items-center gap-8 max-[640px]:flex-col max-[640px]:items-stretch",
181
+ children: [
182
+ /*#__PURE__*/ _jsx(Code, {
183
+ variant: "paragraph",
184
+ className: "min-w-0 flex-1 break-all",
185
+ children: token.raw_token
186
+ }),
187
+ /*#__PURE__*/ _jsx(Button, {
188
+ size: "sm",
189
+ variant: "secondary",
190
+ iconLeft: "fileCopyLine",
191
+ onClick: ()=>void handleCopy(),
192
+ children: copyState === 'copied' ? 'Copied' : 'Copy'
193
+ })
194
+ ]
195
+ }),
196
+ copyState === 'failed' ? /*#__PURE__*/ _jsx(Text, {
197
+ size: "sm",
198
+ className: "text-foreground-neutral-muted",
199
+ children: "Copy failed: select and copy manually."
200
+ }) : null
201
+ ]
202
+ })
203
+ });
204
+ }
205
+
206
+ //# sourceMappingURL=create-manual-registration-token-form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/create-manual-registration-token-form.tsx"],"sourcesContent":["import type {CreateManualRegistrationTokenResponseDto} from '@shipfox/api-runners-dto';\nimport {Button} from '@shipfox/react-ui/button';\nimport {Callout, CalloutContent, CalloutDescription, CalloutTitle} from '@shipfox/react-ui/callout';\nimport {FormField, FormFieldInput, fieldError} from '@shipfox/react-ui/form-field';\nimport {useCopyToClipboard} from '@shipfox/react-ui/hooks';\nimport {ModalBody, ModalFooter} from '@shipfox/react-ui/modal';\nimport {Code, Text} from '@shipfox/react-ui/typography';\nimport {useForm} from '@tanstack/react-form';\nimport {useQueryClient} from '@tanstack/react-query';\nimport {useState} from 'react';\nimport {\n manualRegistrationTokenQueryKeys,\n useCreateManualRegistrationTokenMutation,\n} from '#hooks/api/manual-registration-tokens.js';\nimport {manualRegistrationTokenCreateErrorToFormError} from './form-errors.js';\nimport {\n ExpirationSelect,\n expirationHint,\n type TokenExpirationOption,\n} from './token-expiration-select.js';\n\nexport const CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID = 'create-manual-registration-token-form';\n\nexport function CreateManualRegistrationTokenForm({\n workspaceId,\n onCreated,\n}: {\n workspaceId: string;\n onCreated: (token: CreateManualRegistrationTokenResponseDto) => void;\n}) {\n const queryClient = useQueryClient();\n const createToken = useCreateManualRegistrationTokenMutation();\n const [formError, setFormError] = useState<string | undefined>();\n\n const form = useForm({\n defaultValues: {name: '', expiration: '86400' as TokenExpirationOption},\n onSubmit: async ({value}) => {\n setFormError(undefined);\n const trimmedName = value.name.trim();\n const body = {\n ...(trimmedName ? {name: trimmedName} : {}),\n ...(value.expiration === 'never' ? {} : {ttl_seconds: Number(value.expiration)}),\n };\n\n try {\n const token = await createToken.mutateAsync({workspaceId, body});\n await queryClient.invalidateQueries({\n queryKey: manualRegistrationTokenQueryKeys.list(workspaceId),\n });\n onCreated(token);\n } catch (error) {\n const mapped = manualRegistrationTokenCreateErrorToFormError(error);\n setFormError(mapped.message);\n }\n },\n });\n\n return (\n <>\n <ModalBody className=\"gap-16\">\n <form\n id={CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID}\n className=\"flex w-full flex-col gap-8\"\n noValidate\n onSubmit={(event) => {\n event.preventDefault();\n event.stopPropagation();\n void form.handleSubmit();\n }}\n >\n <div className=\"flex w-full items-end gap-16 max-[640px]:flex-col max-[640px]:items-stretch\">\n <form.Field\n name=\"name\"\n validators={{\n onBlur: ({value}) =>\n value.length <= 80 ? undefined : 'Token name must be 80 characters or fewer.',\n }}\n >\n {(field) => (\n <FormField\n className=\"flex-1\"\n label=\"Token name\"\n id=\"manual-registration-token-name\"\n error={fieldError(field)}\n >\n <FormFieldInput\n placeholder=\"Local runner\"\n maxLength={80}\n value={field.state.value}\n onChange={(event) => field.handleChange(event.target.value)}\n onBlur={field.handleBlur}\n />\n </FormField>\n )}\n </form.Field>\n <form.Field name=\"expiration\">\n {(field) => (\n <FormField\n className=\"flex-1\"\n label=\"Expires\"\n id=\"manual-registration-token-expiration\"\n error={fieldError(field)}\n >\n <ExpirationSelect\n value={field.state.value}\n onValueChange={(next) => field.handleChange(next)}\n />\n </FormField>\n )}\n </form.Field>\n </div>\n <form.Subscribe selector={(state) => state.values.expiration}>\n {(expiration) => (\n <Text size=\"sm\" className=\"text-foreground-neutral-muted\">\n {expirationHint(expiration)}\n </Text>\n )}\n </form.Subscribe>\n </form>\n {formError ? (\n <Callout role=\"alert\" type=\"error\">\n <div className=\"flex flex-col gap-8\">\n <Text size=\"sm\" bold>\n Could not create token\n </Text>\n <Text size=\"sm\">{formError}</Text>\n </div>\n </Callout>\n ) : null}\n </ModalBody>\n <ModalFooter>\n <Button\n type=\"submit\"\n form={CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID}\n isLoading={createToken.isPending}\n >\n Create token\n </Button>\n </ModalFooter>\n </>\n );\n}\n\nexport function CreatedManualRegistrationTokenPanel({\n token,\n}: {\n token: CreateManualRegistrationTokenResponseDto;\n}) {\n const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>('idle');\n const {copy} = useCopyToClipboard({\n text: token.raw_token,\n onCopy: () => {\n setCopyState('copied');\n window.setTimeout(() => setCopyState('idle'), 1500);\n },\n });\n\n async function handleCopy() {\n try {\n await copy();\n } catch {\n setCopyState('failed');\n window.setTimeout(() => setCopyState('idle'), 2500);\n }\n }\n\n return (\n <Callout type=\"success\" variant=\"secondary\" icon={null}>\n <CalloutContent className=\"flex flex-col gap-12\">\n <div className=\"flex flex-col gap-2\">\n <CalloutTitle className=\"mb-0\">Token created</CalloutTitle>\n <CalloutDescription>\n Copy this registration token now. It will not be shown again.\n </CalloutDescription>\n </div>\n <div className=\"flex items-center gap-8 max-[640px]:flex-col max-[640px]:items-stretch\">\n <Code variant=\"paragraph\" className=\"min-w-0 flex-1 break-all\">\n {token.raw_token}\n </Code>\n <Button\n size=\"sm\"\n variant=\"secondary\"\n iconLeft=\"fileCopyLine\"\n onClick={() => void handleCopy()}\n >\n {copyState === 'copied' ? 'Copied' : 'Copy'}\n </Button>\n </div>\n {copyState === 'failed' ? (\n <Text size=\"sm\" className=\"text-foreground-neutral-muted\">\n Copy failed: select and copy manually.\n </Text>\n ) : null}\n </CalloutContent>\n </Callout>\n );\n}\n"],"names":["Button","Callout","CalloutContent","CalloutDescription","CalloutTitle","FormField","FormFieldInput","fieldError","useCopyToClipboard","ModalBody","ModalFooter","Code","Text","useForm","useQueryClient","useState","manualRegistrationTokenQueryKeys","useCreateManualRegistrationTokenMutation","manualRegistrationTokenCreateErrorToFormError","ExpirationSelect","expirationHint","CREATE_MANUAL_REGISTRATION_TOKEN_FORM_ID","CreateManualRegistrationTokenForm","workspaceId","onCreated","queryClient","createToken","formError","setFormError","form","defaultValues","name","expiration","onSubmit","value","undefined","trimmedName","trim","body","ttl_seconds","Number","token","mutateAsync","invalidateQueries","queryKey","list","error","mapped","message","className","id","noValidate","event","preventDefault","stopPropagation","handleSubmit","div","Field","validators","onBlur","length","field","label","placeholder","maxLength","state","onChange","handleChange","target","handleBlur","onValueChange","next","Subscribe","selector","values","size","role","type","bold","isLoading","isPending","CreatedManualRegistrationTokenPanel","copyState","setCopyState","copy","text","raw_token","onCopy","window","setTimeout","handleCopy","variant","icon","iconLeft","onClick"],"mappings":";AACA,SAAQA,MAAM,QAAO,2BAA2B;AAChD,SAAQC,OAAO,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,YAAY,QAAO,4BAA4B;AACpG,SAAQC,SAAS,EAAEC,cAAc,EAAEC,UAAU,QAAO,+BAA+B;AACnF,SAAQC,kBAAkB,QAAO,0BAA0B;AAC3D,SAAQC,SAAS,EAAEC,WAAW,QAAO,0BAA0B;AAC/D,SAAQC,IAAI,EAAEC,IAAI,QAAO,+BAA+B;AACxD,SAAQC,OAAO,QAAO,uBAAuB;AAC7C,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SAAQC,QAAQ,QAAO,QAAQ;AAC/B,SACEC,gCAAgC,EAChCC,wCAAwC,QACnC,2CAA2C;AAClD,SAAQC,6CAA6C,QAAO,mBAAmB;AAC/E,SACEC,gBAAgB,EAChBC,cAAc,QAET,+BAA+B;AAEtC,OAAO,MAAMC,2CAA2C,wCAAwC;AAEhG,OAAO,SAASC,kCAAkC,EAChDC,WAAW,EACXC,SAAS,EAIV;IACC,MAAMC,cAAcX;IACpB,MAAMY,cAAcT;IACpB,MAAM,CAACU,WAAWC,aAAa,GAAGb;IAElC,MAAMc,OAAOhB,QAAQ;QACnBiB,eAAe;YAACC,MAAM;YAAIC,YAAY;QAAgC;QACtEC,UAAU,OAAO,EAACC,KAAK,EAAC;YACtBN,aA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,WAAU;sCAAO;;sCAC/B,KAAC9C;sCAAmB;;;;8BAItB,MAACqD;oBAAIP,WAAU;;sCACb,KAACtC;4BAAKgF,SAAQ;4BAAY1C,WAAU;sCACjCR,MAAM6C,SAAS;;sCAElB,KAACtF;4BACC2E,MAAK;4BACLgB,SAAQ;4BACRE,UAAS;4BACTC,SAAS,IAAM,KAAKJ;sCAEnBR,cAAc,WAAW,WAAW;;;;gBAGxCA,cAAc,yBACb,KAACtE;oBAAK+D,MAAK;oBAAK1B,WAAU;8BAAgC;qBAGxD;;;;AAIZ"}
@@ -0,0 +1,10 @@
1
+ import type { CreateProvisionerTokenResponseDto } from '@shipfox/api-runners-dto';
2
+ export declare const CREATE_PROVISIONER_TOKEN_FORM_ID = "create-provisioner-token-form";
3
+ export declare function CreateProvisionerTokenForm({ workspaceId, onCreated, }: {
4
+ workspaceId: string;
5
+ onCreated: (token: CreateProvisionerTokenResponseDto) => void;
6
+ }): import("react").JSX.Element;
7
+ export declare function CreatedProvisionerTokenPanel({ token }: {
8
+ token: CreateProvisionerTokenResponseDto;
9
+ }): import("react").JSX.Element;
10
+ //# sourceMappingURL=create-provisioner-token-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-provisioner-token-form.d.ts","sourceRoot":"","sources":["../../src/components/create-provisioner-token-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iCAAiC,EAAC,MAAM,0BAA0B,CAAC;AAqBhF,eAAO,MAAM,gCAAgC,kCAAkC,CAAC;AAEhF,wBAAgB,0BAA0B,CAAC,EACzC,WAAW,EACX,SAAS,GACV,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,KAAK,EAAE,iCAAiC,KAAK,IAAI,CAAC;CAC/D,+BAgHA;AAED,wBAAgB,4BAA4B,CAAC,EAAC,KAAK,EAAC,EAAE;IAAC,KAAK,EAAE,iCAAiC,CAAA;CAAC,+BAiD/F"}