@cravery/firebase 0.0.5 → 0.0.7
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/asset/index.d.ts +2 -0
- package/dist/asset/index.d.ts.map +1 -0
- package/dist/asset/index.js +18 -0
- package/dist/asset/index.js.map +1 -0
- package/dist/asset/repository.d.ts +37 -0
- package/dist/asset/repository.d.ts.map +1 -0
- package/dist/asset/repository.js +77 -0
- package/dist/asset/repository.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/recipe/converters.d.ts.map +1 -1
- package/dist/recipe/converters.js +0 -5
- package/dist/recipe/converters.js.map +1 -1
- package/dist/recipe/utils.d.ts.map +1 -1
- package/dist/recipe/utils.js +0 -5
- package/dist/recipe/utils.js.map +1 -1
- package/package.json +59 -60
- package/src/asset/index.ts +1 -0
- package/src/asset/repository.ts +111 -0
- package/src/index.ts +1 -0
- package/src/recipe/converters.ts +98 -103
- package/src/recipe/utils.ts +143 -148
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/asset/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./repository"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/asset/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Firestore } from "firebase-admin/firestore";
|
|
2
|
+
import { Asset } from "@cravery/core";
|
|
3
|
+
export declare class AssetRepository {
|
|
4
|
+
private db;
|
|
5
|
+
private collectionName;
|
|
6
|
+
constructor(db: Firestore, collectionName: string);
|
|
7
|
+
private get collection();
|
|
8
|
+
findById(id: string): Promise<Asset | null>;
|
|
9
|
+
exists(id: string): Promise<boolean>;
|
|
10
|
+
slugExists(slug: string): Promise<boolean>;
|
|
11
|
+
update(slug: string, data: Partial<Asset>): Promise<void>;
|
|
12
|
+
getLocale(slug: string, locale: string): Promise<{
|
|
13
|
+
locale: string;
|
|
14
|
+
name: string;
|
|
15
|
+
notes?: string;
|
|
16
|
+
} | null>;
|
|
17
|
+
setLocale(slug: string, locale: string, data: {
|
|
18
|
+
name: string;
|
|
19
|
+
notes?: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
getAllLocales(slug: string): Promise<{
|
|
22
|
+
locale: string;
|
|
23
|
+
name: string;
|
|
24
|
+
notes?: string;
|
|
25
|
+
}[]>;
|
|
26
|
+
createWithLocale(slug: string, imageUrl: string, locale: string, localeData: {
|
|
27
|
+
name: string;
|
|
28
|
+
notes?: string;
|
|
29
|
+
}): Promise<Asset>;
|
|
30
|
+
}
|
|
31
|
+
export declare class IngredientRepository extends AssetRepository {
|
|
32
|
+
constructor(db: Firestore);
|
|
33
|
+
}
|
|
34
|
+
export declare class EquipmentRepository extends AssetRepository {
|
|
35
|
+
constructor(db: Firestore);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../../src/asset/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,qBAAa,eAAe;IAExB,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,cAAc;gBADd,EAAE,EAAE,SAAS,EACb,cAAc,EAAE,MAAM;IAGhC,OAAO,KAAK,UAAU,GAErB;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAM3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKpC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzD,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAW7D,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACrC,OAAO,CAAC,IAAI,CAAC;IAKV,aAAa,CACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAcxD,gBAAgB,CACpB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3C,OAAO,CAAC,KAAK,CAAC;CAmBlB;AAED,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,EAAE,EAAE,SAAS;CAG1B;AAED,qBAAa,mBAAoB,SAAQ,eAAe;gBAC1C,EAAE,EAAE,SAAS;CAG1B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EquipmentRepository = exports.IngredientRepository = exports.AssetRepository = void 0;
|
|
4
|
+
const firestore_1 = require("firebase-admin/firestore");
|
|
5
|
+
class AssetRepository {
|
|
6
|
+
constructor(db, collectionName) {
|
|
7
|
+
this.db = db;
|
|
8
|
+
this.collectionName = collectionName;
|
|
9
|
+
}
|
|
10
|
+
get collection() {
|
|
11
|
+
return this.db.collection(this.collectionName);
|
|
12
|
+
}
|
|
13
|
+
async findById(id) {
|
|
14
|
+
const doc = await this.collection.doc(id).get();
|
|
15
|
+
if (!doc.exists)
|
|
16
|
+
return null;
|
|
17
|
+
return doc.data();
|
|
18
|
+
}
|
|
19
|
+
async exists(id) {
|
|
20
|
+
const doc = await this.collection.doc(id).get();
|
|
21
|
+
return doc.exists;
|
|
22
|
+
}
|
|
23
|
+
async slugExists(slug) {
|
|
24
|
+
return this.exists(slug);
|
|
25
|
+
}
|
|
26
|
+
async update(slug, data) {
|
|
27
|
+
await this.collection.doc(slug).update(Object.assign(Object.assign({}, data), { updatedAt: firestore_1.Timestamp.now() }));
|
|
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.db.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.AssetRepository = AssetRepository;
|
|
65
|
+
class IngredientRepository extends AssetRepository {
|
|
66
|
+
constructor(db) {
|
|
67
|
+
super(db, "ingredients");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.IngredientRepository = IngredientRepository;
|
|
71
|
+
class EquipmentRepository extends AssetRepository {
|
|
72
|
+
constructor(db) {
|
|
73
|
+
super(db, "equipment");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.EquipmentRepository = EquipmentRepository;
|
|
77
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/asset/repository.ts"],"names":[],"mappings":";;;AAAA,wDAAgE;AAGhE,MAAa,eAAe;IAC1B,YACU,EAAa,EACb,cAAsB;QADtB,OAAE,GAAF,EAAE,CAAW;QACb,mBAAc,GAAd,cAAc,CAAQ;IAC7B,CAAC;IAEJ,IAAY,UAAU;QACpB,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;QAChD,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QAC7B,OAAO,GAAG,CAAC,IAAI,EAAW,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;QAChD,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,IAAoB;QAC7C,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,iCACjC,IAAI,KACP,SAAS,EAAE,qBAAS,CAAC,GAAG,EAAE,IAC1B,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CACb,IA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AAC,IAAI,CAAC,CAAC;QACzC,MAAM,SAAS,GAAU;YACvB,EAAE,EAAE,IAAI;YACR,QAAQ;YACR,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;SACf,CAAC;QACF,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAE7B,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3D,KAAK,CAAC,GAAG,CAAC,SAAS,kBAAI,MAAM,IAAK,UAAU,EAAG,CAAC;QAEhD,MAAM,KAAK,CAAC,MAAM,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA/FD,0CA+FC;AAED,MAAa,oBAAqB,SAAQ,eAAe;IACvD,YAAY,EAAa;QACvB,KAAK,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAC3B,CAAC;CACF;AAJD,oDAIC;AAED,MAAa,mBAAoB,SAAQ,eAAe;IACtD,YAAY,EAAa;QACvB,KAAK,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IACzB,CAAC;CACF;AAJD,kDAIC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ 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("./asset"), exports);
|
|
17
18
|
__exportStar(require("./iam"), exports);
|
|
18
19
|
__exportStar(require("./recipe"), exports);
|
|
19
20
|
__exportStar(require("./utils"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,wCAAsB;AACtB,2CAAyB;AACzB,0CAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../src/recipe/converters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAGvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQrE,eAAO,MAAM,mBAAmB,EAAE,sBAAsB,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../src/recipe/converters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAGvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQrE,eAAO,MAAM,mBAAmB,EAAE,sBAAsB,CAAC,UAAU,CAuDlE,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBAAsB,CAAC,aAAa,CA2BxE,CAAC"}
|
|
@@ -58,11 +58,6 @@ exports.recipeMetaConverter = {
|
|
|
58
58
|
createdAt: (0, utils_1.toTimestamp)(data.createdAt),
|
|
59
59
|
updatedAt: (0, utils_1.toTimestamp)(data.updatedAt),
|
|
60
60
|
deletedAt: (0, utils_1.toOptionalTimestamp)(data.deletedAt),
|
|
61
|
-
// Video generation fields
|
|
62
|
-
videoUrl: data.videoUrl,
|
|
63
|
-
videoGeneratedAt: (0, utils_1.toOptionalTimestamp)(data.videoGeneratedAt),
|
|
64
|
-
videoGenerationStatus: data.videoGenerationStatus,
|
|
65
|
-
videoGenerationError: data.videoGenerationError,
|
|
66
61
|
};
|
|
67
62
|
},
|
|
68
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../../src/recipe/converters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,oCAKkB;AAEL,QAAA,mBAAmB,GAAuC;IACrE,WAAW,CAAC,UAAsB;QAChC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,KAAc,UAAU,EAAnB,IAAI,UAAK,UAAU,EAA7D,6CAAgD,CAAa,CAAC;QAEpE,MAAM,gBAAgB,GAAG,CAAC,EAAO,EAAE,EAAE;YACnC,IAAI,CAAC,EAAE;gBAAE,OAAO,EAAE,CAAC;YACnB,iDAAiD;YACjD,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,UAAU,IAAI,EAAE,EAAE,CAAC;gBAC/C,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,8DAA8D;YAC9D,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,SAAS,IAAI,EAAE,IAAI,aAAa,IAAI,EAAE,EAAE,CAAC;gBACrE,OAAO,IAAA,qBAAa,EAAC,EAAE,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,uDAAuD;QACvD,OAAO,IAAA,sBAAc,gDAChB,IAAI,KACP,SAAS,EAAE,gBAAgB,CAAC,SAAS,CAAC,EACtC,SAAS,EAAE,gB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AS,EAAE,IAAI,CAAC,SAAS;YACzB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -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,
|
|
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"}
|
package/dist/recipe/utils.js
CHANGED
|
@@ -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,
|
package/dist/recipe/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/recipe/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/recipe/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,kCA2DC;AAED,kCA+EC;AA5ID,SAAgB,WAAW,CAAC,IAAgB,EAAE,OAAsB;;IAClE,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE;;QACzD,MAAM,YAAY,GAAG,MAAA,OAAO,CAAC,SAAS,0CAAG,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,uCACK,SAAS,GACT,YAAY,EACf;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,GAAG,CACpD,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE;;QAAC,OAAA,CAAC;YAC9B,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,KAAK,EAAE,MAAA,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,0CAAE,KAAK;YACtD,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE;;gBAAC,OAAA,iCACjE,UAAU,GACV,CAAC,CAAA,MAAA,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,0CAAE,WAAW,CACvD,WAAW,CACZ,KAAI,EAAE,CAAC,EACR,CAAA;aAAA,CAAC;SACJ,CAAC,CAAA;KAAA,CACH,CAAC;IAEF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AAE,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
|
-
"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.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@cravery/firebase",
|
|
3
|
+
"version": "0.0.7",
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./repository";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Firestore, Timestamp } from "firebase-admin/firestore";
|
|
2
|
+
import { Asset } from "@cravery/core";
|
|
3
|
+
|
|
4
|
+
export class AssetRepository {
|
|
5
|
+
constructor(
|
|
6
|
+
private db: Firestore,
|
|
7
|
+
private collectionName: string,
|
|
8
|
+
) {}
|
|
9
|
+
|
|
10
|
+
private get collection() {
|
|
11
|
+
return this.db.collection(this.collectionName);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async findById(id: string): Promise<Asset | null> {
|
|
15
|
+
const doc = await this.collection.doc(id).get();
|
|
16
|
+
if (!doc.exists) return null;
|
|
17
|
+
return doc.data() as Asset;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async exists(id: string): Promise<boolean> {
|
|
21
|
+
const doc = await this.collection.doc(id).get();
|
|
22
|
+
return doc.exists;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async slugExists(slug: string): Promise<boolean> {
|
|
26
|
+
return this.exists(slug);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async update(slug: string, data: Partial<Asset>): Promise<void> {
|
|
30
|
+
await this.collection.doc(slug).update({
|
|
31
|
+
...data,
|
|
32
|
+
updatedAt: Timestamp.now(),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async getLocale(
|
|
37
|
+
slug: string,
|
|
38
|
+
locale: string,
|
|
39
|
+
): Promise<{ locale: string; name: string; notes?: string } | null> {
|
|
40
|
+
const docRef = this.collection.doc(slug).collection("locales").doc(locale);
|
|
41
|
+
const doc = await docRef.get();
|
|
42
|
+
if (!doc.exists) return null;
|
|
43
|
+
return { locale, ...doc.data() } as {
|
|
44
|
+
locale: string;
|
|
45
|
+
name: string;
|
|
46
|
+
notes?: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async setLocale(
|
|
51
|
+
slug: string,
|
|
52
|
+
locale: string,
|
|
53
|
+
data: { name: string; notes?: string },
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const docRef = this.collection.doc(slug).collection("locales").doc(locale);
|
|
56
|
+
await docRef.set({ locale, ...data });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getAllLocales(
|
|
60
|
+
slug: string,
|
|
61
|
+
): Promise<{ locale: string; name: string; notes?: string }[]> {
|
|
62
|
+
const snapshot = await this.collection
|
|
63
|
+
.doc(slug)
|
|
64
|
+
.collection("locales")
|
|
65
|
+
.get();
|
|
66
|
+
return snapshot.docs.map(
|
|
67
|
+
(doc) =>
|
|
68
|
+
({
|
|
69
|
+
locale: doc.id,
|
|
70
|
+
...doc.data(),
|
|
71
|
+
}) as { locale: string; name: string; notes?: string },
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async createWithLocale(
|
|
76
|
+
slug: string,
|
|
77
|
+
imageUrl: string,
|
|
78
|
+
locale: string,
|
|
79
|
+
localeData: { name: string; notes?: string },
|
|
80
|
+
): Promise<Asset> {
|
|
81
|
+
const now = Timestamp.now();
|
|
82
|
+
const batch = this.db.batch();
|
|
83
|
+
|
|
84
|
+
const docRef = this.collection.doc(slug);
|
|
85
|
+
const assetData: Asset = {
|
|
86
|
+
id: slug,
|
|
87
|
+
imageUrl,
|
|
88
|
+
createdAt: now,
|
|
89
|
+
updatedAt: now,
|
|
90
|
+
};
|
|
91
|
+
batch.set(docRef, assetData);
|
|
92
|
+
|
|
93
|
+
const localeRef = docRef.collection("locales").doc(locale);
|
|
94
|
+
batch.set(localeRef, { locale, ...localeData });
|
|
95
|
+
|
|
96
|
+
await batch.commit();
|
|
97
|
+
return assetData;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class IngredientRepository extends AssetRepository {
|
|
102
|
+
constructor(db: Firestore) {
|
|
103
|
+
super(db, "ingredients");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class EquipmentRepository extends AssetRepository {
|
|
108
|
+
constructor(db: Firestore) {
|
|
109
|
+
super(db, "equipment");
|
|
110
|
+
}
|
|
111
|
+
}
|
package/src/index.ts
CHANGED
package/src/recipe/converters.ts
CHANGED
|
@@ -1,103 +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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
tips: data.tips,
|
|
100
|
-
title: data.title,
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
};
|
|
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
|
+
};
|
package/src/recipe/utils.ts
CHANGED
|
@@ -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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
slug,
|
|
88
|
-
}));
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
}
|