@@ -224,6 +224,11 @@ function init<
224
224
*/
225
225
const init_experimental = init ;
226
226
227
+ function steps ( inputChunks ) {
228
+ const chunks = Array . isArray ( inputChunks ) ? inputChunks : [ inputChunks ] ;
229
+ return chunks . flatMap ( getOps ) ;
230
+ }
231
+
227
232
/**
228
233
*
229
234
* The first step: init your application!
@@ -335,12 +340,10 @@ class InstantAdmin<
335
340
transact = (
336
341
inputChunks : TransactionChunk < any , any > | TransactionChunk < any , any > [ ] ,
337
342
) => {
338
- const chunks = Array . isArray ( inputChunks ) ? inputChunks : [ inputChunks ] ;
339
- const steps = chunks . flatMap ( ( tx ) => getOps ( tx ) ) ;
340
343
return jsonFetch ( `${ this . config . apiURI } /admin/transact` , {
341
344
method : 'POST' ,
342
345
headers : authorizedHeaders ( this . config , this . impersonationOpts ) ,
343
- body : JSON . stringify ( { steps : steps } ) ,
346
+ body : JSON . stringify ( { steps : steps ( inputChunks ) } ) ,
344
347
} ) ;
345
348
} ;
346
349
@@ -367,11 +370,15 @@ class InstantAdmin<
367
370
*/
368
371
debugQuery = async < Q extends Query > (
369
372
query : Exactly < Query , Q > ,
370
- opts ?: { rules : any } ,
373
+ opts ?: { rules ? : any ; ruleParams ?: { [ key : string ] : any } } ,
371
374
) : Promise < {
372
375
result : QueryResponse < Q , Schema , WithCardinalityInference > ;
373
376
checkResults : DebugCheckResult [ ] ;
374
377
} > => {
378
+ if ( query && opts && 'ruleParams' in opts ) {
379
+ query = { $$ruleParams : opts [ 'ruleParams' ] , ...query } ;
380
+ }
381
+
375
382
const response = await jsonFetch (
376
383
`${ this . config . apiURI } /admin/query_perms_check` ,
377
384
{
@@ -409,13 +416,11 @@ class InstantAdmin<
409
416
inputChunks : TransactionChunk < any , any > | TransactionChunk < any , any > [ ] ,
410
417
opts ?: { rules ?: any } ,
411
418
) => {
412
- const chunks = Array . isArray ( inputChunks ) ? inputChunks : [ inputChunks ] ;
413
- const steps = chunks . flatMap ( ( tx ) => getOps ( tx ) ) ;
414
419
return jsonFetch ( `${ this . config . apiURI } /admin/transact_perms_check` , {
415
420
method : 'POST' ,
416
421
headers : authorizedHeaders ( this . config , this . impersonationOpts ) ,
417
422
body : JSON . stringify ( {
418
- steps : steps ,
423
+ steps : steps ( inputChunks ) ,
419
424
'rules-override' : opts ?. rules ,
420
425
// @ts -expect-error because we're using a private API (for now)
421
426
'dangerously-commit-tx' : opts ?. __dangerouslyCommit ,
@@ -856,13 +861,11 @@ class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any>> {
856
861
transact = (
857
862
inputChunks : TransactionChunk < any , any > | TransactionChunk < any , any > [ ] ,
858
863
) => {
859
- const chunks = Array . isArray ( inputChunks ) ? inputChunks : [ inputChunks ] ;
860
- const steps = chunks . flatMap ( ( tx ) => getOps ( tx ) ) ;
861
864
return jsonFetch ( `${ this . config . apiURI } /admin/transact` , {
862
865
method : 'POST' ,
863
866
headers : authorizedHeaders ( this . config , this . impersonationOpts ) ,
864
867
body : JSON . stringify ( {
865
- steps : steps ,
868
+ steps : steps ( inputChunks ) ,
866
869
'throw-on-missing-attrs?' : ! ! this . config . schema ,
867
870
} ) ,
868
871
} ) ;
@@ -891,11 +894,15 @@ class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any>> {
891
894
*/
892
895
debugQuery = async < Q extends InstaQLParams < Schema > > (
893
896
query : Q ,
894
- opts ?: { rules : any } ,
897
+ opts ?: { rules ? : any ; ruleParams ?: { [ key : string ] : any } } ,
895
898
) : Promise < {
896
899
result : InstaQLResponse < Schema , Q > ;
897
900
checkResults : DebugCheckResult [ ] ;
898
901
} > => {
902
+ if ( query && opts && 'ruleParams' in opts ) {
903
+ query = { $$ruleParams : opts [ 'ruleParams' ] , ...query } ;
904
+ }
905
+
899
906
const response = await jsonFetch (
900
907
`${ this . config . apiURI } /admin/query_perms_check` ,
901
908
{
@@ -933,13 +940,11 @@ class InstantAdminDatabase<Schema extends InstantSchemaDef<any, any, any>> {
933
940
inputChunks : TransactionChunk < any , any > | TransactionChunk < any , any > [ ] ,
934
941
opts ?: { rules ?: any } ,
935
942
) => {
936
- const chunks = Array . isArray ( inputChunks ) ? inputChunks : [ inputChunks ] ;
937
- const steps = chunks . flatMap ( ( tx ) => getOps ( tx ) ) ;
938
943
return jsonFetch ( `${ this . config . apiURI } /admin/transact_perms_check` , {
939
944
method : 'POST' ,
940
945
headers : authorizedHeaders ( this . config , this . impersonationOpts ) ,
941
946
body : JSON . stringify ( {
942
- steps : steps ,
947
+ steps : steps ( inputChunks ) ,
943
948
'rules-override' : opts ?. rules ,
944
949
// @ts -expect-error because we're using a private API (for now)
945
950
'dangerously-commit-tx' : opts ?. __dangerouslyCommit ,
0 commit comments