@cravery/firebase 0.0.4 → 0.0.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/recipe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElE,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAgE5E;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;IAC3C,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC;CACxB,CA4EA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/recipe/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElE,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CA2D5E;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;IAC3C,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC;CACxB,CA4EA"}
@@ -56,11 +56,6 @@ function mergeRecipe(meta, content) {
56
56
  status: meta.status,
57
57
  time: meta.time,
58
58
  updatedAt: meta.updatedAt,
59
- // Video generation fields
60
- videoUrl: meta.videoUrl,
61
- videoGeneratedAt: meta.videoGeneratedAt,
62
- videoGenerationStatus: meta.videoGenerationStatus,
63
- videoGenerationError: meta.videoGenerationError,
64
59
  equipment,
65
60
  ingredientSections,
66
61
  instructions,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/recipe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kB,CAAC,GAAG,CACtD,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACjC,IAAI;QACJ,KAAK;QACL,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YACvD,IAAI;YACJ,KAAK;YACL,IAAI;SACL,CAAC,CAAC;KACJ,CAAC,CACH,CAAC;IAEF,MAAM,gBAAgB,GAAG,YAAY,CAAC,GAAG,CACvC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;QACpC,QAAQ;QACR,IAAI;QACJ,WAAW;KACZ,CAAC,CACH,CAAC;IACF,MAAM,mBAAmB,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI;QACJ,IAAI;KACL,CAAC,CAAC,CAAC;IAEJ,MAAM,OAAO,GAAkB;QAC7B,WAAW;QACX,SAAS,EAAE,gBAAgB;QAC3B,kBAAkB,EAAE,yBAAyB;QAC7C,YAAY,EAAE,mBAAmB;QACjC,MAAM;QACN,IAAI;QACJ,KAAK;KACN,CAAC;IAEF,MAAM,IAAI,mCACL,UAAU,KACb,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,sBAAsB,EAC1C,YAAY,EAAE,gBAAgB,GAC/B,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
package/package.json CHANGED
@@ -1,60 +1,59 @@
1
- {
2
- "name": "@cravery/firebase",
3
- "version": "0.0.4",
4
- "description": "Shared Firebase Admin SDK utilities for Cravery",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "default": "./dist/index.js"
11
- },
12
- "./recipe": {
13
- "types": "./dist/recipe/index.d.ts",
14
- "default": "./dist/recipe/index.js"
15
- },
16
- "./iam": {
17
- "types": "./dist/iam/index.d.ts",
18
- "default": "./dist/iam/index.js"
19
- },
20
- "./utils": {
21
- "types": "./dist/utils/index.d.ts",
22
- "default": "./dist/utils/index.js"
23
- }
24
- },
25
- "typesVersions": {
26
- "*": {
27
- "recipe": [
28
- "dist/recipe/index.d.ts"
29
- ],
30
- "iam": [
31
- "dist/iam/index.d.ts"
32
- ],
33
- "utils": [
34
- "dist/utils/index.d.ts"
35
- ]
36
- }
37
- },
38
- "scripts": {
39
- "build": "tsc",
40
- "build:watch": "tsc --watch",
41
- "clean": "rimraf dist && npm run build"
42
- },
43
- "keywords": [],
44
- "peerDependencies": {
45
- "firebase-admin": "^13.6.0"
46
- },
47
- "devDependencies": {
48
- "firebase-admin": "^13.6.0",
49
- "rimraf": "^6.1.2",
50
- "typescript": "^5.9.3"
51
- },
52
- "files": [
53
- "dist/**/*",
54
- "src/**/*"
55
- ],
56
- "dependencies": {
57
- "@cravery/core": "^0.0.30",
58
- "@cravery/firebase": "^0.0.1"
59
- }
60
- }
1
+ {
2
+ "name": "@cravery/firebase",
3
+ "version": "0.0.6",
4
+ "description": "Shared Firebase Admin SDK utilities for Cravery",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./recipe": {
13
+ "types": "./dist/recipe/index.d.ts",
14
+ "default": "./dist/recipe/index.js"
15
+ },
16
+ "./iam": {
17
+ "types": "./dist/iam/index.d.ts",
18
+ "default": "./dist/iam/index.js"
19
+ },
20
+ "./utils": {
21
+ "types": "./dist/utils/index.d.ts",
22
+ "default": "./dist/utils/index.js"
23
+ }
24
+ },
25
+ "typesVersions": {
26
+ "*": {
27
+ "recipe": [
28
+ "dist/recipe/index.d.ts"
29
+ ],
30
+ "iam": [
31
+ "dist/iam/index.d.ts"
32
+ ],
33
+ "utils": [
34
+ "dist/utils/index.d.ts"
35
+ ]
36
+ }
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "build:watch": "tsc --watch",
41
+ "clean": "rimraf dist && npm run build"
42
+ },
43
+ "keywords": [],
44
+ "peerDependencies": {
45
+ "firebase-admin": "^13.6.0"
46
+ },
47
+ "devDependencies": {
48
+ "firebase-admin": "^13.6.0",
49
+ "rimraf": "^6.1.2",
50
+ "typescript": "^5.9.3"
51
+ },
52
+ "files": [
53
+ "dist/**/*",
54
+ "src/**/*"
55
+ ],
56
+ "dependencies": {
57
+ "@cravery/core": "^0.0.32"
58
+ }
59
+ }
@@ -1,98 +1,98 @@
1
- import {
2
- FirestoreDataConverter,
3
- QueryDocumentSnapshot,
4
- DocumentData,
5
- } from "firebase-admin/firestore";
6
- import type { RecipeMeta, RecipeContent } from "@cravery/core/types";
7
- import {
8
- toTimestamp,
9
- toOptionalTimestamp,
10
- fromTimestamp,
11
- stripUndefined,
12
- } from "../utils";
13
-
14
- export const recipeMetaConverter: FirestoreDataConverter<RecipeMeta> = {
15
- toFirestore(recipeMeta: RecipeMeta): DocumentData {
16
- const { id, createdAt, updatedAt, deletedAt, ...rest } = recipeMeta;
17
-
18
- const convertTimestamp = (ts: any) => {
19
- if (!ts) return ts;
20
- // Handle Firestore internal format with _seconds
21
- if (typeof ts === "object" && "_seconds" in ts) {
22
- return ts;
23
- }
24
- // Handle Firestore Timestamp objects with seconds/nanoseconds
25
- if (typeof ts === "object" && "seconds" in ts && "nanoseconds" in ts) {
26
- return fromTimestamp(ts);
27
- }
28
- return ts;
29
- };
30
-
31
- // Strip undefined values before returning to Firestore
32
- return stripUndefined({
33
- ...rest,
34
- createdAt: convertTimestamp(createdAt),
35
- updatedAt: convertTimestamp(updatedAt),
36
- ...(deletedAt && { deletedAt: convertTimestamp(deletedAt) }),
37
- });
38
- },
39
-
40
- fromFirestore(snapshot: QueryDocumentSnapshot): RecipeMeta {
41
- const data = snapshot.data();
42
-
43
- return {
44
- id: snapshot.id,
45
- allergens: data.allergens,
46
- confidence: data.confidence,
47
- createdBy: data.createdBy,
48
- cuisine: data.cuisine,
49
- dietaryTags: data.dietaryTags,
50
- difficulty: data.difficulty,
51
- equipment: data.equipment,
52
- imageUrl: data.imageUrl,
53
- ingredientSections: data.ingredientSections,
54
- instructions: data.instructions,
55
- mealTypes: data.mealTypes,
56
- nutrition: data.nutrition,
57
- originalLocale: data.originalLocale,
58
- servings: data.servings,
59
- source: data.source,
60
- sourceUrl: data.sourceUrl,
61
- spiciness: data.spiciness,
62
- status: data.status,
63
- time: data.time,
64
- createdAt: toTimestamp(data.createdAt),
65
- updatedAt: toTimestamp(data.updatedAt),
66
- deletedAt: toOptionalTimestamp(data.deletedAt),
67
- };
68
- },
69
- };
70
-
71
- export const recipeContentConverter: FirestoreDataConverter<RecipeContent> = {
72
- toFirestore(content: RecipeContent): DocumentData {
73
- // Strip undefined values before returning to Firestore
74
- return stripUndefined({
75
- description: content.description,
76
- equipment: content.equipment,
77
- ingredientSections: content.ingredientSections,
78
- instructions: content.instructions,
79
- locale: content.locale,
80
- tips: content.tips,
81
- title: content.title,
82
- });
83
- },
84
-
85
- fromFirestore(snapshot: QueryDocumentSnapshot): RecipeContent {
86
- const data = snapshot.data();
87
-
88
- return {
89
- description: data.description,
90
- equipment: data.equipment,
91
- ingredientSections: data.ingredientSections,
92
- instructions: data.instructions,
93
- locale: data.locale,
94
- tips: data.tips,
95
- title: data.title,
96
- };
97
- },
98
- };
1
+ import {
2
+ FirestoreDataConverter,
3
+ QueryDocumentSnapshot,
4
+ DocumentData,
5
+ } from "firebase-admin/firestore";
6
+ import type { RecipeMeta, RecipeContent } from "@cravery/core/types";
7
+ import {
8
+ toTimestamp,
9
+ toOptionalTimestamp,
10
+ fromTimestamp,
11
+ stripUndefined,
12
+ } from "../utils";
13
+
14
+ export const recipeMetaConverter: FirestoreDataConverter<RecipeMeta> = {
15
+ toFirestore(recipeMeta: RecipeMeta): DocumentData {
16
+ const { id, createdAt, updatedAt, deletedAt, ...rest } = recipeMeta;
17
+
18
+ const convertTimestamp = (ts: any) => {
19
+ if (!ts) return ts;
20
+ // Handle Firestore internal format with _seconds
21
+ if (typeof ts === "object" && "_seconds" in ts) {
22
+ return ts;
23
+ }
24
+ // Handle Firestore Timestamp objects with seconds/nanoseconds
25
+ if (typeof ts === "object" && "seconds" in ts && "nanoseconds" in ts) {
26
+ return fromTimestamp(ts);
27
+ }
28
+ return ts;
29
+ };
30
+
31
+ // Strip undefined values before returning to Firestore
32
+ return stripUndefined({
33
+ ...rest,
34
+ createdAt: convertTimestamp(createdAt),
35
+ updatedAt: convertTimestamp(updatedAt),
36
+ ...(deletedAt && { deletedAt: convertTimestamp(deletedAt) }),
37
+ });
38
+ },
39
+
40
+ fromFirestore(snapshot: QueryDocumentSnapshot): RecipeMeta {
41
+ const data = snapshot.data();
42
+
43
+ return {
44
+ id: snapshot.id,
45
+ allergens: data.allergens,
46
+ confidence: data.confidence,
47
+ createdBy: data.createdBy,
48
+ cuisine: data.cuisine,
49
+ dietaryTags: data.dietaryTags,
50
+ difficulty: data.difficulty,
51
+ equipment: data.equipment,
52
+ imageUrl: data.imageUrl,
53
+ ingredientSections: data.ingredientSections,
54
+ instructions: data.instructions,
55
+ mealTypes: data.mealTypes,
56
+ nutrition: data.nutrition,
57
+ originalLocale: data.originalLocale,
58
+ servings: data.servings,
59
+ source: data.source,
60
+ sourceUrl: data.sourceUrl,
61
+ spiciness: data.spiciness,
62
+ status: data.status,
63
+ time: data.time,
64
+ createdAt: toTimestamp(data.createdAt),
65
+ updatedAt: toTimestamp(data.updatedAt),
66
+ deletedAt: toOptionalTimestamp(data.deletedAt),
67
+ };
68
+ },
69
+ };
70
+
71
+ export const recipeContentConverter: FirestoreDataConverter<RecipeContent> = {
72
+ toFirestore(content: RecipeContent): DocumentData {
73
+ // Strip undefined values before returning to Firestore
74
+ return stripUndefined({
75
+ description: content.description,
76
+ equipment: content.equipment,
77
+ ingredientSections: content.ingredientSections,
78
+ instructions: content.instructions,
79
+ locale: content.locale,
80
+ tips: content.tips,
81
+ title: content.title,
82
+ });
83
+ },
84
+
85
+ fromFirestore(snapshot: QueryDocumentSnapshot): RecipeContent {
86
+ const data = snapshot.data();
87
+
88
+ return {
89
+ description: data.description,
90
+ equipment: data.equipment,
91
+ ingredientSections: data.ingredientSections,
92
+ instructions: data.instructions,
93
+ locale: data.locale,
94
+ tips: data.tips,
95
+ title: data.title,
96
+ };
97
+ },
98
+ };
@@ -1,148 +1,143 @@
1
- import { Recipe, RecipeContent, RecipeMeta } from "@cravery/core";
2
-
3
- export function mergeRecipe(meta: RecipeMeta, content: RecipeContent): Recipe {
4
- const equipment = meta.equipment?.map((equipMeta, index) => {
5
- const equipContent = content.equipment?.[index];
6
- if (!equipContent) {
7
- throw new Error(`Missing equipment content at index ${index}`);
8
- }
9
- return {
10
- ...equipMeta,
11
- ...equipContent,
12
- };
13
- });
14
-
15
- const ingredientSections = meta.ingredientSections.map(
16
- (sectionMeta, sectionIndex) => ({
17
- slug: sectionMeta.slug,
18
- title: content.ingredientSections[sectionIndex]?.title,
19
- ingredients: sectionMeta.ingredients.map((ingredMeta, ingredIndex) => ({
20
- ...ingredMeta,
21
- ...(content.ingredientSections[sectionIndex]?.ingredients[
22
- ingredIndex
23
- ] || {}),
24
- })),
25
- }),
26
- );
27
-
28
- const instructions = meta.instructions.map((instrMeta, index) => ({
29
- ...instrMeta,
30
- ...(content.instructions[index] || {}),
31
- }));
32
-
33
- return {
34
- id: meta.id,
35
- allergens: meta.allergens,
36
- confidence: meta.confidence,
37
- createdAt: meta.createdAt,
38
- createdBy: meta.createdBy,
39
- cuisine: meta.cuisine,
40
- deletedAt: meta.deletedAt,
41
- dietaryTags: meta.dietaryTags,
42
- difficulty: meta.difficulty,
43
- imageUrl: meta.imageUrl,
44
- mealTypes: meta.mealTypes,
45
- nutrition: meta.nutrition,
46
- originalLocale: meta.originalLocale,
47
- servings: meta.servings,
48
- source: meta.source,
49
- sourceUrl: meta.sourceUrl,
50
- spiciness: meta.spiciness,
51
- status: meta.status,
52
- time: meta.time,
53
- updatedAt: meta.updatedAt,
54
- // Video generation fields
55
- videoUrl: meta.videoUrl,
56
- videoGeneratedAt: meta.videoGeneratedAt,
57
- videoGenerationStatus: meta.videoGenerationStatus,
58
- videoGenerationError: meta.videoGenerationError,
59
- equipment,
60
- ingredientSections,
61
- instructions,
62
- description: content.description,
63
- locale: content.locale,
64
- tips: content.tips,
65
- title: content.title,
66
- };
67
- }
68
-
69
- export function splitRecipe(recipe: Recipe): {
70
- meta: Omit<RecipeMeta, "id">;
71
- content: RecipeContent;
72
- } {
73
- const {
74
- id,
75
- description,
76
- equipment,
77
- ingredientSections,
78
- instructions,
79
- locale,
80
- tips,
81
- title,
82
- ...metaFields
83
- } = recipe;
84
-
85
- const equipmentMeta = equipment?.map(({ required, slug }) => ({
86
- required,
87
- slug,
88
- }));
89
- const equipmentContent = equipment?.map(({ name, notes, slug }) => ({
90
- name,
91
- notes,
92
- slug,
93
- }));
94
-
95
- const ingredientSectionsMeta = ingredientSections.map(
96
- ({ ingredients, slug }) => ({
97
- slug,
98
- ingredients: ingredients.map(({ quantity, required, slug, unit }) => ({
99
- quantity,
100
- required,
101
- slug,
102
- unit,
103
- })),
104
- }),
105
- );
106
- const ingredientSectionsContent = ingredientSections.map(
107
- ({ ingredients, slug, title }) => ({
108
- slug,
109
- title,
110
- ingredients: ingredients.map(({ name, notes, slug }) => ({
111
- name,
112
- notes,
113
- slug,
114
- })),
115
- }),
116
- );
117
-
118
- const instructionsMeta = instructions.map(
119
- ({ duration, step, temperature }) => ({
120
- duration,
121
- step,
122
- temperature,
123
- }),
124
- );
125
- const instructionsContent = instructions.map(({ step, text }) => ({
126
- step,
127
- text,
128
- }));
129
-
130
- const content: RecipeContent = {
131
- description,
132
- equipment: equipmentContent,
133
- ingredientSections: ingredientSectionsContent,
134
- instructions: instructionsContent,
135
- locale,
136
- tips,
137
- title,
138
- };
139
-
140
- const meta = {
141
- ...metaFields,
142
- equipment: equipmentMeta,
143
- ingredientSections: ingredientSectionsMeta,
144
- instructions: instructionsMeta,
145
- };
146
-
147
- return { meta, content };
148
- }
1
+ import { Recipe, RecipeContent, RecipeMeta } from "@cravery/core";
2
+
3
+ export function mergeRecipe(meta: RecipeMeta, content: RecipeContent): Recipe {
4
+ const equipment = meta.equipment?.map((equipMeta, index) => {
5
+ const equipContent = content.equipment?.[index];
6
+ if (!equipContent) {
7
+ throw new Error(`Missing equipment content at index ${index}`);
8
+ }
9
+ return {
10
+ ...equipMeta,
11
+ ...equipContent,
12
+ };
13
+ });
14
+
15
+ const ingredientSections = meta.ingredientSections.map(
16
+ (sectionMeta, sectionIndex) => ({
17
+ slug: sectionMeta.slug,
18
+ title: content.ingredientSections[sectionIndex]?.title,
19
+ ingredients: sectionMeta.ingredients.map((ingredMeta, ingredIndex) => ({
20
+ ...ingredMeta,
21
+ ...(content.ingredientSections[sectionIndex]?.ingredients[
22
+ ingredIndex
23
+ ] || {}),
24
+ })),
25
+ }),
26
+ );
27
+
28
+ const instructions = meta.instructions.map((instrMeta, index) => ({
29
+ ...instrMeta,
30
+ ...(content.instructions[index] || {}),
31
+ }));
32
+
33
+ return {
34
+ id: meta.id,
35
+ allergens: meta.allergens,
36
+ confidence: meta.confidence,
37
+ createdAt: meta.createdAt,
38
+ createdBy: meta.createdBy,
39
+ cuisine: meta.cuisine,
40
+ deletedAt: meta.deletedAt,
41
+ dietaryTags: meta.dietaryTags,
42
+ difficulty: meta.difficulty,
43
+ imageUrl: meta.imageUrl,
44
+ mealTypes: meta.mealTypes,
45
+ nutrition: meta.nutrition,
46
+ originalLocale: meta.originalLocale,
47
+ servings: meta.servings,
48
+ source: meta.source,
49
+ sourceUrl: meta.sourceUrl,
50
+ spiciness: meta.spiciness,
51
+ status: meta.status,
52
+ time: meta.time,
53
+ updatedAt: meta.updatedAt,
54
+ equipment,
55
+ ingredientSections,
56
+ instructions,
57
+ description: content.description,
58
+ locale: content.locale,
59
+ tips: content.tips,
60
+ title: content.title,
61
+ };
62
+ }
63
+
64
+ export function splitRecipe(recipe: Recipe): {
65
+ meta: Omit<RecipeMeta, "id">;
66
+ content: RecipeContent;
67
+ } {
68
+ const {
69
+ id,
70
+ description,
71
+ equipment,
72
+ ingredientSections,
73
+ instructions,
74
+ locale,
75
+ tips,
76
+ title,
77
+ ...metaFields
78
+ } = recipe;
79
+
80
+ const equipmentMeta = equipment?.map(({ required, slug }) => ({
81
+ required,
82
+ slug,
83
+ }));
84
+ const equipmentContent = equipment?.map(({ name, notes, slug }) => ({
85
+ name,
86
+ notes,
87
+ slug,
88
+ }));
89
+
90
+ const ingredientSectionsMeta = ingredientSections.map(
91
+ ({ ingredients, slug }) => ({
92
+ slug,
93
+ ingredients: ingredients.map(({ quantity, required, slug, unit }) => ({
94
+ quantity,
95
+ required,
96
+ slug,
97
+ unit,
98
+ })),
99
+ }),
100
+ );
101
+ const ingredientSectionsContent = ingredientSections.map(
102
+ ({ ingredients, slug, title }) => ({
103
+ slug,
104
+ title,
105
+ ingredients: ingredients.map(({ name, notes, slug }) => ({
106
+ name,
107
+ notes,
108
+ slug,
109
+ })),
110
+ }),
111
+ );
112
+
113
+ const instructionsMeta = instructions.map(
114
+ ({ duration, step, temperature }) => ({
115
+ duration,
116
+ step,
117
+ temperature,
118
+ }),
119
+ );
120
+ const instructionsContent = instructions.map(({ step, text }) => ({
121
+ step,
122
+ text,
123
+ }));
124
+
125
+ const content: RecipeContent = {
126
+ description,
127
+ equipment: equipmentContent,
128
+ ingredientSections: ingredientSectionsContent,
129
+ instructions: instructionsContent,
130
+ locale,
131
+ tips,
132
+ title,
133
+ };
134
+
135
+ const meta = {
136
+ ...metaFields,
137
+ equipment: equipmentMeta,
138
+ ingredientSections: ingredientSectionsMeta,
139
+ instructions: instructionsMeta,
140
+ };
141
+
142
+ return { meta, content };
143
+ }