astro-loader-pocketbase 3.0.1 → 3.1.0-next.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-loader-pocketbase",
3
- "version": "3.0.1",
3
+ "version": "3.1.0-next.2",
4
4
  "description": "A content loader for Astro that uses the PocketBase API",
5
5
  "keywords": [
6
6
  "astro",
@@ -50,20 +50,20 @@
50
50
  "@commitlint/cli": "20.5.0",
51
51
  "@commitlint/config-conventional": "20.5.0",
52
52
  "@types/node": "24.10.1",
53
- "@vitest/coverage-v8": "4.1.3",
54
- "astro": "6.1.5",
55
- "globals": "17.4.0",
53
+ "@vitest/coverage-v8": "4.1.5",
54
+ "astro": "6.1.9",
55
+ "globals": "17.5.0",
56
56
  "husky": "9.1.7",
57
57
  "lint-staged": "16.4.0",
58
- "oxfmt": "0.44.0",
59
- "oxlint": "1.59.0",
60
- "oxlint-tsgolint": "0.20.0",
61
- "vitest": "4.1.3",
58
+ "oxfmt": "0.46.0",
59
+ "oxlint": "1.61.0",
60
+ "oxlint-tsgolint": "0.21.1",
61
+ "vitest": "4.1.5",
62
62
  "zod-to-ts": "2.0.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "astro": "^6.0.0",
66
66
  "zod-to-ts": "^2.0.0"
67
67
  },
68
- "packageManager": "npm@11.12.1"
68
+ "packageManager": "npm@11.13.0"
69
69
  }
@@ -13,9 +13,19 @@ import { transformFiles } from "./transform-files";
13
13
  * Basic schema for every PocketBase collection.
14
14
  */
15
15
  const BASIC_SCHEMA = z.object({
16
- id: z.string(),
17
- collectionId: z.string(),
18
- collectionName: z.string()
16
+ id: z.string().meta({
17
+ title: "id",
18
+ description: "The unique identifier for the entry."
19
+ }),
20
+ collectionId: z.string().meta({
21
+ title: "collectionId",
22
+ description:
23
+ "The unique identifier for the collection the entity belongs to."
24
+ }),
25
+ collectionName: z.string().meta({
26
+ title: "collectionName",
27
+ description: "The name of the collection the entity belongs to."
28
+ })
19
29
  });
20
30
 
21
31
  /**
@@ -45,7 +45,6 @@ export function parseSchema(
45
45
  let fieldType: z.ZodType;
46
46
 
47
47
  // Determine the field type and create the corresponding Zod type
48
- // oxlint-disable-next-line switch-exhaustiveness-check
49
48
  switch (field.type) {
50
49
  case "number":
51
50
  fieldType = z.number();
@@ -120,7 +119,11 @@ export function parseSchema(
120
119
  }
121
120
 
122
121
  // Add the field to the fields object
123
- fields[field.name] = fieldType;
122
+ fields[field.name] = fieldType.meta({
123
+ id: field.id,
124
+ title: field.name,
125
+ description: getFieldDescription(field)
126
+ });
124
127
  }
125
128
 
126
129
  return fields;
@@ -145,3 +148,23 @@ function parseSingleOrMultipleValues(
145
148
 
146
149
  return z.array(type);
147
150
  }
151
+
152
+ /**
153
+ * Get the description for a field based on its help text and type.
154
+ */
155
+ function getFieldDescription(field: PocketBaseSchemaEntry): string | undefined {
156
+ switch (true) {
157
+ case !!field.help:
158
+ return field.help;
159
+ case field.type === "autodate" && field.onUpdate:
160
+ return "Date when the entry was last updated. This field is automatically updated by PocketBase whenever the entry is updated.";
161
+ case field.type === "autodate" && field.onCreate:
162
+ return "Date when the entry was created. This field is automatically set by PocketBase when the entry is created.";
163
+ case field.name === "id":
164
+ return "The unique identifier for the entry.";
165
+ case field.hidden:
166
+ return "This field is hidden and may require superuser credentials to access.";
167
+ default:
168
+ return undefined;
169
+ }
170
+ }
@@ -9,10 +9,19 @@ export const pocketBaseSchemaEntry = z.object({
9
9
  * Hidden fields are not returned in the API response.
10
10
  */
11
11
  hidden: z.optional(z.boolean()),
12
+ /**
13
+ * Unique identifier for the field.
14
+ */
15
+ id: z.string(),
12
16
  /**
13
17
  * Name of the field.
14
18
  */
15
19
  name: z.string(),
20
+ /**
21
+ * Help text for the field.
22
+ * This is only present if the field has help text defined.
23
+ */
24
+ help: z.optional(z.string()),
16
25
  /**
17
26
  * Type of the field.
18
27
  */