@ragable/sdk 0.6.18 → 0.6.19

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.mts CHANGED
@@ -926,11 +926,29 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
926
926
  rows: Row[];
927
927
  }
928
928
  interface BrowserCollectionRecord<Row extends Record<string, unknown> = Record<string, unknown>> {
929
+ [key: string]: unknown;
929
930
  id: string;
930
931
  data: Row;
931
932
  createdAt: string;
932
933
  updatedAt: string;
933
934
  }
935
+ /**
936
+ * Collection APIs return record envelopes, but user schema `Row` types should be
937
+ * the JSON row inside `record.data`. If generated app types accidentally use the
938
+ * envelope as `Row`, unwrap it so consumers still get `record.data.<field>`.
939
+ */
940
+ type BrowserCollectionRowData<Row extends Record<string, unknown> = Record<string, unknown>> = Row extends {
941
+ id: string;
942
+ data: infer Data;
943
+ createdAt: string;
944
+ updatedAt: string;
945
+ } ? Data extends Record<string, unknown> ? Data : Row : Row;
946
+ type BrowserCollectionInsertData<Row extends Record<string, unknown>, Insert extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Insert : Insert extends {
947
+ data: infer Data;
948
+ } ? Data extends Record<string, unknown> ? Data : BrowserCollectionRowData<Row> : BrowserCollectionRowData<Row>;
949
+ type BrowserCollectionUpdateData<Row extends Record<string, unknown>, Update extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Update : Update extends {
950
+ data?: infer Data;
951
+ } ? Data extends Record<string, unknown> ? Partial<Data> : Partial<BrowserCollectionRowData<Row>> : Partial<BrowserCollectionRowData<Row>>;
934
952
  interface BrowserCollectionDefinition {
935
953
  id: string;
936
954
  name: string;
@@ -963,16 +981,16 @@ declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<
963
981
  private readonly name;
964
982
  private readonly databaseInstanceId?;
965
983
  constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
966
- find: (whereOrParams?: CollectionWhere<Row> | BrowserCollectionFindParams<Row>) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
967
- insert: (data: Insert) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
968
- update: (where: CollectionWhere<Row>, patch: Update, options?: {
984
+ find: (whereOrParams?: CollectionWhere<BrowserCollectionRowData<Row>> | BrowserCollectionFindParams<BrowserCollectionRowData<Row>>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
985
+ insert: (data: BrowserCollectionInsertData<Row, Insert>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>>>;
986
+ update: (where: CollectionWhere<BrowserCollectionRowData<Row>>, patch: BrowserCollectionUpdateData<Row, Update>, options?: {
969
987
  limit?: number;
970
- }) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
971
- delete: (where: CollectionWhere<Row>, options?: {
988
+ }) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
989
+ delete: (where: CollectionWhere<BrowserCollectionRowData<Row>>, options?: {
972
990
  limit?: number;
973
991
  }) => Promise<PostgrestResult<{
974
992
  deleted: number;
975
- records: BrowserCollectionRecord<Row>[];
993
+ records: BrowserCollectionRecord<BrowserCollectionRowData<Row>>[];
976
994
  }>>;
977
995
  }
978
996
  type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {
package/dist/index.d.ts CHANGED
@@ -926,11 +926,29 @@ interface BrowserSqlQueryResult<Row extends Record<string, unknown> = Record<str
926
926
  rows: Row[];
927
927
  }
928
928
  interface BrowserCollectionRecord<Row extends Record<string, unknown> = Record<string, unknown>> {
929
+ [key: string]: unknown;
929
930
  id: string;
930
931
  data: Row;
931
932
  createdAt: string;
932
933
  updatedAt: string;
933
934
  }
935
+ /**
936
+ * Collection APIs return record envelopes, but user schema `Row` types should be
937
+ * the JSON row inside `record.data`. If generated app types accidentally use the
938
+ * envelope as `Row`, unwrap it so consumers still get `record.data.<field>`.
939
+ */
940
+ type BrowserCollectionRowData<Row extends Record<string, unknown> = Record<string, unknown>> = Row extends {
941
+ id: string;
942
+ data: infer Data;
943
+ createdAt: string;
944
+ updatedAt: string;
945
+ } ? Data extends Record<string, unknown> ? Data : Row : Row;
946
+ type BrowserCollectionInsertData<Row extends Record<string, unknown>, Insert extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Insert : Insert extends {
947
+ data: infer Data;
948
+ } ? Data extends Record<string, unknown> ? Data : BrowserCollectionRowData<Row> : BrowserCollectionRowData<Row>;
949
+ type BrowserCollectionUpdateData<Row extends Record<string, unknown>, Update extends Record<string, unknown>> = BrowserCollectionRowData<Row> extends Row ? Update : Update extends {
950
+ data?: infer Data;
951
+ } ? Data extends Record<string, unknown> ? Partial<Data> : Partial<BrowserCollectionRowData<Row>> : Partial<BrowserCollectionRowData<Row>>;
934
952
  interface BrowserCollectionDefinition {
935
953
  id: string;
936
954
  name: string;
@@ -963,16 +981,16 @@ declare class BrowserCollectionApi<Row extends Record<string, unknown> = Record<
963
981
  private readonly name;
964
982
  private readonly databaseInstanceId?;
965
983
  constructor(database: RagableBrowserDatabaseClient<any>, name: string, databaseInstanceId?: string | undefined);
966
- find: (whereOrParams?: CollectionWhere<Row> | BrowserCollectionFindParams<Row>) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
967
- insert: (data: Insert) => Promise<PostgrestResult<BrowserCollectionRecord<Row>>>;
968
- update: (where: CollectionWhere<Row>, patch: Update, options?: {
984
+ find: (whereOrParams?: CollectionWhere<BrowserCollectionRowData<Row>> | BrowserCollectionFindParams<BrowserCollectionRowData<Row>>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
985
+ insert: (data: BrowserCollectionInsertData<Row, Insert>) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>>>;
986
+ update: (where: CollectionWhere<BrowserCollectionRowData<Row>>, patch: BrowserCollectionUpdateData<Row, Update>, options?: {
969
987
  limit?: number;
970
- }) => Promise<PostgrestResult<BrowserCollectionRecord<Row>[]>>;
971
- delete: (where: CollectionWhere<Row>, options?: {
988
+ }) => Promise<PostgrestResult<BrowserCollectionRecord<BrowserCollectionRowData<Row>>[]>>;
989
+ delete: (where: CollectionWhere<BrowserCollectionRowData<Row>>, options?: {
972
990
  limit?: number;
973
991
  }) => Promise<PostgrestResult<{
974
992
  deleted: number;
975
- records: BrowserCollectionRecord<Row>[];
993
+ records: BrowserCollectionRecord<BrowserCollectionRowData<Row>>[];
976
994
  }>>;
977
995
  }
978
996
  type BrowserCollections<Database extends RagableDatabase = DefaultRagableDatabase> = [keyof Database["public"]["Tables"]] extends [never] ? Record<string, BrowserCollectionApi<Record<string, unknown>>> : {