@twreporter-academy/api-types 0.0.6 → 0.0.7
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/schemas/member.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const V1MemberMeQuerySchema: z.ZodObject<{
|
|
3
|
+
refreshAccess: z.ZodOptional<z.ZodPreprocess<z.ZodBoolean>>;
|
|
4
|
+
}, z.core.$strip>;
|
|
2
5
|
export declare const V1MemberProfileSchema: z.ZodObject<{
|
|
3
6
|
id: z.ZodString;
|
|
4
7
|
email: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../../src/schemas/member.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,qBAAqB;;;;;;;iBASP,CAAA;AAE3B,eAAO,MAAM,6BAA6B;;;;;;;iBAAwB,CAAA;AAElE,eAAO,MAAM,2BAA2B;;;;iBAMP,CAAA"}
|
|
1
|
+
{"version":3,"file":"member.d.ts","sourceRoot":"","sources":["../../src/schemas/member.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,qBAAqB;;iBAYP,CAAA;AAE3B,eAAO,MAAM,qBAAqB;;;;;;;iBASP,CAAA;AAE3B,eAAO,MAAM,6BAA6B;;;;;;;iBAAwB,CAAA;AAElE,eAAO,MAAM,2BAA2B;;;;iBAMP,CAAA"}
|
package/dist/schemas/member.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { RestErrorBodySchema } from '../rest.js';
|
|
3
3
|
import { registry } from './registry.js';
|
|
4
|
+
export const V1MemberMeQuerySchema = z.object({
|
|
5
|
+
refreshAccess: z.preprocess(v => {
|
|
6
|
+
if (v === undefined) return undefined;
|
|
7
|
+
if (Array.isArray(v)) return v[0];
|
|
8
|
+
if (v === true || v === 'true' || v === '1') return true;
|
|
9
|
+
if (v === false || v === 'false' || v === '0') return false;
|
|
10
|
+
return v;
|
|
11
|
+
}, z.boolean()).optional()
|
|
12
|
+
}).openapi('MemberMeQuery');
|
|
4
13
|
export const V1MemberProfileSchema = z.object({
|
|
5
14
|
id: z.string(),
|
|
6
15
|
email: z.string(),
|
|
@@ -76,7 +85,10 @@ registry.registerPath({
|
|
|
76
85
|
method: 'get',
|
|
77
86
|
path: '/v1/members/me',
|
|
78
87
|
tags: ['Members'],
|
|
79
|
-
description: 'Get the authenticated member profile.',
|
|
88
|
+
description: 'Get the authenticated member profile. Set refreshAccess=true to bypass the MemberAccess cache and re-fetch roles from go-api.',
|
|
89
|
+
request: {
|
|
90
|
+
query: V1MemberMeQuerySchema
|
|
91
|
+
},
|
|
80
92
|
responses: {
|
|
81
93
|
200: {
|
|
82
94
|
description: 'Success',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.js","names":["z","RestErrorBodySchema","registry","
|
|
1
|
+
{"version":3,"file":"member.js","names":["z","RestErrorBodySchema","registry","V1MemberMeQuerySchema","object","refreshAccess","preprocess","v","undefined","Array","isArray","boolean","optional","openapi","V1MemberProfileSchema","id","string","email","name","twreporterUserId","hasAccess","createdAt","iso","datetime","nullable","V1MemberProfileResponseSchema","V1AccessTokenResponseSchema","accessToken","expiresAt","number","unauthorizedResponse","description","content","schema","internalServerErrorResponse","registerPath","method","path","tags","responses","request","query"],"sources":["../../src/schemas/member.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { RestErrorBodySchema } from '../rest.js'\nimport { registry } from './registry.js'\n\nexport const V1MemberMeQuerySchema = z\n .object({\n refreshAccess: z\n .preprocess((v) => {\n if (v === undefined) return undefined\n if (Array.isArray(v)) return v[0]\n if (v === true || v === 'true' || v === '1') return true\n if (v === false || v === 'false' || v === '0') return false\n return v\n }, z.boolean())\n .optional(),\n })\n .openapi('MemberMeQuery')\n\nexport const V1MemberProfileSchema = z\n .object({\n id: z.string(),\n email: z.string(),\n name: z.string(),\n twreporterUserId: z.string(),\n hasAccess: z.boolean(),\n createdAt: z.iso.datetime().nullable().optional(),\n })\n .openapi('MemberProfile')\n\nexport const V1MemberProfileResponseSchema = V1MemberProfileSchema\n\nexport const V1AccessTokenResponseSchema = z\n .object({\n accessToken: z.string(),\n twreporterUserId: z.string(),\n expiresAt: z.number(),\n })\n .openapi('AccessTokenResponse')\n\n// --- OpenAPI path registration ---\n\nconst unauthorizedResponse = {\n 401: {\n description: 'Unauthorized — missing or invalid JWT',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n} as const\n\nconst internalServerErrorResponse = {\n 500: {\n description: 'Internal server error',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n} as const\n\nregistry.registerPath({\n method: 'post',\n path: '/auth/access-token',\n tags: ['Auth'],\n description:\n 'Exchange id_token cookie for a JWT access token. Creates the member on first login.',\n responses: {\n 200: {\n description: 'Success',\n content: {\n 'application/json': { schema: V1AccessTokenResponseSchema },\n },\n },\n 400: {\n description: 'Bad request — missing id_token cookie',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n 403: {\n description: 'Forbidden — missing, invalid, or disallowed Origin',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n ...unauthorizedResponse,\n ...internalServerErrorResponse,\n },\n})\n\nregistry.registerPath({\n method: 'get',\n path: '/v1/members/me',\n tags: ['Members'],\n description:\n 'Get the authenticated member profile. Set refreshAccess=true to bypass the MemberAccess cache and re-fetch roles from go-api.',\n request: {\n query: V1MemberMeQuerySchema,\n },\n responses: {\n 200: {\n description: 'Success',\n content: {\n 'application/json': { schema: V1MemberProfileResponseSchema },\n },\n },\n 404: {\n description: 'Member not found',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n ...unauthorizedResponse,\n ...internalServerErrorResponse,\n },\n})\n"],"mappings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