@cravery/core 0.0.7 → 0.0.8

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.
Files changed (137) hide show
  1. package/dist/config/collections.d.ts +5 -0
  2. package/dist/config/collections.d.ts.map +1 -1
  3. package/dist/config/collections.js +5 -0
  4. package/dist/config/collections.js.map +1 -1
  5. package/dist/config/common.js +1 -1
  6. package/dist/config/index.d.ts +1 -0
  7. package/dist/config/index.d.ts.map +1 -1
  8. package/dist/config/index.js +1 -0
  9. package/dist/config/index.js.map +1 -1
  10. package/dist/config/limits.d.ts +8 -0
  11. package/dist/config/limits.d.ts.map +1 -0
  12. package/dist/config/limits.js +36 -0
  13. package/dist/config/limits.js.map +1 -0
  14. package/dist/lib/errors/index.d.ts +11 -2
  15. package/dist/lib/errors/index.d.ts.map +1 -1
  16. package/dist/lib/errors/index.js +31 -4
  17. package/dist/lib/errors/index.js.map +1 -1
  18. package/dist/lib/index.d.ts +1 -0
  19. package/dist/lib/index.d.ts.map +1 -1
  20. package/dist/lib/index.js +1 -0
  21. package/dist/lib/index.js.map +1 -1
  22. package/dist/lib/repository/equipment.repository.d.ts +15 -0
  23. package/dist/lib/repository/equipment.repository.d.ts.map +1 -0
  24. package/dist/lib/repository/equipment.repository.js +65 -0
  25. package/dist/lib/repository/equipment.repository.js.map +1 -0
  26. package/dist/lib/repository/factory.d.ts +10 -0
  27. package/dist/lib/repository/factory.d.ts.map +1 -1
  28. package/dist/lib/repository/factory.js +15 -0
  29. package/dist/lib/repository/factory.js.map +1 -1
  30. package/dist/lib/repository/index.d.ts +5 -0
  31. package/dist/lib/repository/index.d.ts.map +1 -1
  32. package/dist/lib/repository/index.js +5 -0
  33. package/dist/lib/repository/index.js.map +1 -1
  34. package/dist/lib/repository/ingredient.repository.d.ts +15 -0
  35. package/dist/lib/repository/ingredient.repository.d.ts.map +1 -0
  36. package/dist/lib/repository/ingredient.repository.js +65 -0
  37. package/dist/lib/repository/ingredient.repository.js.map +1 -0
  38. package/dist/lib/repository/recipe-queue.repository.d.ts +10 -0
  39. package/dist/lib/repository/recipe-queue.repository.d.ts.map +1 -0
  40. package/dist/lib/repository/recipe-queue.repository.js +37 -0
  41. package/dist/lib/repository/recipe-queue.repository.js.map +1 -0
  42. package/dist/lib/repository/recipe.repository.d.ts +10 -0
  43. package/dist/lib/repository/recipe.repository.d.ts.map +1 -0
  44. package/dist/lib/repository/recipe.repository.js +40 -0
  45. package/dist/lib/repository/recipe.repository.js.map +1 -0
  46. package/dist/lib/repository/report.repository.d.ts +15 -0
  47. package/dist/lib/repository/report.repository.d.ts.map +1 -0
  48. package/dist/lib/repository/report.repository.js +47 -0
  49. package/dist/lib/repository/report.repository.js.map +1 -0
  50. package/dist/lib/usage/index.d.ts +2 -0
  51. package/dist/lib/usage/index.d.ts.map +1 -0
  52. package/dist/lib/usage/index.js +18 -0
  53. package/dist/lib/usage/index.js.map +1 -0
  54. package/dist/lib/usage/usage.service.d.ts +28 -0
  55. package/dist/lib/usage/usage.service.d.ts.map +1 -0
  56. package/dist/lib/usage/usage.service.js +131 -0
  57. package/dist/lib/usage/usage.service.js.map +1 -0
  58. package/dist/lib/utils/index.d.ts +1 -0
  59. package/dist/lib/utils/index.d.ts.map +1 -1
  60. package/dist/lib/utils/index.js +1 -0
  61. package/dist/lib/utils/index.js.map +1 -1
  62. package/dist/lib/utils/slug.d.ts +13 -0
  63. package/dist/lib/utils/slug.d.ts.map +1 -0
  64. package/dist/lib/utils/slug.js +33 -0
  65. package/dist/lib/utils/slug.js.map +1 -0
  66. package/dist/types/ai/genkit.d.ts +246 -0
  67. package/dist/types/ai/genkit.d.ts.map +1 -0
  68. package/dist/types/ai/genkit.js +68 -0
  69. package/dist/types/ai/genkit.js.map +1 -0
  70. package/dist/types/ai/index.d.ts +1 -0
  71. package/dist/types/ai/index.d.ts.map +1 -1
  72. package/dist/types/ai/index.js +1 -0
  73. package/dist/types/ai/index.js.map +1 -1
  74. package/dist/types/asset.d.ts +21 -0
  75. package/dist/types/asset.d.ts.map +1 -0
  76. package/dist/types/asset.js +18 -0
  77. package/dist/types/asset.js.map +1 -0
  78. package/dist/types/equipment-entry.d.ts +21 -0
  79. package/dist/types/equipment-entry.d.ts.map +1 -0
  80. package/dist/types/equipment-entry.js +17 -0
  81. package/dist/types/equipment-entry.js.map +1 -0
  82. package/dist/types/global-asset.d.ts +21 -0
  83. package/dist/types/global-asset.d.ts.map +1 -0
  84. package/dist/types/global-asset.js +18 -0
  85. package/dist/types/global-asset.js.map +1 -0
  86. package/dist/types/idempotency.d.ts +32 -0
  87. package/dist/types/idempotency.d.ts.map +1 -0
  88. package/dist/types/idempotency.js +25 -0
  89. package/dist/types/idempotency.js.map +1 -0
  90. package/dist/types/index.d.ts +2 -0
  91. package/dist/types/index.d.ts.map +1 -1
  92. package/dist/types/index.js +2 -0
  93. package/dist/types/index.js.map +1 -1
  94. package/dist/types/ingredient-entry.d.ts +21 -0
  95. package/dist/types/ingredient-entry.d.ts.map +1 -0
  96. package/dist/types/ingredient-entry.js +17 -0
  97. package/dist/types/ingredient-entry.js.map +1 -0
  98. package/dist/types/moderation.d.ts +24 -17
  99. package/dist/types/moderation.d.ts.map +1 -1
  100. package/dist/types/moderation.js +8 -7
  101. package/dist/types/moderation.js.map +1 -1
  102. package/dist/types/rate-limit.d.ts +26 -0
  103. package/dist/types/rate-limit.d.ts.map +1 -0
  104. package/dist/types/rate-limit.js +22 -0
  105. package/dist/types/rate-limit.js.map +1 -0
  106. package/dist/types/report.d.ts +91 -0
  107. package/dist/types/report.d.ts.map +1 -0
  108. package/dist/types/report.js +61 -0
  109. package/dist/types/report.js.map +1 -0
  110. package/dist/types/user-recipe-ref.d.ts +29 -0
  111. package/dist/types/user-recipe-ref.d.ts.map +1 -0
  112. package/dist/types/user-recipe-ref.js +22 -0
  113. package/dist/types/user-recipe-ref.js.map +1 -0
  114. package/package.json +1 -4
  115. package/src/config/collections.ts +5 -0
  116. package/src/config/common.ts +1 -1
  117. package/src/config/index.ts +1 -0
  118. package/src/config/limits.ts +41 -0
  119. package/src/lib/errors/index.ts +30 -3
  120. package/src/lib/index.ts +1 -0
  121. package/src/lib/repository/equipment.repository.ts +93 -0
  122. package/src/lib/repository/factory.ts +15 -0
  123. package/src/lib/repository/index.ts +5 -0
  124. package/src/lib/repository/ingredient.repository.ts +93 -0
  125. package/src/lib/repository/recipe-queue.repository.ts +49 -0
  126. package/src/lib/repository/recipe.repository.ts +51 -0
  127. package/src/lib/repository/report.repository.ts +79 -0
  128. package/src/lib/usage/index.ts +1 -0
  129. package/src/lib/usage/usage.service.ts +187 -0
  130. package/src/lib/utils/index.ts +1 -0
  131. package/src/lib/utils/slug.ts +33 -0
  132. package/src/types/ai/genkit.ts +77 -0
  133. package/src/types/ai/index.ts +1 -0
  134. package/src/types/asset.ts +19 -0
  135. package/src/types/index.ts +2 -0
  136. package/src/types/moderation.ts +9 -7
  137. package/src/types/report.ts +70 -0
@@ -1,7 +1,12 @@
1
1
  export declare const Collections: {
2
+ Equipment: string;
3
+ Followers: string;
4
+ Ingredients: string;
2
5
  Moderations: string;
3
6
  Profiles: string;
7
+ RecipeQueue: string;
4
8
  Recipes: string;
9
+ Reports: string;
5
10
  Settings: string;
6
11
  Subscriptions: string;
7
12
  Users: string;
@@ -1 +1 @@
1
- {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;CAOvB,CAAC"}
1
+ {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../../src/config/collections.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW;;;;;;;;;;;;CAYvB,CAAC"}
@@ -2,9 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Collections = void 0;
4
4
  exports.Collections = {
5
+ Equipment: "equipment",
6
+ Followers: "followers",
7
+ Ingredients: "ingredients",
5
8
  Moderations: "moderations",
6
9
  Profiles: "profiles",
10
+ RecipeQueue: "recipe_queue",
7
11
  Recipes: "recipes",
12
+ Reports: "reports",
8
13
  Settings: "settings",
9
14
  Subscriptions: "subscriptions",
10
15
  Users: "users",
@@ -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,QAAQ,EAAE,UAAU;IACpB,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,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,cAAc;IAC3B,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,KAAK,EAAE,OAAO;CACf,CAAC"}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlugRegex = void 0;
4
- exports.SlugRegex = /^[a-z][a-z0-9-]*[a-z0-9]$/;
4
+ exports.SlugRegex = /^[a-z][a-z0-9_]*[a-z0-9]$/;
5
5
  //# sourceMappingURL=common.js.map
@@ -1,5 +1,6 @@
1
1
  export * from "./ai";
2
2
  export * from "./collections";
3
3
  export * from "./common";
4
+ export * from "./limits";
4
5
  export * from "./subscription";
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAC;AACrB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ai"), exports);
18
18
  __exportStar(require("./collections"), exports);
19
19
  __exportStar(require("./common"), exports);
20
+ __exportStar(require("./limits"), exports);
20
21
  __exportStar(require("./subscription"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,gDAA8B;AAC9B,2CAAyB;AACzB,iDAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,gDAA8B;AAC9B,2CAAyB;AACzB,2CAAyB;AACzB,iDAA+B"}
@@ -0,0 +1,8 @@
1
+ import type { SubscriptionTier } from "../types/enums";
2
+ export type UsageType = "recipeCreation" | "scan";
3
+ export interface TierLimits {
4
+ daily: Record<UsageType, number>;
5
+ monthly: Record<UsageType, number>;
6
+ }
7
+ export declare const TIER_LIMITS: Record<SubscriptionTier, TierLimits>;
8
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/config/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,gBAAgB,EAAE,UAAU,CA+B5D,CAAC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TIER_LIMITS = void 0;
4
+ exports.TIER_LIMITS = {
5
+ free: {
6
+ daily: {
7
+ recipeCreation: 3,
8
+ scan: 10,
9
+ },
10
+ monthly: {
11
+ recipeCreation: 20,
12
+ scan: 100,
13
+ },
14
+ },
15
+ pro: {
16
+ daily: {
17
+ recipeCreation: 20,
18
+ scan: 100,
19
+ },
20
+ monthly: {
21
+ recipeCreation: 500,
22
+ scan: 3000,
23
+ },
24
+ },
25
+ family: {
26
+ daily: {
27
+ recipeCreation: 50,
28
+ scan: -1,
29
+ },
30
+ monthly: {
31
+ recipeCreation: 1500,
32
+ scan: -1,
33
+ },
34
+ },
35
+ };
36
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/config/limits.ts"],"names":[],"mappings":";;;AASa,QAAA,WAAW,GAAyC;IAC/D,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,cAAc,EAAE,CAAC;YACjB,IAAI,EAAE,EAAE;SACT;QACD,OAAO,EAAE;YACP,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,GAAG;SACV;KACF;IACD,GAAG,EAAE;QACH,KAAK,EAAE;YACL,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,GAAG;SACV;QACD,OAAO,EAAE;YACP,cAAc,EAAE,GAAG;YACnB,IAAI,EAAE,IAAI;SACX;KACF;IACD,MAAM,EAAE;QACN,KAAK,EAAE;YACL,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,CAAC,CAAC;SACT;QACD,OAAO,EAAE;YACP,cAAc,EAAE,IAAI;YACpB,IAAI,EAAE,CAAC,CAAC;SACT;KACF;CACF,CAAC"}
@@ -1,4 +1,4 @@
1
- export declare const APP_ERROR_CODE_VALUES: readonly ["BAD_REQUEST", "UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "CONFLICT", "VALIDATION_ERROR", "INTERNAL_ERROR"];
1
+ export declare const APP_ERROR_CODE_VALUES: readonly ["BAD_REQUEST", "CONFLICT", "DAILY_LIMIT_REACHED", "DUPLICATE_SOURCE_URL", "FORBIDDEN", "INTERNAL_ERROR", "LOW_CONFIDENCE", "MONTHLY_LIMIT_REACHED", "NOT_FOUND", "NO_RECIPE_FOUND", "UNAUTHORIZED", "UNSAFE_CONTENT", "VALIDATION_ERROR"];
2
2
  export type AppErrorCode = (typeof APP_ERROR_CODE_VALUES)[number];
3
3
  export declare class AppError extends Error {
4
4
  readonly code: AppErrorCode;
@@ -7,7 +7,7 @@ export declare class AppError extends Error {
7
7
  constructor(code: AppErrorCode, message: string, statusCode?: number, context?: Record<string, unknown>);
8
8
  toJSON(): {
9
9
  name: string;
10
- code: "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "VALIDATION_ERROR" | "INTERNAL_ERROR";
10
+ code: "BAD_REQUEST" | "CONFLICT" | "DAILY_LIMIT_REACHED" | "DUPLICATE_SOURCE_URL" | "FORBIDDEN" | "INTERNAL_ERROR" | "LOW_CONFIDENCE" | "MONTHLY_LIMIT_REACHED" | "NOT_FOUND" | "NO_RECIPE_FOUND" | "UNAUTHORIZED" | "UNSAFE_CONTENT" | "VALIDATION_ERROR";
11
11
  message: string;
12
12
  statusCode: number;
13
13
  context: Record<string, unknown> | undefined;
@@ -28,4 +28,13 @@ export declare class ForbiddenError extends AppError {
28
28
  export declare class ConflictError extends AppError {
29
29
  constructor(message: string, context?: Record<string, unknown>);
30
30
  }
31
+ export declare class DuplicateError extends AppError {
32
+ constructor(message: string, context?: Record<string, unknown>);
33
+ }
34
+ export declare class DailyLimitError extends AppError {
35
+ constructor(message: string, context?: Record<string, unknown>);
36
+ }
37
+ export declare class MonthlyLimitError extends AppError {
38
+ constructor(message: string, context?: Record<string, unknown>);
39
+ }
31
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/errors/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,sHAQxB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,IAAI,EAAE,YAAY,CAAC;IACnC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGhD,IAAI,EAAE,YAAY,EAClB,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,MAAY,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAanC,MAAM;;;;;;;CASP;AAED,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,O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AO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAI/D"}
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConflictError = exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.ValidationError = exports.AppError = exports.APP_ERROR_CODE_VALUES = void 0;
3
+ exports.MonthlyLimitError = exports.DailyLimitError = exports.DuplicateError = exports.ConflictError = exports.ForbiddenError = exports.UnauthorizedError = exports.NotFoundError = exports.ValidationError = exports.AppError = exports.APP_ERROR_CODE_VALUES = void 0;
4
4
  exports.APP_ERROR_CODE_VALUES = [
5
5
  "BAD_REQUEST",
6
- "UNAUTHORIZED",
6
+ "CONFLICT",
7
+ "DAILY_LIMIT_REACHED",
8
+ "DUPLICATE_SOURCE_URL",
7
9
  "FORBIDDEN",
10
+ "INTERNAL_ERROR",
11
+ "LOW_CONFIDENCE",
12
+ "MONTHLY_LIMIT_REACHED",
8
13
  "NOT_FOUND",
9
- "CONFLICT",
14
+ "NO_RECIPE_FOUND",
15
+ "UNAUTHORIZED",
16
+ "UNSAFE_CONTENT",
10
17
  "VALIDATION_ERROR",
11
- "INTERNAL_ERROR",
12
18
  ];
13
19
  class AppError extends Error {
14
20
  constructor(code, message, statusCode = 500, context) {
@@ -67,4 +73,25 @@ class ConflictError extends AppError {
67
73
  }
68
74
  }
69
75
  exports.ConflictError = ConflictError;
76
+ class DuplicateError extends AppError {
77
+ constructor(message, context) {
78
+ super("DUPLICATE_SOURCE_URL", message, 409, context);
79
+ this.name = "DuplicateError";
80
+ }
81
+ }
82
+ exports.DuplicateError = DuplicateError;
83
+ class DailyLimitError extends AppError {
84
+ constructor(message, context) {
85
+ super("DAILY_LIMIT_REACHED", message, 429, context);
86
+ this.name = "DailyLimitError";
87
+ }
88
+ }
89
+ exports.DailyLimitError = DailyLimitError;
90
+ class MonthlyLimitError extends AppError {
91
+ constructor(message, context) {
92
+ super("MONTHLY_LIMIT_REACHED", message, 429, context);
93
+ this.name = "MonthlyLimitError";
94
+ }
95
+ }
96
+ exports.MonthlyLimitError = MonthlyLimitError;
70
97
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/errors/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG;IACnC,aAAa;IACb,cAAc;IACd,WAAW;IACX,WAAW;IACX,UAAU;IACV,kBAAkB;IAClB,gBAAgB;CACR,CAAC;AAIX,MAAa,QAAS,SAAQ,KAAK;IAKjC,YACE,IAAkB,EAClB,OAAe,EACf,aAAqB,GAAG,EACxB,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,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iBAAkB,SAAQ,QAAQ;IAC7C,YAAY,OAAe,EAAE,OAAiC;QAC5D,KAAK,CAAC,uBAAuB,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC"}
@@ -5,5 +5,6 @@ export * from "./firebase";
5
5
  export * from "./iam";
6
6
  export * from "./repository";
7
7
  export * from "./storage";
8
+ export * from "./usage";
8
9
  export * from "./utils";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,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,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/lib/index.js CHANGED
@@ -21,5 +21,6 @@ __exportStar(require("./firebase"), exports);
21
21
  __exportStar(require("./iam"), exports);
22
22
  __exportStar(require("./repository"), exports);
23
23
  __exportStar(require("./storage"), exports);
24
+ __exportStar(require("./usage"), exports);
24
25
  __exportStar(require("./utils"), exports);
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAqB;AACrB,wCAAsB;AACtB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,4CAA0B;AAC1B,0CAAwB;AACxB,0CAAwB"}
@@ -0,0 +1,15 @@
1
+ import { Firestore } from "firebase-admin/firestore";
2
+ import { FirestoreRepository } from "./firestore.repository";
3
+ import type { Asset, AssetLocale } from "../../types/asset";
4
+ import type { Locale } from "../../types/enums";
5
+ export declare class EquipmentRepository extends FirestoreRepository<Asset> {
6
+ constructor(firestore: Firestore);
7
+ protected validate(data: Partial<Asset>): void;
8
+ findBySlug(slug: string): Promise<Asset | null>;
9
+ slugExists(slug: string): Promise<boolean>;
10
+ getLocale(slug: string, locale: Locale): Promise<AssetLocale | null>;
11
+ setLocale(slug: string, locale: Locale, data: Omit<AssetLocale, "locale">): Promise<void>;
12
+ getAllLocales(slug: string): Promise<AssetLocale[]>;
13
+ createWithLocale(slug: string, imageUrl: string | undefined, locale: Locale, localeData: Omit<AssetLocale, "locale">): Promise<Asset>;
14
+ }
15
+ //# sourceMappingURL=equipment.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equipment.repository.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/equipment.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,mBAAoB,SAAQ,mBAAmB,CAAC,KAAK,CAAC;gBACrD,SAAS,EAAE,SAAS;IAQhC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI;IAWxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAOpE,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC;IAKV,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAWnD,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GACtC,OAAO,CAAC,KAAK,CAAC;CAmBlB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EquipmentRepository = void 0;
4
+ const firestore_1 = require("firebase-admin/firestore");
5
+ const firestore_repository_1 = require("./firestore.repository");
6
+ const asset_1 = require("../../types/asset");
7
+ const collections_1 = require("../../config/collections");
8
+ const errors_1 = require("./errors");
9
+ class EquipmentRepository extends firestore_repository_1.FirestoreRepository {
10
+ constructor(firestore) {
11
+ super(firestore, collections_1.Collections.Equipment, {
12
+ enableTimestamps: true,
13
+ enableSoftDelete: false,
14
+ validateOnWrite: true,
15
+ });
16
+ }
17
+ validate(data) {
18
+ const result = asset_1.AssetSchema.partial().safeParse(data);
19
+ if (!result.success) {
20
+ throw new errors_1.RepositoryError(errors_1.RepositoryErrorCode.VALIDATION_ERROR, "Equipment validation failed", { errors: result.error.issues });
21
+ }
22
+ }
23
+ async findBySlug(slug) {
24
+ return this.findById(slug);
25
+ }
26
+ async slugExists(slug) {
27
+ return this.exists(slug);
28
+ }
29
+ async getLocale(slug, locale) {
30
+ const docRef = this.collection.doc(slug).collection("locales").doc(locale);
31
+ const doc = await docRef.get();
32
+ if (!doc.exists)
33
+ return null;
34
+ return Object.assign({ locale }, doc.data());
35
+ }
36
+ async setLocale(slug, locale, data) {
37
+ const docRef = this.collection.doc(slug).collection("locales").doc(locale);
38
+ await docRef.set(Object.assign({ locale }, data));
39
+ }
40
+ async getAllLocales(slug) {
41
+ const snapshot = await this.collection
42
+ .doc(slug)
43
+ .collection("locales")
44
+ .get();
45
+ return snapshot.docs.map((doc) => (Object.assign({ locale: doc.id }, doc.data())));
46
+ }
47
+ async createWithLocale(slug, imageUrl, locale, localeData) {
48
+ const now = firestore_1.Timestamp.now();
49
+ const batch = this.firestore.batch();
50
+ const docRef = this.collection.doc(slug);
51
+ const assetData = {
52
+ id: slug,
53
+ imageUrl,
54
+ createdAt: now,
55
+ updatedAt: now,
56
+ };
57
+ batch.set(docRef, assetData);
58
+ const localeRef = docRef.collection("locales").doc(locale);
59
+ batch.set(localeRef, Object.assign({ locale }, localeData));
60
+ await batch.commit();
61
+ return assetData;
62
+ }
63
+ }
64
+ exports.EquipmentRepository = EquipmentRepository;
65
+ //# sourceMappingURL=equipment.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equipment.repository.js","sourceRoot":"","sources":["../../../src/lib/repository/equipment.repository.ts"],"names":[],"mappings":";;;AAAA,wDAKkC;AAClC,iEAA6D;AAE7D,6CAAgD;AAChD,0DAAuD;AACvD,qCAAgE;AAGhE,MAAa,mBAAoB,SAAQ,0CAA0B;IACjE,YAAY,SAAoB;QAC9B,KAAK,CA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repository";
2
2
  import { ProfileRepository } from "./profile.repository";
3
3
  import { SettingsRepository } from "./settings.repository";
4
+ import { RecipeRepository } from "./recipe.repository";
5
+ import { RecipeQueueRepository } from "./recipe-queue.repository";
6
+ import { IngredientRepository } from "./ingredient.repository";
7
+ import { EquipmentRepository } from "./equipment.repository";
8
+ import { ReportRepository } from "./report.repository";
4
9
  export declare const repositories: {
5
10
  user: () => UserRepository;
6
11
  profile: () => ProfileRepository;
7
12
  settings: () => SettingsRepository;
13
+ recipe: () => RecipeRepository;
14
+ recipeQueue: () => RecipeQueueRepository;
15
+ ingredient: () => IngredientRepository;
16
+ equipment: () => EquipmentRepository;
17
+ report: () => ReportRepository;
8
18
  };
9
19
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,eAAO,MAAM,YAAY;;;;CAIxB,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAWvD,eAAO,MAAM,YAAY;;;;;;;;;CASxB,CAAC"}
@@ -5,12 +5,27 @@ const firebase_1 = require("../firebase");
5
5
  const user_repository_1 = require("./user.repository");
6
6
  const profile_repository_1 = require("./profile.repository");
7
7
  const settings_repository_1 = require("./settings.repository");
8
+ const recipe_repository_1 = require("./recipe.repository");
9
+ const recipe_queue_repository_1 = require("./recipe-queue.repository");
10
+ const ingredient_repository_1 = require("./ingredient.repository");
11
+ const equipment_repository_1 = require("./equipment.repository");
12
+ const report_repository_1 = require("./report.repository");
8
13
  let userRepo = null;
9
14
  let profileRepo = null;
10
15
  let settingsRepo = null;
16
+ let recipeRepo = null;
17
+ let recipeQueueRepo = null;
18
+ let ingredientRepo = null;
19
+ let equipmentRepo = null;
20
+ let reportRepo = null;
11
21
  exports.repositories = {
12
22
  user: () => (userRepo !== null && userRepo !== void 0 ? userRepo : (userRepo = new user_repository_1.UserRepository(firebase_1.firestore))),
13
23
  profile: () => (profileRepo !== null && profileRepo !== void 0 ? profileRepo : (profileRepo = new profile_repository_1.ProfileRepository(firebase_1.firestore))),
14
24
  settings: () => (settingsRepo !== null && settingsRepo !== void 0 ? settingsRepo : (settingsRepo = new settings_repository_1.SettingsRepository(firebase_1.firestore))),
25
+ recipe: () => (recipeRepo !== null && recipeRepo !== void 0 ? recipeRepo : (recipeRepo = new recipe_repository_1.RecipeRepository(firebase_1.firestore))),
26
+ recipeQueue: () => (recipeQueueRepo !== null && recipeQueueRepo !== void 0 ? recipeQueueRepo : (recipeQueueRepo = new recipe_queue_repository_1.RecipeQueueRepository(firebase_1.firestore))),
27
+ ingredient: () => (ingredientRepo !== null && ingredientRepo !== void 0 ? ingredientRepo : (ingredientRepo = new ingredient_repository_1.IngredientRepository(firebase_1.firestore))),
28
+ equipment: () => (equipmentRepo !== null && equipmentRepo !== void 0 ? equipmentRepo : (equipmentRepo = new equipment_repository_1.EquipmentRepository(firebase_1.firestore))),
29
+ report: () => (reportRepo !== null && reportRepo !== void 0 ? reportRepo : (reportRepo = new report_repository_1.ReportRepository(firebase_1.firestore))),
15
30
  };
16
31
  //# sourceMappingURL=factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/lib/repository/factory.ts"],"names":[],"mappings":";;;AAAA,0CAAwC;AACxC,uDAAmD;AACnD,6DAAyD;AACzD,+DAA2D;AAE3D,IAAI,QAAQ,GAA0B,IAAI,CAAC;AAC3C,IAAI,WAAW,GAA6B,IAAI,CAAC;AACjD,IAAI,YAAY,GAA8B,IAAI,CAAC;AAEtC,QAAA,YAAY,GAAG;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,QAAQ,aAAR,QAAQ,cAAR,QAAQ,IAAR,QAAQ,GAAK,IAAI,gCAAc,CAAC,oBAAS,CAAC,EAAC;IACxD,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,IAAX,WAAW,GAAK,IAAI,sCAAiB,CAAC,oBAAS,CAAC,EAAC;IACjE,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY,aAAZ,YAAY,cAAZ,YAAY,IAAZ,YAAY,GAAK,IAAI,wCAAkB,CAAC,oBAAS,CAAC,EAAC;CACrE,CAAC"}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/lib/repository/factory.ts"],"names":[],"mappings":";;;AAAA,0CAAwC;AACxC,uDAAmD;AACnD,6DAAyD;AACzD,+DAA2D;AAC3D,2DAAuD;AACvD,uEAAkE;AAClE,mEAA+D;AAC/D,iEAA6D;AAC7D,2DAAuD;AAEvD,IAAI,QAAQ,GAA0B,IAAI,CAAC;AAC3C,IAAI,WAAW,GAA6B,IAAI,CAAC;AACjD,IAAI,YAAY,GAA8B,IAAI,CAAC;AACnD,IAAI,UAAU,GAA4B,IAAI,CAAC;AAC/C,IAAI,eAAe,GAAiC,IAAI,CAAC;AACzD,IAAI,cAAc,GAAgC,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";
6
6
  export * from "./profile.repository";
7
7
  export * from "./settings.repository";
8
+ export * from "./recipe.repository";
9
+ export * from "./recipe-queue.repository";
10
+ export * from "./ingredient.repository";
11
+ export * from "./equipment.repository";
12
+ export * from "./report.repository";
8
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -21,4 +21,9 @@ __exportStar(require("./rtdb.repository"), exports);
21
21
  __exportStar(require("./user.repository"), exports);
22
22
  __exportStar(require("./profile.repository"), exports);
23
23
  __exportStar(require("./settings.repository"), exports);
24
+ __exportStar(require("./recipe.repository"), exports);
25
+ __exportStar(require("./recipe-queue.repository"), exports);
26
+ __exportStar(require("./ingredient.repository"), exports);
27
+ __exportStar(require("./equipment.repository"), exports);
28
+ __exportStar(require("./report.repository"), exports);
24
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,yDAAuC;AACvC,oDAAkC;AAClC,oDAAkC;AAClC,uDAAqC;AACrC,wDAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/repository/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,yDAAuC;AACvC,oDAAkC;AAClC,oDAAkC;AAClC,uDAAqC;AACrC,wDAAsC;AACtC,sDAAoC;AACpC,4DAA0C;AAC1C,0DAAwC;AACxC,yDAAuC;AACvC,sDAAoC"}
@@ -0,0 +1,15 @@
1
+ import { Firestore } from "firebase-admin/firestore";
2
+ import { FirestoreRepository } from "./firestore.repository";
3
+ import type { Asset, AssetLocale } from "../../types/asset";
4
+ import type { Locale } from "../../types/enums";
5
+ export declare class IngredientRepository extends FirestoreRepository<Asset> {
6
+ constructor(firestore: Firestore);
7
+ protected validate(data: Partial<Asset>): void;
8
+ findBySlug(slug: string): Promise<Asset | null>;
9
+ slugExists(slug: string): Promise<boolean>;
10
+ getLocale(slug: string, locale: Locale): Promise<AssetLocale | null>;
11
+ setLocale(slug: string, locale: Locale, data: Omit<AssetLocale, "locale">): Promise<void>;
12
+ getAllLocales(slug: string): Promise<AssetLocale[]>;
13
+ createWithLocale(slug: string, imageUrl: string | undefined, locale: Locale, localeData: Omit<AssetLocale, "locale">): Promise<Asset>;
14
+ }
15
+ //# sourceMappingURL=ingredient.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingredient.repository.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/ingredient.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,qBAAa,oBAAqB,SAAQ,mBAAmB,CAAC,KAAK,CAAC;gBACtD,SAAS,EAAE,SAAS;IAQhC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI;IAWxC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAI/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAOpE,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC;IAKV,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAWnD,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GACtC,OAAO,CAAC,KAAK,CAAC;CAmBlB"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IngredientRepository = void 0;
4
+ const firestore_1 = require("firebase-admin/firestore");
5
+ const firestore_repository_1 = require("./firestore.repository");
6
+ const asset_1 = require("../../types/asset");
7
+ const collections_1 = require("../../config/collections");
8
+ const errors_1 = require("./errors");
9
+ class IngredientRepository extends firestore_repository_1.FirestoreRepository {
10
+ constructor(firestore) {
11
+ super(firestore, collections_1.Collections.Ingredients, {
12
+ enableTimestamps: true,
13
+ enableSoftDelete: false,
14
+ validateOnWrite: true,
15
+ });
16
+ }
17
+ validate(data) {
18
+ const result = asset_1.AssetSchema.partial().safeParse(data);
19
+ if (!result.success) {
20
+ throw new errors_1.RepositoryError(errors_1.RepositoryErrorCode.VALIDATION_ERROR, "Ingredient validation failed", { errors: result.error.issues });
21
+ }
22
+ }
23
+ async findBySlug(slug) {
24
+ return this.findById(slug);
25
+ }
26
+ async slugExists(slug) {
27
+ return this.exists(slug);
28
+ }
29
+ async getLocale(slug, locale) {
30
+ const docRef = this.collection.doc(slug).collection("locales").doc(locale);
31
+ const doc = await docRef.get();
32
+ if (!doc.exists)
33
+ return null;
34
+ return Object.assign({ locale }, doc.data());
35
+ }
36
+ async setLocale(slug, locale, data) {
37
+ const docRef = this.collection.doc(slug).collection("locales").doc(locale);
38
+ await docRef.set(Object.assign({ locale }, data));
39
+ }
40
+ async getAllLocales(slug) {
41
+ const snapshot = await this.collection
42
+ .doc(slug)
43
+ .collection("locales")
44
+ .get();
45
+ return snapshot.docs.map((doc) => (Object.assign({ locale: doc.id }, doc.data())));
46
+ }
47
+ async createWithLocale(slug, imageUrl, locale, localeData) {
48
+ const now = firestore_1.Timestamp.now();
49
+ const batch = this.firestore.batch();
50
+ const docRef = this.collection.doc(slug);
51
+ const assetData = {
52
+ id: slug,
53
+ imageUrl,
54
+ createdAt: now,
55
+ updatedAt: now,
56
+ };
57
+ batch.set(docRef, assetData);
58
+ const localeRef = docRef.collection("locales").doc(locale);
59
+ batch.set(localeRef, Object.assign({ locale }, localeData));
60
+ await batch.commit();
61
+ return assetData;
62
+ }
63
+ }
64
+ exports.IngredientRepository = IngredientRepository;
65
+ //# sourceMappingURL=ingredient.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingredient.repository.js","sourceRoot":"","sources":["../../../src/lib/repository/ingredient.repository.ts"],"names":[],"mappings":";;;AAAA,wDAKkC;AAClC,iEAA6D;AAE7D,6CAAgD;AAChD,0DAAuD;AACvD,qCAAgE;AAGhE,MAAa,oBAAqB,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DA+EC"}
@@ -0,0 +1,10 @@
1
+ import { Firestore } from "firebase-admin/firestore";
2
+ import { FirestoreRepository } from "./firestore.repository";
3
+ import type { RecipeMeta } from "../../types/recipe";
4
+ export declare class RecipeQueueRepository extends FirestoreRepository<RecipeMeta> {
5
+ constructor(firestore: Firestore);
6
+ protected validate(data: Partial<RecipeMeta>): void;
7
+ findBySourceUrl(sourceUrl: string): Promise<RecipeMeta | null>;
8
+ findBySourceUrlAndUser(sourceUrl: string, userId: string): Promise<RecipeMeta | null>;
9
+ }
10
+ //# sourceMappingURL=recipe-queue.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-queue.repository.d.ts","sourceRoot":"","sources":["../../../src/lib/repository/recipe-queue.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAKrD,qBAAa,qBAAsB,SAAQ,mBAAmB,CAAC,UAAU,CAAC;gBAC5D,SAAS,EAAE,SAAS;IAQhC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAW7C,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAQ9D,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAU9B"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RecipeQueueRepository = void 0;
4
+ const firestore_repository_1 = require("./firestore.repository");
5
+ const recipe_1 = require("../../types/recipe");
6
+ const collections_1 = require("../../config/collections");
7
+ const errors_1 = require("./errors");
8
+ class RecipeQueueRepository extends firestore_repository_1.FirestoreRepository {
9
+ constructor(firestore) {
10
+ super(firestore, collections_1.Collections.RecipeQueue, {
11
+ enableTimestamps: true,
12
+ enableSoftDelete: false,
13
+ validateOnWrite: true,
14
+ });
15
+ }
16
+ validate(data) {
17
+ const result = recipe_1.RecipeMetaSchema.partial().safeParse(data);
18
+ if (!result.success) {
19
+ throw new errors_1.RepositoryError(errors_1.RepositoryErrorCode.VALIDATION_ERROR, "Recipe queue validation failed", { errors: result.error.issues });
20
+ }
21
+ }
22
+ async findBySourceUrl(sourceUrl) {
23
+ var _a;
24
+ const results = await this.findWhere([{ field: "sourceUrl", op: "==", value: sourceUrl }], { limit: 1 });
25
+ return (_a = results[0]) !== null && _a !== void 0 ? _a : null;
26
+ }
27
+ async findBySourceUrlAndUser(sourceUrl, userId) {
28
+ var _a;
29
+ const results = await this.findWhere([
30
+ { field: "sourceUrl", op: "==", value: sourceUrl },
31
+ { field: "createdBy", op: "==", value: userId },
32
+ ], { limit: 1 });
33
+ return (_a = results[0]) !== null && _a !== void 0 ? _a : null;
34
+ }
35
+ }
36
+ exports.RecipeQueueRepository = RecipeQueueRepository;
37
+ //# sourceMappingURL=recipe-queue.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-queue.repository.js","sourceRoot":"","sources":["../../../src/lib/repository/recipe-queue.repository.ts"],"names":[],"mappings":";;;AACA,iEAA6D;AAE7D,+CAAsD;AACtD,0DAAuD;AACvD,qCAAgE;AAEhE,MAAa,qBAAsB,SAAQ,0CAA+B;IACxE,YAAY,SAAoB;QAC9B,KAAK,CAAC,SAAS,EAAE,yBAAW,CAAC,WAAW,EAAE;YACxC,gBAAgB,EAAE,IAAI;YACtB,gBAAgB,EAAE,KAAK;YACvB,eAAe,EAAE,IAAI;SACtB,CAAC,CAAC;IACL,CAAC;IAES,QAAQ,CAAC,IAAyB;QAC1C,MAAM,MAAM,GAAG,yBAAgB,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,wBAAe,CACvB,4BAAmB,CAAC,gBAAgB,EACpC,gCAAgC,EAChC,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAChC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,SAAiB;;QACrC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,CAClC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EACpD,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;QACF,OAAO,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,IAAI,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,SAAiB,EACjB,MAAc;;QAEd,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,SAAS,CAClC;YACE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;YAClD,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;SAChD,EACD,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;QACF,OAAO,MAAA,OAAO,CAAC,CAAC,CAAC,mCAAI,IAAI,CAAC;IAC5B,CAAC;CACF;AAzCD,sDAyCC"}
@@ -0,0 +1,10 @@
1
+ import { Firestore } from "firebase-admin/firestore";
2
+ import { FirestoreRepository } from "./firestore.repository";
3
+ import type { RecipeMeta } from "../../types/recipe";
4
+ export declare class RecipeRepository extends FirestoreRepository<RecipeMeta> {
5
+ constructor(firestore: Firestore);
6
+ protected validate(data: Partial<RecipeMeta>): void;
7
+ findBySourceUrl(sourceUrl: string): Promise<RecipeMeta | null>;
8
+ hardDelete(id: string): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=recipe.repository.d.ts.map