@auto-engineer/generate-react-client 1.32.0 → 1.34.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 +33 -0
- package/dist/starter/.storybook/main.ts +4 -1
- package/dist/starter/.storybook/manager.ts +4 -5
- package/dist/starter/codegen.ts +17 -0
- package/dist/starter/package.json +7 -4
- package/dist/starter/pnpm-lock.yaml +2643 -69
- package/dist/starter/src/components/ui/DesignSystem-Colors.stories.tsx +1 -0
- package/dist/starter/src/components/ui/DesignSystem-Layout.stories.tsx +1 -0
- package/dist/starter/src/components/ui/DesignSystem-Overview.stories.tsx +1 -0
- package/dist/starter/src/components/ui/DesignSystem-Typography.stories.tsx +1 -0
- package/dist/starter/src/gql/execute.ts +11 -0
- package/dist/starter/src/gql/fragment-masking.ts +83 -0
- package/dist/starter/src/gql/gql.ts +9 -0
- package/dist/starter/src/gql/graphql.ts +182 -0
- package/dist/starter/src/gql/index.ts +2 -0
- package/dist/starter/src/graphql/mutations.ts +0 -0
- package/dist/starter/src/graphql/queries.ts +0 -0
- package/dist/starter/tsconfig.json +6 -0
- package/package.json +2 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import request from 'graphql-request';
|
|
2
|
+
import type { TypedDocumentString } from './graphql';
|
|
3
|
+
|
|
4
|
+
const GRAPHQL_ENDPOINT = 'http://localhost:4000/graphql';
|
|
5
|
+
|
|
6
|
+
export async function execute<TResult, TVariables>(
|
|
7
|
+
query: TypedDocumentString<TResult, TVariables>,
|
|
8
|
+
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
|
|
9
|
+
): Promise<TResult> {
|
|
10
|
+
return request(GRAPHQL_ENDPOINT, query.toString(), variables ? variables : undefined);
|
|
11
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import { ResultOf, DocumentTypeDecoration } from '@graphql-typed-document-node/core';
|
|
3
|
+
import { Incremental, TypedDocumentString } from './graphql';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
|
|
7
|
+
infer TType,
|
|
8
|
+
any
|
|
9
|
+
>
|
|
10
|
+
? [TType] extends [{ ' $fragmentName'?: infer TKey }]
|
|
11
|
+
? TKey extends string
|
|
12
|
+
? { ' $fragmentRefs'?: { [key in TKey]: TType } }
|
|
13
|
+
: never
|
|
14
|
+
: never
|
|
15
|
+
: never;
|
|
16
|
+
|
|
17
|
+
// return non-nullable if `fragmentType` is non-nullable
|
|
18
|
+
export function useFragment<TType>(
|
|
19
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
20
|
+
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>
|
|
21
|
+
): TType;
|
|
22
|
+
// return nullable if `fragmentType` is undefined
|
|
23
|
+
export function useFragment<TType>(
|
|
24
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
25
|
+
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | undefined
|
|
26
|
+
): TType | undefined;
|
|
27
|
+
// return nullable if `fragmentType` is nullable
|
|
28
|
+
export function useFragment<TType>(
|
|
29
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
30
|
+
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null
|
|
31
|
+
): TType | null;
|
|
32
|
+
// return nullable if `fragmentType` is nullable or undefined
|
|
33
|
+
export function useFragment<TType>(
|
|
34
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
35
|
+
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
|
|
36
|
+
): TType | null | undefined;
|
|
37
|
+
// return array of non-nullable if `fragmentType` is array of non-nullable
|
|
38
|
+
export function useFragment<TType>(
|
|
39
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
40
|
+
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>>
|
|
41
|
+
): Array<TType>;
|
|
42
|
+
// return array of nullable if `fragmentType` is array of nullable
|
|
43
|
+
export function useFragment<TType>(
|
|
44
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
45
|
+
fragmentType: Array<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
|
|
46
|
+
): Array<TType> | null | undefined;
|
|
47
|
+
// return readonly array of non-nullable if `fragmentType` is array of non-nullable
|
|
48
|
+
export function useFragment<TType>(
|
|
49
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
50
|
+
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
|
|
51
|
+
): ReadonlyArray<TType>;
|
|
52
|
+
// return readonly array of nullable if `fragmentType` is array of nullable
|
|
53
|
+
export function useFragment<TType>(
|
|
54
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
55
|
+
fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
|
|
56
|
+
): ReadonlyArray<TType> | null | undefined;
|
|
57
|
+
export function useFragment<TType>(
|
|
58
|
+
_documentNode: DocumentTypeDecoration<TType, any>,
|
|
59
|
+
fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | Array<FragmentType<DocumentTypeDecoration<TType, any>>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
|
|
60
|
+
): TType | Array<TType> | ReadonlyArray<TType> | null | undefined {
|
|
61
|
+
return fragmentType as any;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
export function makeFragmentData<
|
|
66
|
+
F extends DocumentTypeDecoration<any, any>,
|
|
67
|
+
FT extends ResultOf<F>
|
|
68
|
+
>(data: FT, _fragment: F): FragmentType<F> {
|
|
69
|
+
return data as FragmentType<F>;
|
|
70
|
+
}
|
|
71
|
+
export function isFragmentReady<TQuery, TFrag>(
|
|
72
|
+
queryNode: TypedDocumentString<TQuery, any>,
|
|
73
|
+
fragmentNode: TypedDocumentString<TFrag, any>,
|
|
74
|
+
data: FragmentType<TypedDocumentString<Incremental<TFrag>, any>> | null | undefined
|
|
75
|
+
): data is FragmentType<typeof fragmentNode> {
|
|
76
|
+
const deferredFields = queryNode.__meta__?.deferredFields as Record<string, (keyof TFrag)[]>;
|
|
77
|
+
const fragName = fragmentNode.__meta__?.fragmentName as string | undefined;
|
|
78
|
+
|
|
79
|
+
if (!deferredFields || !fragName) return true;
|
|
80
|
+
|
|
81
|
+
const fields = deferredFields[fragName] ?? [];
|
|
82
|
+
return fields.length > 0 && fields.every(field => data && field in data);
|
|
83
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export type Maybe<T> = T | null;
|
|
3
|
+
export type InputMaybe<T> = T | null | undefined;
|
|
4
|
+
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
5
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
|
6
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
|
7
|
+
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
|
|
8
|
+
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
|
|
9
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
10
|
+
export type Scalars = {
|
|
11
|
+
ID: { input: string; output: string; }
|
|
12
|
+
String: { input: string; output: string; }
|
|
13
|
+
Boolean: { input: boolean; output: boolean; }
|
|
14
|
+
Int: { input: number; output: number; }
|
|
15
|
+
Float: { input: number; output: number; }
|
|
16
|
+
/** A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.This scalar is serialized to a string in ISO 8601 format and parsed from a string in ISO 8601 format. */
|
|
17
|
+
DateTimeISO: { input: any; output: any; }
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type ActiveWorkoutView = {
|
|
21
|
+
__typename?: 'ActiveWorkoutView';
|
|
22
|
+
duration: Scalars['String']['output'];
|
|
23
|
+
exercises: Array<ActiveWorkoutViewExercises>;
|
|
24
|
+
sessionId: Scalars['String']['output'];
|
|
25
|
+
totalSets: Scalars['Float']['output'];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type ActiveWorkoutViewExercises = {
|
|
29
|
+
__typename?: 'ActiveWorkoutViewExercises';
|
|
30
|
+
exerciseId: Scalars['String']['output'];
|
|
31
|
+
reps: Scalars['Float']['output'];
|
|
32
|
+
sets: Scalars['Float']['output'];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type CalculateWorkoutStatsInput = {
|
|
36
|
+
sessionId: Scalars['String']['input'];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type CompleteWorkoutInput = {
|
|
40
|
+
endTime: Scalars['DateTimeISO']['input'];
|
|
41
|
+
sessionId: Scalars['String']['input'];
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type Mutation = {
|
|
45
|
+
__typename?: 'Mutation';
|
|
46
|
+
calculateWorkoutStats: MutationResponse;
|
|
47
|
+
completeWorkout: MutationResponse;
|
|
48
|
+
setFitnessGoal: MutationResponse;
|
|
49
|
+
startWorkout: MutationResponse;
|
|
50
|
+
updateGoalProgress: MutationResponse;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
export type MutationCalculateWorkoutStatsArgs = {
|
|
55
|
+
input: CalculateWorkoutStatsInput;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
export type MutationCompleteWorkoutArgs = {
|
|
60
|
+
input: CompleteWorkoutInput;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
export type MutationSetFitnessGoalArgs = {
|
|
65
|
+
input: SetFitnessGoalInput;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
export type MutationStartWorkoutArgs = {
|
|
70
|
+
input: StartWorkoutInput;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
export type MutationUpdateGoalProgressArgs = {
|
|
75
|
+
input: UpdateGoalProgressInput;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type MutationError = {
|
|
79
|
+
__typename?: 'MutationError';
|
|
80
|
+
message?: Maybe<Scalars['String']['output']>;
|
|
81
|
+
type: Scalars['String']['output'];
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type MutationResponse = {
|
|
85
|
+
__typename?: 'MutationResponse';
|
|
86
|
+
error?: Maybe<MutationError>;
|
|
87
|
+
success: Scalars['Boolean']['output'];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type ProgressDashboardView = {
|
|
91
|
+
__typename?: 'ProgressDashboardView';
|
|
92
|
+
avgVolume: Scalars['Float']['output'];
|
|
93
|
+
goals: Array<ProgressDashboardViewGoals>;
|
|
94
|
+
totalWorkouts: Scalars['Float']['output'];
|
|
95
|
+
userId: Scalars['String']['output'];
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type ProgressDashboardViewGoals = {
|
|
99
|
+
__typename?: 'ProgressDashboardViewGoals';
|
|
100
|
+
complete: Scalars['Boolean']['output'];
|
|
101
|
+
goalId: Scalars['String']['output'];
|
|
102
|
+
progress: Scalars['Float']['output'];
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export type Query = {
|
|
106
|
+
__typename?: 'Query';
|
|
107
|
+
activeWorkout: Array<ActiveWorkoutView>;
|
|
108
|
+
progressDashboard: Array<ProgressDashboardView>;
|
|
109
|
+
workoutHistory: Array<WorkoutHistoryView>;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
export type QueryActiveWorkoutArgs = {
|
|
114
|
+
userId?: InputMaybe<Scalars['ID']['input']>;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
export type QueryProgressDashboardArgs = {
|
|
119
|
+
userId?: InputMaybe<Scalars['ID']['input']>;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
export type QueryWorkoutHistoryArgs = {
|
|
124
|
+
input?: InputMaybe<Scalars['String']['input']>;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export type SetFitnessGoalInput = {
|
|
128
|
+
goalId: Scalars['String']['input'];
|
|
129
|
+
periodStart: Scalars['DateTimeISO']['input'];
|
|
130
|
+
target: Scalars['Float']['input'];
|
|
131
|
+
type: Scalars['String']['input'];
|
|
132
|
+
userId: Scalars['String']['input'];
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type StartWorkoutExercisesInput = {
|
|
136
|
+
exerciseId: Scalars['String']['input'];
|
|
137
|
+
reps: Scalars['Float']['input'];
|
|
138
|
+
sets: Scalars['Float']['input'];
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type StartWorkoutInput = {
|
|
142
|
+
exercises: Array<StartWorkoutExercisesInput>;
|
|
143
|
+
sessionId: Scalars['String']['input'];
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type UpdateGoalProgressInput = {
|
|
147
|
+
addedVolume: Scalars['Float']['input'];
|
|
148
|
+
goalId: Scalars['String']['input'];
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export type WorkoutHistoryView = {
|
|
152
|
+
__typename?: 'WorkoutHistoryView';
|
|
153
|
+
sessions: Array<WorkoutHistoryViewSessions>;
|
|
154
|
+
userId: Scalars['String']['output'];
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export type WorkoutHistoryViewSessions = {
|
|
158
|
+
__typename?: 'WorkoutHistoryViewSessions';
|
|
159
|
+
date: Scalars['DateTimeISO']['output'];
|
|
160
|
+
duration: Scalars['String']['output'];
|
|
161
|
+
sessionId: Scalars['String']['output'];
|
|
162
|
+
volume: Scalars['Float']['output'];
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export class TypedDocumentString<TResult, TVariables>
|
|
166
|
+
extends String
|
|
167
|
+
implements DocumentTypeDecoration<TResult, TVariables>
|
|
168
|
+
{
|
|
169
|
+
__apiType?: NonNullable<DocumentTypeDecoration<TResult, TVariables>['__apiType']>;
|
|
170
|
+
private value: string;
|
|
171
|
+
public __meta__?: Record<string, any> | undefined;
|
|
172
|
+
|
|
173
|
+
constructor(value: string, __meta__?: Record<string, any> | undefined) {
|
|
174
|
+
super(value);
|
|
175
|
+
this.value = value;
|
|
176
|
+
this.__meta__ = __meta__;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
override toString(): string & DocumentTypeDecoration<TResult, TVariables> {
|
|
180
|
+
return this.value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"debug": "^4.4.1",
|
|
22
|
-
"@auto-engineer/message-bus": "1.
|
|
22
|
+
"@auto-engineer/message-bus": "1.34.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/debug": "^4.1.12"
|
|
26
26
|
},
|
|
27
|
-
"version": "1.
|
|
27
|
+
"version": "1.34.0",
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "tsc && tsx ../../scripts/fix-esm-imports.ts && cp -r starter dist/",
|
|
30
30
|
"test-cli": "tsx test-cli.ts",
|