@proofkit/fmdapi 5.0.2 → 5.0.3-beta.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.
Files changed (39) hide show
  1. package/dist/esm/adapters/core.d.ts +4 -4
  2. package/dist/esm/adapters/fetch-base-types.d.ts +4 -4
  3. package/dist/esm/adapters/fetch-base.d.ts +2 -2
  4. package/dist/esm/adapters/fetch-base.js +36 -49
  5. package/dist/esm/adapters/fetch-base.js.map +1 -1
  6. package/dist/esm/adapters/fetch.d.ts +5 -5
  7. package/dist/esm/adapters/fetch.js +11 -10
  8. package/dist/esm/adapters/fetch.js.map +1 -1
  9. package/dist/esm/adapters/otto.d.ts +2 -2
  10. package/dist/esm/adapters/otto.js +3 -5
  11. package/dist/esm/adapters/otto.js.map +1 -1
  12. package/dist/esm/client-types.d.ts +41 -41
  13. package/dist/esm/client-types.js +1 -6
  14. package/dist/esm/client-types.js.map +1 -1
  15. package/dist/esm/client.d.ts +27 -43
  16. package/dist/esm/client.js +75 -80
  17. package/dist/esm/client.js.map +1 -1
  18. package/dist/esm/index.d.ts +4 -6
  19. package/dist/esm/index.js +5 -5
  20. package/dist/esm/tokenStore/index.d.ts +1 -1
  21. package/dist/esm/tokenStore/types.d.ts +2 -2
  22. package/dist/esm/tokenStore/upstash.d.ts +1 -1
  23. package/dist/esm/utils.d.ts +12 -14
  24. package/dist/esm/utils.js +5 -5
  25. package/dist/esm/utils.js.map +1 -1
  26. package/package.json +11 -13
  27. package/src/adapters/core.ts +6 -9
  28. package/src/adapters/fetch-base-types.ts +5 -3
  29. package/src/adapters/fetch-base.ts +53 -78
  30. package/src/adapters/fetch.ts +19 -24
  31. package/src/adapters/otto.ts +8 -8
  32. package/src/client-types.ts +59 -83
  33. package/src/client.ts +131 -167
  34. package/src/index.ts +4 -9
  35. package/src/tokenStore/file.ts +2 -4
  36. package/src/tokenStore/index.ts +1 -1
  37. package/src/tokenStore/types.ts +2 -2
  38. package/src/tokenStore/upstash.ts +2 -5
  39. package/src/utils.ts +20 -29
@@ -1,21 +1,16 @@
1
1
  import { z } from "zod/v4";
2
2
 
3
- export const ZFieldValue = z.union([
4
- z.string(),
5
- z.number(),
6
- z.null(),
7
- z.unknown(),
8
- ]);
3
+ export const ZFieldValue = z.union([z.string(), z.number(), z.null(), z.unknown()]);
9
4
  export type FieldValue = z.infer<typeof ZFieldValue>;
10
5
 
11
6
  export const ZFieldData = z.record(z.string(), ZFieldValue);
12
7
  export type FieldData = Record<string, unknown>;
13
8
 
14
- export type GenericPortalData = {
9
+ export interface GenericPortalData {
15
10
  [key: string]: {
16
11
  [x: string]: string | number | null | unknown;
17
12
  };
18
- };
13
+ }
19
14
 
20
15
  export type PortalsWithIds<U extends GenericPortalData = GenericPortalData> = {
21
16
  [key in keyof U]: Array<
@@ -25,9 +20,7 @@ export type PortalsWithIds<U extends GenericPortalData = GenericPortalData> = {
25
20
  }
26
21
  >;
27
22
  };
28
- export type UpdatePortalsWithIds<
29
- U extends GenericPortalData = GenericPortalData,
30
- > = {
23
+ export type UpdatePortalsWithIds<U extends GenericPortalData = GenericPortalData> = {
31
24
  [key in keyof U]: Array<
32
25
  U[key] & {
33
26
  recordId: string;
@@ -36,17 +29,14 @@ export type UpdatePortalsWithIds<
36
29
  >;
37
30
  };
38
31
 
39
- export type FMRecord<
40
- T extends FieldData = FieldData,
41
- U extends GenericPortalData = GenericPortalData,
42
- > = {
32
+ export interface FMRecord<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> {
43
33
  fieldData: T;
44
34
  recordId: string;
45
35
  modId: string;
46
36
  portalData: PortalsWithIds<U>;
47
- };
37
+ }
48
38
 
49
- export type ScriptParams = {
39
+ export interface ScriptParams {
50
40
  script?: string;
51
41
  "script.param"?: string;
52
42
  "script.prerequest"?: string;
@@ -54,7 +44,7 @@ export type ScriptParams = {
54
44
  "script.presort"?: string;
55
45
  "script.presort.param"?: string;
56
46
  timeout?: number;
57
- };
47
+ }
58
48
 
59
49
  const ZScriptResponse = z.object({
60
50
  scriptResult: z.string().optional(),
@@ -76,18 +66,18 @@ export const ZDataInfo = z.object({
76
66
  });
77
67
  export type DataInfo = z.infer<typeof ZDataInfo>;
78
68
 
79
- export type CreateParams<U extends GenericPortalData = GenericPortalData> =
80
- ScriptParams & { portalData?: UpdatePortalsWithIds<U> };
69
+ export type CreateParams<U extends GenericPortalData = GenericPortalData> = ScriptParams & {
70
+ portalData?: UpdatePortalsWithIds<U>;
71
+ };
81
72
 
82
73
  export type CreateResponse = ScriptResponse & {
83
74
  recordId: string;
84
75
  modId: string;
85
76
  };
86
77
 
87
- export type UpdateParams<U extends GenericPortalData = GenericPortalData> =
88
- CreateParams<U> & {
89
- modId?: number;
90
- };
78
+ export type UpdateParams<U extends GenericPortalData = GenericPortalData> = CreateParams<U> & {
79
+ modId?: number;
80
+ };
91
81
 
92
82
  export type UpdateResponse = ScriptResponse & {
93
83
  modId: string;
@@ -97,42 +87,38 @@ export type DeleteParams = ScriptParams;
97
87
 
98
88
  export type DeleteResponse = ScriptResponse;
99
89
 
100
- export type RangeParams = {
90
+ export interface RangeParams {
101
91
  offset?: number;
102
92
  limit?: number;
103
- };
104
- export type RangeParamsRaw = {
93
+ }
94
+ export interface RangeParamsRaw {
105
95
  _offset?: number;
106
96
  _limit?: number;
107
- };
97
+ }
108
98
 
109
- export type PortalRanges<U extends GenericPortalData = GenericPortalData> =
110
- Partial<{ [key in keyof U]: RangeParams }>;
99
+ export type PortalRanges<U extends GenericPortalData = GenericPortalData> = Partial<{ [key in keyof U]: RangeParams }>;
111
100
 
112
- export type PortalRangesParams<
113
- U extends GenericPortalData = GenericPortalData,
114
- > = {
101
+ export interface PortalRangesParams<U extends GenericPortalData = GenericPortalData> {
115
102
  portalRanges?: PortalRanges<U>;
116
- };
103
+ }
117
104
 
118
- export type GetParams<U extends GenericPortalData = GenericPortalData> =
119
- ScriptParams &
120
- PortalRangesParams<U> & {
121
- "layout.response"?: string;
122
- dateformats?: "US" | "file_locale" | "ISO8601";
123
- };
105
+ export type GetParams<U extends GenericPortalData = GenericPortalData> = ScriptParams &
106
+ PortalRangesParams<U> & {
107
+ "layout.response"?: string;
108
+ dateformats?: "US" | "file_locale" | "ISO8601";
109
+ };
124
110
 
125
- export type Sort<T extends FieldData = FieldData> = {
111
+ export interface Sort<T extends FieldData = FieldData> {
126
112
  fieldName: keyof T;
127
113
  sortOrder?: "ascend" | "descend" | (string & {});
128
- };
114
+ }
129
115
 
130
116
  export type ListParams<
131
117
  T extends FieldData = FieldData,
132
118
  U extends GenericPortalData = GenericPortalData,
133
119
  > = GetParams<U> &
134
120
  RangeParams & {
135
- sort?: Sort<T> | Array<Sort<T>>;
121
+ sort?: Sort<T> | Sort<T>[];
136
122
  };
137
123
 
138
124
  export type ListParamsRaw<
@@ -140,14 +126,14 @@ export type ListParamsRaw<
140
126
  U extends GenericPortalData = GenericPortalData,
141
127
  > = GetParams<U> &
142
128
  RangeParamsRaw & {
143
- _sort?: Array<Sort<T>>;
129
+ _sort?: Sort<T>[];
144
130
  };
145
131
 
146
132
  export type GetResponse<
147
133
  T extends FieldData = FieldData,
148
134
  U extends GenericPortalData = GenericPortalData,
149
135
  > = ScriptResponse & {
150
- data: Array<FMRecord<T, U>>;
136
+ data: FMRecord<T, U>[];
151
137
  dataInfo: DataInfo;
152
138
  };
153
139
  export type GetResponseOne<
@@ -161,44 +147,34 @@ export type GetResponseOne<
161
147
  type SecondLevelKeys<T> = {
162
148
  [K in keyof T]: keyof T[K];
163
149
  }[keyof T];
164
- export type Query<
165
- T extends FieldData = FieldData,
166
- U extends GenericPortalData = GenericPortalData,
167
- > = Partial<{
150
+ export type Query<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = Partial<{
168
151
  [key in keyof T]: T[key] extends number ? number | string : string;
169
152
  }> &
170
153
  Partial<{ [key in SecondLevelKeys<U>]?: string }> & {
171
154
  omit?: "true";
172
155
  };
173
156
 
174
- export type LayoutMetadataResponse = {
157
+ export interface LayoutMetadataResponse {
175
158
  fieldMetaData: FieldMetaData[];
176
159
  portalMetaData: { [key: string]: FieldMetaData[] };
177
160
  valueLists?: ValueList[];
178
- };
179
- export type ProductInfoMetadataResponse = {
161
+ }
162
+ export interface ProductInfoMetadataResponse {
180
163
  name: string;
181
164
  dateFormat: string;
182
165
  timeFormat: string;
183
166
  timeStampFormat: string;
184
- };
185
- export type DatabaseMetadataResponse = {
167
+ }
168
+ export interface DatabaseMetadataResponse {
186
169
  databases: Array<{
187
170
  name: string;
188
171
  }>;
189
- };
172
+ }
190
173
 
191
- export type FieldMetaData = {
174
+ export interface FieldMetaData {
192
175
  name: string;
193
176
  type: "normal" | "calculation" | "summary";
194
- displayType:
195
- | "editText"
196
- | "popupList"
197
- | "popupMenu"
198
- | "checkBox"
199
- | "calendar"
200
- | "radioButtons"
201
- | "secureText";
177
+ displayType: "editText" | "popupList" | "popupMenu" | "checkBox" | "calendar" | "radioButtons" | "secureText";
202
178
  result: "text" | "number" | "date" | "time" | "timeStamp" | "container";
203
179
  global: boolean;
204
180
  autoEnter: boolean;
@@ -210,29 +186,29 @@ export type FieldMetaData = {
210
186
  repetitions: number;
211
187
  timeOfDay: boolean;
212
188
  valueList?: string;
213
- };
189
+ }
214
190
 
215
- type ValueList = {
191
+ interface ValueList {
216
192
  name: string;
217
193
  // TODO need to test type of value list from other file
218
194
  type: "customList" | "byField";
219
195
  values: Array<{ value: string; displayValue: string }>;
220
- };
196
+ }
221
197
 
222
198
  /**
223
199
  * Represents the data returned by a call to the Data API `layouts` endpoint.
224
200
  */
225
- export type AllLayoutsMetadataResponse = {
201
+ export interface AllLayoutsMetadataResponse {
226
202
  /**
227
203
  * A list of `Layout` or `LayoutsFolder` objects.
228
204
  */
229
205
  layouts: LayoutOrFolder[];
230
- };
206
+ }
231
207
 
232
208
  /**
233
209
  * Represents a FileMaker layout.
234
210
  */
235
- export type Layout = {
211
+ export interface Layout {
236
212
  /**
237
213
  * The name of the layout
238
214
  */
@@ -242,12 +218,12 @@ export type Layout = {
242
218
  * the layout is associated with.
243
219
  */
244
220
  table: string;
245
- };
221
+ }
246
222
 
247
223
  /**
248
224
  * Represents a folder of `Layout` or `LayoutsFolder` objects.
249
225
  */
250
- export type LayoutsFolder = {
226
+ export interface LayoutsFolder {
251
227
  /**
252
228
  * The name of the folder
253
229
  */
@@ -257,39 +233,39 @@ export type LayoutsFolder = {
257
233
  * A list of the Layout or LayoutsFolder objects in the folder.
258
234
  */
259
235
  folderLayoutNames?: LayoutOrFolder[];
260
- };
236
+ }
261
237
 
262
238
  export type LayoutOrFolder = Layout | LayoutsFolder;
263
239
 
264
240
  /**
265
241
  * Represents the data returned by a call to the Data API `scripts` endpoint.
266
242
  */
267
- export type ScriptsMetadataResponse = {
243
+ export interface ScriptsMetadataResponse {
268
244
  /**
269
245
  * A list of `Layout` or `LayoutsFolder` objects.
270
246
  */
271
247
  scripts: ScriptOrFolder[];
272
- };
273
- type Script = {
248
+ }
249
+ interface Script {
274
250
  name: string;
275
251
  isFolder: false;
276
- };
277
- type ScriptFolder = {
252
+ }
253
+ interface ScriptFolder {
278
254
  name: string;
279
255
  isFolder: true;
280
256
  folderScriptNames: ScriptOrFolder[];
281
- };
257
+ }
282
258
  export type ScriptOrFolder = Script | ScriptFolder;
283
259
 
284
- export type RawFMResponse<T = unknown> = {
260
+ export interface RawFMResponse<T = unknown> {
285
261
  response?: T;
286
262
  messages?: [{ code: string }];
287
- };
263
+ }
288
264
 
289
265
  export class FileMakerError extends Error {
290
- public readonly code: string;
266
+ readonly code: string;
291
267
 
292
- public constructor(code: string, message: string) {
268
+ constructor(code: string, message: string) {
293
269
  super(message);
294
270
  this.code = code;
295
271
  }