@cravery/core 0.0.11 → 0.0.13
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 +80 -80
- package/dist/lib/ai/cost.d.ts.map +1 -1
- package/dist/lib/ai/cost.js +2 -1
- package/dist/lib/ai/cost.js.map +1 -1
- package/dist/lib/ai/flow.d.ts.map +1 -1
- package/dist/lib/ai/flow.js.map +1 -1
- package/dist/lib/api.d.ts +4 -2
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +17 -7
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/firebase.d.ts +1 -1
- package/dist/lib/firebase.d.ts.map +1 -1
- package/dist/lib/iam.d.ts +3 -0
- package/dist/lib/iam.d.ts.map +1 -1
- package/dist/lib/iam.js +17 -2
- package/dist/lib/iam.js.map +1 -1
- package/dist/lib/usage/usage.service.d.ts.map +1 -1
- package/dist/lib/usage/usage.service.js.map +1 -1
- package/dist/types/core/asset.d.ts +4 -5
- package/dist/types/core/asset.d.ts.map +1 -1
- package/dist/types/core/settings.d.ts +4 -5
- package/dist/types/core/settings.d.ts.map +1 -1
- package/dist/types/core/settings.js.map +1 -1
- package/dist/types/iam/enums/subscription_role.d.ts.map +1 -1
- package/dist/types/iam/enums/subscription_role.js +1 -4
- package/dist/types/iam/enums/subscription_role.js.map +1 -1
- package/dist/types/iam/profile.d.ts +4 -8
- package/dist/types/iam/profile.d.ts.map +1 -1
- package/dist/types/iam/profile.js +0 -1
- package/dist/types/iam/profile.js.map +1 -1
- package/dist/types/iam/subscription.d.ts +40 -35
- package/dist/types/iam/subscription.d.ts.map +1 -1
- package/dist/types/iam/subscription.js.map +1 -1
- package/dist/types/iam/user.d.ts +22 -21
- package/dist/types/iam/user.d.ts.map +1 -1
- package/dist/types/iam/user.js.map +1 -1
- package/dist/types/moderation/moderation.d.ts +28 -37
- package/dist/types/moderation/moderation.d.ts.map +1 -1
- package/dist/types/recipe/recipe.d.ts +104 -225
- package/dist/types/recipe/recipe.d.ts.map +1 -1
- package/dist/types/report/report.d.ts +38 -47
- package/dist/types/report/report.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/lib/ai/cost.ts +82 -81
- package/src/lib/ai/flow.ts +1 -0
- package/src/lib/api.ts +23 -10
- package/src/lib/iam.ts +15 -0
- package/src/lib/usage/usage.service.ts +5 -1
- package/src/types/ai/recipe.ts +1 -1
- package/src/types/ai/translation.ts +1 -1
- package/src/types/core/settings.ts +7 -1
- package/src/types/iam/enums/subscription_role.ts +1 -4
- package/src/types/iam/profile.ts +0 -1
- package/src/types/iam/subscription.ts +5 -1
- package/src/types/iam/user.ts +1 -4
- package/src/types/report/enums/index.ts +4 -4
- package/src/types/report/enums/report_priority.ts +10 -10
- package/src/types/report/enums/report_status.ts +10 -10
- package/src/types/report/enums/report_target_type.ts +10 -10
- package/src/types/report/enums/report_type.ts +12 -12
- package/src/types/report/index.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"recipe.d.ts","sourceRoot":"","sources":["../../../src/types/recipe/recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AA8B3B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwB3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAElD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAQ5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
|
-
import type { Timestamp } from "firebase-admin/firestore";
|
|
3
2
|
export declare const ReportEvidenceSchema: z.ZodObject<{
|
|
4
3
|
aiScore: z.ZodOptional<z.ZodNumber>;
|
|
5
4
|
aiSuggestions: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
|
|
@@ -52,53 +51,45 @@ export declare const ReportSchema: z.ZodObject<{
|
|
|
52
51
|
updatedAt: z.ZodType<Timestamp, z.ZodTypeDef, Timestamp>;
|
|
53
52
|
userId: z.ZodString;
|
|
54
53
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
createdAt
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
priority
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
imageHashes?: string[] | undefined;
|
|
75
|
-
} | undefined;
|
|
76
|
-
reportedBy?: string | undefined;
|
|
77
|
-
resolution?: string | undefined;
|
|
54
|
+
[x: string]: any;
|
|
55
|
+
categories?: unknown;
|
|
56
|
+
createdAt?: unknown;
|
|
57
|
+
description?: unknown;
|
|
58
|
+
evidence?: unknown;
|
|
59
|
+
id?: unknown;
|
|
60
|
+
notes?: unknown;
|
|
61
|
+
priority?: unknown;
|
|
62
|
+
reason?: unknown;
|
|
63
|
+
reportedBy?: unknown;
|
|
64
|
+
resolution?: unknown;
|
|
65
|
+
reviewedAt?: unknown;
|
|
66
|
+
reviewedBy?: unknown;
|
|
67
|
+
status?: unknown;
|
|
68
|
+
targetId?: unknown;
|
|
69
|
+
targetType?: unknown;
|
|
70
|
+
type?: unknown;
|
|
71
|
+
updatedAt?: unknown;
|
|
72
|
+
userId?: unknown;
|
|
78
73
|
}, {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
createdAt
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
priority
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
imageHashes?: string[] | undefined;
|
|
99
|
-
} | undefined;
|
|
100
|
-
reportedBy?: string | undefined;
|
|
101
|
-
resolution?: string | undefined;
|
|
74
|
+
[x: string]: any;
|
|
75
|
+
categories?: unknown;
|
|
76
|
+
createdAt?: unknown;
|
|
77
|
+
description?: unknown;
|
|
78
|
+
evidence?: unknown;
|
|
79
|
+
id?: unknown;
|
|
80
|
+
notes?: unknown;
|
|
81
|
+
priority?: unknown;
|
|
82
|
+
reason?: unknown;
|
|
83
|
+
reportedBy?: unknown;
|
|
84
|
+
resolution?: unknown;
|
|
85
|
+
reviewedAt?: unknown;
|
|
86
|
+
reviewedBy?: unknown;
|
|
87
|
+
status?: unknown;
|
|
88
|
+
targetId?: unknown;
|
|
89
|
+
targetType?: unknown;
|
|
90
|
+
type?: unknown;
|
|
91
|
+
updatedAt?: unknown;
|
|
92
|
+
userId?: unknown;
|
|
102
93
|
}>;
|
|
103
94
|
export type Report = z.infer<typeof ReportSchema>;
|
|
104
95
|
//# sourceMappingURL=report.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/types/report/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/types/report/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAS3B,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAK/B,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/lib/ai/cost.ts
CHANGED
|
@@ -1,81 +1,82 @@
|
|
|
1
|
-
import { getDatabase, ServerValue } from "firebase-admin/database";
|
|
2
|
-
import { AIModelConfig } from "../../types";
|
|
3
|
-
|
|
4
|
-
interface BaseUsage {
|
|
5
|
-
flowName: string;
|
|
6
|
-
model: AIModelConfig;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface MultimodalUsage extends BaseUsage {
|
|
10
|
-
type: "multimodal";
|
|
11
|
-
inputTokens: number;
|
|
12
|
-
outputTokens: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface ImageUsage extends BaseUsage {
|
|
16
|
-
type: "image";
|
|
17
|
-
imageCount: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface EmbeddingUsage extends BaseUsage {
|
|
21
|
-
type: "embedding";
|
|
22
|
-
tokenCount: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type AIUsage = MultimodalUsage | ImageUsage | EmbeddingUsage;
|
|
26
|
-
|
|
27
|
-
export const logAIUsage = (usage: AIUsage): number => {
|
|
28
|
-
const { flowName, model } = usage;
|
|
29
|
-
|
|
30
|
-
let cost: number;
|
|
31
|
-
let metrics: Record<string, number>;
|
|
32
|
-
|
|
33
|
-
switch (usage.type) {
|
|
34
|
-
case "multimodal":
|
|
35
|
-
cost =
|
|
36
|
-
(usage.inputTokens / 1_000_000) * model.cost.input +
|
|
37
|
-
(usage.outputTokens / 1_000_000) * model.cost.output;
|
|
38
|
-
metrics = {
|
|
39
|
-
inputTokens: usage.inputTokens,
|
|
40
|
-
outputTokens: usage.outputTokens,
|
|
41
|
-
};
|
|
42
|
-
break;
|
|
43
|
-
case "image":
|
|
44
|
-
cost = usage.imageCount * model.cost.output;
|
|
45
|
-
metrics = { images: usage.imageCount };
|
|
46
|
-
break;
|
|
47
|
-
case "embedding":
|
|
48
|
-
cost = (usage.tokenCount / 1_000) * model.cost.input;
|
|
49
|
-
metrics = { tokens: usage.tokenCount };
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const db = getDatabase();
|
|
54
|
-
const date = new Date().toISOString().split("T")[0];
|
|
55
|
-
const base = `ai_usage/live/${date}`;
|
|
56
|
-
|
|
57
|
-
const updates: Record<string, unknown> = {
|
|
58
|
-
[`${base}/total`]: ServerValue.increment(cost),
|
|
59
|
-
[`${base}/count`]: ServerValue.increment(1),
|
|
60
|
-
[`${base}/flows/${flowName}/cost`]: ServerValue.increment(cost),
|
|
61
|
-
[`${base}/flows/${flowName}/count`]: ServerValue.increment(1),
|
|
62
|
-
[`${base}/models/${model.alias}/cost`]: ServerValue.increment(cost),
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
for (const [key, value] of Object.entries(metrics)) {
|
|
66
|
-
updates[`${base}/models/${model.alias}/${key}`] =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import { getDatabase, ServerValue } from "firebase-admin/database";
|
|
2
|
+
import { AIModelConfig } from "../../types";
|
|
3
|
+
|
|
4
|
+
interface BaseUsage {
|
|
5
|
+
flowName: string;
|
|
6
|
+
model: AIModelConfig;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface MultimodalUsage extends BaseUsage {
|
|
10
|
+
type: "multimodal";
|
|
11
|
+
inputTokens: number;
|
|
12
|
+
outputTokens: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ImageUsage extends BaseUsage {
|
|
16
|
+
type: "image";
|
|
17
|
+
imageCount: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface EmbeddingUsage extends BaseUsage {
|
|
21
|
+
type: "embedding";
|
|
22
|
+
tokenCount: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type AIUsage = MultimodalUsage | ImageUsage | EmbeddingUsage;
|
|
26
|
+
|
|
27
|
+
export const logAIUsage = (usage: AIUsage): number => {
|
|
28
|
+
const { flowName, model } = usage;
|
|
29
|
+
|
|
30
|
+
let cost: number;
|
|
31
|
+
let metrics: Record<string, number>;
|
|
32
|
+
|
|
33
|
+
switch (usage.type) {
|
|
34
|
+
case "multimodal":
|
|
35
|
+
cost =
|
|
36
|
+
(usage.inputTokens / 1_000_000) * model.cost.input +
|
|
37
|
+
(usage.outputTokens / 1_000_000) * model.cost.output;
|
|
38
|
+
metrics = {
|
|
39
|
+
inputTokens: usage.inputTokens,
|
|
40
|
+
outputTokens: usage.outputTokens,
|
|
41
|
+
};
|
|
42
|
+
break;
|
|
43
|
+
case "image":
|
|
44
|
+
cost = usage.imageCount * model.cost.output;
|
|
45
|
+
metrics = { images: usage.imageCount };
|
|
46
|
+
break;
|
|
47
|
+
case "embedding":
|
|
48
|
+
cost = (usage.tokenCount / 1_000) * model.cost.input;
|
|
49
|
+
metrics = { tokens: usage.tokenCount };
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const db = getDatabase();
|
|
54
|
+
const date = new Date().toISOString().split("T")[0];
|
|
55
|
+
const base = `ai_usage/live/${date}`;
|
|
56
|
+
|
|
57
|
+
const updates: Record<string, unknown> = {
|
|
58
|
+
[`${base}/total`]: ServerValue.increment(cost),
|
|
59
|
+
[`${base}/count`]: ServerValue.increment(1),
|
|
60
|
+
[`${base}/flows/${flowName}/cost`]: ServerValue.increment(cost),
|
|
61
|
+
[`${base}/flows/${flowName}/count`]: ServerValue.increment(1),
|
|
62
|
+
[`${base}/models/${model.alias}/cost`]: ServerValue.increment(cost),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
for (const [key, value] of Object.entries(metrics)) {
|
|
66
|
+
updates[`${base}/models/${model.alias}/${key}`] =
|
|
67
|
+
ServerValue.increment(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
db.ref()
|
|
71
|
+
.update(updates)
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
console.error("[AI Usage] Failed to log usage:", {
|
|
74
|
+
flowName,
|
|
75
|
+
model: model.id,
|
|
76
|
+
cost,
|
|
77
|
+
error: error instanceof Error ? error.message : String(error),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return cost;
|
|
82
|
+
};
|
package/src/lib/ai/flow.ts
CHANGED
package/src/lib/api.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
CallableOptions,
|
|
6
6
|
} from "firebase-functions/v2/https";
|
|
7
7
|
import { z } from "genkit";
|
|
8
|
-
import { isAdmin,
|
|
8
|
+
import { isAdmin, isModeratorOrAbove, isTranslatorOrAbove } from "./iam";
|
|
9
9
|
|
|
10
10
|
const DEFAULT_OPTIONS: CallableOptions = { cors: true, enforceAppCheck: true };
|
|
11
11
|
|
|
@@ -29,12 +29,14 @@ class CallableBuilder<T> {
|
|
|
29
29
|
private requiresAuth = false;
|
|
30
30
|
private requiresAdmin = false;
|
|
31
31
|
private requiresModerator = false;
|
|
32
|
+
private requiresTranslator = false;
|
|
32
33
|
private options: CallableOptions = DEFAULT_OPTIONS;
|
|
33
34
|
|
|
34
35
|
constructor(private schema: z.ZodSchema<T>) {}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
this.
|
|
37
|
+
requireAdmin() {
|
|
38
|
+
this.requiresAuth = true;
|
|
39
|
+
this.requiresAdmin = true;
|
|
38
40
|
return this;
|
|
39
41
|
}
|
|
40
42
|
|
|
@@ -43,15 +45,20 @@ class CallableBuilder<T> {
|
|
|
43
45
|
return this;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
requireModerator() {
|
|
47
49
|
this.requiresAuth = true;
|
|
48
|
-
this.
|
|
50
|
+
this.requiresModerator = true;
|
|
49
51
|
return this;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
requireTranslator() {
|
|
53
55
|
this.requiresAuth = true;
|
|
54
|
-
this.
|
|
56
|
+
this.requiresTranslator = true;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
withOptions(options: CallableOptions) {
|
|
61
|
+
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
55
62
|
return this;
|
|
56
63
|
}
|
|
57
64
|
|
|
@@ -66,13 +73,19 @@ class CallableBuilder<T> {
|
|
|
66
73
|
|
|
67
74
|
if (this.requiresAdmin && !(await isAdmin(uid))) {
|
|
68
75
|
throw new HttpsError("permission-denied", "Admin access required");
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this.requiresModerator && !(await isModerator(uid))) {
|
|
76
|
+
} else if (this.requiresModerator && !(await isModeratorOrAbove(uid))) {
|
|
72
77
|
throw new HttpsError(
|
|
73
78
|
"permission-denied",
|
|
74
79
|
"Moderator access required",
|
|
75
80
|
);
|
|
81
|
+
} else if (
|
|
82
|
+
this.requiresTranslator &&
|
|
83
|
+
!(await isTranslatorOrAbove(uid))
|
|
84
|
+
) {
|
|
85
|
+
throw new HttpsError(
|
|
86
|
+
"permission-denied",
|
|
87
|
+
"Translator access required",
|
|
88
|
+
);
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
|
package/src/lib/iam.ts
CHANGED
|
@@ -17,6 +17,21 @@ export const isAdmin = async (uid: string): Promise<boolean> => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const isModerator = async (uid: string): Promise<boolean> => {
|
|
20
|
+
const role = await getUserRole(uid);
|
|
21
|
+
return role === "moderator";
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const isModeratorOrAbove = async (uid: string): Promise<boolean> => {
|
|
20
25
|
const role = await getUserRole(uid);
|
|
21
26
|
return role === "admin" || role === "moderator";
|
|
22
27
|
};
|
|
28
|
+
|
|
29
|
+
export const isTranslator = async (uid: string): Promise<boolean> => {
|
|
30
|
+
const role = await getUserRole(uid);
|
|
31
|
+
return role === "translator";
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const isTranslatorOrAbove = async (uid: string): Promise<boolean> => {
|
|
35
|
+
const role = await getUserRole(uid);
|
|
36
|
+
return role === "admin" || role === "moderator" || role === "translator";
|
|
37
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Database } from "firebase-admin/database";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DailyLimitError,
|
|
4
|
+
MonthlyLimitError,
|
|
5
|
+
SubscriptionTier,
|
|
6
|
+
} from "../../types";
|
|
3
7
|
import { LIMITS, type UsageType } from "../../config/limits";
|
|
4
8
|
|
|
5
9
|
interface UsageCounter {
|
package/src/types/ai/recipe.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
2
|
import type { Timestamp } from "firebase-admin/firestore";
|
|
3
3
|
import { LocaleSchema, MeasurementSystemSchema, ThemeSchema } from "./enums";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AllergenSchema,
|
|
6
|
+
CuisineSchema,
|
|
7
|
+
DietaryTagSchema,
|
|
8
|
+
SpicinessSchema,
|
|
9
|
+
TemperatureUnitSchema,
|
|
10
|
+
} from "../recipe";
|
|
5
11
|
|
|
6
12
|
export const NotificationSettingsSchema = z.object({
|
|
7
13
|
email: z.boolean(),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
2
|
|
|
3
|
-
export const SUBSCRIPTION_ROLE_VALUES = [
|
|
4
|
-
"member",
|
|
5
|
-
"owner",
|
|
6
|
-
] as const;
|
|
3
|
+
export const SUBSCRIPTION_ROLE_VALUES = ["member", "owner"] as const;
|
|
7
4
|
export const SubscriptionRoleSchema = z.enum(SUBSCRIPTION_ROLE_VALUES);
|
|
8
5
|
export type SubscriptionRole = (typeof SUBSCRIPTION_ROLE_VALUES)[number];
|
package/src/types/iam/profile.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { ProfileStatusSchema } from "./enums";
|
|
|
5
5
|
export const ProfileSchema = z.object({
|
|
6
6
|
bio: z.string().max(280).optional(),
|
|
7
7
|
createdAt: z.custom<Timestamp>(),
|
|
8
|
-
handle: z.string().min(3).max(20),
|
|
9
8
|
id: z.string(),
|
|
10
9
|
imageUrl: z.string().url().optional(),
|
|
11
10
|
name: z.string().min(1).max(50),
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
2
|
import type { Timestamp } from "firebase-admin/firestore";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
SubscriptionRoleSchema,
|
|
5
|
+
SubscriptionStatusSchema,
|
|
6
|
+
SubscriptionTierSchema,
|
|
7
|
+
} from "./enums";
|
|
4
8
|
import { MAX_MEMBERS_FAMILY_PLAN } from "../../config";
|
|
5
9
|
|
|
6
10
|
export const MemberSchema = z.object({
|
package/src/types/iam/user.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { z } from "genkit";
|
|
2
2
|
import type { Timestamp } from "firebase-admin/firestore";
|
|
3
|
-
import {
|
|
4
|
-
UserRoleSchema,
|
|
5
|
-
UserStatusSchema,
|
|
6
|
-
} from "./enums";
|
|
3
|
+
import { UserRoleSchema, UserStatusSchema } from "./enums";
|
|
7
4
|
|
|
8
5
|
export const UserSchema = z.object({
|
|
9
6
|
createdAt: z.custom<Timestamp>(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./report_priority";
|
|
2
|
-
export * from "./report_status";
|
|
3
|
-
export * from "./report_target_type";
|
|
4
|
-
export * from "./report_type";
|
|
1
|
+
export * from "./report_priority";
|
|
2
|
+
export * from "./report_status";
|
|
3
|
+
export * from "./report_target_type";
|
|
4
|
+
export * from "./report_type";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { z } from "genkit";
|
|
2
|
-
|
|
3
|
-
export const REPORT_PRIORITY_VALUES = [
|
|
4
|
-
"critical",
|
|
5
|
-
"high",
|
|
6
|
-
"low",
|
|
7
|
-
"medium",
|
|
8
|
-
] as const;
|
|
9
|
-
export const ReportPrioritySchema = z.enum(REPORT_PRIORITY_VALUES);
|
|
10
|
-
export type ReportPriority = (typeof REPORT_PRIORITY_VALUES)[number];
|
|
1
|
+
import { z } from "genkit";
|
|
2
|
+
|
|
3
|
+
export const REPORT_PRIORITY_VALUES = [
|
|
4
|
+
"critical",
|
|
5
|
+
"high",
|
|
6
|
+
"low",
|
|
7
|
+
"medium",
|
|
8
|
+
] as const;
|
|
9
|
+
export const ReportPrioritySchema = z.enum(REPORT_PRIORITY_VALUES);
|
|
10
|
+
export type ReportPriority = (typeof REPORT_PRIORITY_VALUES)[number];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { z } from "genkit";
|
|
2
|
-
|
|
3
|
-
export const REPORT_STATUS_VALUES = [
|
|
4
|
-
"escalated",
|
|
5
|
-
"pending",
|
|
6
|
-
"resolved",
|
|
7
|
-
"reviewed",
|
|
8
|
-
] as const;
|
|
9
|
-
export const ReportStatusSchema = z.enum(REPORT_STATUS_VALUES);
|
|
10
|
-
export type ReportStatus = (typeof REPORT_STATUS_VALUES)[number];
|
|
1
|
+
import { z } from "genkit";
|
|
2
|
+
|
|
3
|
+
export const REPORT_STATUS_VALUES = [
|
|
4
|
+
"escalated",
|
|
5
|
+
"pending",
|
|
6
|
+
"resolved",
|
|
7
|
+
"reviewed",
|
|
8
|
+
] as const;
|
|
9
|
+
export const ReportStatusSchema = z.enum(REPORT_STATUS_VALUES);
|
|
10
|
+
export type ReportStatus = (typeof REPORT_STATUS_VALUES)[number];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { z } from "genkit";
|
|
2
|
-
|
|
3
|
-
export const REPORT_TARGET_TYPE_VALUES = [
|
|
4
|
-
"image",
|
|
5
|
-
"profile",
|
|
6
|
-
"recipe",
|
|
7
|
-
"user",
|
|
8
|
-
] as const;
|
|
9
|
-
export const ReportTargetTypeSchema = z.enum(REPORT_TARGET_TYPE_VALUES);
|
|
10
|
-
export type ReportTargetType = (typeof REPORT_TARGET_TYPE_VALUES)[number];
|
|
1
|
+
import { z } from "genkit";
|
|
2
|
+
|
|
3
|
+
export const REPORT_TARGET_TYPE_VALUES = [
|
|
4
|
+
"image",
|
|
5
|
+
"profile",
|
|
6
|
+
"recipe",
|
|
7
|
+
"user",
|
|
8
|
+
] as const;
|
|
9
|
+
export const ReportTargetTypeSchema = z.enum(REPORT_TARGET_TYPE_VALUES);
|
|
10
|
+
export type ReportTargetType = (typeof REPORT_TARGET_TYPE_VALUES)[number];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { z } from "genkit";
|
|
2
|
-
|
|
3
|
-
export const REPORT_TYPE_VALUES = [
|
|
4
|
-
"auto_rejected",
|
|
5
|
-
"manual_rejected",
|
|
6
|
-
"repeated_violations",
|
|
7
|
-
"unsafe_generated",
|
|
8
|
-
"unsafe_upload",
|
|
9
|
-
"user_report",
|
|
10
|
-
] as const;
|
|
11
|
-
export const ReportTypeSchema = z.enum(REPORT_TYPE_VALUES);
|
|
12
|
-
export type ReportType = (typeof REPORT_TYPE_VALUES)[number];
|
|
1
|
+
import { z } from "genkit";
|
|
2
|
+
|
|
3
|
+
export const REPORT_TYPE_VALUES = [
|
|
4
|
+
"auto_rejected",
|
|
5
|
+
"manual_rejected",
|
|
6
|
+
"repeated_violations",
|
|
7
|
+
"unsafe_generated",
|
|
8
|
+
"unsafe_upload",
|
|
9
|
+
"user_report",
|
|
10
|
+
] as const;
|
|
11
|
+
export const ReportTypeSchema = z.enum(REPORT_TYPE_VALUES);
|
|
12
|
+
export type ReportType = (typeof REPORT_TYPE_VALUES)[number];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./enums";
|
|
2
|
-
export * from "./report";
|
|
1
|
+
export * from "./enums";
|
|
2
|
+
export * from "./report";
|