Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-09-20 21:38:22 +08:00
parent 185ea0fd7b
commit 3bf9d9ea22
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
4 changed files with 278 additions and 63 deletions

View File

@ -5,6 +5,7 @@ import { useFeatureFlagEnabled } from "posthog-js/react"
import { jotaiStore } from "~/lib/jotai"
import type { FeatureKeys } from "~/modules/ab/atoms"
import { debugFeaturesAtom, enableDebugOverrideAtom, IS_DEBUG_ENV } from "~/modules/ab/atoms"
import { abPayloadFallback } from "~/modules/ab/fallback"
export const useAb = (feature: FeatureKeys) => {
const isEnableDebugOverrides = useAtomValue(enableDebugOverrideAtom)
@ -32,5 +33,5 @@ export const isAbEnabled = (feature: FeatureKeys) => {
}
export const getAbValue = (feature: FeatureKeys) => {
return PostHog.getFeatureFlagPayload(feature)
return PostHog.getFeatureFlagPayload(feature) || abPayloadFallback[feature]
}

View File

@ -11,10 +11,11 @@ export const getImageProxyUrl = ({
width: number
height: number
}) => {
const abValue = getAbValue("Image_Proxy_V2")
if (isAbEnabled("Image_Proxy_V2")) {
return `${getAbValue("Image_Proxy_V2")}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
return `${abValue}?url=${encodeURIComponent(url)}&width=${width}&height=${height}`
} else {
return `${getAbValue("Image_Proxy_V2")}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
return `${abValue}/unsafe/fit-in/${width}x${height}/${encodeURIComponent(url)}`
}
}

View File

@ -0,0 +1,5 @@
import type { FeatureKeys } from "./atoms"
export const abPayloadFallback: Record<FeatureKeys, string> = {
Image_Proxy_V2: "https://thumbor.follow.is",
}

View File

@ -1,15 +1,179 @@
import * as hono_hono_base from 'hono/hono-base';
import { HttpBindings } from '@hono/node-server';
import * as drizzle_orm from 'drizzle-orm';
import { InferInsertModel } from 'drizzle-orm';
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
import * as zod from 'zod';
import { z } from 'zod';
import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
import * as drizzle_orm from 'drizzle-orm';
import { InferInsertModel } from 'drizzle-orm';
type Env = {
Bindings: HttpBindings;
};
declare const achievements: drizzle_orm_pg_core.PgTableWithColumns<{
name: "achievements";
schema: undefined;
columns: {
id: drizzle_orm_pg_core.PgColumn<{
name: "id";
tableName: "achievements";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: true;
isPrimaryKey: true;
isAutoincrement: false;
hasRuntimeDefault: true;
enumValues: [string, ...string[]];
baseColumn: never;
generated: undefined;
}, {}, {}>;
userId: drizzle_orm_pg_core.PgColumn<{
name: "user_id";
tableName: "achievements";
dataType: "string";
columnType: "PgText";
data: string;
driverParam: string;
notNull: true;
hasDefault: false;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: [string, ...string[]];
baseColumn: never;
generated: undefined;
}, {}, {}>;
type: drizzle_orm_pg_core.PgColumn<{
name: "type";
tableName: "achievements";
dataType: "string";
columnType: "PgText";
data: "received" | "checking" | "completed" | "incomplete";
driverParam: string;
notNull: true;
hasDefault: false;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: ["checking", "completed", "incomplete", "received"];
baseColumn: never;
generated: undefined;
}, {}, {}>;
actionId: drizzle_orm_pg_core.PgColumn<{
name: "action_id";
tableName: "achievements";
dataType: "number";
columnType: "PgInteger";
data: number;
driverParam: string | number;
notNull: true;
hasDefault: false;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: undefined;
baseColumn: never;
generated: undefined;
}, {}, {}>;
progress: drizzle_orm_pg_core.PgColumn<{
name: "progress";
tableName: "achievements";
dataType: "number";
columnType: "PgInteger";
data: number;
driverParam: string | number;
notNull: true;
hasDefault: true;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: undefined;
baseColumn: never;
generated: undefined;
}, {}, {}>;
progressMax: drizzle_orm_pg_core.PgColumn<{
name: "progress_max";
tableName: "achievements";
dataType: "number";
columnType: "PgInteger";
data: number;
driverParam: string | number;
notNull: true;
hasDefault: true;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: undefined;
baseColumn: never;
generated: undefined;
}, {}, {}>;
done: drizzle_orm_pg_core.PgColumn<{
name: "done";
tableName: "achievements";
dataType: "boolean";
columnType: "PgBoolean";
data: boolean;
driverParam: boolean;
notNull: true;
hasDefault: true;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: undefined;
baseColumn: never;
generated: undefined;
}, {}, {}>;
doneAt: drizzle_orm_pg_core.PgColumn<{
name: "done_at";
tableName: "achievements";
dataType: "date";
columnType: "PgTimestamp";
data: Date;
driverParam: string;
notNull: false;
hasDefault: false;
isPrimaryKey: false;
isAutoincrement: false;
hasRuntimeDefault: false;
enumValues: undefined;
baseColumn: never;
generated: undefined;
}, {}, {}>;
};
dialect: "pg";
}>;
declare const achievementsOpenAPISchema: zod.ZodObject<{
id: zod.ZodString;
userId: zod.ZodString;
type: zod.ZodEnum<["checking", "completed", "incomplete", "received"]>;
actionId: zod.ZodNumber;
progress: zod.ZodNumber;
progressMax: zod.ZodNumber;
done: zod.ZodBoolean;
doneAt: zod.ZodNullable<zod.ZodString>;
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
type: "received" | "checking" | "completed" | "incomplete";
id: string;
userId: string;
actionId: number;
progress: number;
progressMax: number;
done: boolean;
doneAt: string | null;
}, {
type: "received" | "checking" | "completed" | "incomplete";
id: string;
userId: string;
actionId: number;
progress: number;
progressMax: number;
done: boolean;
doneAt: string | null;
}>;
declare const languageSchema: z.ZodEnum<["en", "ja", "zh-CN", "zh-TW"]>;
declare const conditionFieldSchema: z.ZodEnum<["view", "title", "site_url", "feed_url", "category"]>;
declare const conditionOperatorSchema: z.ZodEnum<["contains", "not_contains", "eq", "not_eq", "gt", "lt", "regex"]>;
@ -110,11 +274,11 @@ declare const actionsItemOpenAPISchema: z.ZodObject<{
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}, {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}>, "many">>;
}, "strip", z.ZodTypeAny, {
@ -127,7 +291,7 @@ declare const actionsItemOpenAPISchema: z.ZodObject<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
}, {
@ -140,17 +304,12 @@ declare const actionsItemOpenAPISchema: z.ZodObject<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
}>;
}, "strip", z.ZodTypeAny, {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -161,17 +320,17 @@ declare const actionsItemOpenAPISchema: z.ZodObject<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}, {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -182,10 +341,15 @@ declare const actionsItemOpenAPISchema: z.ZodObject<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}>;
declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
userId: z.ZodString;
@ -230,11 +394,11 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}, {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}>, "many">>;
}, "strip", z.ZodTypeAny, {
@ -247,7 +411,7 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
}, {
@ -260,17 +424,12 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
}>;
}, "strip", z.ZodTypeAny, {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -281,17 +440,17 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}, {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -302,20 +461,20 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}>, "many">>>;
}>, "strip", z.ZodTypeAny, {
userId: string;
rules?: {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -326,20 +485,20 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}[] | null | undefined;
}, {
userId: string;
rules?: {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -350,10 +509,15 @@ declare const actionsOpenAPISchema: z.ZodObject<z.objectUtil.extendShape<Omit<{
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}[] | null | undefined;
}>;
declare const actionsRelations: drizzle_orm.Relations<"actions", {
@ -3736,11 +3900,6 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
userId: string;
rules?: {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -3751,10 +3910,15 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}[] | null | undefined;
} | undefined;
};
@ -3766,11 +3930,6 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
json: {
rules?: {
name: string;
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
result: {
summary?: boolean | undefined;
translation?: "en" | "ja" | "zh-CN" | "zh-TW" | undefined;
@ -3781,10 +3940,15 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
}[] | undefined;
blockRules?: {
value: string | number;
field: "title" | "content" | "all" | "author" | "url" | "order";
field: "title" | "all" | "content" | "author" | "url" | "order";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[] | undefined;
};
condition: {
value: string;
field: "title" | "view" | "site_url" | "feed_url" | "category";
operator: "contains" | "not_contains" | "eq" | "not_eq" | "gt" | "lt" | "regex";
}[];
}[] | null | undefined;
};
};
@ -3795,7 +3959,51 @@ declare const _routes: hono_hono_base.HonoBase<Env, {
status: 200;
};
};
} & {
"/achievement": {
$get: {
input: {
query: {
type?: string | string[] | undefined;
};
};
output: {
code: number;
data: {
type: "received" | "checking" | "completed" | "incomplete";
id: string;
userId: string;
actionId: number;
progress: number;
progressMax: number;
done: boolean;
doneAt: string | null;
power: string;
}[];
done: number;
total: number;
};
outputFormat: "json" | "text";
status: 200;
};
$put: {
input: {
json: {
actionId: number;
};
};
output: {
code: number;
data: {
actionId: number;
result: boolean;
};
};
outputFormat: "json" | "text";
status: 200;
};
};
}, "/">;
type AppType = typeof _routes;
export { type ActionsModel, type AppType, type AttachmentsModel, type EntriesModel, type EntryReadHistoriesModel, type FeedModel, type MediaModel, type SettingsModel, accounts, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, collections, collectionsOpenAPISchema, collectionsRelations, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsInputSchema, feedsOpenAPISchema, feedsRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, sessions, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, users, usersOpenApiSchema, usersRelations, verificationTokens, wallets, walletsOpenAPISchema, walletsRelations };
export { type ActionsModel, type AppType, type AttachmentsModel, type EntriesModel, type EntryReadHistoriesModel, type FeedModel, type MediaModel, type SettingsModel, accounts, achievements, achievementsOpenAPISchema, actions, actionsItemOpenAPISchema, actionsOpenAPISchema, actionsRelations, collections, collectionsOpenAPISchema, collectionsRelations, entries, entriesOpenAPISchema, entriesRelations, entryReadHistories, entryReadHistoriesOpenAPISchema, entryReadHistoriesRelations, feedPowerTokens, feedPowerTokensOpenAPISchema, feedPowerTokensRelations, feeds, feedsInputSchema, feedsOpenAPISchema, feedsRelations, invitations, invitationsOpenAPISchema, invitationsRelations, languageSchema, sessions, settings, subscriptions, subscriptionsOpenAPISchema, subscriptionsRelations, timeline, timelineOpenAPISchema, timelineRelations, transactionType, transactions, transactionsOpenAPISchema, transactionsRelations, users, usersOpenApiSchema, usersRelations, verificationTokens, wallets, walletsOpenAPISchema, walletsRelations };