@proofkit/fmdapi 5.0.3-beta.0 → 5.1.0-beta.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/bin/intent.js +20 -0
- package/dist/esm/adapters/core.d.ts +4 -4
- package/dist/esm/adapters/fetch-base-types.d.ts +4 -4
- package/dist/esm/adapters/fetch-base.d.ts +2 -2
- package/dist/esm/adapters/fetch-base.js +36 -49
- package/dist/esm/adapters/fetch-base.js.map +1 -1
- package/dist/esm/adapters/fetch.d.ts +5 -5
- package/dist/esm/adapters/fetch.js +11 -10
- package/dist/esm/adapters/fetch.js.map +1 -1
- package/dist/esm/adapters/fm-http.d.ts +32 -0
- package/dist/esm/adapters/fm-http.js +170 -0
- package/dist/esm/adapters/fm-http.js.map +1 -0
- package/dist/esm/adapters/otto.d.ts +2 -2
- package/dist/esm/adapters/otto.js +3 -5
- package/dist/esm/adapters/otto.js.map +1 -1
- package/dist/esm/client-types.d.ts +41 -41
- package/dist/esm/client-types.js +1 -6
- package/dist/esm/client-types.js.map +1 -1
- package/dist/esm/client.d.ts +28 -44
- package/dist/esm/client.js +75 -80
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/index.d.ts +5 -6
- package/dist/esm/index.js +7 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tokenStore/index.d.ts +1 -1
- package/dist/esm/tokenStore/memory.js.map +1 -1
- package/dist/esm/tokenStore/types.d.ts +2 -2
- package/dist/esm/tokenStore/upstash.d.ts +1 -1
- package/dist/esm/utils.d.ts +7 -7
- package/dist/esm/utils.js +6 -4
- package/dist/esm/utils.js.map +1 -1
- package/package.json +37 -26
- package/skills/fmdapi-client/SKILL.md +490 -0
- package/src/adapters/core.ts +6 -9
- package/src/adapters/fetch-base-types.ts +5 -3
- package/src/adapters/fetch-base.ts +53 -78
- package/src/adapters/fetch.ts +19 -24
- package/src/adapters/fm-http.ts +224 -0
- package/src/adapters/otto.ts +8 -8
- package/src/client-types.ts +59 -83
- package/src/client.ts +131 -167
- package/src/index.ts +5 -9
- package/src/tokenStore/file.ts +2 -4
- package/src/tokenStore/index.ts +1 -1
- package/src/tokenStore/types.ts +2 -2
- package/src/tokenStore/upstash.ts +2 -5
- package/src/utils.ts +16 -23
|
@@ -7,8 +7,8 @@ class OttoAdapter extends BaseFetchAdapter {
|
|
|
7
7
|
super({ ...options, refreshToken: false });
|
|
8
8
|
__publicField(this, "apiKey");
|
|
9
9
|
__publicField(this, "port");
|
|
10
|
-
__publicField(this, "getToken",
|
|
11
|
-
return this.apiKey;
|
|
10
|
+
__publicField(this, "getToken", () => {
|
|
11
|
+
return Promise.resolve(this.apiKey);
|
|
12
12
|
});
|
|
13
13
|
this.apiKey = options.auth.apiKey;
|
|
14
14
|
this.port = options.auth.ottoPort;
|
|
@@ -17,9 +17,7 @@ class OttoAdapter extends BaseFetchAdapter {
|
|
|
17
17
|
} else if (this.apiKey.startsWith("dk_")) {
|
|
18
18
|
this.baseUrl.pathname = `otto/${this.baseUrl.pathname.replace(/^\/+|\/+$/g, "")}`;
|
|
19
19
|
} else {
|
|
20
|
-
throw new Error(
|
|
21
|
-
"Invalid Otto API key format. Must start with 'KEY_' (Otto v3) or 'dk_' (OttoFMS)"
|
|
22
|
-
);
|
|
20
|
+
throw new Error("Invalid Otto API key format. Must start with 'KEY_' (Otto v3) or 'dk_' (OttoFMS)");
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otto.js","sources":["../../../src/adapters/otto.ts"],"sourcesContent":["import { BaseFetchAdapter } from \"./fetch-base.js\";\nimport type { BaseFetchAdapterOptions } from \"./fetch-base-types.js\";\n\nexport type Otto3APIKey = `KEY_${string}`;\nexport type OttoFMSAPIKey = `dk_${string}`;\nexport type OttoAPIKey = Otto3APIKey | OttoFMSAPIKey;\n\nexport function isOtto3APIKey(key: string): key is Otto3APIKey {\n return key.startsWith(\"KEY_\");\n}\nexport function isOttoFMSAPIKey(key: string): key is OttoFMSAPIKey {\n return key.startsWith(\"dk_\");\n}\nexport function isOttoAPIKey(key: string): key is OttoAPIKey {\n return isOtto3APIKey(key) || isOttoFMSAPIKey(key);\n}\n\nexport function isOttoAuth(auth: unknown): auth is OttoAuth {\n if (typeof auth !== \"object\" || auth === null) return false;\n return \"apiKey\" in auth;\n}\n\ntype OttoAuth =\n | {\n apiKey: Otto3APIKey;\n ottoPort?: number;\n }\n | { apiKey: OttoFMSAPIKey; ottoPort?: never };\n\nexport type OttoAdapterOptions = BaseFetchAdapterOptions & {\n auth: OttoAuth;\n};\n\nexport class OttoAdapter extends BaseFetchAdapter {\n private apiKey: OttoAPIKey | Otto3APIKey;\n private port: number | undefined;\n\n constructor(options: OttoAdapterOptions) {\n super({ ...options, refreshToken: false });\n this.apiKey = options.auth.apiKey;\n this.port = options.auth.ottoPort;\n\n if (this.apiKey.startsWith(\"KEY_\")) {\n // otto v3 uses port 3030\n this.baseUrl.port = (this.port ?? 3030).toString();\n } else if (this.apiKey.startsWith(\"dk_\")) {\n // otto v4 uses default port, but with /otto prefix\n this.baseUrl.pathname = `otto/${this.baseUrl.pathname.replace(/^\\/+|\\/+$/g, \"\")}`;\n } else {\n throw new Error(\
|
|
1
|
+
{"version":3,"file":"otto.js","sources":["../../../src/adapters/otto.ts"],"sourcesContent":["import { BaseFetchAdapter } from \"./fetch-base.js\";\nimport type { BaseFetchAdapterOptions } from \"./fetch-base-types.js\";\n\nexport type Otto3APIKey = `KEY_${string}`;\nexport type OttoFMSAPIKey = `dk_${string}`;\nexport type OttoAPIKey = Otto3APIKey | OttoFMSAPIKey;\n\nexport function isOtto3APIKey(key: string): key is Otto3APIKey {\n return key.startsWith(\"KEY_\");\n}\nexport function isOttoFMSAPIKey(key: string): key is OttoFMSAPIKey {\n return key.startsWith(\"dk_\");\n}\nexport function isOttoAPIKey(key: string): key is OttoAPIKey {\n return isOtto3APIKey(key) || isOttoFMSAPIKey(key);\n}\n\nexport function isOttoAuth(auth: unknown): auth is OttoAuth {\n if (typeof auth !== \"object\" || auth === null) {\n return false;\n }\n return \"apiKey\" in auth;\n}\n\ntype OttoAuth =\n | {\n apiKey: Otto3APIKey;\n ottoPort?: number;\n }\n | { apiKey: OttoFMSAPIKey; ottoPort?: never };\n\nexport type OttoAdapterOptions = BaseFetchAdapterOptions & {\n auth: OttoAuth;\n};\n\nexport class OttoAdapter extends BaseFetchAdapter {\n private readonly apiKey: OttoAPIKey | Otto3APIKey;\n private readonly port: number | undefined;\n\n constructor(options: OttoAdapterOptions) {\n super({ ...options, refreshToken: false });\n this.apiKey = options.auth.apiKey;\n this.port = options.auth.ottoPort;\n\n if (this.apiKey.startsWith(\"KEY_\")) {\n // otto v3 uses port 3030\n this.baseUrl.port = (this.port ?? 3030).toString();\n } else if (this.apiKey.startsWith(\"dk_\")) {\n // otto v4 uses default port, but with /otto prefix\n this.baseUrl.pathname = `otto/${this.baseUrl.pathname.replace(/^\\/+|\\/+$/g, \"\")}`;\n } else {\n throw new Error(\"Invalid Otto API key format. Must start with 'KEY_' (Otto v3) or 'dk_' (OttoFMS)\");\n }\n }\n\n protected override getToken = (): Promise<string> => {\n return Promise.resolve(this.apiKey);\n };\n}\n"],"names":[],"mappings":";;;;AAmCO,MAAM,oBAAoB,iBAAiB;AAAA,EAIhD,YAAY,SAA6B;AACvC,UAAM,EAAE,GAAG,SAAS,cAAc,OAAO;AAJ1B;AACA;AAkBE,oCAAW,MAAuB;AACnD,aAAO,QAAQ,QAAQ,KAAK,MAAM;AAAA,IACpC;AAhBE,SAAK,SAAS,QAAQ,KAAK;AAC3B,SAAK,OAAO,QAAQ,KAAK;AAEzB,QAAI,KAAK,OAAO,WAAW,MAAM,GAAG;AAElC,WAAK,QAAQ,QAAQ,KAAK,QAAQ,MAAM,SAAA;AAAA,IAC1C,WAAW,KAAK,OAAO,WAAW,KAAK,GAAG;AAExC,WAAK,QAAQ,WAAW,QAAQ,KAAK,QAAQ,SAAS,QAAQ,cAAc,EAAE,CAAC;AAAA,IACjF,OAAO;AACL,YAAM,IAAI,MAAM,kFAAkF;AAAA,IACpG;AAAA,EACF;AAKF;"}
|
|
@@ -3,11 +3,11 @@ export declare const ZFieldValue: z.ZodUnion<readonly [z.ZodString, z.ZodNumber,
|
|
|
3
3
|
export type FieldValue = z.infer<typeof ZFieldValue>;
|
|
4
4
|
export declare const ZFieldData: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodNull, z.ZodUnknown]>>;
|
|
5
5
|
export type FieldData = Record<string, unknown>;
|
|
6
|
-
export
|
|
6
|
+
export interface GenericPortalData {
|
|
7
7
|
[key: string]: {
|
|
8
8
|
[x: string]: string | number | null | unknown;
|
|
9
9
|
};
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
export type PortalsWithIds<U extends GenericPortalData = GenericPortalData> = {
|
|
12
12
|
[key in keyof U]: Array<U[key] & {
|
|
13
13
|
recordId: string;
|
|
@@ -20,13 +20,13 @@ export type UpdatePortalsWithIds<U extends GenericPortalData = GenericPortalData
|
|
|
20
20
|
modId?: string;
|
|
21
21
|
}>;
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export interface FMRecord<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> {
|
|
24
24
|
fieldData: T;
|
|
25
25
|
recordId: string;
|
|
26
26
|
modId: string;
|
|
27
27
|
portalData: PortalsWithIds<U>;
|
|
28
|
-
}
|
|
29
|
-
export
|
|
28
|
+
}
|
|
29
|
+
export interface ScriptParams {
|
|
30
30
|
script?: string;
|
|
31
31
|
"script.param"?: string;
|
|
32
32
|
"script.prerequest"?: string;
|
|
@@ -34,7 +34,7 @@ export type ScriptParams = {
|
|
|
34
34
|
"script.presort"?: string;
|
|
35
35
|
"script.presort.param"?: string;
|
|
36
36
|
timeout?: number;
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
declare const ZScriptResponse: z.ZodObject<{
|
|
39
39
|
scriptResult: z.ZodOptional<z.ZodString>;
|
|
40
40
|
scriptError: z.ZodOptional<z.ZodString>;
|
|
@@ -68,36 +68,36 @@ export type UpdateResponse = ScriptResponse & {
|
|
|
68
68
|
};
|
|
69
69
|
export type DeleteParams = ScriptParams;
|
|
70
70
|
export type DeleteResponse = ScriptResponse;
|
|
71
|
-
export
|
|
71
|
+
export interface RangeParams {
|
|
72
72
|
offset?: number;
|
|
73
73
|
limit?: number;
|
|
74
|
-
}
|
|
75
|
-
export
|
|
74
|
+
}
|
|
75
|
+
export interface RangeParamsRaw {
|
|
76
76
|
_offset?: number;
|
|
77
77
|
_limit?: number;
|
|
78
|
-
}
|
|
78
|
+
}
|
|
79
79
|
export type PortalRanges<U extends GenericPortalData = GenericPortalData> = Partial<{
|
|
80
80
|
[key in keyof U]: RangeParams;
|
|
81
81
|
}>;
|
|
82
|
-
export
|
|
82
|
+
export interface PortalRangesParams<U extends GenericPortalData = GenericPortalData> {
|
|
83
83
|
portalRanges?: PortalRanges<U>;
|
|
84
|
-
}
|
|
84
|
+
}
|
|
85
85
|
export type GetParams<U extends GenericPortalData = GenericPortalData> = ScriptParams & PortalRangesParams<U> & {
|
|
86
86
|
"layout.response"?: string;
|
|
87
87
|
dateformats?: "US" | "file_locale" | "ISO8601";
|
|
88
88
|
};
|
|
89
|
-
export
|
|
89
|
+
export interface Sort<T extends FieldData = FieldData> {
|
|
90
90
|
fieldName: keyof T;
|
|
91
91
|
sortOrder?: "ascend" | "descend" | (string & {});
|
|
92
|
-
}
|
|
92
|
+
}
|
|
93
93
|
export type ListParams<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = GetParams<U> & RangeParams & {
|
|
94
|
-
sort?: Sort<T> |
|
|
94
|
+
sort?: Sort<T> | Sort<T>[];
|
|
95
95
|
};
|
|
96
96
|
export type ListParamsRaw<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = GetParams<U> & RangeParamsRaw & {
|
|
97
|
-
_sort?:
|
|
97
|
+
_sort?: Sort<T>[];
|
|
98
98
|
};
|
|
99
99
|
export type GetResponse<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = ScriptResponse & {
|
|
100
|
-
data:
|
|
100
|
+
data: FMRecord<T, U>[];
|
|
101
101
|
dataInfo: DataInfo;
|
|
102
102
|
};
|
|
103
103
|
export type GetResponseOne<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = ScriptResponse & {
|
|
@@ -114,25 +114,25 @@ export type Query<T extends FieldData = FieldData, U extends GenericPortalData =
|
|
|
114
114
|
}> & {
|
|
115
115
|
omit?: "true";
|
|
116
116
|
};
|
|
117
|
-
export
|
|
117
|
+
export interface LayoutMetadataResponse {
|
|
118
118
|
fieldMetaData: FieldMetaData[];
|
|
119
119
|
portalMetaData: {
|
|
120
120
|
[key: string]: FieldMetaData[];
|
|
121
121
|
};
|
|
122
122
|
valueLists?: ValueList[];
|
|
123
|
-
}
|
|
124
|
-
export
|
|
123
|
+
}
|
|
124
|
+
export interface ProductInfoMetadataResponse {
|
|
125
125
|
name: string;
|
|
126
126
|
dateFormat: string;
|
|
127
127
|
timeFormat: string;
|
|
128
128
|
timeStampFormat: string;
|
|
129
|
-
}
|
|
130
|
-
export
|
|
129
|
+
}
|
|
130
|
+
export interface DatabaseMetadataResponse {
|
|
131
131
|
databases: Array<{
|
|
132
132
|
name: string;
|
|
133
133
|
}>;
|
|
134
|
-
}
|
|
135
|
-
export
|
|
134
|
+
}
|
|
135
|
+
export interface FieldMetaData {
|
|
136
136
|
name: string;
|
|
137
137
|
type: "normal" | "calculation" | "summary";
|
|
138
138
|
displayType: "editText" | "popupList" | "popupMenu" | "checkBox" | "calendar" | "radioButtons" | "secureText";
|
|
@@ -147,28 +147,28 @@ export type FieldMetaData = {
|
|
|
147
147
|
repetitions: number;
|
|
148
148
|
timeOfDay: boolean;
|
|
149
149
|
valueList?: string;
|
|
150
|
-
}
|
|
151
|
-
|
|
150
|
+
}
|
|
151
|
+
interface ValueList {
|
|
152
152
|
name: string;
|
|
153
153
|
type: "customList" | "byField";
|
|
154
154
|
values: Array<{
|
|
155
155
|
value: string;
|
|
156
156
|
displayValue: string;
|
|
157
157
|
}>;
|
|
158
|
-
}
|
|
158
|
+
}
|
|
159
159
|
/**
|
|
160
160
|
* Represents the data returned by a call to the Data API `layouts` endpoint.
|
|
161
161
|
*/
|
|
162
|
-
export
|
|
162
|
+
export interface AllLayoutsMetadataResponse {
|
|
163
163
|
/**
|
|
164
164
|
* A list of `Layout` or `LayoutsFolder` objects.
|
|
165
165
|
*/
|
|
166
166
|
layouts: LayoutOrFolder[];
|
|
167
|
-
}
|
|
167
|
+
}
|
|
168
168
|
/**
|
|
169
169
|
* Represents a FileMaker layout.
|
|
170
170
|
*/
|
|
171
|
-
export
|
|
171
|
+
export interface Layout {
|
|
172
172
|
/**
|
|
173
173
|
* The name of the layout
|
|
174
174
|
*/
|
|
@@ -178,11 +178,11 @@ export type Layout = {
|
|
|
178
178
|
* the layout is associated with.
|
|
179
179
|
*/
|
|
180
180
|
table: string;
|
|
181
|
-
}
|
|
181
|
+
}
|
|
182
182
|
/**
|
|
183
183
|
* Represents a folder of `Layout` or `LayoutsFolder` objects.
|
|
184
184
|
*/
|
|
185
|
-
export
|
|
185
|
+
export interface LayoutsFolder {
|
|
186
186
|
/**
|
|
187
187
|
* The name of the folder
|
|
188
188
|
*/
|
|
@@ -192,33 +192,33 @@ export type LayoutsFolder = {
|
|
|
192
192
|
* A list of the Layout or LayoutsFolder objects in the folder.
|
|
193
193
|
*/
|
|
194
194
|
folderLayoutNames?: LayoutOrFolder[];
|
|
195
|
-
}
|
|
195
|
+
}
|
|
196
196
|
export type LayoutOrFolder = Layout | LayoutsFolder;
|
|
197
197
|
/**
|
|
198
198
|
* Represents the data returned by a call to the Data API `scripts` endpoint.
|
|
199
199
|
*/
|
|
200
|
-
export
|
|
200
|
+
export interface ScriptsMetadataResponse {
|
|
201
201
|
/**
|
|
202
202
|
* A list of `Layout` or `LayoutsFolder` objects.
|
|
203
203
|
*/
|
|
204
204
|
scripts: ScriptOrFolder[];
|
|
205
|
-
}
|
|
206
|
-
|
|
205
|
+
}
|
|
206
|
+
interface Script {
|
|
207
207
|
name: string;
|
|
208
208
|
isFolder: false;
|
|
209
|
-
}
|
|
210
|
-
|
|
209
|
+
}
|
|
210
|
+
interface ScriptFolder {
|
|
211
211
|
name: string;
|
|
212
212
|
isFolder: true;
|
|
213
213
|
folderScriptNames: ScriptOrFolder[];
|
|
214
|
-
}
|
|
214
|
+
}
|
|
215
215
|
export type ScriptOrFolder = Script | ScriptFolder;
|
|
216
|
-
export
|
|
216
|
+
export interface RawFMResponse<T = unknown> {
|
|
217
217
|
response?: T;
|
|
218
218
|
messages?: [{
|
|
219
219
|
code: string;
|
|
220
220
|
}];
|
|
221
|
-
}
|
|
221
|
+
}
|
|
222
222
|
export declare class FileMakerError extends Error {
|
|
223
223
|
readonly code: string;
|
|
224
224
|
constructor(code: string, message: string);
|
package/dist/esm/client-types.js
CHANGED
|
@@ -2,12 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
|
-
const ZFieldValue = z.union([
|
|
6
|
-
z.string(),
|
|
7
|
-
z.number(),
|
|
8
|
-
z.null(),
|
|
9
|
-
z.unknown()
|
|
10
|
-
]);
|
|
5
|
+
const ZFieldValue = z.union([z.string(), z.number(), z.null(), z.unknown()]);
|
|
11
6
|
const ZFieldData = z.record(z.string(), ZFieldValue);
|
|
12
7
|
z.object({
|
|
13
8
|
scriptResult: z.string().optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-types.js","sources":["../../src/client-types.ts"],"sourcesContent":["import { z } from \"zod/v4\";\n\nexport const ZFieldValue = z.union([
|
|
1
|
+
{"version":3,"file":"client-types.js","sources":["../../src/client-types.ts"],"sourcesContent":["import { z } from \"zod/v4\";\n\nexport const ZFieldValue = z.union([z.string(), z.number(), z.null(), z.unknown()]);\nexport type FieldValue = z.infer<typeof ZFieldValue>;\n\nexport const ZFieldData = z.record(z.string(), ZFieldValue);\nexport type FieldData = Record<string, unknown>;\n\nexport interface GenericPortalData {\n [key: string]: {\n [x: string]: string | number | null | unknown;\n };\n}\n\nexport type PortalsWithIds<U extends GenericPortalData = GenericPortalData> = {\n [key in keyof U]: Array<\n U[key] & {\n recordId: string;\n modId: string;\n }\n >;\n};\nexport type UpdatePortalsWithIds<U extends GenericPortalData = GenericPortalData> = {\n [key in keyof U]: Array<\n U[key] & {\n recordId: string;\n modId?: string;\n }\n >;\n};\n\nexport interface FMRecord<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> {\n fieldData: T;\n recordId: string;\n modId: string;\n portalData: PortalsWithIds<U>;\n}\n\nexport interface ScriptParams {\n script?: string;\n \"script.param\"?: string;\n \"script.prerequest\"?: string;\n \"script.prerequest.param\"?: string;\n \"script.presort\"?: string;\n \"script.presort.param\"?: string;\n timeout?: number;\n}\n\nconst ZScriptResponse = z.object({\n scriptResult: z.string().optional(),\n scriptError: z.string().optional(),\n \"scriptResult.prerequest\": z.string().optional(),\n \"scriptError.prerequest\": z.string().optional(),\n \"scriptResult.presort\": z.string().optional(),\n \"scriptError.presort\": z.string().optional(),\n});\nexport type ScriptResponse = z.infer<typeof ZScriptResponse>;\n\nexport const ZDataInfo = z.object({\n database: z.string(),\n layout: z.string(),\n table: z.string(),\n totalRecordCount: z.number(),\n foundCount: z.number(),\n returnedCount: z.number(),\n});\nexport type DataInfo = z.infer<typeof ZDataInfo>;\n\nexport type CreateParams<U extends GenericPortalData = GenericPortalData> = ScriptParams & {\n portalData?: UpdatePortalsWithIds<U>;\n};\n\nexport type CreateResponse = ScriptResponse & {\n recordId: string;\n modId: string;\n};\n\nexport type UpdateParams<U extends GenericPortalData = GenericPortalData> = CreateParams<U> & {\n modId?: number;\n};\n\nexport type UpdateResponse = ScriptResponse & {\n modId: string;\n};\n\nexport type DeleteParams = ScriptParams;\n\nexport type DeleteResponse = ScriptResponse;\n\nexport interface RangeParams {\n offset?: number;\n limit?: number;\n}\nexport interface RangeParamsRaw {\n _offset?: number;\n _limit?: number;\n}\n\nexport type PortalRanges<U extends GenericPortalData = GenericPortalData> = Partial<{ [key in keyof U]: RangeParams }>;\n\nexport interface PortalRangesParams<U extends GenericPortalData = GenericPortalData> {\n portalRanges?: PortalRanges<U>;\n}\n\nexport type GetParams<U extends GenericPortalData = GenericPortalData> = ScriptParams &\n PortalRangesParams<U> & {\n \"layout.response\"?: string;\n dateformats?: \"US\" | \"file_locale\" | \"ISO8601\";\n };\n\nexport interface Sort<T extends FieldData = FieldData> {\n fieldName: keyof T;\n sortOrder?: \"ascend\" | \"descend\" | (string & {});\n}\n\nexport type ListParams<\n T extends FieldData = FieldData,\n U extends GenericPortalData = GenericPortalData,\n> = GetParams<U> &\n RangeParams & {\n sort?: Sort<T> | Sort<T>[];\n };\n\nexport type ListParamsRaw<\n T extends FieldData = FieldData,\n U extends GenericPortalData = GenericPortalData,\n> = GetParams<U> &\n RangeParamsRaw & {\n _sort?: Sort<T>[];\n };\n\nexport type GetResponse<\n T extends FieldData = FieldData,\n U extends GenericPortalData = GenericPortalData,\n> = ScriptResponse & {\n data: FMRecord<T, U>[];\n dataInfo: DataInfo;\n};\nexport type GetResponseOne<\n T extends FieldData = FieldData,\n U extends GenericPortalData = GenericPortalData,\n> = ScriptResponse & {\n data: FMRecord<T, U>;\n dataInfo: DataInfo;\n};\n\ntype SecondLevelKeys<T> = {\n [K in keyof T]: keyof T[K];\n}[keyof T];\nexport type Query<T extends FieldData = FieldData, U extends GenericPortalData = GenericPortalData> = Partial<{\n [key in keyof T]: T[key] extends number ? number | string : string;\n}> &\n Partial<{ [key in SecondLevelKeys<U>]?: string }> & {\n omit?: \"true\";\n };\n\nexport interface LayoutMetadataResponse {\n fieldMetaData: FieldMetaData[];\n portalMetaData: { [key: string]: FieldMetaData[] };\n valueLists?: ValueList[];\n}\nexport interface ProductInfoMetadataResponse {\n name: string;\n dateFormat: string;\n timeFormat: string;\n timeStampFormat: string;\n}\nexport interface DatabaseMetadataResponse {\n databases: Array<{\n name: string;\n }>;\n}\n\nexport interface FieldMetaData {\n name: string;\n type: \"normal\" | \"calculation\" | \"summary\";\n displayType: \"editText\" | \"popupList\" | \"popupMenu\" | \"checkBox\" | \"calendar\" | \"radioButtons\" | \"secureText\";\n result: \"text\" | \"number\" | \"date\" | \"time\" | \"timeStamp\" | \"container\";\n global: boolean;\n autoEnter: boolean;\n fourDigitYear: boolean;\n maxRepeat: number;\n maxCharacters: number;\n notEmpty: boolean;\n numeric: boolean;\n repetitions: number;\n timeOfDay: boolean;\n valueList?: string;\n}\n\ninterface ValueList {\n name: string;\n // TODO need to test type of value list from other file\n type: \"customList\" | \"byField\";\n values: Array<{ value: string; displayValue: string }>;\n}\n\n/**\n * Represents the data returned by a call to the Data API `layouts` endpoint.\n */\nexport interface AllLayoutsMetadataResponse {\n /**\n * A list of `Layout` or `LayoutsFolder` objects.\n */\n layouts: LayoutOrFolder[];\n}\n\n/**\n * Represents a FileMaker layout.\n */\nexport interface Layout {\n /**\n * The name of the layout\n */\n name: string;\n /**\n * If the node is a layout, `table` may contain the name of the table\n * the layout is associated with.\n */\n table: string;\n}\n\n/**\n * Represents a folder of `Layout` or `LayoutsFolder` objects.\n */\nexport interface LayoutsFolder {\n /**\n * The name of the folder\n */\n name: string;\n isFolder: boolean;\n /**\n * A list of the Layout or LayoutsFolder objects in the folder.\n */\n folderLayoutNames?: LayoutOrFolder[];\n}\n\nexport type LayoutOrFolder = Layout | LayoutsFolder;\n\n/**\n * Represents the data returned by a call to the Data API `scripts` endpoint.\n */\nexport interface ScriptsMetadataResponse {\n /**\n * A list of `Layout` or `LayoutsFolder` objects.\n */\n scripts: ScriptOrFolder[];\n}\ninterface Script {\n name: string;\n isFolder: false;\n}\ninterface ScriptFolder {\n name: string;\n isFolder: true;\n folderScriptNames: ScriptOrFolder[];\n}\nexport type ScriptOrFolder = Script | ScriptFolder;\n\nexport interface RawFMResponse<T = unknown> {\n response?: T;\n messages?: [{ code: string }];\n}\n\nexport class FileMakerError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n }\n}\n"],"names":[],"mappings":";;;;AAEO,MAAM,cAAc,EAAE,MAAM,CAAC,EAAE,UAAU,EAAE,OAAA,GAAU,EAAE,KAAA,GAAQ,EAAE,QAAA,CAAS,CAAC;AAG3E,MAAM,aAAa,EAAE,OAAO,EAAE,OAAA,GAAU,WAAW;AA2ClC,EAAE,OAAO;AAAA,EAC/B,cAAc,EAAE,OAAA,EAAS,SAAA;AAAA,EACzB,aAAa,EAAE,OAAA,EAAS,SAAA;AAAA,EACxB,2BAA2B,EAAE,OAAA,EAAS,SAAA;AAAA,EACtC,0BAA0B,EAAE,OAAA,EAAS,SAAA;AAAA,EACrC,wBAAwB,EAAE,OAAA,EAAS,SAAA;AAAA,EACnC,uBAAuB,EAAE,OAAA,EAAS,SAAA;AACpC,CAAC;AAGM,MAAM,YAAY,EAAE,OAAO;AAAA,EAChC,UAAU,EAAE,OAAA;AAAA,EACZ,QAAQ,EAAE,OAAA;AAAA,EACV,OAAO,EAAE,OAAA;AAAA,EACT,kBAAkB,EAAE,OAAA;AAAA,EACpB,YAAY,EAAE,OAAA;AAAA,EACd,eAAe,EAAE,OAAA;AACnB,CAAC;AAuMM,MAAM,uBAAuB,MAAM;AAAA,EAGxC,YAAY,MAAc,SAAiB;AACzC,UAAM,OAAO;AAHN;AAIP,SAAK,OAAO;AAAA,EACd;AACF;"}
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Adapter, ExecuteScriptOptions } from './adapters/core.js';
|
|
2
|
-
import { CreateResponse, DeleteResponse, FMRecord, FieldData, GenericPortalData, GetResponse, GetResponseOne, ListParams, Query, UpdateResponse } from './client-types.js';
|
|
3
1
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
|
-
|
|
2
|
+
import { Adapter, ExecuteScriptOptions } from './adapters/core.js';
|
|
3
|
+
import { CreateResponse, DeleteResponse, FieldData, FMRecord, GenericPortalData, GetResponse, GetResponseOne, ListParams, Query, UpdateResponse } from './client-types.js';
|
|
4
|
+
export interface ClientObjectProps {
|
|
5
5
|
/**
|
|
6
6
|
* The layout to use by default for all requests. Can be overrridden on each request.
|
|
7
7
|
*/
|
|
@@ -16,22 +16,31 @@ export type ClientObjectProps = {
|
|
|
16
16
|
*/
|
|
17
17
|
portalData?: Record<string, StandardSchemaV1<FieldData>>;
|
|
18
18
|
};
|
|
19
|
-
}
|
|
20
|
-
|
|
19
|
+
}
|
|
20
|
+
interface FetchOptions {
|
|
21
21
|
fetch?: RequestInit;
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
|
+
export interface IgnoreEmptyResult {
|
|
24
|
+
/**
|
|
25
|
+
* If true, a find that returns no results will retun an empty array instead of throwing an error.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
ignoreEmptyResult?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ContainerUploadArgs<T extends FieldData = FieldData> {
|
|
31
|
+
containerFieldName: keyof T;
|
|
32
|
+
containerFieldRepetition?: string | number;
|
|
33
|
+
file: Blob;
|
|
34
|
+
recordId: number | string;
|
|
35
|
+
modId?: number;
|
|
36
|
+
timeout?: number;
|
|
37
|
+
}
|
|
23
38
|
declare function DataApi<Fd extends FieldData = FieldData, Pd extends GenericPortalData = GenericPortalData, Opts extends ClientObjectProps = ClientObjectProps, Adp extends Adapter = Adapter>(options: Opts & {
|
|
24
39
|
adapter: Adp;
|
|
25
|
-
}): Omit<Adp, "create" | "
|
|
40
|
+
}): Omit<Adp, "create" | "update" | "delete" | "find" | "get" | "list" | "layoutMetadata" | "containerUpload" | "executeScript"> & {
|
|
26
41
|
layout: Opts["layout"];
|
|
27
|
-
list: {
|
|
28
|
-
|
|
29
|
-
(args: ListParams<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & FetchOptions): Promise<GetResponse<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
30
|
-
};
|
|
31
|
-
listAll: {
|
|
32
|
-
<T extends FieldData = Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, U extends Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd = Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>(): Promise<FMRecord<T, U>[]>;
|
|
33
|
-
<T extends FieldData = Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, U extends Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd = Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>(args: ListParams<T, U> & FetchOptions): Promise<FMRecord<T, U>[]>;
|
|
34
|
-
};
|
|
42
|
+
list: (args?: ListParams<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & FetchOptions) => Promise<GetResponse<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
43
|
+
listAll: (args?: ListParams<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & FetchOptions) => Promise<FMRecord<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>[]>;
|
|
35
44
|
create: <T extends Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd = Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, U extends Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd = Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>(args: (import('./client-types.js').ScriptParams & {
|
|
36
45
|
portalData?: import('./client-types.js').UpdatePortalsWithIds<U> | undefined;
|
|
37
46
|
} & {
|
|
@@ -62,13 +71,7 @@ declare function DataApi<Fd extends FieldData = FieldData, Pd extends GenericPor
|
|
|
62
71
|
} & {
|
|
63
72
|
query: Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd> | Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd>[];
|
|
64
73
|
timeout?: number;
|
|
65
|
-
}) & {
|
|
66
|
-
/**
|
|
67
|
-
* If true, a find that returns no results will retun an empty array instead of throwing an error.
|
|
68
|
-
* @default false
|
|
69
|
-
*/
|
|
70
|
-
ignoreEmptyResult?: boolean;
|
|
71
|
-
} & FetchOptions) => Promise<GetResponse<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
74
|
+
}) & IgnoreEmptyResult & FetchOptions) => Promise<GetResponse<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
72
75
|
findOne: (args: (import('./client-types.js').ScriptParams & import('./client-types.js').PortalRangesParams<Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & {
|
|
73
76
|
"layout.response"?: string;
|
|
74
77
|
dateformats?: "US" | "file_locale" | "ISO8601";
|
|
@@ -86,13 +89,7 @@ declare function DataApi<Fd extends FieldData = FieldData, Pd extends GenericPor
|
|
|
86
89
|
} & {
|
|
87
90
|
query: Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd> | Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd>[];
|
|
88
91
|
timeout?: number;
|
|
89
|
-
}) & {
|
|
90
|
-
/**
|
|
91
|
-
* If true, a find that returns no results will retun an empty array instead of throwing an error.
|
|
92
|
-
* @default false
|
|
93
|
-
*/
|
|
94
|
-
ignoreEmptyResult?: boolean;
|
|
95
|
-
} & FetchOptions) => Promise<GetResponseOne<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
92
|
+
}) & IgnoreEmptyResult & FetchOptions) => Promise<GetResponseOne<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd>>;
|
|
96
93
|
maybeFindFirst: (args: (import('./client-types.js').ScriptParams & import('./client-types.js').PortalRangesParams<Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & {
|
|
97
94
|
"layout.response"?: string;
|
|
98
95
|
dateformats?: "US" | "file_locale" | "ISO8601";
|
|
@@ -101,13 +98,7 @@ declare function DataApi<Fd extends FieldData = FieldData, Pd extends GenericPor
|
|
|
101
98
|
} & {
|
|
102
99
|
query: Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd> | Query<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd>[];
|
|
103
100
|
timeout?: number;
|
|
104
|
-
}) & {
|
|
105
|
-
/**
|
|
106
|
-
* If true, a find that returns no results will retun an empty array instead of throwing an error.
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
ignoreEmptyResult?: boolean;
|
|
110
|
-
} & FetchOptions) => Promise<GetResponseOne<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> | null>;
|
|
101
|
+
}) & IgnoreEmptyResult & FetchOptions) => Promise<GetResponseOne<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd, Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> | null>;
|
|
111
102
|
findAll: (args: (import('./client-types.js').ScriptParams & import('./client-types.js').PortalRangesParams<Opts["schema"] extends object ? Opts["schema"]["portalData"] extends object ? { [K in keyof Opts["schema"]["portalData"]]: StandardSchemaV1.InferOutput<Opts["schema"]["portalData"][K]>; } : Pd : Pd> & {
|
|
112
103
|
"layout.response"?: string;
|
|
113
104
|
dateformats?: "US" | "file_locale" | "ISO8601";
|
|
@@ -120,14 +111,7 @@ declare function DataApi<Fd extends FieldData = FieldData, Pd extends GenericPor
|
|
|
120
111
|
layoutMetadata: (args?: {
|
|
121
112
|
timeout?: number;
|
|
122
113
|
} & FetchOptions) => Promise<import('./client-types.js').LayoutMetadataResponse>;
|
|
123
|
-
containerUpload: <
|
|
124
|
-
containerFieldName: keyof T;
|
|
125
|
-
containerFieldRepetition?: string | number;
|
|
126
|
-
file: Blob;
|
|
127
|
-
recordId: number | string;
|
|
128
|
-
modId?: number;
|
|
129
|
-
timeout?: number;
|
|
130
|
-
} & FetchOptions) => Promise<void>;
|
|
114
|
+
containerUpload: (args: ContainerUploadArgs<Opts["schema"] extends object ? StandardSchemaV1.InferOutput<Opts["schema"]["fieldData"]> : Fd> & FetchOptions) => Promise<void>;
|
|
131
115
|
executeScript: (args: Omit<ExecuteScriptOptions, "layout"> & FetchOptions) => Promise<{
|
|
132
116
|
scriptResult?: string | undefined;
|
|
133
117
|
scriptError?: string | undefined;
|