@contedra/core 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 contedra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # @contedra/core
2
+
3
+ Core library for the Contedra toolkit — Firebase connection, Conteditor model parsing, and Zod schema generation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @contedra/core
9
+ ```
10
+
11
+ ## API
12
+
13
+ ### `loadModel(filePath: string): ModelDefinition`
14
+
15
+ Loads a Conteditor model definition from a JSON file.
16
+
17
+ ### `buildSchema(properties: ModelProperty[], bodyField?: string): ZodObject`
18
+
19
+ Builds a Zod validation schema from model properties. Excludes the `bodyField` property (handled separately by Astro).
20
+
21
+ ### `dataTypeToZod(property: ModelProperty): ZodType`
22
+
23
+ Converts a single model property to its corresponding Zod schema type.
24
+
25
+ ### `detectBodyField(model: ModelDefinition, explicitBodyField?: string): string | undefined`
26
+
27
+ Auto-detects the markdown body field from model properties by looking for `fieldType.element: "markdown"`. If `explicitBodyField` is provided, validates that it exists in the model.
28
+
29
+ ### `initFirestore(config: FirebaseConfig): Firestore`
30
+
31
+ Initializes Firebase Admin SDK and returns a Firestore instance.
32
+
33
+ ### `fetchDocuments(firestore: Firestore, collectionName: string): Promise<DocumentData[]>`
34
+
35
+ Fetches all documents from a Firestore collection.
36
+
37
+ ### `transformDocumentData(data: Record<string, unknown>, model: ModelDefinition, bodyField?: string): Record<string, unknown>`
38
+
39
+ Converts Firestore document data to proper JS types (Timestamps to Dates, etc.).
40
+
41
+ ## Types
42
+
43
+ ```typescript
44
+ interface ModelDefinition {
45
+ id: string;
46
+ modelName: string;
47
+ properties: ModelProperty[];
48
+ }
49
+
50
+ interface ModelProperty {
51
+ propertyName: string;
52
+ dataType: "string" | "datetime" | "relatedOne" | "relatedMany";
53
+ fieldType?: { element?: string };
54
+ require?: boolean;
55
+ defaultValue?: unknown;
56
+ relatedModel?: string;
57
+ }
58
+
59
+ interface FirebaseConfig {
60
+ projectId: string;
61
+ credential?: string; // Path to service account JSON
62
+ }
63
+ ```
64
+
65
+ ## License
66
+
67
+ MIT
@@ -0,0 +1,11 @@
1
+ import type { FirebaseConfig, ModelDefinition } from "./types.js";
2
+ export declare function initFirestore(config: FirebaseConfig): FirebaseFirestore.Firestore;
3
+ export declare function fetchDocuments(firestore: FirebaseFirestore.Firestore, collectionName: string): Promise<Array<{
4
+ id: string;
5
+ data: Record<string, unknown>;
6
+ }>>;
7
+ export declare function transformDocumentData(data: Record<string, unknown>, model: ModelDefinition, bodyField?: string): {
8
+ data: Record<string, unknown>;
9
+ body?: string;
10
+ };
11
+ //# sourceMappingURL=firestore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../src/firestore.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,+BAenD;AAED,wBAAsB,cAAc,CAClC,SAAS,EAAE,iBAAiB,CAAC,SAAS,EACtC,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAAC,CAM/D;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,eAAe,EACtB,SAAS,CAAC,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAgBlD"}
@@ -0,0 +1,61 @@
1
+ import { cert, getApps, initializeApp } from "firebase-admin/app";
2
+ import { getFirestore, Timestamp } from "firebase-admin/firestore";
3
+ export function initFirestore(config) {
4
+ const appName = `contedra-${config.projectId}`;
5
+ const existingApp = getApps().find((app) => app.name === appName);
6
+ const app = existingApp ??
7
+ initializeApp({
8
+ projectId: config.projectId,
9
+ ...(config.credential ? { credential: cert(config.credential) } : {}),
10
+ }, appName);
11
+ return getFirestore(app);
12
+ }
13
+ export async function fetchDocuments(firestore, collectionName) {
14
+ const snapshot = await firestore.collection(collectionName).get();
15
+ return snapshot.docs.map((doc) => ({
16
+ id: doc.id,
17
+ data: doc.data(),
18
+ }));
19
+ }
20
+ export function transformDocumentData(data, model, bodyField) {
21
+ const result = {};
22
+ let body;
23
+ for (const prop of model.properties) {
24
+ const value = data[prop.propertyName];
25
+ if (prop.propertyName === bodyField) {
26
+ body = value != null ? String(value) : undefined;
27
+ continue;
28
+ }
29
+ result[prop.propertyName] = convertValue(value, prop.dataType);
30
+ }
31
+ return { data: result, body };
32
+ }
33
+ function convertValue(value, dataType) {
34
+ if (value == null)
35
+ return undefined;
36
+ switch (dataType) {
37
+ case "datetime":
38
+ if (value instanceof Timestamp) {
39
+ return value.toDate();
40
+ }
41
+ return value;
42
+ case "relatedOne":
43
+ if (typeof value === "object" && value !== null && "id" in value) {
44
+ return value.id;
45
+ }
46
+ return String(value);
47
+ case "relatedMany":
48
+ if (Array.isArray(value)) {
49
+ return value.map((v) => {
50
+ if (typeof v === "object" && v !== null && "id" in v) {
51
+ return v.id;
52
+ }
53
+ return String(v);
54
+ });
55
+ }
56
+ return [];
57
+ default:
58
+ return value;
59
+ }
60
+ }
61
+ //# sourceMappingURL=firestore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"firestore.js","sourceRoot":"","sources":["../src/firestore.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,5 @@
1
+ export { loadModel, detectBodyField } from "./model.js";
2
+ export { buildSchema, dataTypeToZod } from "./schema.js";
3
+ export { initFirestore, fetchDocuments, transformDocumentData } from "./firestore.js";
4
+ export type { ModelDefinition, ModelProperty, FirebaseConfig } from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACtF,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { loadModel, detectBodyField } from "./model.js";
2
+ export { buildSchema, dataTypeToZod } from "./schema.js";
3
+ export { initFirestore, fetchDocuments, transformDocumentData } from "./firestore.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { ModelDefinition } from "./types.js";
2
+ export declare function loadModel(filePath: string): Promise<ModelDefinition>;
3
+ export declare function detectBodyField(model: ModelDefinition, explicitBodyField?: string): string | undefined;
4
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAW1E;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,GAAG,SAAS,CAiBpB"}
package/dist/model.js ADDED
@@ -0,0 +1,21 @@
1
+ import { readFile } from "node:fs/promises";
2
+ export async function loadModel(filePath) {
3
+ const raw = await readFile(filePath, "utf-8");
4
+ const model = JSON.parse(raw);
5
+ if (!model.modelName || !Array.isArray(model.properties)) {
6
+ throw new Error(`Invalid model definition: must have "modelName" and "properties"`);
7
+ }
8
+ return model;
9
+ }
10
+ export function detectBodyField(model, explicitBodyField) {
11
+ if (explicitBodyField) {
12
+ const prop = model.properties.find((p) => p.propertyName === explicitBodyField);
13
+ if (!prop) {
14
+ throw new Error(`bodyField "${explicitBodyField}" not found in model "${model.modelName}"`);
15
+ }
16
+ return explicitBodyField;
17
+ }
18
+ const markdownProp = model.properties.find((p) => p.fieldType?.element === "markdown");
19
+ return markdownProp?.propertyName;
20
+ }
21
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB;IAC9C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAoB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE/C,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,KAAsB,EACtB,iBAA0B;IAE1B,IAAI,iBAAiB,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAChC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,iBAAiB,CAC5C,CAAC;QACF,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CACb,cAAc,iBAAiB,yBAAyB,KAAK,CAAC,SAAS,GAAG,CAC3E,CAAC;QACJ,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CACxC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,OAAO,KAAK,UAAU,CAC3C,CAAC;IACF,OAAO,YAAY,EAAE,YAAY,CAAC;AACpC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { z, type ZodTypeAny } from "zod";
2
+ import type { ModelProperty } from "./types.js";
3
+ export declare function dataTypeToZod(property: ModelProperty): ZodTypeAny;
4
+ export declare function buildSchema(properties: ModelProperty[], bodyField?: string): z.ZodObject<Record<string, ZodTypeAny>>;
5
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,GAAG,UAAU,CAyBjE;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,aAAa,EAAE,EAC3B,SAAS,CAAC,EAAE,MAAM,GACjB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CASzC"}
package/dist/schema.js ADDED
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ export function dataTypeToZod(property) {
3
+ let schema;
4
+ switch (property.dataType) {
5
+ case "string":
6
+ schema = z.string();
7
+ break;
8
+ case "datetime":
9
+ schema = z.coerce.date();
10
+ break;
11
+ case "relatedOne":
12
+ schema = z.string();
13
+ break;
14
+ case "relatedMany":
15
+ schema = z.array(z.string());
16
+ break;
17
+ default:
18
+ schema = z.unknown();
19
+ }
20
+ if (!property.require) {
21
+ schema = schema.optional();
22
+ }
23
+ return schema;
24
+ }
25
+ export function buildSchema(properties, bodyField) {
26
+ const shape = {};
27
+ for (const prop of properties) {
28
+ if (prop.propertyName === bodyField)
29
+ continue;
30
+ shape[prop.propertyName] = dataTypeToZod(prop);
31
+ }
32
+ return z.object(shape);
33
+ }
34
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAmB,MAAM,KAAK,CAAC;AAGzC,MAAM,UAAU,aAAa,CAAC,QAAuB;IACnD,IAAI,MAAkB,CAAC;IAEvB,QAAQ,QAAQ,CAAC,QAAQ,EAAE,CAAC;QAC1B,KAAK,QAAQ;YACX,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM;QACR,KAAK,UAAU;YACb,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACzB,MAAM;QACR,KAAK,YAAY;YACf,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM;QACR,KAAK,aAAa;YAChB,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7B,MAAM;QACR;YACE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtB,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,UAA2B,EAC3B,SAAkB;IAElB,MAAM,KAAK,GAA+B,EAAE,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;QAC9B,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;YAAE,SAAS;QAC9C,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,21 @@
1
+ export interface ModelProperty {
2
+ propertyName: string;
3
+ dataType: "string" | "datetime" | "relatedOne" | "relatedMany";
4
+ fieldType?: {
5
+ element: string;
6
+ };
7
+ require?: boolean;
8
+ defaultValue?: string;
9
+ relatedModel?: string;
10
+ }
11
+ export interface ModelDefinition {
12
+ id: string;
13
+ modelName: string;
14
+ properties: ModelProperty[];
15
+ }
16
+ export interface FirebaseConfig {
17
+ projectId: string;
18
+ /** Path to service account JSON (uses Application Default Credentials if omitted) */
19
+ credential?: string;
20
+ }
21
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,aAAa,CAAC;IAC/D,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@contedra/core",
3
+ "version": "0.1.0",
4
+ "description": "Core library for Contedra toolkit — Firebase connection, model parsing, and schema generation",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "conteditor",
19
+ "firestore",
20
+ "firebase"
21
+ ],
22
+ "author": "Contedra",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/contedra/toolkit",
27
+ "directory": "packages/core"
28
+ },
29
+ "dependencies": {
30
+ "firebase-admin": "^13.0.0",
31
+ "zod": "^3.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "oxlint": "^1.57.0",
35
+ "typescript": "^5.7.0",
36
+ "vitest": "^3.0.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "test": "vitest run",
41
+ "lint": "oxlint src"
42
+ }
43
+ }