@cravery/core 0.0.3 → 0.0.4
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/config/collections.d.ts +1 -0
- package/dist/config/collections.d.ts.map +1 -1
- package/dist/config/collections.js +1 -0
- package/dist/config/collections.js.map +1 -1
- package/dist/lib/ai/cost.d.ts +22 -0
- package/dist/lib/ai/cost.d.ts.map +1 -0
- package/dist/lib/ai/cost.js +45 -0
- package/dist/lib/ai/cost.js.map +1 -0
- package/dist/lib/ai/embedding.d.ts +4 -0
- package/dist/lib/ai/embedding.d.ts.map +1 -0
- package/dist/lib/ai/embedding.js +48 -0
- package/dist/lib/ai/embedding.js.map +1 -0
- package/dist/lib/ai/errors.d.ts +14 -0
- package/dist/lib/ai/errors.d.ts.map +1 -0
- package/dist/lib/ai/errors.js +40 -0
- package/dist/lib/ai/errors.js.map +1 -0
- package/dist/lib/ai/flow.d.ts +53 -0
- package/dist/lib/ai/flow.d.ts.map +1 -0
- package/dist/lib/ai/flow.js +60 -0
- package/dist/lib/ai/flow.js.map +1 -0
- package/dist/lib/ai/genkit.d.ts +4 -0
- package/dist/lib/ai/genkit.d.ts.map +1 -0
- package/dist/lib/ai/genkit.js +16 -0
- package/dist/lib/ai/genkit.js.map +1 -0
- package/dist/lib/ai/image.d.ts +7 -0
- package/dist/lib/ai/image.d.ts.map +1 -0
- package/dist/lib/ai/image.js +23 -0
- package/dist/lib/ai/image.js.map +1 -0
- package/dist/lib/ai/index.d.ts +7 -0
- package/dist/lib/ai/index.d.ts.map +1 -0
- package/dist/lib/ai/index.js +23 -0
- package/dist/lib/ai/index.js.map +1 -0
- package/dist/lib/firebase.d.ts +1 -1
- package/dist/lib/firebase.d.ts.map +1 -1
- package/dist/lib/index.d.ts +2 -5
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -5
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/repository/errors.d.ts +20 -0
- package/dist/lib/repository/errors.d.ts.map +1 -0
- package/dist/lib/repository/errors.js +33 -0
- package/dist/lib/repository/errors.js.map +1 -0
- package/dist/lib/repository/firestore.repository.d.ts +50 -0
- package/dist/lib/repository/firestore.repository.d.ts.map +1 -0
- package/dist/lib/repository/firestore.repository.js +407 -0
- package/dist/lib/repository/firestore.repository.js.map +1 -0
- package/dist/lib/repository/index.d.ts +7 -0
- package/dist/lib/repository/index.d.ts.map +1 -0
- package/dist/lib/repository/index.js +23 -0
- package/dist/lib/repository/index.js.map +1 -0
- package/dist/lib/repository/profile.repository.d.ts +12 -0
- package/dist/lib/repository/profile.repository.d.ts.map +1 -0
- package/dist/lib/repository/profile.repository.js +39 -0
- package/dist/lib/repository/profile.repository.js.map +1 -0
- package/dist/lib/repository/rtdb.repository.d.ts +21 -0
- package/dist/lib/repository/rtdb.repository.d.ts.map +1 -0
- package/dist/lib/repository/rtdb.repository.js +55 -0
- package/dist/lib/repository/rtdb.repository.js.map +1 -0
- package/dist/lib/repository/settings.repository.d.ts +10 -0
- package/dist/lib/repository/settings.repository.d.ts.map +1 -0
- package/dist/lib/repository/settings.repository.js +30 -0
- package/dist/lib/repository/settings.repository.js.map +1 -0
- package/dist/lib/repository/user.repository.d.ts +11 -0
- package/dist/lib/repository/user.repository.d.ts.map +1 -0
- package/dist/lib/repository/user.repository.js +36 -0
- package/dist/lib/repository/user.repository.js.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/moderation.d.ts +0 -1
- package/dist/types/moderation.d.ts.map +1 -1
- package/dist/types/profile.d.ts +1 -1
- package/dist/types/profile.d.ts.map +1 -1
- package/dist/types/profile.js.map +1 -1
- package/dist/types/recipe.d.ts +0 -1
- package/dist/types/recipe.d.ts.map +1 -1
- package/dist/types/repository.d.ts +83 -0
- package/dist/types/repository.d.ts.map +1 -0
- package/dist/types/repository.js +6 -0
- package/dist/types/repository.js.map +1 -0
- package/dist/types/settings.d.ts +141 -0
- package/dist/types/settings.d.ts.map +1 -0
- package/dist/types/settings.js +70 -0
- package/dist/types/settings.js.map +1 -0
- package/dist/types/subscription.d.ts +0 -1
- package/dist/types/subscription.d.ts.map +1 -1
- package/dist/types/user.d.ts +1 -1
- package/dist/types/user.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/collections.ts +1 -0
- package/src/lib/{cost.ts → ai/cost.ts} +1 -1
- package/src/lib/{embedding.ts → ai/embedding.ts} +2 -2
- package/src/lib/{flow.ts → ai/flow.ts} +3 -3
- package/src/lib/{image.ts → ai/image.ts} +1 -2
- package/src/lib/ai/index.ts +6 -0
- package/src/lib/index.ts +2 -5
- package/src/lib/repository/errors.ts +37 -0
- package/src/lib/repository/firestore.repository.ts +607 -0
- package/src/lib/repository/index.ts +6 -0
- package/src/lib/repository/profile.repository.ts +51 -0
- package/src/lib/repository/rtdb.repository.ts +68 -0
- package/src/lib/repository/settings.repository.ts +38 -0
- package/src/lib/repository/user.repository.ts +44 -0
- package/src/types/index.ts +2 -1
- package/src/types/profile.ts +2 -0
- package/src/types/repository.ts +115 -0
- package/src/types/settings.ts +85 -0
- package/src/types/user.ts +2 -0
- /package/src/{types/error.ts → lib/ai/errors.ts} +0 -0
- /package/src/lib/{genkit.ts → ai/genkit.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,aAAa,EAAE,eAAe;IAC9B,KAAK,EAAE,OAAO;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"collections.js","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG;IACzB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,KAAK,EAAE,OAAO;CACf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AIModelConfig } from "../../types";
|
|
2
|
+
interface BaseUsage {
|
|
3
|
+
flowName: string;
|
|
4
|
+
model: AIModelConfig;
|
|
5
|
+
}
|
|
6
|
+
interface MultimodalUsage extends BaseUsage {
|
|
7
|
+
type: "multimodal";
|
|
8
|
+
inputTokens: number;
|
|
9
|
+
outputTokens: number;
|
|
10
|
+
}
|
|
11
|
+
interface ImageUsage extends BaseUsage {
|
|
12
|
+
type: "image";
|
|
13
|
+
imageCount: number;
|
|
14
|
+
}
|
|
15
|
+
interface EmbeddingUsage extends BaseUsage {
|
|
16
|
+
type: "embedding";
|
|
17
|
+
tokenCount: number;
|
|
18
|
+
}
|
|
19
|
+
export type AIUsage = MultimodalUsage | ImageUsage | EmbeddingUsage;
|
|
20
|
+
export declare const logAIUsage: (usage: AIUsage) => number;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/cost.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,UAAU,SAAS;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,UAAU,eAAgB,SAAQ,SAAS;IACzC,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,UAAW,SAAQ,SAAS;IACpC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAe,SAAQ,SAAS;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,UAAU,GAAG,cAAc,CAAC;AAEpE,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,MA6C3C,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logAIUsage = void 0;
|
|
4
|
+
const database_1 = require("firebase-admin/database");
|
|
5
|
+
const logAIUsage = (usage) => {
|
|
6
|
+
const { flowName, model } = usage;
|
|
7
|
+
let cost;
|
|
8
|
+
let metrics;
|
|
9
|
+
switch (usage.type) {
|
|
10
|
+
case "multimodal":
|
|
11
|
+
cost =
|
|
12
|
+
(usage.inputTokens / 1000000) * model.cost.input +
|
|
13
|
+
(usage.outputTokens / 1000000) * model.cost.output;
|
|
14
|
+
metrics = {
|
|
15
|
+
inputTokens: usage.inputTokens,
|
|
16
|
+
outputTokens: usage.outputTokens,
|
|
17
|
+
};
|
|
18
|
+
break;
|
|
19
|
+
case "image":
|
|
20
|
+
cost = usage.imageCount * model.cost.output;
|
|
21
|
+
metrics = { images: usage.imageCount };
|
|
22
|
+
break;
|
|
23
|
+
case "embedding":
|
|
24
|
+
cost = (usage.tokenCount / 1000) * model.cost.input;
|
|
25
|
+
metrics = { tokens: usage.tokenCount };
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
const db = (0, database_1.getDatabase)();
|
|
29
|
+
const date = new Date().toISOString().split("T")[0];
|
|
30
|
+
const base = `ai_usage/live/${date}`;
|
|
31
|
+
const updates = {
|
|
32
|
+
[`${base}/total`]: database_1.ServerValue.increment(cost),
|
|
33
|
+
[`${base}/count`]: database_1.ServerValue.increment(1),
|
|
34
|
+
[`${base}/flows/${flowName}/cost`]: database_1.ServerValue.increment(cost),
|
|
35
|
+
[`${base}/flows/${flowName}/count`]: database_1.ServerValue.increment(1),
|
|
36
|
+
[`${base}/models/${model.id}/cost`]: database_1.ServerValue.increment(cost),
|
|
37
|
+
};
|
|
38
|
+
for (const [key, value] of Object.entries(metrics)) {
|
|
39
|
+
updates[`${base}/models/${model.id}/${key}`] = database_1.ServerValue.increment(value);
|
|
40
|
+
}
|
|
41
|
+
db.ref().update(updates).catch(console.error);
|
|
42
|
+
return cost;
|
|
43
|
+
};
|
|
44
|
+
exports.logAIUsage = logAIUsage;
|
|
45
|
+
//# sourceMappingURL=cost.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.js","sourceRoot":"","sources":["../../../src/lib/ai/cost.ts"],"names":[],"mappings":";;;AAAA,sDAAmE;AA0B5D,MAAM,UAAU,GAAG,CAAC,KAAc,EAAU,EAAE;IACnD,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAElC,IAAI,IAAY,CAAC;IACjB,IAAI,OAA+B,CAAC;IAEpC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,YAAY;YACf,IAAI;gBACF,CAAC,KAAK,CAAC,WAAW,GAAG,OAAS,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK;oBAClD,CAAC,KAAK,CAAC,YAAY,GAAG,OAAS,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YACvD,OAAO,GAAG;gBACR,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;aACjC,CAAC;YACF,MAAM;QACR,KAAK,OAAO;YACV,IAAI,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,CAAC,GAAG,sBAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IAED,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE9C,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AA7CW,QAAA,UAAU,cA6CrB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const generateEmbedding: (text: string, flowName: string) => Promise<number[]>;
|
|
2
|
+
export declare const storeEmbedding: (collection: string, docId: string, text: string, flowName?: string, vectorField?: string) => Promise<void>;
|
|
3
|
+
export declare const recipesRetriever: import("genkit").RetrieverAction;
|
|
4
|
+
//# sourceMappingURL=embedding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/embedding.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,EAAE,UAAU,MAAM,sBAerE,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,WAAW,MAAM,EACjB,cAAa,MAAoB,kBAYlC,CAAC;AAEF,eAAO,MAAM,gBAAgB,kCAS3B,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recipesRetriever = exports.storeEmbedding = exports.generateEmbedding = void 0;
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
5
|
+
const firebase_1 = require("@genkit-ai/firebase");
|
|
6
|
+
const firebase_2 = require("../firebase");
|
|
7
|
+
const genkit_1 = require("./genkit");
|
|
8
|
+
const cost_1 = require("./cost");
|
|
9
|
+
const ai_1 = require("../../config/ai");
|
|
10
|
+
const generateEmbedding = async (text, flowName) => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (text.length < 1 || text.length > 7500) {
|
|
13
|
+
throw new Error("Validation error: Text out of range");
|
|
14
|
+
}
|
|
15
|
+
const response = await genkit_1.ai.embed({
|
|
16
|
+
embedder: genkit_1.geminiEmbedding001,
|
|
17
|
+
content: text,
|
|
18
|
+
});
|
|
19
|
+
(0, cost_1.logAIUsage)({
|
|
20
|
+
type: "embedding",
|
|
21
|
+
flowName,
|
|
22
|
+
model: ai_1.AI_MODELS.GeminiEmbedding001,
|
|
23
|
+
tokenCount: text.length,
|
|
24
|
+
});
|
|
25
|
+
return (_a = response[0]) === null || _a === void 0 ? void 0 : _a.embedding;
|
|
26
|
+
};
|
|
27
|
+
exports.generateEmbedding = generateEmbedding;
|
|
28
|
+
const storeEmbedding = async (collection, docId, text, flowName, vectorField = "embedding") => {
|
|
29
|
+
const embedding = await (0, exports.generateEmbedding)(text, flowName || `${collection}:embedding`);
|
|
30
|
+
await firebase_2.firestore
|
|
31
|
+
.collection(collection)
|
|
32
|
+
.doc(docId)
|
|
33
|
+
.update({
|
|
34
|
+
[vectorField]: firestore_1.FieldValue.vector(embedding),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.storeEmbedding = storeEmbedding;
|
|
38
|
+
exports.recipesRetriever = (0, firebase_1.defineFirestoreRetriever)(genkit_1.ai, {
|
|
39
|
+
name: "recipesRetriever",
|
|
40
|
+
firestore: firebase_2.firestore,
|
|
41
|
+
collection: "recipes",
|
|
42
|
+
contentField: "searchTerms",
|
|
43
|
+
vectorField: "titleEmbedding",
|
|
44
|
+
embedder: genkit_1.geminiEmbedding001,
|
|
45
|
+
distanceMeasure: "COSINE",
|
|
46
|
+
distanceResultField: "distance",
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=embedding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.js","sourceRoot":"","sources":["../../../src/lib/ai/embedding.ts"],"names":[],"mappings":";;;AAAA,wDA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T,oBAAS;IACT,UAAU,EAAE,SAAS;IACrB,YAAY,EAAE,aAAa;IAC3B,WAAW,EAAE,gBAAgB;IAC7B,QAAQ,EAAE,2BAAkB;IAC5B,eAAe,EAAE,QAAQ;IACzB,mBAAmB,EAAE,UAAU;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const AI_ERROR_CODE_VALUES: readonly ["hallucination_detected", "image_unclear", "impossible_constraint", "invalid_input", "invalid_url", "low_confidence", "model_error", "no_recipe_found", "nonsense_input", "rate_limit", "timeout", "translation_failed", "unsafe_input", "url_not_accessible"];
|
|
2
|
+
export type AIErrorCode = (typeof AI_ERROR_CODE_VALUES)[number];
|
|
3
|
+
export declare class AIFlowError extends Error {
|
|
4
|
+
readonly code: AIErrorCode;
|
|
5
|
+
readonly suggestions?: string[];
|
|
6
|
+
constructor(code: AIErrorCode, message: string, suggestions?: string[]);
|
|
7
|
+
toJSON(): {
|
|
8
|
+
name: string;
|
|
9
|
+
code: "hallucination_detected" | "image_unclear" | "impossible_constraint" | "invalid_input" | "invalid_url" | "low_confidence" | "model_error" | "no_recipe_found" | "nonsense_input" | "rate_limit" | "timeout" | "translation_failed" | "unsafe_input" | "url_not_accessible";
|
|
10
|
+
message: string;
|
|
11
|
+
suggestions: string[] | undefined;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,0QAevB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,WAAW,CAAC;IAClC,SAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;gBAE3B,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE;IAWtE,MAAM;;;;;;CAQP"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIFlowError = exports.AI_ERROR_CODE_VALUES = void 0;
|
|
4
|
+
exports.AI_ERROR_CODE_VALUES = [
|
|
5
|
+
"hallucination_detected",
|
|
6
|
+
"image_unclear",
|
|
7
|
+
"impossible_constraint",
|
|
8
|
+
"invalid_input",
|
|
9
|
+
"invalid_url",
|
|
10
|
+
"low_confidence",
|
|
11
|
+
"model_error",
|
|
12
|
+
"no_recipe_found",
|
|
13
|
+
"nonsense_input",
|
|
14
|
+
"rate_limit",
|
|
15
|
+
"timeout",
|
|
16
|
+
"translation_failed",
|
|
17
|
+
"unsafe_input",
|
|
18
|
+
"url_not_accessible",
|
|
19
|
+
];
|
|
20
|
+
class AIFlowError extends Error {
|
|
21
|
+
constructor(code, message, suggestions) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "AIFlowError";
|
|
24
|
+
this.code = code;
|
|
25
|
+
this.suggestions = suggestions;
|
|
26
|
+
if (Error.captureStackTrace) {
|
|
27
|
+
Error.captureStackTrace(this, AIFlowError);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
toJSON() {
|
|
31
|
+
return {
|
|
32
|
+
name: this.name,
|
|
33
|
+
code: this.code,
|
|
34
|
+
message: this.message,
|
|
35
|
+
suggestions: this.suggestions,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.AIFlowError = AIFlowError;
|
|
40
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/lib/ai/errors.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAClC,wBAAwB;IACxB,eAAe;IACf,uBAAuB;IACvB,eAAe;IACf,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,SAAS;IACT,oBAAoB;IACpB,cAAc;IACd,oBAAoB;CACZ,CAAC;AAIX,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAY,IAAiB,EAAE,OAAe,EAAE,WAAsB;QACpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;CACF;AAvBD,kCAuBC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "genkit";
|
|
2
|
+
import { AIModelConfig } from "../../types";
|
|
3
|
+
export declare const ImagenOutputSchema: z.ZodObject<{
|
|
4
|
+
images: z.ZodArray<z.ZodObject<{
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
path: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
url: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}, {
|
|
11
|
+
url: string;
|
|
12
|
+
path: string;
|
|
13
|
+
}>, "many">;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
images: {
|
|
16
|
+
url: string;
|
|
17
|
+
path: string;
|
|
18
|
+
}[];
|
|
19
|
+
}, {
|
|
20
|
+
images: {
|
|
21
|
+
url: string;
|
|
22
|
+
path: string;
|
|
23
|
+
}[];
|
|
24
|
+
}>;
|
|
25
|
+
export type FlowHandler<T, R> = (input: T, output: R | null) => Promise<R>;
|
|
26
|
+
export type ImageFlowHandler<T> = (input: T, prompt: string) => Promise<{
|
|
27
|
+
base64Data: string;
|
|
28
|
+
storagePath: string;
|
|
29
|
+
}[]>;
|
|
30
|
+
export declare const createGeminiFlow: <T, R>(name: string, inputSchema: z.ZodSchema<T>, outputSchema: z.ZodSchema<R>, handler: FlowHandler<T, R>, model?: AIModelConfig) => import("genkit").Action<z.ZodType<T, z.ZodTypeDef, T>, z.ZodType<R, z.ZodTypeDef, R>, z.ZodTypeAny>;
|
|
31
|
+
export declare const createImagenFlow: <T>(name: string, inputSchema: z.ZodSchema<T>, handler: ImageFlowHandler<T>, model?: AIModelConfig) => import("genkit").Action<z.ZodType<T, z.ZodTypeDef, T>, z.ZodObject<{
|
|
32
|
+
images: z.ZodArray<z.ZodObject<{
|
|
33
|
+
url: z.ZodString;
|
|
34
|
+
path: z.ZodString;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
url: string;
|
|
37
|
+
path: string;
|
|
38
|
+
}, {
|
|
39
|
+
url: string;
|
|
40
|
+
path: string;
|
|
41
|
+
}>, "many">;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
images: {
|
|
44
|
+
url: string;
|
|
45
|
+
path: string;
|
|
46
|
+
}[];
|
|
47
|
+
}, {
|
|
48
|
+
images: {
|
|
49
|
+
url: string;
|
|
50
|
+
path: string;
|
|
51
|
+
}[];
|
|
52
|
+
}>, z.ZodTypeAny>;
|
|
53
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAO7B,CAAC;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAC3E,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAChC,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAAC;AAE5D,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,EACnC,MAAM,MAAM,EACZ,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC5B,SAAS,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC1B,QAAO,aAAuC,wGA4B/C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,MAAM,MAAM,EACZ,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAC3B,SAAS,gBAAgB,CAAC,CAAC,CAAC,EAC5B,QAAO,aAAqC;;;;;;;;;;;;;;;;;;;;;iBA2B7C,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createImagenFlow = exports.createGeminiFlow = exports.ImagenOutputSchema = void 0;
|
|
4
|
+
const genkit_1 = require("genkit");
|
|
5
|
+
const ai_1 = require("../../config/ai");
|
|
6
|
+
const cost_1 = require("./cost");
|
|
7
|
+
const genkit_2 = require("./genkit");
|
|
8
|
+
const storage_1 = require("../storage");
|
|
9
|
+
exports.ImagenOutputSchema = genkit_1.z.object({
|
|
10
|
+
images: genkit_1.z.array(genkit_1.z.object({
|
|
11
|
+
url: genkit_1.z.string(),
|
|
12
|
+
path: genkit_1.z.string(),
|
|
13
|
+
})),
|
|
14
|
+
});
|
|
15
|
+
const createGeminiFlow = (name, inputSchema, outputSchema, handler, model = ai_1.AI_MODELS.Gemini25Flash) => {
|
|
16
|
+
const FlowInputSchema = genkit_2.ai.defineSchema(`${name}InputSchema`, inputSchema);
|
|
17
|
+
const FlowOutputSchema = genkit_2.ai.defineSchema(`${name}OutputSchema`, outputSchema);
|
|
18
|
+
const prompt = genkit_2.ai.prompt(name);
|
|
19
|
+
return genkit_2.ai.defineFlow({
|
|
20
|
+
name: name,
|
|
21
|
+
inputSchema: inputSchema,
|
|
22
|
+
outputSchema: outputSchema,
|
|
23
|
+
}, async (input) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const response = await prompt(input);
|
|
26
|
+
(0, cost_1.logAIUsage)({
|
|
27
|
+
type: "multimodal",
|
|
28
|
+
flowName: name,
|
|
29
|
+
model,
|
|
30
|
+
inputTokens: ((_a = response.usage) === null || _a === void 0 ? void 0 : _a.inputTokens) || 0,
|
|
31
|
+
outputTokens: ((_b = response.usage) === null || _b === void 0 ? void 0 : _b.outputTokens) || 0,
|
|
32
|
+
});
|
|
33
|
+
return handler(input, response.output);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.createGeminiFlow = createGeminiFlow;
|
|
37
|
+
const createImagenFlow = (name, inputSchema, handler, model = ai_1.AI_MODELS.Imagen4Fast) => {
|
|
38
|
+
return genkit_2.ai.defineFlow({
|
|
39
|
+
name: name,
|
|
40
|
+
inputSchema: inputSchema,
|
|
41
|
+
outputSchema: exports.ImagenOutputSchema,
|
|
42
|
+
}, async (input) => {
|
|
43
|
+
const imageData = await handler(input, name);
|
|
44
|
+
const uploadPromises = imageData.map(({ base64Data, storagePath }) => (0, storage_1.uploadImageToStorage)(base64Data, storagePath).catch((err) => {
|
|
45
|
+
throw err;
|
|
46
|
+
}));
|
|
47
|
+
const uploadedImages = await Promise.all(uploadPromises);
|
|
48
|
+
(0, cost_1.logAIUsage)({
|
|
49
|
+
type: "image",
|
|
50
|
+
flowName: name,
|
|
51
|
+
model,
|
|
52
|
+
imageCount: imageData.length,
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
images: uploadedImages,
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.createImagenFlow = createImagenFlow;
|
|
60
|
+
//# sourceMappingURL=flow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../../../src/lib/ai/flow.ts"],"names":[],"mappings":";;;AAAA,mCAA2B;AAC3B,wCAA4C;AAC5C,iCAAoC;AACpC,qCAA8B;AAC9B,wCAAkD;AAGrC,QAAA,kBAAkB,GAAG,UAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,UAAC,CAAC,KAAK,CACb,UAAC,CAAC,MAAM,CAAC;QACP,GAAG,EAAE,UAAC,CAAC,MAAM,EAAE;QACf,IAAI,EAAE,UAAC,CAAC,MAAM,EAAE;KACjB,CAAC,CACH;CACF,CAAC,CAAC;AAOI,MAAM,gBAAgB,GAAG,CAC9B,IAAY,EACZ,WAA2B,EAC3B,YAA4B,EAC5B,OAA0B,EAC1B,QAAuB,cAAS,CAAC,aAAa,EAC9C,EAAE;IACF,MAAM,eAAe,GAAG,WAAE,CAAC,YAAY,CAAC,GAAG,IAAI,aAAa,EAAE,WAAW,CAAC,CAAC;IAC3E,MAAM,gBAAgB,GAAG,WAAE,CAAC,YAAY,CAAC,GAAG,IAAI,cAAc,EAAE,YAAY,CAAC,CAAC;IAC9E,MAAM,MAAM,GAAG,WAAE,CAAC,MAAM,CAItB,IAAI,CAAC,CAAC;IAER,OAAO,WAAE,CAAC,UAAU,CAClB;QACE,IAAI,E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,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,IAAI;YACd,KAAK;YACL,UAAU,EAAE,SAAS,CAAC,MAAM;SAC7B,CAAC,CAAC;QACH,OAAO;YACL,MAAM,EAAE,cAAc;SACvB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AA/BW,QAAA,gBAAgB,oBA+B3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genkit.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/genkit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAMnD,eAAO,MAAM,EAAE,yBAOb,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,iBAEhC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.geminiEmbedding001 = exports.ai = void 0;
|
|
4
|
+
const genkit_1 = require("genkit");
|
|
5
|
+
const google_genai_1 = require("@genkit-ai/google-genai");
|
|
6
|
+
const projectId = process.env.GCLOUD_PROJECT || process.env.GCP_PROJECT || "canary-cravery";
|
|
7
|
+
exports.ai = (0, genkit_1.genkit)({
|
|
8
|
+
plugins: [
|
|
9
|
+
(0, google_genai_1.vertexAI)({
|
|
10
|
+
location: "us-central1",
|
|
11
|
+
projectId,
|
|
12
|
+
}),
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
exports.geminiEmbedding001 = google_genai_1.vertexAI.embedder("gemini-embedding-001");
|
|
16
|
+
//# sourceMappingURL=genkit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genkit.js","sourceRoot":"","sources":["../../../src/lib/ai/genkit.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;AACnD,0DAAmD;AAEnD,MAAM,SAAS,GACb,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,gBAAgB,CAAC;AAE/D,QAAA,EAAE,GAAG,IAAA,eAAM,EAAC;IACvB,OAAO,EAAE;QACP,IAAA,uBAAQ,EAAC;YACP,QAAQ,EAAE,aAAa;YACvB,SAAS;SACV,CAAC;KACH;CACF,CAAC,CAAC;AAEU,QAAA,kBAAkB,GAAsB,uBAAQ,CAAC,QAAQ,CACpE,sBAAsB,CACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG/C,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,GAAI,UAAU,gBAAgB,KAAG,SAkBzD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImageData = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const getImageData = (response) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const media = response.media;
|
|
8
|
+
if (!(media === null || media === void 0 ? void 0 : media.url)) {
|
|
9
|
+
throw new errors_1.AIFlowError("model_error", "No image data in response", [
|
|
10
|
+
"Try with a different recipe description",
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
const url = media.url;
|
|
14
|
+
const contentType = (_a = media.contentType) !== null && _a !== void 0 ? _a : "image/png";
|
|
15
|
+
if (url.startsWith("data:")) {
|
|
16
|
+
const base64Part = url.split(",")[1];
|
|
17
|
+
if (base64Part)
|
|
18
|
+
return { base64: base64Part, contentType };
|
|
19
|
+
}
|
|
20
|
+
return { base64: url, contentType };
|
|
21
|
+
};
|
|
22
|
+
exports.getImageData = getImageData;
|
|
23
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../../src/lib/ai/image.ts"],"names":[],"mappings":";;;AACA,qCAAuC;AAOhC,MAAM,YAAY,GAAG,CAAC,QAA0B,EAAa,EAAE;;IACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAE7B,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,GAAG,CAAA,EAAE,CAAC;QAChB,MAAM,IAAI,oBAAW,CAAC,aAAa,EAAE,2BAA2B,EAAE;YAChE,yCAAyC;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACtB,MAAM,WAAW,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,WAAW,CAAC;IAErD,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,UAAU;YAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAC7D,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AACtC,CAAC,CAAC;AAlBW,QAAA,YAAY,gBAkBvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./cost"), exports);
|
|
18
|
+
__exportStar(require("./embedding"), exports);
|
|
19
|
+
__exportStar(require("./errors"), exports);
|
|
20
|
+
__exportStar(require("./flow"), exports);
|
|
21
|
+
__exportStar(require("./genkit"), exports);
|
|
22
|
+
__exportStar(require("./image"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/ai/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,8CAA4B;AAC5B,2CAAyB;AACzB,yCAAuB;AACvB,2CAAyB;AACzB,0CAAwB"}
|
package/dist/lib/firebase.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../src/lib/firebase.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"firebase.d.ts","sourceRoot":"","sources":["../../src/lib/firebase.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,WAAiB,CAAC;AACxC,eAAO,MAAM,IAAI,4CAAgB,CAAC"}
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
export * from "./ai";
|
|
1
2
|
export * from "./api";
|
|
2
|
-
export * from "./cost";
|
|
3
|
-
export * from "./embedding";
|
|
4
3
|
export * from "./firebase";
|
|
5
|
-
export * from "./flow";
|
|
6
|
-
export * from "./genkit";
|
|
7
4
|
export * from "./iam";
|
|
8
|
-
export * from "./
|
|
5
|
+
export * from "./repository";
|
|
9
6
|
export * from "./storage";
|
|
10
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -14,13 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ai"), exports);
|
|
17
18
|
__exportStar(require("./api"), exports);
|
|
18
|
-
__exportStar(require("./cost"), exports);
|
|
19
|
-
__exportStar(require("./embedding"), exports);
|
|
20
19
|
__exportStar(require("./firebase"), exports);
|
|
21
|
-
__exportStar(require("./flow"), exports);
|
|
22
|
-
__exportStar(require("./genkit"), exports);
|
|
23
20
|
__exportStar(require("./iam"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./repository"), exports);
|
|
25
22
|
__exportStar(require("./storage"), exports);
|
|
26
23
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,wCAAsB;AACtB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare enum RepositoryErrorCode {
|
|
2
|
+
NOT_FOUND = "NOT_FOUND",
|
|
3
|
+
ALREADY_EXISTS = "ALREADY_EXISTS",
|
|
4
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
5
|
+
QUERY_LIMIT_EXCEEDED = "QUERY_LIMIT_EXCEEDED",
|
|
6
|
+
TRANSACTION_FAILED = "TRANSACTION_FAILED",
|
|
7
|
+
PERMISSION_DENIED = "PERMISSION_DENIED"
|
|
8
|
+
}
|
|
9
|
+
export declare class RepositoryError extends Error {
|
|
10
|
+
readonly code: RepositoryErrorCode;
|
|
11
|
+
readonly context?: Record<string, unknown>;
|
|
12
|
+
constructor(code: RepositoryErrorCode, message: string, context?: Record<string, unknown>);
|
|
13
|
+
toJSON(): {
|
|
14
|
+
name: string;
|
|
15
|
+
code: RepositoryErrorCode;
|
|
16
|
+
message: string;
|
|
17
|
+
context: Record<string, unknown> | undefined;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/errors.ts"],"names":[],"mappings":"AAAA,oBAAY,mBAAmB;IAC7B,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,gBAAgB,qBAAqB;IACrC,oBAAoB,yBAAyB;IAC7C,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAgB,IAAI,EAAE,mBAAmB,CAAC;IAC1C,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGhD,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAYnC,MAAM;;;;;;CAQP"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RepositoryError = exports.RepositoryErrorCode = void 0;
|
|
4
|
+
var RepositoryErrorCode;
|
|
5
|
+
(function (RepositoryErrorCode) {
|
|
6
|
+
RepositoryErrorCode["NOT_FOUND"] = "NOT_FOUND";
|
|
7
|
+
RepositoryErrorCode["ALREADY_EXISTS"] = "ALREADY_EXISTS";
|
|
8
|
+
RepositoryErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
9
|
+
RepositoryErrorCode["QUERY_LIMIT_EXCEEDED"] = "QUERY_LIMIT_EXCEEDED";
|
|
10
|
+
RepositoryErrorCode["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
|
|
11
|
+
RepositoryErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
12
|
+
})(RepositoryErrorCode || (exports.RepositoryErrorCode = RepositoryErrorCode = {}));
|
|
13
|
+
class RepositoryError extends Error {
|
|
14
|
+
constructor(code, message, context) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "RepositoryError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.context = context;
|
|
19
|
+
if (Error.captureStackTrace) {
|
|
20
|
+
Error.captureStackTrace(this, RepositoryError);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
name: this.name,
|
|
26
|
+
code: this.code,
|
|
27
|
+
message: this.message,
|
|
28
|
+
context: this.context,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.RepositoryError = RepositoryError;
|
|
33
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/lib/repository/errors.ts"],"names":[],"mappings":";;;AAAA,IAAY,mBAOX;AAPD,WAAY,mBAAmB;IAC7B,8CAAuB,CAAA;IACvB,wDAAiC,CAAA;IACjC,4DAAqC,CAAA;IACrC,oEAA6C,CAAA;IAC7C,gEAAyC,CAAA;IACzC,8DAAuC,CAAA;AACzC,CAAC,EAPW,mBAAmB,mCAAnB,mBAAmB,QAO9B;AAED,MAAa,eAAgB,SAAQ,KAAK;IAIxC,YACE,IAAyB,EACzB,OAAe,EACf,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AA3BD,0CA2BC"}
|