@elek-io/core 0.16.0 → 0.16.2

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.
@@ -39,7 +39,7 @@ var __exportAll = (all, no_symbols) => {
39
39
  //#region package.json
40
40
  var package_default = {
41
41
  name: "@elek-io/core",
42
- version: "0.16.0",
42
+ version: "0.16.2",
43
43
  description: "Handles core functionality of elek.io Projects like file IO and version control.",
44
44
  homepage: "https://elek.io",
45
45
  repository: "https://github.com/elek-io/core",
@@ -109,7 +109,7 @@ var package_default = {
109
109
  "@types/node": "24.12.0",
110
110
  "@types/semver": "7.7.1",
111
111
  "@vitest/coverage-v8": "4.0.18",
112
- "astro": "5.18.0",
112
+ "astro": "6.0.0-beta.20",
113
113
  "eslint": "10.0.3",
114
114
  "eslint-config-prettier": "10.1.8",
115
115
  "globals": "17.4.0",
@@ -120,7 +120,7 @@ var package_default = {
120
120
  "vitest": "4.0.18"
121
121
  },
122
122
  peerDependencies: {
123
- "astro": ">=5.0.0",
123
+ "astro": ">=6.0.0-beta.0",
124
124
  "dugite": "3.2.0"
125
125
  },
126
126
  peerDependenciesMeta: { "astro": { "optional": true } }
@@ -3726,6 +3726,34 @@ function buildEntryValuesSchema(fieldDefinitions) {
3726
3726
  }
3727
3727
  return z.object(shape);
3728
3728
  }
3729
+ /**
3730
+ * Generates a TypeScript type string from collection field definitions
3731
+ * for use with Astro's `createSchema` API.
3732
+ *
3733
+ * The generated string is written by Astro to a `.ts` file and imported
3734
+ * as the `Entry` type for the collection.
3735
+ */
3736
+ function buildEntryValuesTypeString(fieldDefinitions) {
3737
+ if (fieldDefinitions.length === 0) return "export type Entry = Record<string, never>;";
3738
+ return [
3739
+ `type SupportedLanguage = "bg" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "hu" | "it" | "ja" | "ko" | "lt" | "lv" | "nb" | "nl" | "pl" | "pt" | "ro" | "ru" | "sk" | "sl" | "sv" | "tr" | "uk" | "zh";`,
3740
+ `export type Entry = {`,
3741
+ fieldDefinitions.map((fieldDef) => {
3742
+ const tsType = valueTypeToTsType(fieldDef.valueType);
3743
+ return ` "${fieldDef.id}": Partial<Record<SupportedLanguage, ${tsType}>>`;
3744
+ }).join(";\n") + ";",
3745
+ `};`
3746
+ ].join("\n");
3747
+ }
3748
+ function valueTypeToTsType(valueType) {
3749
+ switch (valueType) {
3750
+ case "string": return "string";
3751
+ case "number": return "number";
3752
+ case "boolean": return "boolean";
3753
+ case "reference": return "Array<{ id: string; objectType: string }>";
3754
+ default: return "unknown";
3755
+ }
3756
+ }
3729
3757
 
3730
3758
  //#endregion
3731
3759
  //#region src/astro/transform.ts
@@ -3768,7 +3796,7 @@ const core = new ElekIoCore({ log: { level: "info" } });
3768
3796
  function elekAssets(props) {
3769
3797
  return {
3770
3798
  name: "elek-assets",
3771
- schema: () => assetSchema,
3799
+ schema: assetSchema,
3772
3800
  load: async (context) => {
3773
3801
  context.logger.info(`Loading elek.io Assets for Project "${props.projectId}", saving to "${props.outDir}"`);
3774
3802
  context.store.clear();
@@ -3827,11 +3855,15 @@ function elekAssets(props) {
3827
3855
  function elekEntries(props) {
3828
3856
  return {
3829
3857
  name: "elek-entries",
3830
- schema: async () => {
3831
- return buildEntryValuesSchema((await core.collections.read({
3858
+ createSchema: async () => {
3859
+ const collection = await core.collections.read({
3832
3860
  projectId: props.projectId,
3833
3861
  id: props.collectionId
3834
- })).fieldDefinitions);
3862
+ });
3863
+ return {
3864
+ schema: buildEntryValuesSchema(collection.fieldDefinitions),
3865
+ types: buildEntryValuesTypeString(collection.fieldDefinitions)
3866
+ };
3835
3867
  },
3836
3868
  load: async (context) => {
3837
3869
  context.logger.info(`Loading elek.io Entries of Collection "${props.collectionId}" and Project "${props.projectId}"`);