File tree Expand file tree Collapse file tree 5 files changed +26
-8
lines changed
Expand file tree Collapse file tree 5 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @proofkit/fmdapi " : patch
3+ ---
4+
5+ Update executeScript method to infer layout name from client
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import type {
1111 Query ,
1212 UpdateParams ,
1313 UpdateResponse ,
14+ ScriptParams ,
15+ ScriptResponse ,
1416} from "../client-types.js" ;
1517
1618export type BaseRequest = {
@@ -44,7 +46,10 @@ export type ContainerUploadOptions = BaseRequest & {
4446 modId ?: number ;
4547 } ;
4648} ;
47-
49+ export type ExecuteScriptOptions = BaseRequest & {
50+ script : string ;
51+ scriptParam ?: string ;
52+ } ;
4853export type LayoutMetadataOptions = BaseRequest ;
4954
5055export interface Adapter {
@@ -59,4 +64,6 @@ export interface Adapter {
5964 layoutMetadata : (
6065 opts : LayoutMetadataOptions ,
6166 ) => Promise < LayoutMetadataResponse > ;
67+
68+ executeScript : ( opts : ExecuteScriptOptions ) => Promise < ScriptResponse > ;
6269}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import type {
1717 ContainerUploadOptions ,
1818 CreateOptions ,
1919 DeleteOptions ,
20+ ExecuteScriptOptions ,
2021 FindOptions ,
2122 GetOptions ,
2223 LayoutMetadataOptions ,
@@ -28,11 +29,6 @@ import type {
2829 GetTokenArguments ,
2930} from "./fetch-base-types.js" ;
3031
31- export type ExecuteScriptOptions = BaseRequest & {
32- script : string ;
33- scriptParam ?: string ;
34- } ;
35-
3632export class BaseFetchAdapter implements Adapter {
3733 protected server : string ;
3834 protected db : string ;
Original file line number Diff line number Diff line change 1- import type { Adapter } from "./adapters/core.js" ;
1+ import type { Adapter , ExecuteScriptOptions } from "./adapters/core.js" ;
22import type {
33 CreateParams ,
44 CreateResponse ,
@@ -80,6 +80,7 @@ function DataApi<
8080 update,
8181 layoutMetadata,
8282 containerUpload,
83+ executeScript,
8384 ...otherMethods
8485 } = options . adapter ;
8586
@@ -126,6 +127,8 @@ function DataApi<
126127 timeout ?: number ;
127128 } ;
128129
130+ type ExecuteScriptArgs = Omit < ExecuteScriptOptions , "layout" > ;
131+
129132 /**
130133 * List all records from a given layout, no find criteria applied.
131134 */
@@ -516,6 +519,13 @@ function DataApi<
516519 return result ;
517520 }
518521
522+ async function _executeScript ( args : ExecuteScriptArgs & FetchOptions ) {
523+ return await executeScript ( {
524+ ...args ,
525+ layout,
526+ } ) ;
527+ }
528+
519529 return {
520530 ...otherMethods ,
521531 layout : options . layout as Opts [ "layout" ] ,
@@ -532,6 +542,7 @@ function DataApi<
532542 findAll,
533543 layoutMetadata : _layoutMetadata ,
534544 containerUpload : _containerUpload ,
545+ executeScript : _executeScript ,
535546 } ;
536547}
537548
Original file line number Diff line number Diff line change @@ -319,7 +319,6 @@ describe("other methods", () => {
319319 const resp = await client . executeScript ( {
320320 script : "script" ,
321321 scriptParam : param ,
322- layout : client . layout ,
323322 } ) ;
324323
325324 expect ( resp . scriptResult ) . toBe ( "result" ) ;
You can’t perform that action at this time.
0 commit comments