@twreporter-academy/api-types 0.0.11 → 0.0.12
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
|
@@ -8,6 +8,8 @@ export declare const V1MemberProfileSchema: z.ZodObject<{
|
|
|
8
8
|
name: z.ZodString;
|
|
9
9
|
twreporterUserId: z.ZodString;
|
|
10
10
|
hasAccess: z.ZodBoolean;
|
|
11
|
+
role: z.ZodNullable<z.ZodString>;
|
|
12
|
+
expiredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
11
13
|
createdAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
12
14
|
}, z.core.$strip>;
|
|
13
15
|
export declare const V1MemberProfileResponseSchema: z.ZodObject<{
|
|
@@ -16,6 +18,8 @@ export declare const V1MemberProfileResponseSchema: z.ZodObject<{
|
|
|
16
18
|
name: z.ZodString;
|
|
17
19
|
twreporterUserId: z.ZodString;
|
|
18
20
|
hasAccess: z.ZodBoolean;
|
|
21
|
+
role: z.ZodNullable<z.ZodString>;
|
|
22
|
+
expiredAt: z.ZodNullable<z.ZodISODateTime>;
|
|
19
23
|
createdAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
|
|
20
24
|
}, z.core.$strip>;
|
|
21
25
|
export declare const V1AccessTokenResponseSchema: z.ZodObject<{
|
|
@@ -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;;iBAYP,CAAA;AAE3B,eAAO,MAAM,qBAAqB
|
|
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;;;;;;;;;iBAWP,CAAA;AAE3B,eAAO,MAAM,6BAA6B;;;;;;;;;iBAAwB,CAAA;AAElE,eAAO,MAAM,2BAA2B;;;;iBAMP,CAAA;AAEjC,eAAO,MAAM,6BAA6B;;iBAIP,CAAA;AAEnC,eAAO,MAAM,gCAAgC;;;;EAI3C,CAAA;AAEF,eAAO,MAAM,iCAAiC;;;;;;;iBAKP,CAAA"}
|
package/dist/schemas/member.js
CHANGED
|
@@ -16,6 +16,8 @@ export const V1MemberProfileSchema = z.object({
|
|
|
16
16
|
name: z.string(),
|
|
17
17
|
twreporterUserId: z.string(),
|
|
18
18
|
hasAccess: z.boolean(),
|
|
19
|
+
role: z.string().nullable(),
|
|
20
|
+
expiredAt: z.iso.datetime().nullable(),
|
|
19
21
|
createdAt: z.iso.datetime().nullable().optional()
|
|
20
22
|
}).openapi('MemberProfile');
|
|
21
23
|
export const V1MemberProfileResponseSchema = V1MemberProfileSchema;
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
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","role","nullable","expiredAt","iso","datetime","createdAt","V1MemberProfileResponseSchema","V1AccessTokenResponseSchema","accessToken","expiresAt","number","V1RevokeMemberCacheBodySchema","V1RevokeMemberCacheOutcomeSchema","enum","V1RevokeMemberCacheResponseSchema","ok","literal","outcome","unauthorizedResponse","description","content","schema","internalServerErrorResponse","registerPath","method","path","tags","responses","request","query","body"],"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 role: z.string().nullable(),\n expiredAt: z.iso.datetime().nullable(),\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\nexport const V1RevokeMemberCacheBodySchema = z\n .object({\n email: z.email(),\n })\n .openapi('RevokeMemberCacheBody')\n\nexport const V1RevokeMemberCacheOutcomeSchema = z.enum([\n 'revoked',\n 'not_found',\n 'manual_grant',\n])\n\nexport const V1RevokeMemberCacheResponseSchema = z\n .object({\n ok: z.literal(true),\n outcome: V1RevokeMemberCacheOutcomeSchema,\n })\n .openapi('RevokeMemberCacheResponse')\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\nregistry.registerPath({\n method: 'post',\n path: '/v1/admin/members/revoke-cache',\n tags: ['Admin'],\n description:\n 'Invalidate MemberAccess cache for a member by email (clear checkedAt). Requires a Google OIDC ID token from an allowlisted caller. Terminal outcomes (revoked, not_found, manual_grant) always return 200 so Pub/Sub push can acknowledge delivery.',\n request: {\n body: {\n content: {\n 'application/json': { schema: V1RevokeMemberCacheBodySchema },\n },\n },\n },\n responses: {\n 200: {\n description:\n 'Request processed. outcome is revoked, not_found, or manual_grant.',\n content: {\n 'application/json': { schema: V1RevokeMemberCacheResponseSchema },\n },\n },\n 400: {\n description: 'Invalid request body',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n 401: {\n description: 'Unauthorized — missing or invalid GCP IAM token',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n 403: {\n description: 'Forbidden — valid token but caller not allowlisted',\n content: { 'application/json': { schema: RestErrorBodySchema } },\n },\n ...internalServerErrorResponse,\n },\n})\n"],"mappings":"AAAA,SAASA,CAAC,QAAQ,KAAK;AAEvB,SAASC,mBAAmB,QAAQ,YAAY;AAChD,SAASC,QAAQ,QAAQ,eAAe;AAExC,OAAO,MAAMC,qBAAqB,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