@svadmin/airtable 0.3.0 → 0.4.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,10 +1,12 @@
1
1
  {
2
2
  "name": "@svadmin/airtable",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Airtable DataProvider for svadmin",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
- "files": ["src/**/*"],
7
+ "files": [
8
+ "src/**/*"
9
+ ],
8
10
  "main": "src/index.ts",
9
11
  "types": "src/index.ts",
10
12
  "exports": {
@@ -14,7 +16,12 @@
14
16
  }
15
17
  },
16
18
  "peerDependencies": {
17
- "@svadmin/core": "^0.3.0"
19
+ "@svadmin/core": "^0.4.1"
18
20
  },
19
- "license": "MIT"
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/zuohuadong/svadmin.git",
25
+ "directory": "packages/airtable"
26
+ }
20
27
  }
@@ -4,6 +4,11 @@ import type {
4
4
  GetManyParams, GetManyResult, CustomParams, CustomResult, Sort, Filter
5
5
  } from '@svadmin/core';
6
6
 
7
+ interface AirtableRecord {
8
+ id: string;
9
+ fields: Record<string, unknown>;
10
+ }
11
+
7
12
  function generateFilterByFormula(filters?: Filter[]): string | undefined {
8
13
  if (!filters || filters.length === 0) return undefined;
9
14
 
@@ -62,7 +67,7 @@ export function createAirtableDataProvider(apiKey: string, baseId: string): Data
62
67
 
63
68
  // Airtable doesn't return total count easily without offset matching, we can only return current length or a large number
64
69
  return {
65
- data: data.records.map((r: any) => ({ ...r.fields, id: r.id })) as T[],
70
+ data: data.records.map((r: AirtableRecord) => ({ ...r.fields, id: r.id })) as T[],
66
71
  total: data.records.length,
67
72
  };
68
73
  },
@@ -111,7 +116,7 @@ export function createAirtableDataProvider(apiKey: string, baseId: string): Data
111
116
  const response = await fetch(url.toString(), { headers });
112
117
  if (!response.ok) throw new Error(`HTTP error: ${response.status}`);
113
118
  const data = await response.json();
114
- return { data: data.records.map((r: any) => ({ ...r.fields, id: r.id })) as T[] };
119
+ return { data: data.records.map((r: AirtableRecord) => ({ ...r.fields, id: r.id })) as T[] };
115
120
  },
116
121
 
117
122
  async custom<T>({ url, method, payload, headers: customHeaders, query }: CustomParams): Promise<CustomResult<T>> {