@ctil/gql 1.1.0 → 1.1.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/dist/index.d.cts CHANGED
@@ -223,6 +223,10 @@ declare function buildGraphQLQueryList(input: QueryInput): {
223
223
  query: string;
224
224
  variables: Record<string, any> | undefined;
225
225
  };
226
+ declare function buildGraphQLQuery(input: QueryInput): {
227
+ query: string;
228
+ variables: Record<string, any> | undefined;
229
+ };
226
230
  /** 生成按 ID 查询的 GraphQL query(固定主键参数名为 id) */
227
231
  declare function buildGraphQLQueryByIdFixed(queryByIdInput: QueryByIdInput): {
228
232
  query: string;
@@ -238,6 +242,14 @@ declare function buildGraphQLQueryAggregate(input: QueryAggregateInput): {
238
242
  variables: Record<string, any> | undefined;
239
243
  };
240
244
 
245
+ interface MutationInput {
246
+ operationName: string;
247
+ fields: FieldInput[];
248
+ datas?: Record<string, any>[];
249
+ _set?: Record<string, any>[];
250
+ where?: WhereInput;
251
+ variables?: Record<string, any>;
252
+ }
241
253
  interface InsertOneInput {
242
254
  operationName: string;
243
255
  fields: FieldInput[];
@@ -286,6 +298,10 @@ type MutationField = {
286
298
  affected_rows?: boolean;
287
299
  returning?: FieldInput[];
288
300
  };
301
+ declare function buildGraphQLMutation(input: MutationInput): {
302
+ query: string;
303
+ variables: Record<string, any>;
304
+ };
289
305
  /** 生成单个插入的 GraphQL mutation */
290
306
  declare function buildGraphQLMutationInsertOne(input: InsertOneInput): {
291
307
  query: string;
@@ -468,6 +484,7 @@ type index_LoginInput = LoginInput;
468
484
  type index_LogoutDeviceInput = LogoutDeviceInput;
469
485
  type index_LogoutInput = LogoutInput;
470
486
  type index_MutationField = MutationField;
487
+ type index_MutationInput = MutationInput;
471
488
  type index_PresignedUrlResult = PresignedUrlResult;
472
489
  type index_QueryAggregateInput = QueryAggregateInput;
473
490
  type index_QueryByIdInput = QueryByIdInput;
@@ -486,6 +503,7 @@ declare const index_buildCommonResultSelection: typeof buildCommonResultSelectio
486
503
  declare const index_buildDataValue: typeof buildDataValue;
487
504
  declare const index_buildFields: typeof buildFields;
488
505
  declare const index_buildGraphQLGetFilePreview: typeof buildGraphQLGetFilePreview;
506
+ declare const index_buildGraphQLMutation: typeof buildGraphQLMutation;
489
507
  declare const index_buildGraphQLMutationBatchInsert: typeof buildGraphQLMutationBatchInsert;
490
508
  declare const index_buildGraphQLMutationBatchUpdate: typeof buildGraphQLMutationBatchUpdate;
491
509
  declare const index_buildGraphQLMutationDelete: typeof buildGraphQLMutationDelete;
@@ -501,6 +519,7 @@ declare const index_buildGraphQLMutationSendCode: typeof buildGraphQLMutationSen
501
519
  declare const index_buildGraphQLMutationUpdate: typeof buildGraphQLMutationUpdate;
502
520
  declare const index_buildGraphQLMutationUpdateByPk: typeof buildGraphQLMutationUpdateByPk;
503
521
  declare const index_buildGraphQLMutationVerifyCode: typeof buildGraphQLMutationVerifyCode;
522
+ declare const index_buildGraphQLQuery: typeof buildGraphQLQuery;
504
523
  declare const index_buildGraphQLQueryAggregate: typeof buildGraphQLQueryAggregate;
505
524
  declare const index_buildGraphQLQueryByIdFixed: typeof buildGraphQLQueryByIdFixed;
506
525
  declare const index_buildGraphQLQueryList: typeof buildGraphQLQueryList;
@@ -512,7 +531,7 @@ declare const index_formatGraphQLValue: typeof formatGraphQLValue;
512
531
  declare const index_generateOperationName: typeof generateOperationName;
513
532
  declare const index_toPascalCase: typeof toPascalCase;
514
533
  declare namespace index {
515
- export { type index_AggregateFieldInput as AggregateFieldInput, type index_BatchInsertInput as BatchInsertInput, type index_BatchUpdateInput as BatchUpdateInput, type index_DeleteByIdInput as DeleteByIdInput, type index_DeleteInput as DeleteInput, type index_FieldInput as FieldInput, type index_FieldNode as FieldNode, type index_FilePreview as FilePreview, type index_InsertOneInput as InsertOneInput, type index_LoginInput as LoginInput, type index_LogoutDeviceInput as LogoutDeviceInput, type index_LogoutInput as LogoutInput, type index_MutationField as MutationField, type index_PresignedUrlResult as PresignedUrlResult, type index_QueryAggregateInput as QueryAggregateInput, type index_QueryByIdInput as QueryByIdInput, type index_QueryInput as QueryInput, type index_QueryPageListInput as QueryPageListInput, type index_RefreshTokenInput as RefreshTokenInput, type index_RegisterUserInput as RegisterUserInput, type index_SendCodeInput as SendCodeInput, type index_UpdateByPkInput as UpdateByPkInput, type index_UpdateInput as UpdateInput, type index_UploadHeaders as UploadHeaders, type index_UploadPresignedUrlInput as UploadPresignedUrlInput, type index_VerifyCodeInput as VerifyCodeInput, type index_WhereInput as WhereInput, index_buildCommonResultSelection as buildCommonResultSelection, index_buildDataValue as buildDataValue, index_buildFields as buildFields, index_buildGraphQLGetFilePreview as buildGraphQLGetFilePreview, index_buildGraphQLMutationBatchInsert as buildGraphQLMutationBatchInsert, index_buildGraphQLMutationBatchUpdate as buildGraphQLMutationBatchUpdate, index_buildGraphQLMutationDelete as buildGraphQLMutationDelete, index_buildGraphQLMutationDeleteById as buildGraphQLMutationDeleteById, index_buildGraphQLMutationInsertOne as buildGraphQLMutationInsertOne, index_buildGraphQLMutationLogin as buildGraphQLMutationLogin, index_buildGraphQLMutationLogout as buildGraphQLMutationLogout, index_buildGraphQLMutationLogoutAllDevices as buildGraphQLMutationLogoutAllDevices, index_buildGraphQLMutationLogoutDevice as buildGraphQLMutationLogoutDevice, index_buildGraphQLMutationRefreshToken as buildGraphQLMutationRefreshToken, index_buildGraphQLMutationRegisterUser as buildGraphQLMutationRegisterUser, index_buildGraphQLMutationSendCode as buildGraphQLMutationSendCode, index_buildGraphQLMutationUpdate as buildGraphQLMutationUpdate, index_buildGraphQLMutationUpdateByPk as buildGraphQLMutationUpdateByPk, index_buildGraphQLMutationVerifyCode as buildGraphQLMutationVerifyCode, index_buildGraphQLQueryAggregate as buildGraphQLQueryAggregate, index_buildGraphQLQueryByIdFixed as buildGraphQLQueryByIdFixed, index_buildGraphQLQueryList as buildGraphQLQueryList, index_buildGraphQLQueryPageList as buildGraphQLQueryPageList, index_buildGraphQLUploadPresignedUrl as buildGraphQLUploadPresignedUrl, index_buildMutationFields as buildMutationFields, index_buildWhere as buildWhere, index_formatGraphQLValue as formatGraphQLValue, index_generateOperationName as generateOperationName, index_toPascalCase as toPascalCase };
534
+ export { type index_AggregateFieldInput as AggregateFieldInput, type index_BatchInsertInput as BatchInsertInput, type index_BatchUpdateInput as BatchUpdateInput, type index_DeleteByIdInput as DeleteByIdInput, type index_DeleteInput as DeleteInput, type index_FieldInput as FieldInput, type index_FieldNode as FieldNode, type index_FilePreview as FilePreview, type index_InsertOneInput as InsertOneInput, type index_LoginInput as LoginInput, type index_LogoutDeviceInput as LogoutDeviceInput, type index_LogoutInput as LogoutInput, type index_MutationField as MutationField, type index_MutationInput as MutationInput, type index_PresignedUrlResult as PresignedUrlResult, type index_QueryAggregateInput as QueryAggregateInput, type index_QueryByIdInput as QueryByIdInput, type index_QueryInput as QueryInput, type index_QueryPageListInput as QueryPageListInput, type index_RefreshTokenInput as RefreshTokenInput, type index_RegisterUserInput as RegisterUserInput, type index_SendCodeInput as SendCodeInput, type index_UpdateByPkInput as UpdateByPkInput, type index_UpdateInput as UpdateInput, type index_UploadHeaders as UploadHeaders, type index_UploadPresignedUrlInput as UploadPresignedUrlInput, type index_VerifyCodeInput as VerifyCodeInput, type index_WhereInput as WhereInput, index_buildCommonResultSelection as buildCommonResultSelection, index_buildDataValue as buildDataValue, index_buildFields as buildFields, index_buildGraphQLGetFilePreview as buildGraphQLGetFilePreview, index_buildGraphQLMutation as buildGraphQLMutation, index_buildGraphQLMutationBatchInsert as buildGraphQLMutationBatchInsert, index_buildGraphQLMutationBatchUpdate as buildGraphQLMutationBatchUpdate, index_buildGraphQLMutationDelete as buildGraphQLMutationDelete, index_buildGraphQLMutationDeleteById as buildGraphQLMutationDeleteById, index_buildGraphQLMutationInsertOne as buildGraphQLMutationInsertOne, index_buildGraphQLMutationLogin as buildGraphQLMutationLogin, index_buildGraphQLMutationLogout as buildGraphQLMutationLogout, index_buildGraphQLMutationLogoutAllDevices as buildGraphQLMutationLogoutAllDevices, index_buildGraphQLMutationLogoutDevice as buildGraphQLMutationLogoutDevice, index_buildGraphQLMutationRefreshToken as buildGraphQLMutationRefreshToken, index_buildGraphQLMutationRegisterUser as buildGraphQLMutationRegisterUser, index_buildGraphQLMutationSendCode as buildGraphQLMutationSendCode, index_buildGraphQLMutationUpdate as buildGraphQLMutationUpdate, index_buildGraphQLMutationUpdateByPk as buildGraphQLMutationUpdateByPk, index_buildGraphQLMutationVerifyCode as buildGraphQLMutationVerifyCode, index_buildGraphQLQuery as buildGraphQLQuery, index_buildGraphQLQueryAggregate as buildGraphQLQueryAggregate, index_buildGraphQLQueryByIdFixed as buildGraphQLQueryByIdFixed, index_buildGraphQLQueryList as buildGraphQLQueryList, index_buildGraphQLQueryPageList as buildGraphQLQueryPageList, index_buildGraphQLUploadPresignedUrl as buildGraphQLUploadPresignedUrl, index_buildMutationFields as buildMutationFields, index_buildWhere as buildWhere, index_formatGraphQLValue as formatGraphQLValue, index_generateOperationName as generateOperationName, index_toPascalCase as toPascalCase };
516
535
  }
517
536
 
518
537
  declare const rateLimitConfig: {
@@ -580,6 +599,7 @@ declare const auth: {
580
599
  };
581
600
 
582
601
  declare const query: {
602
+ run<T = requestResult<any>>(input: QueryInput): Promise<T>;
583
603
  list<T = requestResult<any>>(input: QueryInput, useCache?: boolean, ttl?: number): Promise<T>;
584
604
  byId<T = requestResult<any>>(input: QueryByIdInput, useCache?: boolean, ttl?: number): Promise<T>;
585
605
  page<T = requestResult<any>>(input: QueryPageListInput, useCache?: boolean, ttl?: number): Promise<T>;
@@ -587,6 +607,7 @@ declare const query: {
587
607
  };
588
608
 
589
609
  declare const mutation: {
610
+ run<T = requestResult<any>>(input: MutationInput): Promise<T>;
590
611
  insertOne<T = requestResult<any>>(input: InsertOneInput): Promise<T>;
591
612
  batchInsert<T = requestResult<any>>(input: BatchInsertInput): Promise<T>;
592
613
  update<T = requestResult<any>>(input: UpdateInput): Promise<T>;
@@ -725,4 +746,4 @@ declare function formatSize(bytes: number): string;
725
746
  declare function fileToBase64(file: File | Blob): Promise<string>;
726
747
  declare function base64ToFile(dataurl: string, filename: string, mimeType?: string): File;
727
748
 
728
- export { type AggregateFieldInput, type BatchInsertInput, type BatchUpdateInput, type DeleteByIdInput, type DeleteInput, type DeviceInfo, type FieldInput, type FieldNode, type InsertOneInput, type LoginInput, type LogoutDeviceInput, type LogoutInput, type QueryAggregateInput, type QueryByIdInput, type QueryInput, type QueryPageListInput, type RefreshTokenInput, type RegisterUserInput, type RequestConfig, type RequestInterceptor, type SendCodeInput, type UpdateByPkInput, type UpdateInput, type UserToken, type VerifyCodeInput, type WhereInput, add, addDays, auth, base64Decode, base64Encode, base64ToFile, capitalize, ceil, clearHeaders, countSubstr, deepClone, diffDays, difference, divide, fileToBase64, flatten, floor, formatDate, formatMoney, formatSize, fromNow, get, getBrowserDeviceInfo, getClient, getDeviceInfo, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndpoint, getExtName, getHeader, getHeaders, getLoginInfo, getLoginRoles, getRateLimitConfig, getStartOfDay, getStartOfMonth, getStartOfWeek, getToken, gql, index as gqlBuilder, groupBy, hashCode, inRange, initGraphQLClient, intersection, isEmail, isEmptyObject, isEqual, isLeapYear, isNumeric, kebabToCamel, md5, merge, multiply, mutation, omit, oss, pick, query, randomInt, randomString, type rateLimitConfig$1 as rateLimitConfig, removeAllSpace, removeHeader, removeToken, type requestResult, reverse, round, roundWithPrecision, secondsToTime, set, setEndpoint, setHeader, setHeaders, setRateLimitConfig, setToken, simpleSHA1, sms, subtract, toCamelCase, toFixed, toNonExponential, toNumber, toPercent, toSnakeCase, trim, truncate, uncapitalize, unflatten, union, unique, useInterceptor };
749
+ export { type AggregateFieldInput, type BatchInsertInput, type BatchUpdateInput, type DeleteByIdInput, type DeleteInput, type DeviceInfo, type FieldInput, type FieldNode, type InsertOneInput, type LoginInput, type LogoutDeviceInput, type LogoutInput, type MutationInput, type QueryAggregateInput, type QueryByIdInput, type QueryInput, type QueryPageListInput, type RefreshTokenInput, type RegisterUserInput, type RequestConfig, type RequestInterceptor, type SendCodeInput, type UpdateByPkInput, type UpdateInput, type UserToken, type VerifyCodeInput, type WhereInput, add, addDays, auth, base64Decode, base64Encode, base64ToFile, capitalize, ceil, clearHeaders, countSubstr, deepClone, diffDays, difference, divide, fileToBase64, flatten, floor, formatDate, formatMoney, formatSize, fromNow, get, getBrowserDeviceInfo, getClient, getDeviceInfo, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndpoint, getExtName, getHeader, getHeaders, getLoginInfo, getLoginRoles, getRateLimitConfig, getStartOfDay, getStartOfMonth, getStartOfWeek, getToken, gql, index as gqlBuilder, groupBy, hashCode, inRange, initGraphQLClient, intersection, isEmail, isEmptyObject, isEqual, isLeapYear, isNumeric, kebabToCamel, md5, merge, multiply, mutation, omit, oss, pick, query, randomInt, randomString, type rateLimitConfig$1 as rateLimitConfig, removeAllSpace, removeHeader, removeToken, type requestResult, reverse, round, roundWithPrecision, secondsToTime, set, setEndpoint, setHeader, setHeaders, setRateLimitConfig, setToken, simpleSHA1, sms, subtract, toCamelCase, toFixed, toNonExponential, toNumber, toPercent, toSnakeCase, trim, truncate, uncapitalize, unflatten, union, unique, useInterceptor };
package/dist/index.d.ts CHANGED
@@ -223,6 +223,10 @@ declare function buildGraphQLQueryList(input: QueryInput): {
223
223
  query: string;
224
224
  variables: Record<string, any> | undefined;
225
225
  };
226
+ declare function buildGraphQLQuery(input: QueryInput): {
227
+ query: string;
228
+ variables: Record<string, any> | undefined;
229
+ };
226
230
  /** 生成按 ID 查询的 GraphQL query(固定主键参数名为 id) */
227
231
  declare function buildGraphQLQueryByIdFixed(queryByIdInput: QueryByIdInput): {
228
232
  query: string;
@@ -238,6 +242,14 @@ declare function buildGraphQLQueryAggregate(input: QueryAggregateInput): {
238
242
  variables: Record<string, any> | undefined;
239
243
  };
240
244
 
245
+ interface MutationInput {
246
+ operationName: string;
247
+ fields: FieldInput[];
248
+ datas?: Record<string, any>[];
249
+ _set?: Record<string, any>[];
250
+ where?: WhereInput;
251
+ variables?: Record<string, any>;
252
+ }
241
253
  interface InsertOneInput {
242
254
  operationName: string;
243
255
  fields: FieldInput[];
@@ -286,6 +298,10 @@ type MutationField = {
286
298
  affected_rows?: boolean;
287
299
  returning?: FieldInput[];
288
300
  };
301
+ declare function buildGraphQLMutation(input: MutationInput): {
302
+ query: string;
303
+ variables: Record<string, any>;
304
+ };
289
305
  /** 生成单个插入的 GraphQL mutation */
290
306
  declare function buildGraphQLMutationInsertOne(input: InsertOneInput): {
291
307
  query: string;
@@ -468,6 +484,7 @@ type index_LoginInput = LoginInput;
468
484
  type index_LogoutDeviceInput = LogoutDeviceInput;
469
485
  type index_LogoutInput = LogoutInput;
470
486
  type index_MutationField = MutationField;
487
+ type index_MutationInput = MutationInput;
471
488
  type index_PresignedUrlResult = PresignedUrlResult;
472
489
  type index_QueryAggregateInput = QueryAggregateInput;
473
490
  type index_QueryByIdInput = QueryByIdInput;
@@ -486,6 +503,7 @@ declare const index_buildCommonResultSelection: typeof buildCommonResultSelectio
486
503
  declare const index_buildDataValue: typeof buildDataValue;
487
504
  declare const index_buildFields: typeof buildFields;
488
505
  declare const index_buildGraphQLGetFilePreview: typeof buildGraphQLGetFilePreview;
506
+ declare const index_buildGraphQLMutation: typeof buildGraphQLMutation;
489
507
  declare const index_buildGraphQLMutationBatchInsert: typeof buildGraphQLMutationBatchInsert;
490
508
  declare const index_buildGraphQLMutationBatchUpdate: typeof buildGraphQLMutationBatchUpdate;
491
509
  declare const index_buildGraphQLMutationDelete: typeof buildGraphQLMutationDelete;
@@ -501,6 +519,7 @@ declare const index_buildGraphQLMutationSendCode: typeof buildGraphQLMutationSen
501
519
  declare const index_buildGraphQLMutationUpdate: typeof buildGraphQLMutationUpdate;
502
520
  declare const index_buildGraphQLMutationUpdateByPk: typeof buildGraphQLMutationUpdateByPk;
503
521
  declare const index_buildGraphQLMutationVerifyCode: typeof buildGraphQLMutationVerifyCode;
522
+ declare const index_buildGraphQLQuery: typeof buildGraphQLQuery;
504
523
  declare const index_buildGraphQLQueryAggregate: typeof buildGraphQLQueryAggregate;
505
524
  declare const index_buildGraphQLQueryByIdFixed: typeof buildGraphQLQueryByIdFixed;
506
525
  declare const index_buildGraphQLQueryList: typeof buildGraphQLQueryList;
@@ -512,7 +531,7 @@ declare const index_formatGraphQLValue: typeof formatGraphQLValue;
512
531
  declare const index_generateOperationName: typeof generateOperationName;
513
532
  declare const index_toPascalCase: typeof toPascalCase;
514
533
  declare namespace index {
515
- export { type index_AggregateFieldInput as AggregateFieldInput, type index_BatchInsertInput as BatchInsertInput, type index_BatchUpdateInput as BatchUpdateInput, type index_DeleteByIdInput as DeleteByIdInput, type index_DeleteInput as DeleteInput, type index_FieldInput as FieldInput, type index_FieldNode as FieldNode, type index_FilePreview as FilePreview, type index_InsertOneInput as InsertOneInput, type index_LoginInput as LoginInput, type index_LogoutDeviceInput as LogoutDeviceInput, type index_LogoutInput as LogoutInput, type index_MutationField as MutationField, type index_PresignedUrlResult as PresignedUrlResult, type index_QueryAggregateInput as QueryAggregateInput, type index_QueryByIdInput as QueryByIdInput, type index_QueryInput as QueryInput, type index_QueryPageListInput as QueryPageListInput, type index_RefreshTokenInput as RefreshTokenInput, type index_RegisterUserInput as RegisterUserInput, type index_SendCodeInput as SendCodeInput, type index_UpdateByPkInput as UpdateByPkInput, type index_UpdateInput as UpdateInput, type index_UploadHeaders as UploadHeaders, type index_UploadPresignedUrlInput as UploadPresignedUrlInput, type index_VerifyCodeInput as VerifyCodeInput, type index_WhereInput as WhereInput, index_buildCommonResultSelection as buildCommonResultSelection, index_buildDataValue as buildDataValue, index_buildFields as buildFields, index_buildGraphQLGetFilePreview as buildGraphQLGetFilePreview, index_buildGraphQLMutationBatchInsert as buildGraphQLMutationBatchInsert, index_buildGraphQLMutationBatchUpdate as buildGraphQLMutationBatchUpdate, index_buildGraphQLMutationDelete as buildGraphQLMutationDelete, index_buildGraphQLMutationDeleteById as buildGraphQLMutationDeleteById, index_buildGraphQLMutationInsertOne as buildGraphQLMutationInsertOne, index_buildGraphQLMutationLogin as buildGraphQLMutationLogin, index_buildGraphQLMutationLogout as buildGraphQLMutationLogout, index_buildGraphQLMutationLogoutAllDevices as buildGraphQLMutationLogoutAllDevices, index_buildGraphQLMutationLogoutDevice as buildGraphQLMutationLogoutDevice, index_buildGraphQLMutationRefreshToken as buildGraphQLMutationRefreshToken, index_buildGraphQLMutationRegisterUser as buildGraphQLMutationRegisterUser, index_buildGraphQLMutationSendCode as buildGraphQLMutationSendCode, index_buildGraphQLMutationUpdate as buildGraphQLMutationUpdate, index_buildGraphQLMutationUpdateByPk as buildGraphQLMutationUpdateByPk, index_buildGraphQLMutationVerifyCode as buildGraphQLMutationVerifyCode, index_buildGraphQLQueryAggregate as buildGraphQLQueryAggregate, index_buildGraphQLQueryByIdFixed as buildGraphQLQueryByIdFixed, index_buildGraphQLQueryList as buildGraphQLQueryList, index_buildGraphQLQueryPageList as buildGraphQLQueryPageList, index_buildGraphQLUploadPresignedUrl as buildGraphQLUploadPresignedUrl, index_buildMutationFields as buildMutationFields, index_buildWhere as buildWhere, index_formatGraphQLValue as formatGraphQLValue, index_generateOperationName as generateOperationName, index_toPascalCase as toPascalCase };
534
+ export { type index_AggregateFieldInput as AggregateFieldInput, type index_BatchInsertInput as BatchInsertInput, type index_BatchUpdateInput as BatchUpdateInput, type index_DeleteByIdInput as DeleteByIdInput, type index_DeleteInput as DeleteInput, type index_FieldInput as FieldInput, type index_FieldNode as FieldNode, type index_FilePreview as FilePreview, type index_InsertOneInput as InsertOneInput, type index_LoginInput as LoginInput, type index_LogoutDeviceInput as LogoutDeviceInput, type index_LogoutInput as LogoutInput, type index_MutationField as MutationField, type index_MutationInput as MutationInput, type index_PresignedUrlResult as PresignedUrlResult, type index_QueryAggregateInput as QueryAggregateInput, type index_QueryByIdInput as QueryByIdInput, type index_QueryInput as QueryInput, type index_QueryPageListInput as QueryPageListInput, type index_RefreshTokenInput as RefreshTokenInput, type index_RegisterUserInput as RegisterUserInput, type index_SendCodeInput as SendCodeInput, type index_UpdateByPkInput as UpdateByPkInput, type index_UpdateInput as UpdateInput, type index_UploadHeaders as UploadHeaders, type index_UploadPresignedUrlInput as UploadPresignedUrlInput, type index_VerifyCodeInput as VerifyCodeInput, type index_WhereInput as WhereInput, index_buildCommonResultSelection as buildCommonResultSelection, index_buildDataValue as buildDataValue, index_buildFields as buildFields, index_buildGraphQLGetFilePreview as buildGraphQLGetFilePreview, index_buildGraphQLMutation as buildGraphQLMutation, index_buildGraphQLMutationBatchInsert as buildGraphQLMutationBatchInsert, index_buildGraphQLMutationBatchUpdate as buildGraphQLMutationBatchUpdate, index_buildGraphQLMutationDelete as buildGraphQLMutationDelete, index_buildGraphQLMutationDeleteById as buildGraphQLMutationDeleteById, index_buildGraphQLMutationInsertOne as buildGraphQLMutationInsertOne, index_buildGraphQLMutationLogin as buildGraphQLMutationLogin, index_buildGraphQLMutationLogout as buildGraphQLMutationLogout, index_buildGraphQLMutationLogoutAllDevices as buildGraphQLMutationLogoutAllDevices, index_buildGraphQLMutationLogoutDevice as buildGraphQLMutationLogoutDevice, index_buildGraphQLMutationRefreshToken as buildGraphQLMutationRefreshToken, index_buildGraphQLMutationRegisterUser as buildGraphQLMutationRegisterUser, index_buildGraphQLMutationSendCode as buildGraphQLMutationSendCode, index_buildGraphQLMutationUpdate as buildGraphQLMutationUpdate, index_buildGraphQLMutationUpdateByPk as buildGraphQLMutationUpdateByPk, index_buildGraphQLMutationVerifyCode as buildGraphQLMutationVerifyCode, index_buildGraphQLQuery as buildGraphQLQuery, index_buildGraphQLQueryAggregate as buildGraphQLQueryAggregate, index_buildGraphQLQueryByIdFixed as buildGraphQLQueryByIdFixed, index_buildGraphQLQueryList as buildGraphQLQueryList, index_buildGraphQLQueryPageList as buildGraphQLQueryPageList, index_buildGraphQLUploadPresignedUrl as buildGraphQLUploadPresignedUrl, index_buildMutationFields as buildMutationFields, index_buildWhere as buildWhere, index_formatGraphQLValue as formatGraphQLValue, index_generateOperationName as generateOperationName, index_toPascalCase as toPascalCase };
516
535
  }
517
536
 
518
537
  declare const rateLimitConfig: {
@@ -580,6 +599,7 @@ declare const auth: {
580
599
  };
581
600
 
582
601
  declare const query: {
602
+ run<T = requestResult<any>>(input: QueryInput): Promise<T>;
583
603
  list<T = requestResult<any>>(input: QueryInput, useCache?: boolean, ttl?: number): Promise<T>;
584
604
  byId<T = requestResult<any>>(input: QueryByIdInput, useCache?: boolean, ttl?: number): Promise<T>;
585
605
  page<T = requestResult<any>>(input: QueryPageListInput, useCache?: boolean, ttl?: number): Promise<T>;
@@ -587,6 +607,7 @@ declare const query: {
587
607
  };
588
608
 
589
609
  declare const mutation: {
610
+ run<T = requestResult<any>>(input: MutationInput): Promise<T>;
590
611
  insertOne<T = requestResult<any>>(input: InsertOneInput): Promise<T>;
591
612
  batchInsert<T = requestResult<any>>(input: BatchInsertInput): Promise<T>;
592
613
  update<T = requestResult<any>>(input: UpdateInput): Promise<T>;
@@ -725,4 +746,4 @@ declare function formatSize(bytes: number): string;
725
746
  declare function fileToBase64(file: File | Blob): Promise<string>;
726
747
  declare function base64ToFile(dataurl: string, filename: string, mimeType?: string): File;
727
748
 
728
- export { type AggregateFieldInput, type BatchInsertInput, type BatchUpdateInput, type DeleteByIdInput, type DeleteInput, type DeviceInfo, type FieldInput, type FieldNode, type InsertOneInput, type LoginInput, type LogoutDeviceInput, type LogoutInput, type QueryAggregateInput, type QueryByIdInput, type QueryInput, type QueryPageListInput, type RefreshTokenInput, type RegisterUserInput, type RequestConfig, type RequestInterceptor, type SendCodeInput, type UpdateByPkInput, type UpdateInput, type UserToken, type VerifyCodeInput, type WhereInput, add, addDays, auth, base64Decode, base64Encode, base64ToFile, capitalize, ceil, clearHeaders, countSubstr, deepClone, diffDays, difference, divide, fileToBase64, flatten, floor, formatDate, formatMoney, formatSize, fromNow, get, getBrowserDeviceInfo, getClient, getDeviceInfo, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndpoint, getExtName, getHeader, getHeaders, getLoginInfo, getLoginRoles, getRateLimitConfig, getStartOfDay, getStartOfMonth, getStartOfWeek, getToken, gql, index as gqlBuilder, groupBy, hashCode, inRange, initGraphQLClient, intersection, isEmail, isEmptyObject, isEqual, isLeapYear, isNumeric, kebabToCamel, md5, merge, multiply, mutation, omit, oss, pick, query, randomInt, randomString, type rateLimitConfig$1 as rateLimitConfig, removeAllSpace, removeHeader, removeToken, type requestResult, reverse, round, roundWithPrecision, secondsToTime, set, setEndpoint, setHeader, setHeaders, setRateLimitConfig, setToken, simpleSHA1, sms, subtract, toCamelCase, toFixed, toNonExponential, toNumber, toPercent, toSnakeCase, trim, truncate, uncapitalize, unflatten, union, unique, useInterceptor };
749
+ export { type AggregateFieldInput, type BatchInsertInput, type BatchUpdateInput, type DeleteByIdInput, type DeleteInput, type DeviceInfo, type FieldInput, type FieldNode, type InsertOneInput, type LoginInput, type LogoutDeviceInput, type LogoutInput, type MutationInput, type QueryAggregateInput, type QueryByIdInput, type QueryInput, type QueryPageListInput, type RefreshTokenInput, type RegisterUserInput, type RequestConfig, type RequestInterceptor, type SendCodeInput, type UpdateByPkInput, type UpdateInput, type UserToken, type VerifyCodeInput, type WhereInput, add, addDays, auth, base64Decode, base64Encode, base64ToFile, capitalize, ceil, clearHeaders, countSubstr, deepClone, diffDays, difference, divide, fileToBase64, flatten, floor, formatDate, formatMoney, formatSize, fromNow, get, getBrowserDeviceInfo, getClient, getDeviceInfo, getEndOfDay, getEndOfMonth, getEndOfWeek, getEndpoint, getExtName, getHeader, getHeaders, getLoginInfo, getLoginRoles, getRateLimitConfig, getStartOfDay, getStartOfMonth, getStartOfWeek, getToken, gql, index as gqlBuilder, groupBy, hashCode, inRange, initGraphQLClient, intersection, isEmail, isEmptyObject, isEqual, isLeapYear, isNumeric, kebabToCamel, md5, merge, multiply, mutation, omit, oss, pick, query, randomInt, randomString, type rateLimitConfig$1 as rateLimitConfig, removeAllSpace, removeHeader, removeToken, type requestResult, reverse, round, roundWithPrecision, secondsToTime, set, setEndpoint, setHeader, setHeaders, setRateLimitConfig, setToken, simpleSHA1, sms, subtract, toCamelCase, toFixed, toNonExponential, toNumber, toPercent, toSnakeCase, trim, truncate, uncapitalize, unflatten, union, unique, useInterceptor };
package/dist/index.js CHANGED
@@ -908,6 +908,7 @@ __export(builders_exports, {
908
908
  buildDataValue: () => buildDataValue,
909
909
  buildFields: () => buildFields,
910
910
  buildGraphQLGetFilePreview: () => buildGraphQLGetFilePreview,
911
+ buildGraphQLMutation: () => buildGraphQLMutation,
911
912
  buildGraphQLMutationBatchInsert: () => buildGraphQLMutationBatchInsert,
912
913
  buildGraphQLMutationBatchUpdate: () => buildGraphQLMutationBatchUpdate,
913
914
  buildGraphQLMutationDelete: () => buildGraphQLMutationDelete,
@@ -923,6 +924,7 @@ __export(builders_exports, {
923
924
  buildGraphQLMutationUpdate: () => buildGraphQLMutationUpdate,
924
925
  buildGraphQLMutationUpdateByPk: () => buildGraphQLMutationUpdateByPk,
925
926
  buildGraphQLMutationVerifyCode: () => buildGraphQLMutationVerifyCode,
927
+ buildGraphQLQuery: () => buildGraphQLQuery,
926
928
  buildGraphQLQueryAggregate: () => buildGraphQLQueryAggregate,
927
929
  buildGraphQLQueryByIdFixed: () => buildGraphQLQueryByIdFixed,
928
930
  buildGraphQLQueryList: () => buildGraphQLQueryList,
@@ -1076,6 +1078,22 @@ function buildGraphQLQueryList(input) {
1076
1078
  const query2 = `query ${operationName.toLowerCase()}${varDefs ? `(${varDefs})` : ""} { ${operationName.toLowerCase()}${topArgsStr} ${fields ? "{" + buildFields(fields) + "}" : ""} }`;
1077
1079
  return { query: query2, variables };
1078
1080
  }
1081
+ function buildGraphQLQuery(input) {
1082
+ const { operationName, fields, variables, where, orderBy, distinctOn, limit, offset } = input;
1083
+ const varDefs = variables ? Object.keys(variables).map((k) => `$${k}: String!`).join(", ") : "";
1084
+ const topArgs = [];
1085
+ if (where) topArgs.push(`where: { ${buildWhere(where)} }`);
1086
+ if (distinctOn) topArgs.push(`distinct_on: [${distinctOn.map((s) => `${s}`).join(" ")}]`);
1087
+ if (orderBy)
1088
+ topArgs.push(
1089
+ `order_by: {${Object.entries(orderBy).map(([k, v]) => `${k}: ${v}`).join(" ")}}`
1090
+ );
1091
+ if (limit !== void 0) topArgs.push(`limit: ${limit}`);
1092
+ if (offset !== void 0) topArgs.push(`offset: ${offset}`);
1093
+ const topArgsStr = topArgs.length ? `(${topArgs.join(" ")})` : "";
1094
+ const query2 = `query ${operationName}${varDefs ? `(${varDefs})` : ""} { ${operationName}${topArgsStr} ${fields ? "{" + buildFields(fields) + "}" : ""} }`;
1095
+ return { query: query2, variables };
1096
+ }
1079
1097
  function buildGraphQLQueryByIdFixed(queryByIdInput) {
1080
1098
  const { pk, fields, operationName } = queryByIdInput;
1081
1099
  const variables = { id: pk };
@@ -1134,6 +1152,56 @@ function buildGraphQLQueryAggregate(input) {
1134
1152
  }
1135
1153
 
1136
1154
  // src/builders/mutation.ts
1155
+ function buildGraphQLMutation(input) {
1156
+ const { operationName, fields, datas, _set, where, variables } = input;
1157
+ if (!operationName) {
1158
+ throw new Error("operationName is required");
1159
+ }
1160
+ if (!fields || fields.length === 0) {
1161
+ throw new Error("fields is required");
1162
+ }
1163
+ const finalVariables = { ...variables || {} };
1164
+ const varDefs = Object.keys(finalVariables).map((k) => `$${k}: String!`).join(", ");
1165
+ const fieldsStr = buildFields(fields);
1166
+ if (datas) {
1167
+ const dataArray = Array.isArray(datas) ? datas : [datas];
1168
+ finalVariables.datas = dataArray;
1169
+ const datasArg = "$datas";
1170
+ const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
1171
+ ${operationName}(${operationName}: ${datasArg}) {
1172
+ affected_rows
1173
+ returning { ${fieldsStr} }
1174
+ }
1175
+ }`;
1176
+ return { query: query2, variables: finalVariables };
1177
+ }
1178
+ if (_set) {
1179
+ if (!where) {
1180
+ throw new Error("update mutation requires where condition");
1181
+ }
1182
+ finalVariables._set = _set;
1183
+ const setArg = "$_set";
1184
+ const whereArg = buildWhere(where);
1185
+ const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
1186
+ ${operationName}(where: { ${whereArg} }, _set: ${setArg}) {
1187
+ affected_rows
1188
+ returning { ${fieldsStr} }
1189
+ }
1190
+ }`;
1191
+ return { query: query2, variables: finalVariables };
1192
+ }
1193
+ if (where) {
1194
+ const whereArg = buildWhere(where);
1195
+ const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
1196
+ ${operationName}(where: { ${whereArg} }) {
1197
+ affected_rows
1198
+ returning { ${fieldsStr} }
1199
+ }
1200
+ }`;
1201
+ return { query: query2, variables: finalVariables };
1202
+ }
1203
+ throw new Error("Invalid mutation input: either datas, _set+where, or where must be provided");
1204
+ }
1137
1205
  function buildGraphQLMutationInsertOne(input) {
1138
1206
  const { operationName, fields, data, variables } = input;
1139
1207
  const entityName = operationName;
@@ -1877,6 +1945,11 @@ var query = {
1877
1945
  // NOTE:
1878
1946
  // GraphQL batch queries should be implemented via alias + fragment builders.
1879
1947
  // Deferred until v2 API redesign.
1948
+ async run(input) {
1949
+ const { query: query2, variables } = buildGraphQLQuery(input);
1950
+ const result = await execute({ query: query2, variables });
1951
+ return result;
1952
+ },
1880
1953
  async list(input, useCache = false, ttl) {
1881
1954
  return rateLimit("list", "query", async () => {
1882
1955
  input.operationName = input.operationName + "s";
@@ -1934,6 +2007,11 @@ var query = {
1934
2007
 
1935
2008
  // src/core/api/mutation.ts
1936
2009
  var mutation = {
2010
+ async run(input) {
2011
+ const { query: query2, variables } = buildGraphQLMutation(input);
2012
+ const result = await execute({ query: query2, variables });
2013
+ return result;
2014
+ },
1937
2015
  async insertOne(input) {
1938
2016
  return rateLimit("insertOne", "mutation", async () => {
1939
2017
  const { query: query2, variables } = buildGraphQLMutationInsertOne(input);