@beorchid-llc/thrivo-contracts 0.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 +7 -0
- package/dist/common.d.ts +78 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +31 -0
- package/dist/common.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/users.d.ts +201 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +41 -0
- package/dist/users.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @beorchid-llc/thrivo-contracts
|
|
2
|
+
|
|
3
|
+
Shared Zod schemas, DTO types, error codes, and route metadata for Thrivo clients.
|
|
4
|
+
|
|
5
|
+
The backend is the source of truth. Backend route validation and controller responses should use these
|
|
6
|
+
schemas directly, then mobile/admin/public consume the published package instead of maintaining local
|
|
7
|
+
mirrors.
|
package/dist/common.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const errorCodeSchema: z.ZodEnum<["VALIDATION_ERROR", "UNAUTHORIZED", "FORBIDDEN", "PREMIUM_REQUIRED", "NOT_FOUND", "CONFLICT", "RATE_LIMITED", "UPSTREAM_ERROR", "INTERNAL_ERROR"]>;
|
|
3
|
+
export type ErrorCode = z.infer<typeof errorCodeSchema>;
|
|
4
|
+
export declare const metaSchema: z.ZodObject<{
|
|
5
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
7
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
9
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
}, z.ZodUnknown, "strip">>;
|
|
11
|
+
export type Meta = z.infer<typeof metaSchema>;
|
|
12
|
+
export declare const apiErrorSchema: z.ZodObject<{
|
|
13
|
+
error: z.ZodObject<{
|
|
14
|
+
code: z.ZodEnum<["VALIDATION_ERROR", "UNAUTHORIZED", "FORBIDDEN", "PREMIUM_REQUIRED", "NOT_FOUND", "CONFLICT", "RATE_LIMITED", "UPSTREAM_ERROR", "INTERNAL_ERROR"]>;
|
|
15
|
+
message: z.ZodString;
|
|
16
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
code: "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "PREMIUM_REQUIRED" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "UPSTREAM_ERROR" | "INTERNAL_ERROR";
|
|
19
|
+
message: string;
|
|
20
|
+
details?: unknown;
|
|
21
|
+
}, {
|
|
22
|
+
code: "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "PREMIUM_REQUIRED" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "UPSTREAM_ERROR" | "INTERNAL_ERROR";
|
|
23
|
+
message: string;
|
|
24
|
+
details?: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
error: {
|
|
28
|
+
code: "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "PREMIUM_REQUIRED" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "UPSTREAM_ERROR" | "INTERNAL_ERROR";
|
|
29
|
+
message: string;
|
|
30
|
+
details?: unknown;
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
error: {
|
|
34
|
+
code: "VALIDATION_ERROR" | "UNAUTHORIZED" | "FORBIDDEN" | "PREMIUM_REQUIRED" | "NOT_FOUND" | "CONFLICT" | "RATE_LIMITED" | "UPSTREAM_ERROR" | "INTERNAL_ERROR";
|
|
35
|
+
message: string;
|
|
36
|
+
details?: unknown;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export type ApiError = z.infer<typeof apiErrorSchema>;
|
|
40
|
+
export declare function apiSuccessSchema<T extends z.ZodTypeAny>(data: T): z.ZodObject<{
|
|
41
|
+
data: T;
|
|
42
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
45
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
46
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
47
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
+
}, z.ZodUnknown, "strip">>>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
|
|
50
|
+
data: T;
|
|
51
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
53
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
54
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
56
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
}, z.ZodUnknown, "strip">>>;
|
|
58
|
+
}>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
|
|
59
|
+
data: T;
|
|
60
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
61
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
62
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
63
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
64
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
65
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
66
|
+
}, z.ZodUnknown, "strip">>>;
|
|
67
|
+
}> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
|
|
68
|
+
export type ApiSuccess<T> = {
|
|
69
|
+
data: T;
|
|
70
|
+
meta?: Meta;
|
|
71
|
+
};
|
|
72
|
+
export type HttpMethod = "GET" | "POST" | "PATCH" | "DELETE";
|
|
73
|
+
export type RouteContract = {
|
|
74
|
+
method: HttpMethod;
|
|
75
|
+
path: `/api/v1/${string}`;
|
|
76
|
+
auth: "public" | "user" | "admin" | "signature";
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,+JAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,UAAU;;;;;;0BAIC,CAAC;AAEzB,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAE9C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;EAMzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;kEAK/D;AAED,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IAC1B,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,WAAW,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;CACjD,CAAC"}
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const errorCodeSchema = z.enum([
|
|
3
|
+
"VALIDATION_ERROR",
|
|
4
|
+
"UNAUTHORIZED",
|
|
5
|
+
"FORBIDDEN",
|
|
6
|
+
"PREMIUM_REQUIRED",
|
|
7
|
+
"NOT_FOUND",
|
|
8
|
+
"CONFLICT",
|
|
9
|
+
"RATE_LIMITED",
|
|
10
|
+
"UPSTREAM_ERROR",
|
|
11
|
+
"INTERNAL_ERROR",
|
|
12
|
+
]);
|
|
13
|
+
export const metaSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
nextCursor: z.string().nullable().optional(),
|
|
16
|
+
})
|
|
17
|
+
.catchall(z.unknown());
|
|
18
|
+
export const apiErrorSchema = z.object({
|
|
19
|
+
error: z.object({
|
|
20
|
+
code: errorCodeSchema,
|
|
21
|
+
message: z.string(),
|
|
22
|
+
details: z.unknown().optional(),
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
export function apiSuccessSchema(data) {
|
|
26
|
+
return z.object({
|
|
27
|
+
data,
|
|
28
|
+
meta: metaSchema.optional(),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC;IACpC,kBAAkB;IAClB,cAAc;IACd,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,UAAU;IACV,cAAc;IACd,gBAAgB;IAChB,gBAAgB;CACjB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CAC7C,CAAC;KACD,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAIzB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC;CACH,CAAC,CAAC;AAIH,MAAM,UAAU,gBAAgB,CAAyB,IAAO;IAC9D,OAAO,CAAC,CAAC,MAAM,CAAC;QACd,IAAI;QACJ,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/users.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const goalSchema: z.ZodEnum<["lose", "maintain", "gain"]>;
|
|
3
|
+
export declare const sexSchema: z.ZodEnum<["male", "female"]>;
|
|
4
|
+
export declare const tierSchema: z.ZodEnum<["free", "premium"]>;
|
|
5
|
+
export declare const userProfileSchema: z.ZodObject<{
|
|
6
|
+
id: z.ZodString;
|
|
7
|
+
email: z.ZodString;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
goal: z.ZodNullable<z.ZodEnum<["lose", "maintain", "gain"]>>;
|
|
10
|
+
sex: z.ZodNullable<z.ZodEnum<["male", "female"]>>;
|
|
11
|
+
age: z.ZodNullable<z.ZodNumber>;
|
|
12
|
+
heightCm: z.ZodNullable<z.ZodString>;
|
|
13
|
+
weightKg: z.ZodNullable<z.ZodString>;
|
|
14
|
+
targetWeightKg: z.ZodNullable<z.ZodString>;
|
|
15
|
+
tdeeKcal: z.ZodNullable<z.ZodNumber>;
|
|
16
|
+
dailyTargetKcal: z.ZodNullable<z.ZodNumber>;
|
|
17
|
+
targetProteinG: z.ZodNullable<z.ZodNumber>;
|
|
18
|
+
targetCarbsG: z.ZodNullable<z.ZodNumber>;
|
|
19
|
+
targetFatG: z.ZodNullable<z.ZodNumber>;
|
|
20
|
+
notifyAt: z.ZodNullable<z.ZodString>;
|
|
21
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
22
|
+
tier: z.ZodEnum<["free", "premium"]>;
|
|
23
|
+
onboardingStep: z.ZodNumber;
|
|
24
|
+
createdAt: z.ZodDate;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
id: string;
|
|
27
|
+
email: string;
|
|
28
|
+
name: string;
|
|
29
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
30
|
+
sex: "male" | "female" | null;
|
|
31
|
+
age: number | null;
|
|
32
|
+
heightCm: string | null;
|
|
33
|
+
weightKg: string | null;
|
|
34
|
+
targetWeightKg: string | null;
|
|
35
|
+
tdeeKcal: number | null;
|
|
36
|
+
dailyTargetKcal: number | null;
|
|
37
|
+
targetProteinG: number | null;
|
|
38
|
+
targetCarbsG: number | null;
|
|
39
|
+
targetFatG: number | null;
|
|
40
|
+
notifyAt: string | null;
|
|
41
|
+
timezone: string | null;
|
|
42
|
+
tier: "free" | "premium";
|
|
43
|
+
onboardingStep: number;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
}, {
|
|
46
|
+
id: string;
|
|
47
|
+
email: string;
|
|
48
|
+
name: string;
|
|
49
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
50
|
+
sex: "male" | "female" | null;
|
|
51
|
+
age: number | null;
|
|
52
|
+
heightCm: string | null;
|
|
53
|
+
weightKg: string | null;
|
|
54
|
+
targetWeightKg: string | null;
|
|
55
|
+
tdeeKcal: number | null;
|
|
56
|
+
dailyTargetKcal: number | null;
|
|
57
|
+
targetProteinG: number | null;
|
|
58
|
+
targetCarbsG: number | null;
|
|
59
|
+
targetFatG: number | null;
|
|
60
|
+
notifyAt: string | null;
|
|
61
|
+
timezone: string | null;
|
|
62
|
+
tier: "free" | "premium";
|
|
63
|
+
onboardingStep: number;
|
|
64
|
+
createdAt: Date;
|
|
65
|
+
}>;
|
|
66
|
+
export type UserProfile = z.infer<typeof userProfileSchema>;
|
|
67
|
+
export declare const getMeResponseSchema: z.ZodObject<{
|
|
68
|
+
data: z.ZodObject<{
|
|
69
|
+
id: z.ZodString;
|
|
70
|
+
email: z.ZodString;
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
goal: z.ZodNullable<z.ZodEnum<["lose", "maintain", "gain"]>>;
|
|
73
|
+
sex: z.ZodNullable<z.ZodEnum<["male", "female"]>>;
|
|
74
|
+
age: z.ZodNullable<z.ZodNumber>;
|
|
75
|
+
heightCm: z.ZodNullable<z.ZodString>;
|
|
76
|
+
weightKg: z.ZodNullable<z.ZodString>;
|
|
77
|
+
targetWeightKg: z.ZodNullable<z.ZodString>;
|
|
78
|
+
tdeeKcal: z.ZodNullable<z.ZodNumber>;
|
|
79
|
+
dailyTargetKcal: z.ZodNullable<z.ZodNumber>;
|
|
80
|
+
targetProteinG: z.ZodNullable<z.ZodNumber>;
|
|
81
|
+
targetCarbsG: z.ZodNullable<z.ZodNumber>;
|
|
82
|
+
targetFatG: z.ZodNullable<z.ZodNumber>;
|
|
83
|
+
notifyAt: z.ZodNullable<z.ZodString>;
|
|
84
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
85
|
+
tier: z.ZodEnum<["free", "premium"]>;
|
|
86
|
+
onboardingStep: z.ZodNumber;
|
|
87
|
+
createdAt: z.ZodDate;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
id: string;
|
|
90
|
+
email: string;
|
|
91
|
+
name: string;
|
|
92
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
93
|
+
sex: "male" | "female" | null;
|
|
94
|
+
age: number | null;
|
|
95
|
+
heightCm: string | null;
|
|
96
|
+
weightKg: string | null;
|
|
97
|
+
targetWeightKg: string | null;
|
|
98
|
+
tdeeKcal: number | null;
|
|
99
|
+
dailyTargetKcal: number | null;
|
|
100
|
+
targetProteinG: number | null;
|
|
101
|
+
targetCarbsG: number | null;
|
|
102
|
+
targetFatG: number | null;
|
|
103
|
+
notifyAt: string | null;
|
|
104
|
+
timezone: string | null;
|
|
105
|
+
tier: "free" | "premium";
|
|
106
|
+
onboardingStep: number;
|
|
107
|
+
createdAt: Date;
|
|
108
|
+
}, {
|
|
109
|
+
id: string;
|
|
110
|
+
email: string;
|
|
111
|
+
name: string;
|
|
112
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
113
|
+
sex: "male" | "female" | null;
|
|
114
|
+
age: number | null;
|
|
115
|
+
heightCm: string | null;
|
|
116
|
+
weightKg: string | null;
|
|
117
|
+
targetWeightKg: string | null;
|
|
118
|
+
tdeeKcal: number | null;
|
|
119
|
+
dailyTargetKcal: number | null;
|
|
120
|
+
targetProteinG: number | null;
|
|
121
|
+
targetCarbsG: number | null;
|
|
122
|
+
targetFatG: number | null;
|
|
123
|
+
notifyAt: string | null;
|
|
124
|
+
timezone: string | null;
|
|
125
|
+
tier: "free" | "premium";
|
|
126
|
+
onboardingStep: number;
|
|
127
|
+
createdAt: Date;
|
|
128
|
+
}>;
|
|
129
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
130
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
}, "strip", z.ZodUnknown, z.objectOutputType<{
|
|
132
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
}, z.ZodUnknown, "strip">, z.objectInputType<{
|
|
134
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
135
|
+
}, z.ZodUnknown, "strip">>>;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
data: {
|
|
138
|
+
id: string;
|
|
139
|
+
email: string;
|
|
140
|
+
name: string;
|
|
141
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
142
|
+
sex: "male" | "female" | null;
|
|
143
|
+
age: number | null;
|
|
144
|
+
heightCm: string | null;
|
|
145
|
+
weightKg: string | null;
|
|
146
|
+
targetWeightKg: string | null;
|
|
147
|
+
tdeeKcal: number | null;
|
|
148
|
+
dailyTargetKcal: number | null;
|
|
149
|
+
targetProteinG: number | null;
|
|
150
|
+
targetCarbsG: number | null;
|
|
151
|
+
targetFatG: number | null;
|
|
152
|
+
notifyAt: string | null;
|
|
153
|
+
timezone: string | null;
|
|
154
|
+
tier: "free" | "premium";
|
|
155
|
+
onboardingStep: number;
|
|
156
|
+
createdAt: Date;
|
|
157
|
+
};
|
|
158
|
+
meta?: z.objectOutputType<{
|
|
159
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
160
|
+
}, z.ZodUnknown, "strip"> | undefined;
|
|
161
|
+
}, {
|
|
162
|
+
data: {
|
|
163
|
+
id: string;
|
|
164
|
+
email: string;
|
|
165
|
+
name: string;
|
|
166
|
+
goal: "lose" | "maintain" | "gain" | null;
|
|
167
|
+
sex: "male" | "female" | null;
|
|
168
|
+
age: number | null;
|
|
169
|
+
heightCm: string | null;
|
|
170
|
+
weightKg: string | null;
|
|
171
|
+
targetWeightKg: string | null;
|
|
172
|
+
tdeeKcal: number | null;
|
|
173
|
+
dailyTargetKcal: number | null;
|
|
174
|
+
targetProteinG: number | null;
|
|
175
|
+
targetCarbsG: number | null;
|
|
176
|
+
targetFatG: number | null;
|
|
177
|
+
notifyAt: string | null;
|
|
178
|
+
timezone: string | null;
|
|
179
|
+
tier: "free" | "premium";
|
|
180
|
+
onboardingStep: number;
|
|
181
|
+
createdAt: Date;
|
|
182
|
+
};
|
|
183
|
+
meta?: z.objectInputType<{
|
|
184
|
+
nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
185
|
+
}, z.ZodUnknown, "strip"> | undefined;
|
|
186
|
+
}>;
|
|
187
|
+
export type GetMeResponse = z.infer<typeof getMeResponseSchema>;
|
|
188
|
+
export declare const deleteMeResponseSchema: z.ZodNull;
|
|
189
|
+
export declare const userRoutes: {
|
|
190
|
+
getMe: {
|
|
191
|
+
method: "GET";
|
|
192
|
+
path: "/api/v1/users/me";
|
|
193
|
+
auth: "user";
|
|
194
|
+
};
|
|
195
|
+
deleteMe: {
|
|
196
|
+
method: "DELETE";
|
|
197
|
+
path: "/api/v1/users/me";
|
|
198
|
+
auth: "user";
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,UAAU,yCAAuC,CAAC;AAC/D,eAAO,MAAM,SAAS,+BAA6B,CAAC;AACpD,eAAO,MAAM,UAAU,gCAA8B,CAAC;AAEtD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoB5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAsC,CAAC;AAEvE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,sBAAsB,WAAW,CAAC;AAE/C,eAAO,MAAM,UAAU;;;;;;;;;;;CAWkB,CAAC"}
|
package/dist/users.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { apiSuccessSchema } from "./common";
|
|
3
|
+
export const goalSchema = z.enum(["lose", "maintain", "gain"]);
|
|
4
|
+
export const sexSchema = z.enum(["male", "female"]);
|
|
5
|
+
export const tierSchema = z.enum(["free", "premium"]);
|
|
6
|
+
export const userProfileSchema = z.object({
|
|
7
|
+
id: z.string().uuid(),
|
|
8
|
+
email: z.string().email(),
|
|
9
|
+
name: z.string(),
|
|
10
|
+
goal: goalSchema.nullable(),
|
|
11
|
+
sex: sexSchema.nullable(),
|
|
12
|
+
age: z.number().int().nullable(),
|
|
13
|
+
heightCm: z.string().nullable(),
|
|
14
|
+
weightKg: z.string().nullable(),
|
|
15
|
+
targetWeightKg: z.string().nullable(),
|
|
16
|
+
tdeeKcal: z.number().int().nullable(),
|
|
17
|
+
dailyTargetKcal: z.number().int().nullable(),
|
|
18
|
+
targetProteinG: z.number().int().nullable(),
|
|
19
|
+
targetCarbsG: z.number().int().nullable(),
|
|
20
|
+
targetFatG: z.number().int().nullable(),
|
|
21
|
+
notifyAt: z.string().nullable(),
|
|
22
|
+
timezone: z.string().nullable(),
|
|
23
|
+
tier: tierSchema,
|
|
24
|
+
onboardingStep: z.number().int(),
|
|
25
|
+
createdAt: z.coerce.date(),
|
|
26
|
+
});
|
|
27
|
+
export const getMeResponseSchema = apiSuccessSchema(userProfileSchema);
|
|
28
|
+
export const deleteMeResponseSchema = z.null();
|
|
29
|
+
export const userRoutes = {
|
|
30
|
+
getMe: {
|
|
31
|
+
method: "GET",
|
|
32
|
+
path: "/api/v1/users/me",
|
|
33
|
+
auth: "user",
|
|
34
|
+
},
|
|
35
|
+
deleteMe: {
|
|
36
|
+
method: "DELETE",
|
|
37
|
+
path: "/api/v1/users/me",
|
|
38
|
+
auth: "user",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=users.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../src/users.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AAEhE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IACrB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;IAC3B,GAAG,EAAE,SAAS,CAAC,QAAQ,EAAE;IACzB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACrC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC5C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC3C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACzC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,IAAI,EAAE,UAAU;IAChB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE;CAC3B,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;AAIvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,MAAM;KACb;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,MAAM;KACb;CACsC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beorchid-llc/thrivo-contracts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared Thrivo API request and response contracts.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./common": {
|
|
16
|
+
"types": "./dist/common.d.ts",
|
|
17
|
+
"import": "./dist/common.js"
|
|
18
|
+
},
|
|
19
|
+
"./users": {
|
|
20
|
+
"types": "./dist/users.d.ts",
|
|
21
|
+
"import": "./dist/users.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"license": "UNLICENSED",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"zod": "^3.24.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"zod": "^3.24.0",
|
|
39
|
+
"typescript": "^5.6.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.json",
|
|
43
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
44
|
+
"pack:dry": "npm pack --dry-run"
|
|
45
|
+
}
|
|
46
|
+
}
|