prostgles-types 4.0.113 → 4.0.115

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.ts CHANGED
@@ -13,7 +13,7 @@ export declare const _PG_date: readonly ["date", "timestamp", "timestamptz"];
13
13
  export declare const _PG_interval: readonly ["interval"];
14
14
  export declare const _PG_postgis: readonly ["geometry", "geography"];
15
15
  export declare const _PG_geometric: readonly ["point", "line", "lseg", "box", "path", "polygon", "circle"];
16
- export type PG_COLUMN_UDT_DATA_TYPE = typeof _PG_strings[number] | typeof _PG_numbers[number] | typeof _PG_geometric[number] | typeof _PG_json[number] | typeof _PG_bool[number] | typeof _PG_date[number] | typeof _PG_interval[number] | typeof _PG_postgis[number];
16
+ export type PG_COLUMN_UDT_DATA_TYPE = (typeof _PG_strings)[number] | (typeof _PG_numbers)[number] | (typeof _PG_geometric)[number] | (typeof _PG_json)[number] | (typeof _PG_bool)[number] | (typeof _PG_date)[number] | (typeof _PG_interval)[number] | (typeof _PG_postgis)[number];
17
17
  export declare const TS_PG_Types: {
18
18
  readonly "number[]": ("_int2" | "_int4" | "_float4" | "_float8" | "_oid")[];
19
19
  readonly "boolean[]": "_bool"[];
@@ -25,12 +25,33 @@ export declare const TS_PG_Types: {
25
25
  readonly any: readonly ["json", "jsonb", "interval"];
26
26
  };
27
27
  export type TS_COLUMN_DATA_TYPES = keyof typeof TS_PG_Types;
28
+ /**
29
+ * Generated Typescript schema for the tables and views in the database
30
+ * Example:
31
+ *
32
+ *
33
+ * type DBSchema = {
34
+ * ..view_name: {
35
+ * is_view: boolean;
36
+ * select: boolean;
37
+ * insert: boolean;
38
+ * update: boolean;
39
+ * delete: boolean;
40
+ * insertColumns: { col1?: number | null; col2: string; }
41
+ * columns: { col1: number | null; col2: string; }
42
+ * }
43
+ * }
44
+ */
28
45
  export type DBTableSchema = {
29
46
  is_view?: boolean;
30
47
  select?: boolean;
31
48
  insert?: boolean;
32
49
  update?: boolean;
33
50
  delete?: boolean;
51
+ /**
52
+ * Used in update, insertm select and filters
53
+ * fields that are nullable or with a default value are be optional
54
+ */
34
55
  columns: AnyObject;
35
56
  };
36
57
  export type DBSchema = {
@@ -38,37 +59,108 @@ export type DBSchema = {
38
59
  };
39
60
  export type ColumnInfo = {
40
61
  name: string;
62
+ /**
63
+ * Column display name. Will be first non empty value from i18n data, comment, name
64
+ */
41
65
  label: string;
66
+ /**
67
+ * Column description (if provided)
68
+ */
42
69
  comment: string;
70
+ /**
71
+ * Ordinal position of the column within the table (count starts at 1)
72
+ */
43
73
  ordinal_position: number;
74
+ /**
75
+ * True if column is nullable. A not-null constraint is one way a column can be known not nullable, but there may be others.
76
+ */
44
77
  is_nullable: boolean;
45
78
  is_updatable: boolean;
79
+ /**
80
+ * If the column is a generated column (converted to boolean from ALWAYS and NEVER)
81
+ */
46
82
  is_generated: boolean;
83
+ /**
84
+ * Simplified data type
85
+ */
47
86
  data_type: string;
87
+ /**
88
+ * Postgres raw data types. values starting with underscore means it's an array of that data type
89
+ */
48
90
  udt_name: PG_COLUMN_UDT_DATA_TYPE;
91
+ /**
92
+ * Element data type
93
+ */
49
94
  element_type: string;
95
+ /**
96
+ * Element raw data type
97
+ */
50
98
  element_udt_name: string;
99
+ /**
100
+ * PRIMARY KEY constraint on column. A table can have more then one PK
101
+ */
51
102
  is_pkey: boolean;
103
+ /**
104
+ * Foreign key constraint
105
+ * A column can reference multiple tables
106
+ */
52
107
  references?: {
53
108
  ftable: string;
54
109
  fcols: string[];
55
110
  cols: string[];
56
111
  }[];
112
+ /**
113
+ * true if column has a default value
114
+ * Used for excluding pkey from insert
115
+ */
57
116
  has_default: boolean;
117
+ /**
118
+ * Column default value
119
+ */
58
120
  column_default?: any;
121
+ /**
122
+ * Extracted from tableConfig
123
+ * Used in SmartForm
124
+ */
59
125
  min?: string | number;
60
126
  max?: string | number;
61
127
  hint?: string;
62
128
  jsonbSchema?: JSONB.JSONBSchema;
129
+ /**
130
+ * If degined then this column is referencing the file table
131
+ * Extracted from FileTable config
132
+ * Used in SmartForm
133
+ */
63
134
  file?: FileColumnConfig;
64
135
  };
65
136
  export type ValidatedColumnInfo = ColumnInfo & {
137
+ /**
138
+ * TypeScript data type
139
+ */
66
140
  tsDataType: TS_COLUMN_DATA_TYPES;
141
+ /**
142
+ * Can be viewed/selected
143
+ */
67
144
  select: boolean;
145
+ /**
146
+ * Can be ordered by
147
+ */
68
148
  orderBy: boolean;
149
+ /**
150
+ * Can be filtered by
151
+ */
69
152
  filter: boolean;
153
+ /**
154
+ * Can be inserted
155
+ */
70
156
  insert: boolean;
157
+ /**
158
+ * Can be updated
159
+ */
71
160
  update: boolean;
161
+ /**
162
+ * Can be used in the delete filter
163
+ */
72
164
  delete: boolean;
73
165
  };
74
166
  export type DBSchemaTable = {
@@ -76,8 +168,20 @@ export type DBSchemaTable = {
76
168
  info: TableInfo;
77
169
  columns: ValidatedColumnInfo[];
78
170
  };
171
+ /**
172
+ * List of fields to include or exclude
173
+ */
79
174
  export type FieldFilter<T extends AnyObject = AnyObject> = SelectTyped<T>;
80
175
  export type AscOrDesc = 1 | -1 | boolean;
176
+ /**
177
+ * @example
178
+ * { product_name: -1 } -> SORT BY product_name DESC
179
+ * [{ field_name: (1 | -1 | boolean) }]
180
+ * true | 1 -> ascending
181
+ * false | -1 -> descending
182
+ * Array order is maintained
183
+ * if nullEmpty is true then empty text will be replaced to null (so nulls sorting takes effect on it)
184
+ */
81
185
  export type _OrderBy<T extends AnyObject> = {
82
186
  [K in keyof Partial<T>]: AscOrDesc;
83
187
  } | {
@@ -105,10 +209,15 @@ export type JoinCondition = {
105
209
  } | ComplexFilter;
106
210
  export type JoinPath = {
107
211
  table: string;
212
+ /**
213
+ * {
214
+ * leftColumn: "rightColumn"
215
+ * }
216
+ */
108
217
  on?: Record<string, string>[];
109
218
  };
110
219
  export type RawJoinPath = string | (JoinPath | string)[];
111
- export type DetailedJoinSelect = Partial<Record<typeof JOIN_KEYS[number], RawJoinPath>> & {
220
+ export type DetailedJoinSelect = Partial<Record<(typeof JOIN_KEYS)[number], RawJoinPath>> & {
112
221
  select: Select;
113
222
  filter?: FullFilter<void, void>;
114
223
  having?: FullFilter<void, void>;
@@ -118,22 +227,31 @@ export type DetailedJoinSelect = Partial<Record<typeof JOIN_KEYS[number], RawJoi
118
227
  } & ({
119
228
  $condition?: undefined;
120
229
  } | {
230
+ /**
231
+ * If present then will overwrite $path and any inferred joins
232
+ */
121
233
  $condition?: JoinCondition[];
122
234
  });
123
- export type SimpleJoinSelect = "*" | Record<string, 1 | "*" | true | FunctionSelect> | Record<string, 0 | false>;
235
+ export type SimpleJoinSelect = "*"
236
+ /** Aliased Shorthand join: table_name: { ...select } */
237
+ | Record<string, 1 | "*" | true | FunctionSelect> | Record<string, 0 | false>;
124
238
  export type JoinSelect = SimpleJoinSelect | DetailedJoinSelect;
125
239
  type FunctionShorthand = string;
126
240
  type FunctionFull = Record<string, any[] | readonly any[] | FunctionShorthand>;
127
241
  type FunctionSelect = FunctionShorthand | FunctionFull;
242
+ /**
243
+ * { computed_field: { funcName: [args] } }
244
+ */
128
245
  type FunctionAliasedSelect = Record<string, FunctionFull>;
129
246
  type InclusiveSelect = true | 1 | FunctionSelect | JoinSelect;
130
- type SelectFuncs<T extends AnyObject = AnyObject, IsTyped = false> = (({
247
+ type SelectFuncs<T extends AnyObject = AnyObject, IsTyped = false> = ({
131
248
  [K in keyof Partial<T>]: InclusiveSelect;
132
249
  } & Record<string, IsTyped extends true ? FunctionFull : InclusiveSelect>) | FunctionAliasedSelect | {
133
250
  [K in keyof Partial<T>]: true | 1 | string;
134
251
  } | {
135
252
  [K in keyof Partial<T>]: 0 | false;
136
- } | CommonSelect | (keyof Partial<T>)[]);
253
+ } | CommonSelect | (keyof Partial<T>)[];
254
+ /** S param is needed to ensure the non typed select works fine */
137
255
  export type Select<T extends AnyObject | void = void, S extends DBSchema | void = void> = {
138
256
  t: T;
139
257
  s: S;
@@ -149,30 +267,112 @@ export type SelectBasic = {
149
267
  [key: string]: any;
150
268
  } | {} | undefined | "" | "*";
151
269
  type CommonSelectParams = {
270
+ /**
271
+ * Max number of rows to return
272
+ * - If undefined then 1000 will be applied as the default
273
+ * - On client publish rules can affect this behaviour: cannot request more than the maxLimit (if present)
274
+ */
152
275
  limit?: number | null;
276
+ /**
277
+ * Number of rows to skip
278
+ */
153
279
  offset?: number;
280
+ /**
281
+ * Will group by all non aggregated fields specified in select (or all fields by default)
282
+ */
154
283
  groupBy?: boolean;
155
- returnType?: "row" | "value" | "values" | "statement" | "statement-no-rls" | "statement-where";
284
+ /**
285
+ * Result data structure/type:
286
+ * - row: the first row as an object
287
+ * - value: the first value from of first field
288
+ * - values: array of values from the selected field
289
+ * - statement: sql statement
290
+ * - statement-no-rls: sql statement without row level security
291
+ * - statement-where: sql statement where condition
292
+ */
293
+ returnType?: "row"
294
+ /**
295
+ * Will return the first value from the selected field
296
+ */
297
+ | "value"
298
+ /**
299
+ * Will return an array of values from the selected field. Similar to array_agg(field).
300
+ */
301
+ | "values"
302
+ /**
303
+ * Will return the sql statement. Requires publishRawSQL privileges if called by client
304
+ */
305
+ | "statement"
306
+ /**
307
+ * Will return the sql statement excluding the user header. Requires publishRawSQL privileges if called by client
308
+ */
309
+ | "statement-no-rls"
310
+ /**
311
+ * Will return the sql statement where condition. Requires publishRawSQL privileges if called by client
312
+ */
313
+ | "statement-where";
156
314
  };
157
315
  export type SelectParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = CommonSelectParams & {
316
+ /**
317
+ * Fields/expressions/linked data to select
318
+ * - If empty then all fields will be selected
319
+ * - If "*" then all fields will be selected
320
+ * - If { field: 0 } then all fields except the specified field will be selected
321
+ * - If { field: 1 } then only the specified field will be selected
322
+ * - If { field: { funcName: [args] } } then the field will be selected with the specified function applied
323
+ * - If { field: { nestedTable: { field: 1 } } } then the field will be selected with the nested table fields
324
+ */
158
325
  select?: Select<T, S>;
326
+ /**
327
+ * Order by options
328
+ * - If array then the order will be maintained
329
+ */
159
330
  orderBy?: OrderBy<S extends DBSchema ? T : void>;
331
+ /**
332
+ * Filter applied after any aggregations (group by)
333
+ */
160
334
  having?: FullFilter<T, S>;
161
335
  };
162
336
  export type SubscribeParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = SelectParams<T, S> & {
337
+ /**
338
+ * If true then the subscription will be throttled to the provided number of milliseconds
339
+ */
163
340
  throttle?: number;
164
341
  throttleOpts?: {
342
+ /**
343
+ * False by default.
344
+ * If true then the first value will be emitted at the end of the interval. Instant otherwise
345
+ * */
165
346
  skipFirst?: boolean;
166
347
  };
167
348
  };
168
349
  export type UpdateParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = {
350
+ /**
351
+ * If defined will returns the specified fields of the updated record(s)
352
+ */
169
353
  returning?: Select<T, S>;
354
+ /**
355
+ * Used for sync.
356
+ * If true then only valid and allowed fields will be updated
357
+ */
170
358
  removeDisallowedFields?: boolean;
171
359
  multi?: boolean;
172
360
  } & Pick<CommonSelectParams, "returnType">;
173
361
  export type InsertParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = {
362
+ /**
363
+ * If defined will returns the specified fields of the updated record(s)
364
+ */
174
365
  returning?: Select<T, S>;
366
+ /**
367
+ * By default the insert may fail due to a unique/exclusion constraint violation error. To control this:
368
+ * - DoNothing: will ignore the error and do nothing
369
+ * - DoUpdate: will update all non primary key columns of the conflicting row
370
+ */
175
371
  onConflict?: "DoNothing" | "DoUpdate";
372
+ /**
373
+ * Used for sync.
374
+ * If true then only valid and allowed fields will be inserted
375
+ */
176
376
  removeDisallowedFields?: boolean;
177
377
  } & Pick<CommonSelectParams, "returnType">;
178
378
  export type DeleteParams<T extends AnyObject | void = void, S extends DBSchema | void = void> = {
@@ -180,23 +380,54 @@ export type DeleteParams<T extends AnyObject | void = void, S extends DBSchema |
180
380
  } & Pick<CommonSelectParams, "returnType">;
181
381
  export type PartialLax<T = AnyObject> = Partial<T>;
182
382
  export type TableInfo = {
383
+ /**
384
+ * OID from the postgres database
385
+ * Useful in handling renamed tables
386
+ */
183
387
  oid: number;
388
+ /**
389
+ * Comment from the postgres database
390
+ */
184
391
  comment?: string;
392
+ /**
393
+ * Defined if this is the fileTable
394
+ */
185
395
  isFileTable?: {
396
+ /**
397
+ * Defined if direct inserts are disabled.
398
+ * Only nested inserts through the specified tables/columns are allowed
399
+ * */
186
400
  allowedNestedInserts?: {
187
401
  table: string;
188
402
  column: string;
189
403
  }[] | undefined;
190
404
  };
405
+ /**
406
+ * True if fileTable is enabled and this table references the fileTable
407
+ */
191
408
  hasFiles?: boolean;
192
409
  isView?: boolean;
410
+ /**
411
+ * Name of the fileTable (if enabled)
412
+ */
193
413
  fileTableName?: string;
414
+ /**
415
+ * Used for getColumns in cases where the columns are dynamic based on the request.
416
+ * See dynamicFields from Update rules
417
+ */
194
418
  dynamicRules?: {
195
419
  update?: boolean;
196
420
  };
421
+ /**
422
+ * Additional table info provided through TableConfig
423
+ */
197
424
  info?: {
198
425
  label?: string;
199
426
  };
427
+ /**
428
+ * List of unique column indexes/constraints.
429
+ * Column groups where at least a column is not allowed to be viewed (selected) are omitted.
430
+ */
200
431
  uniqueColumnGroups: string[][] | undefined;
201
432
  };
202
433
  export type OnError = (err: any) => void;
@@ -248,23 +479,75 @@ type GetColumns = (lang?: string, params?: {
248
479
  data: AnyObject;
249
480
  filter: AnyObject;
250
481
  }) => Promise<ValidatedColumnInfo[]>;
482
+ /**
483
+ * Methods for interacting with a view
484
+ * - On client-side some methods are restricted (and undefined) based on publish rules on the server
485
+ */
251
486
  export type ViewHandler<TD extends AnyObject = AnyObject, S extends DBSchema | void = void> = {
252
- getInfo?: (lang?: string) => Promise<TableInfo>;
253
- getColumns?: GetColumns;
487
+ /**
488
+ * Retrieves the table/view info
489
+ */
490
+ getInfo: (lang?: string) => Promise<TableInfo>;
491
+ /**
492
+ * Retrieves columns metadata of the table/view
493
+ */
494
+ getColumns: GetColumns;
495
+ /**
496
+ * Retrieves a list of matching records from the view/table
497
+ */
254
498
  find: <P extends SelectParams<TD, S>>(filter?: FullFilter<TD, S>, selectParams?: P) => Promise<GetSelectReturnType<S, P, TD, true>>;
499
+ /**
500
+ * Retrieves a record from the view/table
501
+ */
255
502
  findOne: <P extends SelectParams<TD, S>>(filter?: FullFilter<TD, S>, selectParams?: P) => Promise<undefined | GetSelectReturnType<S, P, TD, false>>;
503
+ /**
504
+ * Retrieves a list of matching records from the view/table and subscribes to changes
505
+ */
256
506
  subscribe: <P extends SubscribeParams<TD, S>>(filter: FullFilter<TD, S>, params: P, onData: (items: GetSelectReturnType<S, P, TD, true>) => any, onError?: OnError) => Promise<SubscriptionHandler>;
507
+ /**
508
+ * Retrieves first matching record from the view/table and subscribes to changes
509
+ */
257
510
  subscribeOne: <P extends SubscribeParams<TD, S>>(filter: FullFilter<TD, S>, params: P, onData: (item: GetSelectReturnType<S, P, TD, false> | undefined) => any, onError?: OnError) => Promise<SubscriptionHandler>;
511
+ /**
512
+ * Returns the number of rows that match the filter
513
+ */
258
514
  count: <P extends SelectParams<TD, S>>(filter?: FullFilter<TD, S>, selectParams?: P) => Promise<number>;
515
+ /**
516
+ * Returns result size in bits
517
+ */
259
518
  size: <P extends SelectParams<TD, S>>(filter?: FullFilter<TD, S>, selectParams?: P) => Promise<string>;
260
519
  };
261
520
  type UpsertDataToPGCastLax<T extends AnyObject> = PartialLax<UpsertDataToPGCast<T>>;
262
521
  type InsertData<T extends AnyObject> = UpsertDataToPGCast<T> | UpsertDataToPGCast<T>[];
522
+ /**
523
+ * Methods for interacting with a table
524
+ * - On client-side some methods are restricted (and undefined) based on publish rules on the server
525
+ */
263
526
  export type TableHandler<TD extends AnyObject = AnyObject, S extends DBSchema | void = void> = ViewHandler<TD, S> & {
527
+ /**
528
+ * Updates a record in the table based on the specified filter criteria
529
+ * - Use { multi: false } to ensure no more than one row is updated
530
+ */
264
531
  update: <P extends UpdateParams<TD, S>>(filter: FullFilter<TD, S>, newData: UpsertDataToPGCastLax<TD>, params?: P) => Promise<GetUpdateReturnType<P, TD, S> | undefined>;
532
+ /**
533
+ * Updates multiple records in the table in a batch operation.
534
+ * - Each item in the `data` array contains a filter and the corresponding data to update.
535
+ */
265
536
  updateBatch: <P extends UpdateParams<TD, S>>(data: [FullFilter<TD, S>, UpsertDataToPGCastLax<TD>][], params?: P) => Promise<GetUpdateReturnType<P, TD, S> | void>;
537
+ /**
538
+ * Inserts a new record into the table.
539
+ */
266
540
  insert: <P extends InsertParams<TD, S>, D extends InsertData<TD>>(data: D, params?: P) => Promise<GetInsertReturnType<D, P, TD, S>>;
541
+ /**
542
+ * Inserts or updates a record in the table.
543
+ * - If a record matching the `filter` exists, it updates the record.
544
+ * - If no matching record exists, it inserts a new record.
545
+ */
267
546
  upsert: <P extends UpdateParams<TD, S>>(filter: FullFilter<TD, S>, newData: UpsertDataToPGCastLax<TD>, params?: P) => Promise<GetUpdateReturnType<P, TD, S>>;
547
+ /**
548
+ * Deletes records from the table based on the specified filter criteria.
549
+ * - If no filter is provided, all records may be deleted (use with caution).
550
+ */
268
551
  delete: <P extends DeleteParams<TD, S>>(filter?: FullFilter<TD, S>, params?: P) => Promise<GetUpdateReturnType<P, TD, S> | undefined>;
269
552
  };
270
553
  export type JoinMakerOptions<TT extends AnyObject = AnyObject> = SelectParams<TT> & {
@@ -335,9 +618,16 @@ export type SocketSQLStreamHandlers = {
335
618
  export type SocketSQLStreamClient = SocketSQLStreamServer & {
336
619
  start: (listener: (packet: SocketSQLStreamPacket) => void) => Promise<SocketSQLStreamHandlers>;
337
620
  };
338
- export type CheckForListen<T, O extends SQLOptions> = O["allowListen"] extends true ? (DBEventHandles | T) : T;
339
- export type GetSQLReturnType<O extends SQLOptions> = CheckForListen<(O["returnType"] extends "row" ? AnyObject | null : O["returnType"] extends "rows" ? AnyObject[] : O["returnType"] extends "value" ? any | null : O["returnType"] extends "values" ? any[] : O["returnType"] extends "statement" ? string : O["returnType"] extends "noticeSubscription" ? DBEventHandles : O["returnType"] extends "stream" ? SocketSQLStreamClient : SQLResult<O["returnType"]>), O>;
340
- export type SQLHandler = <Opts extends SQLOptions>(query: string, args?: AnyObject | any[], options?: Opts, serverSideOptions?: {
621
+ export type CheckForListen<T, O extends SQLOptions> = O["allowListen"] extends true ? DBEventHandles | T : T;
622
+ export type GetSQLReturnType<O extends SQLOptions> = CheckForListen<O["returnType"] extends "row" ? AnyObject | null : O["returnType"] extends "rows" ? AnyObject[] : O["returnType"] extends "value" ? any | null : O["returnType"] extends "values" ? any[] : O["returnType"] extends "statement" ? string : O["returnType"] extends "noticeSubscription" ? DBEventHandles : O["returnType"] extends "stream" ? SocketSQLStreamClient : SQLResult<O["returnType"]>, O>;
623
+ export type SQLHandler =
624
+ /**
625
+ *
626
+ * @param query <string> query. e.g.: SELECT * FROM users;
627
+ * @param params <any[] | object> query arguments to be escaped. e.g.: { name: 'dwadaw' }
628
+ * @param options <object> { returnType: "statement" | "rows" | "noticeSubscription" }
629
+ */
630
+ <Opts extends SQLOptions>(query: string, args?: AnyObject | any[], options?: Opts, serverSideOptions?: {
341
631
  socket: any;
342
632
  } | {
343
633
  httpReq: any;
@@ -363,11 +653,32 @@ export type DBNotifConfig = DBNoticeConfig & {
363
653
  notifChannel: string;
364
654
  };
365
655
  export type SQLOptions = {
656
+ /**
657
+ * Return type of the query
658
+ */
366
659
  returnType?: Required<SelectParams>["returnType"] | "default-with-rollback" | "statement" | "rows" | "noticeSubscription" | "arrayMode" | "stream";
660
+ /**
661
+ * If allowListen not specified and a LISTEN query is issued then expect error
662
+ */
367
663
  allowListen?: boolean;
664
+ /**
665
+ * Positive integer that works only with returnType="stream".
666
+ * If provided then the query will be cancelled when the specified number of rows have been streamed
667
+ */
368
668
  streamLimit?: number;
669
+ /**
670
+ * If true then the connection will be persisted and used for subsequent queries
671
+ */
369
672
  persistStreamConnection?: boolean;
673
+ /**
674
+ * connectionId of the stream connection to use
675
+ * Acquired from the first query with persistStreamConnection=true
676
+ */
370
677
  streamConnectionId?: string;
678
+ /**
679
+ * If false then the query will not be checked for params. Used to ignore queries with param like text (e.g.: ${someText} )
680
+ * Defaults to true
681
+ */
371
682
  hasParams?: boolean;
372
683
  };
373
684
  export type SQLRequest = {
@@ -397,12 +708,18 @@ export declare const CHANNELS: {
397
708
  LOGIN: string;
398
709
  LOGOUT: string;
399
710
  AUTHGUARD: string;
711
+ /**
712
+ * Used for sending any connection errors from onSocketConnect
713
+ */
400
714
  CONNECTION: string;
401
715
  _preffix: string;
402
716
  };
403
717
  export type SubscriptionChannels = {
718
+ /** Used by server to emit data to client */
404
719
  channelName: string;
720
+ /** Used by client to confirm when ready */
405
721
  channelNameReady: string;
722
+ /** Used by client to stop subscription */
406
723
  channelNameUnsubscribe: string;
407
724
  };
408
725
  export type AuthGuardLocation = {
@@ -429,10 +746,10 @@ export declare const RULE_METHODS: {
429
746
  readonly sync: readonly ["sync", "unsync"];
430
747
  readonly subscribe: readonly ["unsubscribe", "subscribe", "subscribeOne"];
431
748
  };
432
- export type MethodKey = typeof RULE_METHODS[keyof typeof RULE_METHODS][number];
433
- export type TableSchemaForClient = Record<string, Partial<Record<MethodKey, (MethodKey extends "insert" ? {
749
+ export type MethodKey = (typeof RULE_METHODS)[keyof typeof RULE_METHODS][number];
750
+ export type TableSchemaForClient = Record<string, Partial<Record<MethodKey, MethodKey extends "insert" ? {
434
751
  allowedNestedInserts?: string[];
435
- } : AnyObject)>>>;
752
+ } : AnyObject>>>;
436
753
  export type TableSchema = {
437
754
  schema: string;
438
755
  name: string;
@@ -450,7 +767,7 @@ export type TableSchema = {
450
767
  delete: boolean;
451
768
  };
452
769
  };
453
- export type MethodFunction = (...args: any) => (any | Promise<any>);
770
+ export type MethodFunction = (...args: any) => any | Promise<any>;
454
771
  export type MethodFullDef = {
455
772
  input: Record<string, JSONB.JSONBSchema>;
456
773
  run: MethodFunction;
@@ -482,10 +799,10 @@ export type ClientSchema = {
482
799
  tableSchemaErrors: TableSchemaErrors;
483
800
  tableSchema?: DBSchemaTable[];
484
801
  schema: TableSchemaForClient;
485
- methods: (string | {
802
+ methods: (string | ({
486
803
  name: string;
487
804
  description?: string;
488
- } & Pick<MethodFullDef, "input" | "output">)[];
805
+ } & Pick<MethodFullDef, "input" | "output">))[];
489
806
  };
490
807
  export type ProstglesError = {
491
808
  message: string;
@@ -502,7 +819,7 @@ export { CONTENT_TYPE_TO_EXT } from "./files";
502
819
  export type { ALLOWED_CONTENT_TYPE, ALLOWED_EXTENSION, FileColumnConfig, FileType } from "./files";
503
820
  export * from "./filters";
504
821
  export * from "./jsonb";
505
- export type { ClientExpressData, ClientSyncHandles, ClientSyncInfo, ClientSyncPullResponse, SyncBatchParams, SyncConfig, onUpdatesParams } from "./replication";
822
+ export type { ClientExpressData, ClientSyncHandles, ClientSyncInfo, ClientSyncPullResponse, SyncBatchParams, SyncConfig, onUpdatesParams, } from "./replication";
506
823
  export * from "./util";
507
824
  export * from "./auth";
508
825
  //# sourceMappingURL=index.d.ts.map