astro-loader-pocketbase 2.5.0 → 2.6.0-next.1

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": "2.5.0",
3
+ "version": "2.6.0-next.1",
4
4
  "description": "A content loader for Astro that uses the PocketBase API",
5
5
  "keywords": [
6
6
  "astro",
@@ -32,9 +32,21 @@ export async function cleanupEntries(
32
32
 
33
33
  // Fetch all ids of the collection
34
34
  do {
35
+ // Build search parameters
36
+ const searchParams = new URLSearchParams({
37
+ page: `${++page}`,
38
+ perPage: "1000",
39
+ fields: "id"
40
+ });
41
+
42
+ if (options.filter) {
43
+ // If a filter is set, add it to the search parameters
44
+ searchParams.set("filter", `(${options.filter})`);
45
+ }
46
+
35
47
  // Fetch ids from the collection
36
48
  const collectionRequest = await fetch(
37
- `${collectionUrl}?page=${++page}&perPage=1000&fields=id`,
49
+ `${collectionUrl}?${searchParams.toString()}`,
38
50
  {
39
51
  headers: collectionHeaders
40
52
  }
@@ -47,14 +59,17 @@ export async function cleanupEntries(
47
59
  context.logger.error(
48
60
  `The collection is not accessible without superuser rights. Please provide superuser credentials in the config.`
49
61
  );
50
- return;
62
+ } else {
63
+ const reason = await collectionRequest
64
+ .json()
65
+ .then((data) => data.message);
66
+ const errorMessage = `Fetching ids failed with status code ${collectionRequest.status}.\nReason: ${reason}`;
67
+ context.logger.error(errorMessage);
51
68
  }
52
69
 
53
- const reason = await collectionRequest
54
- .json()
55
- .then((data) => data.message);
56
- const errorMessage = `Fetching ids failed with status code ${collectionRequest.status}.\nReason: ${reason}`;
57
- context.logger.error(errorMessage);
70
+ // Remove all entries from the store
71
+ context.logger.info(`Removing all entries from the store.`);
72
+ context.store.clear();
58
73
  return;
59
74
  }
60
75
 
@@ -35,6 +35,12 @@ export function parseSchema(
35
35
  // Coerce and parse the value as a date
36
36
  fieldType = z.coerce.date();
37
37
  break;
38
+ case "geoPoint":
39
+ fieldType = z.object({
40
+ lon: z.number(),
41
+ lat: z.number()
42
+ });
43
+ break;
38
44
  case "select":
39
45
  if (!field.values) {
40
46
  throw new Error(