@freehour/supabase-core 1.1.0 → 1.1.2

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/README.md CHANGED
@@ -29,7 +29,7 @@ bun pm trust @freehour/supabase-core
29
29
 
30
30
  ### Configuration
31
31
 
32
- If you generate migrations from schemas, make sure to include the `supabase_core` schema in your `schema_paths` in `supabase/config.toml`.
32
+ If you generate migrations from schemas, make sure to include the `supabase-core` schema in your `schema_paths` in `supabase/config.toml`.
33
33
 
34
34
  ```toml
35
35
  schema_paths = ["./schemas/supabase-core/*.sql", /* your app schema paths */]
@@ -1,72 +1,24 @@
1
1
  import { PostgrestResponseSuccess, PostgrestQueryBuilder, PostgrestFilterBuilder, UnstableGetResult } from '@supabase/postgrest-js';
2
2
  import { PostgrestSingleResponse } from '@supabase/supabase-js';
3
+ import { FuzzySearchParams, UpsertOptions } from './data';
3
4
  import { BaseDatabase, CoreDatabase } from './database';
4
5
  import { DatabaseService } from './database-service';
5
6
  import { ColumnName, ID, Insert, RelationName, RelationType, Row, SchemaName, TableName, Update, ViewName } from './relation';
6
- import { CountMethod, Select, SelectColumns, SelectOptions } from './select';
7
+ import { Select, SelectColumns, SelectOptions, CountMethod } from './select';
7
8
  import { OmitFrom } from './utils';
8
9
  import { Filter } from './filter';
9
10
  import { PaginatedList } from './postgrest-extensions';
10
- /**
11
- * Options for fuzzy searching within a database table or view.
12
- */
13
- export interface FuzzySearchParams<Database extends BaseDatabase<Database>, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
14
- /**
15
- * The name of the column to search in.
16
- */
17
- column: ColumnName<Database, Schema, Type, Relation>;
18
- /**
19
- * The search term to use for the fuzzy search.
20
- * This is the term that will be matched against the specified column.
21
- * If empty or undefined, the function will return all rows sorted by the search column.
22
- * @default ''
23
- */
24
- searchTerm?: string;
25
- /**
26
- * The minimum similarity score for results to be included.
27
- * This is a number between 0 and 1, where 1 means an exact match.
28
- * @default 0
29
- */
30
- minSimilarity?: number;
31
- /**
32
- * The maximum number of results to return.
33
- * @default 64
34
- */
35
- limit?: number;
36
- }
37
- /**
38
- * Options for upserting data into a database.
39
- * Upserting means inserting a new row or updating an existing row if it already exists.
40
- */
41
- export interface UpsertOptions<Database extends BaseDatabase<Database>, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
42
- /**
43
- * The name of the columns to use for conflict resolution.
44
- * This column is used to determine if a row already exists in the database.
45
- * If a row with the same value in this column exists, it will be updated instead of inserted.
46
- * If not specified, uses the primary key of the relation.
47
- */
48
- onConflict?: ColumnName<Database, Schema, Type, Relation>[];
49
- /**
50
- * If `true`, duplicate rows are ignored. If
51
- * `false`, duplicate rows are merged with existing rows.
52
- */
53
- ignoreDuplicates?: boolean;
54
- /**
55
- * Count algorithm to use to count upserted rows.
56
- */
57
- countMethod?: CountMethod;
58
- }
59
11
  export interface DataServiceParams<Database extends BaseDatabase<Database>, Schema extends SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
60
12
  /**
61
13
  * The database service instance to use for database operations.
62
14
  */
63
15
  database: DatabaseService<Database>;
64
16
  /**
65
- * The name of the schema containing the view.
17
+ * The name of the schema containing the table or view.
66
18
  */
67
19
  schema: Schema;
68
20
  /**
69
- * The name of the view or table that this service interacts with.
21
+ * The name of the table or view that this service interacts with.
70
22
  */
71
23
  relation: Relation;
72
24
  }
@@ -3056,7 +3008,6 @@ export declare class DataService<Database extends BaseDatabase<Database>, Schema
3056
3008
  /**
3057
3009
  * Inserts or updates a row in the relation.
3058
3010
  * @param insert The data to insert or update in the relation.
3059
- * @param options Options for the upsert operation, such as conflict resolution.
3060
3011
  * @returns The inserted or updated row.
3061
3012
  * @throws DatabaseApiError if the upsert operation fails.
3062
3013
  */
@@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OAAO,EAAE,IAAI,CAAC;gBAEtC,EACR,QAAQ,EACR,MAAM,EACN,IAAI,GACP,EAAE,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;CAOnD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAC/B,QAAQ,EAAE,uBAAuB,CAAC,KAAK,CAAC,GACzC,wBAAwB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAMlE"}
package/dist/data.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { BaseDatabase } from './database';
2
+ import { ColumnName, RelationName, RelationType, SchemaName } from './relation';
3
+ import { CountMethod } from './select';
4
+ /**
5
+ * Options for fuzzy searching within a database table or view.
6
+ */
7
+ export interface FuzzySearchParams<Database extends BaseDatabase<Database>, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
8
+ /**
9
+ * The name of the column to search in.
10
+ */
11
+ column: ColumnName<Database, Schema, Type, Relation>;
12
+ /**
13
+ * The search term to use for the fuzzy search.
14
+ * This is the term that will be matched against the specified column.
15
+ * If empty or undefined, the function will return all rows sorted by the search column.
16
+ * @default ''
17
+ */
18
+ searchTerm?: string;
19
+ /**
20
+ * The minimum similarity score for results to be included.
21
+ * This is a number between 0 and 1, where 1 means an exact match.
22
+ * @default 0
23
+ */
24
+ minSimilarity?: number;
25
+ /**
26
+ * The maximum number of results to return.
27
+ * @default 64
28
+ */
29
+ limit?: number;
30
+ }
31
+ /**
32
+ * Options for upserting data into a database.
33
+ * Upserting means inserting a new row or updating an existing row if it already exists.
34
+ */
35
+ export interface UpsertOptions<Database extends BaseDatabase<Database>, Schema extends SchemaName<Database> = SchemaName<Database>, Type extends RelationType = RelationType, Relation extends RelationName<Database, Schema, Type> = RelationName<Database, Schema, Type>> {
36
+ /**
37
+ * The name of the columns to use for conflict resolution.
38
+ * This column is used to determine if a row already exists in the database.
39
+ * If a row with the same value in this column exists, it will be updated instead of inserted.
40
+ * If not specified, uses the primary key of the relation.
41
+ */
42
+ onConflict?: ColumnName<Database, Schema, Type, Relation>[];
43
+ /**
44
+ * If `true`, duplicate rows are ignored. If
45
+ * `false`, duplicate rows are merged with existing rows.
46
+ */
47
+ ignoreDuplicates?: boolean;
48
+ /**
49
+ * Count algorithm to use to count upserted rows.
50
+ */
51
+ countMethod?: CountMethod;
52
+ }
53
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../lib/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAC9B,QAAQ,SAAS,YAAY,CAAC,QAAQ,CAAC,EACvC,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,EAC1D,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,QAAQ,SAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;IAE5F;;OAEG;IACH,MAAM,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IAErD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa,CAC1B,QAAQ,SAAS,YAAY,CAAC,QAAQ,CAAC,EACvC,MAAM,SAAS,UAAU,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,EAC1D,IAAI,SAAS,YAAY,GAAG,YAAY,EACxC,QAAQ,SAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;IAE5F;;;;;OAKG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;IAE5D;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B"}
@@ -1,11 +1,13 @@
1
- import { Embedding, EmbeddingPreprocessingStep, EmbeddingSynchronizationResult, FileMetadata, Metadata } from './embedding';
1
+ import { Embedding, EmbeddingPreprocessingStep, EmbeddingSynchronizationResult, FileMetadata, Metadata, MetadataGeneratorFn } from './embedding';
2
2
  import { FileRef, StorageLocation } from './storage';
3
3
  import { StorageService } from './storage-service';
4
- type MetadataGeneratorFn = ((file: File, location: StorageLocation) => Metadata);
4
+ export interface EmbeddingServiceParams<BucketName extends string> {
5
+ storage: StorageService<BucketName>;
6
+ }
5
7
  export declare abstract class EmbeddingService<BucketName extends string = string> {
6
8
  private readonly preprocesses;
7
9
  protected readonly storage: StorageService<BucketName>;
8
- constructor(storage: StorageService<BucketName>);
10
+ constructor({ storage, }: EmbeddingServiceParams<BucketName>);
9
11
  /**
10
12
  * Retrieves the embeddings associated with the given file reference.
11
13
  *
@@ -41,13 +43,7 @@ export declare abstract class EmbeddingService<BucketName extends string = strin
41
43
  addPreprocessingStep(preprocess: EmbeddingPreprocessingStep): this;
42
44
  removePreprocessingStep(name: string): this;
43
45
  get(fileRef: FileRef<BucketName>): Promise<Embedding[]>;
44
- ingest(params: FileRef<BucketName> & {
45
- metadata?: Metadata | MetadataGeneratorFn;
46
- }): Promise<Embedding[]>;
47
- synchronize({ bucket, metadata, }: {
48
- bucket: BucketName;
49
- metadata?: Metadata | MetadataGeneratorFn;
50
- }): Promise<EmbeddingSynchronizationResult[]>;
46
+ ingest(fileRef: FileRef<BucketName>, metadata?: Metadata | MetadataGeneratorFn): Promise<Embedding[]>;
47
+ synchronize(bucket: BucketName, metadata?: Metadata | MetadataGeneratorFn): Promise<EmbeddingSynchronizationResult[]>;
51
48
  }
52
- export {};
53
49
  //# sourceMappingURL=embedding-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,0BAA0B,EAAmC,8BAA8B,EAAmC,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnM,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD,KAAK,mBAAmB,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,KAAK,QAAQ,CAAC,CAAC;AAEjF,8BAAsB,gBAAgB,CAClC,UAAU,SAAS,MAAM,GAAG,MAAM;IAGlC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAoC;IACjE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;gBAE3C,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC;IAI/C;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAEjF;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE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AAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,mBAAmB,GAAG,OAAO,CAAC,8BAA8B,EAAE,CAAC;CA2B9H"}
@@ -2,6 +2,7 @@ import { MimeString } from '@freehour/mime';
2
2
  import { Json } from './json';
3
3
  import { FileRef, StorageLocation } from './storage';
4
4
  export type Metadata = Record<string, Json>;
5
+ export type MetadataGeneratorFn = ((file: File, location: StorageLocation) => Metadata);
5
6
  export interface FileMetadata {
6
7
  name: string;
7
8
  type: MimeString;
@@ -1 +1 @@
1
- {"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../lib/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAG1D,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAE5C,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAU,SAAQ,eAAe;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,YAAY,GAAG,QAAQ,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,+BAA+B;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,+BAA+B;IAC5C,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,MAAM,MAAM,8BAA8B,GAAG,+BAA+B,GAAG,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M,MAAM,8BAA8B,GAAG,+BAA+B,GAAG,+BAA+B,CAAC;AAE/G,MAAM,WAAW,0BAA0B;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,KAAK,MAAM,CAAC;CACzD;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAwBzE,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { assert as l } from "@freehour/assert";
2
- import p from "zod";
3
- import { PostgrestError as $ } from "@supabase/supabase-js";
4
- import { Mime as q } from "@freehour/mime";
2
+ import m from "zod";
3
+ import { PostgrestError as P } from "@supabase/supabase-js";
4
+ import { Mime as S } from "@freehour/mime";
5
5
  class k extends Error {
6
6
  constructor(t, e = {}) {
7
7
  super(t, e), this.name = this.constructor.name, Error.captureStackTrace(this, this.constructor);
@@ -45,7 +45,7 @@ class x extends k {
45
45
  super(t, a), this.expression = e, this.format = r;
46
46
  }
47
47
  }
48
- class P extends k {
48
+ class _ extends k {
49
49
  /**
50
50
  * The schema where the record was expected to be found.
51
51
  */
@@ -83,21 +83,21 @@ class I extends Error {
83
83
  super(t, a), this.value = e, this.supported = r;
84
84
  }
85
85
  }
86
- const j = p.object({
87
- code: p.string(),
88
- details: p.string().nullable(),
89
- hint: p.string().nullable(),
90
- name: p.string().optional(),
91
- message: p.string().optional()
86
+ const $ = m.object({
87
+ code: m.string(),
88
+ details: m.string().nullable(),
89
+ hint: m.string().nullable(),
90
+ name: m.string().optional(),
91
+ message: m.string().optional()
92
92
  });
93
93
  function G(s) {
94
- return s instanceof $ || j.safeParse(s).success;
94
+ return s instanceof P || $.safeParse(s).success;
95
95
  }
96
96
  const v = ["eq", "neq", "gt", "gte", "lt", "lte", "like", "ilike", "match", "imatch", "in", "is", "isdistinct", "fts", "plfts", "phfts", "wfts", "cs", "cd", "ov", "sl", "sr", "nxr", "nxl", "adj"], H = ["and", "or"], J = ",", O = "~", Q = (s) => (t = {}) => {
97
97
  const e = (a) => t[a] ?? a, r = Object.keys(s.shape);
98
- return p.string().transform((a, n) => {
98
+ return m.string().transform((a, n) => {
99
99
  try {
100
- return A(a, r, e);
100
+ return M(a, r, e);
101
101
  } catch (i) {
102
102
  return n.addIssue({
103
103
  code: "custom",
@@ -111,61 +111,61 @@ const v = ["eq", "neq", "gt", "gte", "lt", "lte", "like", "ilike", "match", "ima
111
111
  }
112
112
  });
113
113
  };
114
- function N(s) {
114
+ function j(s) {
115
115
  return s.startsWith("not.") ? s.slice(4) : `not.${s}`;
116
116
  }
117
- function L(s) {
117
+ function N(s) {
118
118
  return {
119
119
  ...s,
120
- op: N(s.op)
120
+ op: j(s.op)
121
121
  };
122
122
  }
123
- function S(s, t = (e) => e) {
123
+ function q(s, t = (e) => e) {
124
124
  if (s.type === "logical") {
125
- const e = s.args.map((r) => S(r, t));
125
+ const e = s.args.map((r) => q(r, t));
126
126
  return `${s.op}(${e})`;
127
127
  }
128
128
  return `${t(s.key)}.${s.op}.${s.value}`;
129
129
  }
130
- function M(s, t = (r) => r, e = O) {
131
- return s.map((r) => S(r, t)).join(e);
130
+ function L(s, t = (r) => r, e = O) {
131
+ return s.map((r) => q(r, t)).join(e);
132
132
  }
133
- function b(s, t = [], e = (r) => r) {
133
+ function y(s, t = [], e = (r) => r) {
134
134
  function r(u) {
135
- const w = [];
136
- let y = 0, d = "";
137
- for (const f of u)
138
- f === "(" ? (y++, d += f) : f === ")" ? (y--, d += f) : f === "," && y === 0 ? (w.push(d.trim()), d = "") : d += f;
139
- return d && w.push(d.trim()), w;
135
+ const p = [];
136
+ let b = 0, f = "";
137
+ for (const g of u)
138
+ g === "(" ? (b++, f += g) : g === ")" ? (b--, f += g) : g === "," && b === 0 ? (p.push(f.trim()), f = "") : f += g;
139
+ return f && p.push(f.trim()), p;
140
140
  }
141
141
  if (s.endsWith(")")) {
142
142
  if (s.startsWith("and("))
143
143
  return {
144
144
  type: "logical",
145
145
  op: "and",
146
- args: r(s.slice(4, -1)).map((u) => b(u, t, e))
146
+ args: r(s.slice(4, -1)).map((u) => y(u, t, e))
147
147
  };
148
148
  if (s.startsWith("or("))
149
149
  return {
150
150
  type: "logical",
151
151
  op: "or",
152
- args: r(s.slice(3, -1)).map((u) => b(u, t, e))
152
+ args: r(s.slice(3, -1)).map((u) => y(u, t, e))
153
153
  };
154
154
  if (s.startsWith("not.and("))
155
155
  return {
156
156
  type: "logical",
157
157
  op: "not.and",
158
- args: r(s.slice(8, -1)).map((u) => b(u, t, e))
158
+ args: r(s.slice(8, -1)).map((u) => y(u, t, e))
159
159
  };
160
160
  if (s.startsWith("not.or("))
161
161
  return {
162
162
  type: "logical",
163
163
  op: "not.or",
164
- args: r(s.slice(7, -1)).map((u) => b(u, t, e))
164
+ args: r(s.slice(7, -1)).map((u) => y(u, t, e))
165
165
  };
166
166
  }
167
- const n = `^(${t.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : t.join("|")})\\.((?:not\\.)?(?:${v.join("|")}))\\.(.+)$`, o = new RegExp(n).exec(s);
168
- if (!o)
167
+ const n = `^(${t.length === 0 ? "[a-zA-Z_][a-zA-Z0-9_]*" : t.join("|")})\\.((?:not\\.)?(?:${v.join("|")}))\\.(.+)$`, c = new RegExp(n).exec(s);
168
+ if (!c)
169
169
  throw new x(`Invalid filter expression '${s}'`, {
170
170
  expression: s,
171
171
  format: {
@@ -174,22 +174,22 @@ function b(s, t = [], e = (r) => r) {
174
174
  operators: v
175
175
  }
176
176
  });
177
- const [, c, h, g] = o;
177
+ const [, o, h, d] = c;
178
178
  return {
179
179
  type: "condition",
180
- key: e(c),
180
+ key: e(o),
181
181
  op: h,
182
- value: l.defined(g)
182
+ value: l.defined(d)
183
183
  };
184
184
  }
185
- function A(s, t = [], e = (a) => a, r = O) {
186
- return s.length === 0 ? [] : s.split(r).map((a) => b(a, t, e));
185
+ function M(s, t = [], e = (a) => a, r = O) {
186
+ return s.length === 0 ? [] : s.split(r).map((a) => y(a, t, e));
187
187
  }
188
- function D(s, t = "/") {
188
+ function A(s, t = "/") {
189
189
  const e = s.lastIndexOf(t);
190
190
  return e === -1 ? ["", s] : [s.substring(0, e), s.substring(e + 1)];
191
191
  }
192
- function _(s) {
192
+ function D(s) {
193
193
  return Array.isArray(s) ? s : [s];
194
194
  }
195
195
  function z(s, t) {
@@ -205,7 +205,7 @@ function T(s, t) {
205
205
  function W(s) {
206
206
  return Object.entries(s);
207
207
  }
208
- const m = {
208
+ const w = {
209
209
  /**
210
210
  * Query extension for PostgREST queries.
211
211
  * Supports typesafe column selection and counting.
@@ -226,9 +226,9 @@ const m = {
226
226
  * @param options The options for the selection, such as count.
227
227
  * @returns The PostgREST filter builder with selection applied and filter extension enabled.
228
228
  */
229
- select: (t, e) => m.filter.enable(
229
+ select: (t, e) => w.filter.enable(
230
230
  s.select(
231
- _(t).join(","),
231
+ D(t).join(","),
232
232
  e
233
233
  )
234
234
  ),
@@ -239,7 +239,7 @@ const m = {
239
239
  * @param method The counting method to use, defaults to 'exact'.
240
240
  * @returns The PostgREST filter builder with counting applied and filter extension enabled.
241
241
  */
242
- count: (t = "exact") => m.filter.enable(
242
+ count: (t = "exact") => w.filter.enable(
243
243
  s.select("*", { count: t, head: !0 })
244
244
  ),
245
245
  /**
@@ -248,7 +248,7 @@ const m = {
248
248
  *
249
249
  * @returns The PostgREST filter builder with delete applied and filter extension enabled.
250
250
  */
251
- delete: () => m.filter.enable(
251
+ delete: () => w.filter.enable(
252
252
  s.delete()
253
253
  )
254
254
  })
@@ -272,15 +272,15 @@ const m = {
272
272
  * A filter is defined as an array of AST filter nodes including conditions and logical operators.
273
273
  * @param filter The filter to apply.
274
274
  */
275
- apply: (e) => m.filter.enable(
275
+ apply: (e) => w.filter.enable(
276
276
  (() => {
277
277
  function r(a, n) {
278
278
  if (n.type === "logical") {
279
- const i = M(n.args, (o) => o, ",");
279
+ const i = L(n.args, (c) => c, ",");
280
280
  return n.op === "or" ? a.or(i) : n.op === "not.or" ? a.or(i, { referencedTable: "not" }) : r(a, {
281
281
  type: "logical",
282
282
  op: n.op === "and" ? "not.or" : "or",
283
- args: n.args.map(L)
283
+ args: n.args.map(N)
284
284
  });
285
285
  }
286
286
  return a.filter(n.key, n.op, n.value);
@@ -296,7 +296,7 @@ const m = {
296
296
  * @param count Optional count of total items, if known.
297
297
  * If provided, it will be used to check if the pagination range is valid and resolve to an empty range if not.
298
298
  */
299
- paginate: (e, r, a) => m.filter.enable(
299
+ paginate: (e, r, a) => w.filter.enable(
300
300
  (() => {
301
301
  l(e >= 0, "Page index must be ≥ 0"), l(r >= 0, "Page limit must be ≥ 0");
302
302
  const n = e * r, i = n + r - 1;
@@ -323,12 +323,12 @@ const m = {
323
323
  * @returns The paginated list of queried items.
324
324
  */
325
325
  collect: () => s.throwOnError().then((e) => {
326
- const { data: r, count: a } = e, { page: n, limit: i, ...o } = l.defined(t.pagination, "Pagination context is required for collect(). Make sure to call paginate() before collect()"), c = a ?? o.count;
327
- return l(i > 0, "Page limit must be > 0"), l(Array.isArray(r), "Data must be an array for pagination, make sure to select multiple rows in query"), l(c !== void 0, "Row count is required for pagination, make sure to count in query or pass `count` in paginate()"), {
326
+ const { data: r, count: a } = e, { page: n, limit: i, ...c } = l.defined(t.pagination, "Pagination context is required for collect(). Make sure to call paginate() before collect()"), o = a ?? c.count;
327
+ return l(i > 0, "Page limit must be > 0"), l(Array.isArray(r), "Data must be an array for pagination, make sure to select multiple rows in query"), l(o !== void 0, "Row count is required for pagination, make sure to count in query or pass `count` in paginate()"), {
328
328
  items: r,
329
- totalItems: c,
329
+ totalItems: o,
330
330
  page: n,
331
- totalPages: Math.ceil(c / i),
331
+ totalPages: Math.ceil(o / i),
332
332
  limit: i
333
333
  };
334
334
  })
@@ -353,7 +353,7 @@ class F {
353
353
  this.database = t, this.schema = e, this.relation = r;
354
354
  }
355
355
  recordNotFoundError(t) {
356
- return new P(`Record with id ${t} not found in ${this.schema}.${this.relation}`, {
356
+ return new _(`Record with id ${t} not found in ${this.schema}.${this.relation}`, {
357
357
  schema: this.schema,
358
358
  relation: this.relation,
359
359
  id: t
@@ -367,7 +367,7 @@ class F {
367
367
  */
368
368
  get query() {
369
369
  const t = this.database.schema(this.schema).from(this.relation);
370
- return m.query.enable(t);
370
+ return w.query.enable(t);
371
371
  }
372
372
  /**
373
373
  * Performs a fuzzy search on the specified column of the relation.
@@ -460,7 +460,6 @@ class F {
460
460
  /**
461
461
  * Inserts or updates a row in the relation.
462
462
  * @param insert The data to insert or update in the relation.
463
- * @param options Options for the upsert operation, such as conflict resolution.
464
463
  * @returns The inserted or updated row.
465
464
  * @throws DatabaseApiError if the upsert operation fails.
466
465
  */
@@ -557,7 +556,9 @@ class Y {
557
556
  class K {
558
557
  preprocesses = [];
559
558
  storage;
560
- constructor(t) {
559
+ constructor({
560
+ storage: t
561
+ }) {
561
562
  this.storage = t;
562
563
  }
563
564
  /**
@@ -572,17 +573,14 @@ class K {
572
573
  const e = [];
573
574
  let r = !0, a;
574
575
  for (; r; ) {
575
- const { objects: n, ...i } = await this.storage.getFiles({
576
- bucket: t,
577
- cursor: a
578
- }), o = await Promise.all(
579
- n.map(async (c) => {
580
- const h = new Date(c.updated_at), g = await this.storage.getFileStorageLocation({ fileId: c.id }), u = await this.getEmbeddings(g);
581
- return u.length === 0 || u.some((w) => w.createdAt < h);
576
+ const { objects: n, ...i } = await this.storage.getFiles(t, { cursor: a }), c = await Promise.all(
577
+ n.map(async (o) => {
578
+ const h = new Date(o.updated_at), d = await this.storage.getFileStorageLocation({ fileId: o.id }), u = await this.getEmbeddings(d);
579
+ return u.length === 0 || u.some((p) => p.createdAt < h);
582
580
  })
583
581
  );
584
582
  e.push(
585
- ...n.filter((c, h) => o[h]).map(({ id: c }) => ({ fileId: c }))
583
+ ...n.filter((o, h) => c[h]).map(({ id: o }) => ({ fileId: o }))
586
584
  ), { hasNext: r, nextCursor: a } = i;
587
585
  }
588
586
  return e;
@@ -602,28 +600,25 @@ class K {
602
600
  const e = await this.storage.getFileStorageLocation(t);
603
601
  return this.getEmbeddings(e);
604
602
  }
605
- async ingest(t) {
606
- const { file: e, ...r } = await this.storage.downloadFile(t), a = q.parse(e.type);
607
- if (a.type !== "text")
608
- throw new I(`Unsupported file type: ${a}. Only text files can be embedded.`);
609
- await this.deleteEmbeddings(r);
610
- const n = {
611
- name: e.name,
612
- type: e.type,
613
- size: e.size,
614
- ...r,
615
- ...typeof t.metadata == "function" ? t.metadata(e, r) : t.metadata
616
- }, i = this.preprocess(await e.text(), n);
617
- return this.createEmbeddings(r, i, n);
618
- }
619
- async synchronize({
620
- bucket: t,
621
- metadata: e
622
- }) {
603
+ async ingest(t, e) {
604
+ const { file: r, ...a } = await this.storage.downloadFile(t), n = S.parse(r.type);
605
+ if (n.type !== "text")
606
+ throw new I(`Unsupported file type: ${n}. Only text files can be embedded.`);
607
+ await this.deleteEmbeddings(a);
608
+ const i = {
609
+ name: r.name,
610
+ type: r.type,
611
+ size: r.size,
612
+ ...a,
613
+ ...typeof e == "function" ? e(r, a) : e
614
+ }, c = this.preprocess(await r.text(), i);
615
+ return this.createEmbeddings(a, c, i);
616
+ }
617
+ async synchronize(t, e) {
623
618
  const r = await this.getOutdatedEmbeddings(t);
624
619
  return (await Promise.all(
625
620
  r.map(
626
- async (n) => this.ingest({ ...n, metadata: e }).then(() => ({
621
+ async (n) => this.ingest(n, e).then(() => ({
627
622
  file: n,
628
623
  success: !0,
629
624
  error: null
@@ -676,78 +671,7 @@ class et {
676
671
  throw a;
677
672
  return r;
678
673
  }
679
- async uploadFile({
680
- bucket: t,
681
- path: e,
682
- file: r,
683
- overwriteExisting: a = !1
684
- }) {
685
- const { data: n, error: i } = await this.client.from(t).upload(
686
- `${e}/${r.name}`,
687
- r,
688
- {
689
- upsert: a
690
- }
691
- );
692
- if (i)
693
- throw i;
694
- return {
695
- fileId: n.id,
696
- bucket: t,
697
- path: n.path
698
- };
699
- }
700
- async downloadFile(t) {
701
- const { fileId: e, bucket: r, path: a, properties: n } = await this.getFileInfo(t), { data: i, error: o } = await this.client.from(r).download(a);
702
- if (o)
703
- throw o;
704
- const [, c] = D(a);
705
- return {
706
- fileId: e,
707
- bucket: r,
708
- path: a,
709
- file: new File([i], c, n)
710
- };
711
- }
712
- async deleteFiles(t) {
713
- const e = "fileIds" in t ? (await this.files.query.select(["bucket_id", "path_tokens"]).containedBy("id", t.fileIds).throwOnError()).data.map(({ bucket_id: n, path_tokens: i }) => ({
714
- bucket: l.notNull(n, "bucket_id must not be null"),
715
- paths: l.notNull(i, "path_tokens must not be null").join("/")
716
- })) : _(t), r = W(
717
- z(e, (n) => n.bucket)
718
- ).map(([n, i]) => ({
719
- bucket: n,
720
- paths: i.flatMap((o) => o.paths)
721
- })).filter(({ paths: n }) => n.length > 0);
722
- return (await Promise.all(r.map(
723
- async ({ bucket: n, paths: i }) => this.client.from(n).remove(i).then(({ data: o, error: c }) => {
724
- if (c)
725
- throw c;
726
- return o.map((h, g) => ({
727
- fileId: l.notNull(h.id, "file id must not be null"),
728
- bucket: n,
729
- path: l.defined(i[g])
730
- }));
731
- })
732
- ))).flat();
733
- }
734
- async existsFile(t) {
735
- const { bucket: e, path: r } = await this.getFileStorageLocation(t), { data: a, error: n } = await this.client.from(e).exists(r);
736
- if (n)
737
- throw n;
738
- return a;
739
- }
740
- async assertExistsFile(t) {
741
- const { bucket: e, path: r } = await this.getFileStorageLocation(t), { data: a, error: n } = await this.client.from(e).exists(r);
742
- if (n)
743
- throw n;
744
- if (!a)
745
- throw new E(`File not found in bucket '${e}' at path '${r}'`, { bucket: e, path: r });
746
- }
747
- async getFiles({
748
- bucket: t,
749
- ...e
750
- }) {
674
+ async getFiles(t, e) {
751
675
  const { data: r, error: a } = await this.client.from(t).listV2(e);
752
676
  if (a)
753
677
  throw a;
@@ -768,29 +692,85 @@ class et {
768
692
  return { fileId: a, bucket: e, path: r };
769
693
  }
770
694
  async getFileInfo(t) {
771
- const { fileId: e, bucket: r, path: a } = await this.getFileStorageLocation(t), { id: n, bucketId: i, metadata: o, ...c } = await this.getFileObject(r, a);
695
+ const { fileId: e, bucket: r, path: a } = await this.getFileStorageLocation(t), { id: n, bucketId: i, metadata: c, ...o } = await this.getFileObject(r, a);
772
696
  return l(n === e, "file ID from storage client must match file ID from database"), l(i === r, "bucketId from storage client must match bucket from database"), {
773
- ...c,
697
+ ...o,
774
698
  fileId: e,
775
699
  bucket: r,
776
700
  path: a,
777
- metadata: o,
778
- properties: o ? {
779
- type: o.mimetype,
780
- lastModified: new Date(o.lastModified).getTime()
701
+ metadata: c,
702
+ properties: c ? {
703
+ type: c.mimetype,
704
+ lastModified: new Date(c.lastModified).getTime()
781
705
  } : {}
782
706
  };
783
707
  }
784
- async getPublicURL({
785
- transform: t,
786
- download: e,
787
- ...r
788
- }) {
789
- const { bucket: a, path: n } = await this.getFileStorageLocation(r), { data: { publicUrl: i } } = this.client.from(a).getPublicUrl(n, {
790
- transform: t,
791
- download: e
792
- });
793
- return i;
708
+ async getPublicURL(t, e) {
709
+ const { bucket: r, path: a } = await this.getFileStorageLocation(t), { data: { publicUrl: n } } = this.client.from(r).getPublicUrl(a, e);
710
+ return n;
711
+ }
712
+ async existsFile(t) {
713
+ const { bucket: e, path: r } = await this.getFileStorageLocation(t), { data: a, error: n } = await this.client.from(e).exists(r);
714
+ if (n)
715
+ throw n;
716
+ return a;
717
+ }
718
+ async assertExistsFile(t) {
719
+ const { bucket: e, path: r } = await this.getFileStorageLocation(t), { data: a, error: n } = await this.client.from(e).exists(r);
720
+ if (n)
721
+ throw n;
722
+ if (!a)
723
+ throw new E(`File not found in bucket '${e}' at path '${r}'`, { bucket: e, path: r });
724
+ }
725
+ async uploadFile(t, { bucket: e, path: r }, { overwriteExisting: a = !1 } = {}) {
726
+ const { data: n, error: i } = await this.client.from(e).upload(
727
+ `${r}/${t.name}`,
728
+ t,
729
+ {
730
+ upsert: a
731
+ }
732
+ );
733
+ if (i)
734
+ throw i;
735
+ return {
736
+ fileId: n.id,
737
+ bucket: e,
738
+ path: n.path
739
+ };
740
+ }
741
+ async downloadFile(t) {
742
+ const { fileId: e, bucket: r, path: a, properties: n } = await this.getFileInfo(t), { data: i, error: c } = await this.client.from(r).download(a);
743
+ if (c)
744
+ throw c;
745
+ const [, o] = A(a);
746
+ return {
747
+ fileId: e,
748
+ bucket: r,
749
+ path: a,
750
+ file: new File([i], o, n)
751
+ };
752
+ }
753
+ async deleteFiles(t) {
754
+ const e = t.filter((o) => "fileId" in o).map((o) => o.fileId), a = (await this.files.query.select(["bucket_id", "path_tokens"]).containedBy("id", e).throwOnError()).data.map(({ bucket_id: o, path_tokens: h }) => ({
755
+ bucket: l.notNull(o, "bucket_id must not be null"),
756
+ path: l.notNull(h, "path_tokens must not be null").join("/")
757
+ })), n = t.filter((o) => "path" in o).concat(a), i = W(
758
+ z(n, (o) => o.bucket)
759
+ ).map(([o, h]) => ({
760
+ bucket: o,
761
+ paths: h.map((d) => d.path)
762
+ }));
763
+ return (await Promise.all(i.map(
764
+ async ({ bucket: o, paths: h }) => this.client.from(o).remove(h).then(({ data: d, error: u }) => {
765
+ if (u)
766
+ throw u;
767
+ return d.map((p, b) => ({
768
+ fileId: l.notNull(p.id, "file id must not be null"),
769
+ bucket: o,
770
+ path: l.defined(h[b], "path must not be null")
771
+ }));
772
+ })
773
+ ))).flat();
794
774
  }
795
775
  }
796
776
  export {
@@ -804,26 +784,26 @@ export {
804
784
  H as LogicalOp,
805
785
  J as LogicalOpSeparator,
806
786
  x as ParseError,
807
- j as PostgrestErrorInterface,
808
- P as RecordNotFoundError,
787
+ $ as PostgrestErrorInterface,
788
+ _ as RecordNotFoundError,
809
789
  et as StorageService,
810
790
  C as TableDataService,
811
791
  k as TracedError,
812
792
  I as UnsupportedMimeError,
813
793
  U as ViewDataService,
814
794
  X as assertCounted,
815
- _ as coerceArray,
816
- M as encodeFilter,
817
- S as encodeFilterNode,
795
+ D as coerceArray,
796
+ L as encodeFilter,
797
+ q as encodeFilterNode,
818
798
  W as entries,
819
799
  z as groupBy,
820
800
  G as isDatabaseApiError,
821
- L as negateFilterNode,
822
- N as negateOp,
823
- b as parseFilterExpression,
824
- A as parseFilterExpressionChain,
825
- m as postgrestExtensions,
801
+ N as negateFilterNode,
802
+ j as negateOp,
803
+ y as parseFilterExpression,
804
+ M as parseFilterExpressionChain,
805
+ w as postgrestExtensions,
826
806
  tt as preprocessingSteps,
827
807
  T as removeElement,
828
- D as splitPath
808
+ A as splitPath
829
809
  };
@@ -1,10 +1,6 @@
1
- import { SearchV2Folder, SearchV2Object, SearchV2Options, StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
1
+ import { SearchV2Options, SearchV2Result } from '@supabase/storage-js';
2
2
  import { DatabaseService } from './database-service';
3
- import { FileInfo, FileRef, PublicURLOptions, StorageLocation } from './storage';
4
- import { MaybeArray } from './utils';
5
- export declare class StorageClient<BucketName extends string = string> extends SupabaseStorageClient {
6
- from(bucket: BucketName | (string & {})): ReturnType<SupabaseStorageClient['from']>;
7
- }
3
+ import { FileInfo, FilePointer, FileRef, PublicURLOptions, StorageClient, StorageLocation, UploadFileOptions } from './storage';
8
4
  export interface StorageServiceParams<BucketName extends string = string> {
9
5
  client: StorageClient<BucketName>;
10
6
  database: DatabaseService<any>;
@@ -18,39 +14,16 @@ export declare class StorageService<BucketName extends string = string> {
18
14
  constructor({ client, database, }: StorageServiceParams<BucketName>);
19
15
  private get files();
20
16
  private getFileObject;
21
- uploadFile({ bucket, path, file, overwriteExisting, }: {
22
- file: File;
23
- bucket: BucketName;
24
- path: string;
25
- overwriteExisting?: boolean;
26
- }): Promise<StorageLocation>;
27
- downloadFile(params: {
28
- bucket: BucketName;
29
- path: string;
30
- properties?: FilePropertyBag;
31
- } | {
32
- fileId: string;
33
- }): Promise<StorageLocation & {
34
- file: File;
35
- }>;
36
- deleteFiles(params: MaybeArray<{
37
- bucket: BucketName;
38
- paths: string | string[];
39
- }> | {
40
- fileIds: string[];
41
- }): Promise<StorageLocation[]>;
17
+ getFiles(bucket: BucketName, options?: SearchV2Options): Promise<SearchV2Result>;
18
+ getFileStorageLocation(fileRef: FileRef<BucketName>): Promise<StorageLocation>;
19
+ getFileInfo(fileRef: FileRef<BucketName>): Promise<FileInfo>;
20
+ getPublicURL(fileRef: FileRef<BucketName>, options?: PublicURLOptions): Promise<string>;
42
21
  existsFile(fileRef: FileRef<BucketName>): Promise<boolean>;
43
22
  assertExistsFile(fileRef: FileRef<BucketName>): Promise<void>;
44
- getFiles({ bucket, ...options }: {
45
- bucket: BucketName;
46
- } & SearchV2Options): Promise<{
47
- hasNext: boolean;
48
- folders: SearchV2Folder[];
49
- objects: SearchV2Object[];
50
- nextCursor?: string;
23
+ uploadFile(file: File, { bucket, path }: FilePointer<BucketName>, { overwriteExisting }?: UploadFileOptions): Promise<StorageLocation>;
24
+ downloadFile(fileRef: FileRef<BucketName>): Promise<StorageLocation & {
25
+ file: File;
51
26
  }>;
52
- getFileStorageLocation(fileRef: FileRef<BucketName>): Promise<StorageLocation>;
53
- getFileInfo(fileRef: FileRef<BucketName>): Promise<FileInfo>;
54
- getPublicURL({ transform, download, ...params }: FileRef<BucketName> & PublicURLOptions): Promise<string>;
27
+ deleteFiles(fileRefs: FileRef<BucketName>[]): Promise<StorageLocation[]>;
55
28
  }
56
29
  //# sourceMappingURL=storage-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage-service.d.ts","sourceRoot":"","sources":["../lib/storage-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA0B,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACtF,OAAO,KAA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AsBrB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,eAAe,GAAG;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC;IAoBrF,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CA2CjF"}
package/dist/storage.d.ts CHANGED
@@ -1,23 +1,30 @@
1
- import { Camelize, FileObjectV2, TransformOptions } from '@supabase/storage-js';
1
+ import { Camelize, FileObjectV2, TransformOptions, StorageClient as SupabaseStorageClient } from '@supabase/storage-js';
2
2
  import { StorageObjectsTable } from './database';
3
3
  import { OmitFrom } from './utils';
4
- export type StorageObject = StorageObjectsTable['Row'];
5
- export interface PublicURLOptions {
6
- download?: string | boolean;
7
- transform?: TransformOptions;
4
+ export declare class StorageClient<BucketName extends string = string> extends SupabaseStorageClient {
5
+ from(bucket: BucketName | (string & {})): ReturnType<SupabaseStorageClient['from']>;
8
6
  }
7
+ export type StorageObject = StorageObjectsTable['Row'];
9
8
  export interface StorageLocation {
10
9
  fileId: string;
11
10
  bucket: string;
12
11
  path: string;
13
12
  }
14
- export type FileRef<BucketName extends string = string> = {
15
- fileId: string;
16
- } | {
13
+ export interface FilePointer<BucketName extends string = string> {
17
14
  bucket: BucketName;
18
15
  path: string;
19
- };
16
+ }
17
+ export type FileRef<BucketName extends string = string> = {
18
+ fileId: string;
19
+ } | FilePointer<BucketName>;
20
20
  export interface FileInfo extends OmitFrom<Camelize<FileObjectV2>, 'id' | 'bucketId'>, StorageLocation {
21
21
  properties: FilePropertyBag;
22
22
  }
23
+ export interface PublicURLOptions {
24
+ download?: string | boolean;
25
+ transform?: TransformOptions;
26
+ }
27
+ export interface UploadFileOptions {
28
+ overwriteExisting?: boolean;
29
+ }
23
30
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../lib/storage.ts"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MAAM,GAAG,MAAM,CAAE,SAAQ,qBAAqB;IAChG,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,UAAU,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC;CACtF;AAED,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM;IAC3D,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,OAAO,CAAC,UAAU,SAAS,MAAM,GAAG,MAAM,IAAI;IACtD,MAAM,EAAE,MAAM,CAAC;CAClB,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;AAE5B,MAAM,WAAW,QAAS,SAAQ,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,GAAG,UAAU,CAAC,EAAE,eAAe;IAClG,UAAU,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@freehour/supabase-core",
3
3
  "private": false,
4
4
  "displayName": "Supabase-Core",
5
- "description": "Core services for Supabase",
6
- "version": "1.1.0",
5
+ "description": "Lightweight services for supabase to make it easier to work with databases, tables and storage buckets",
6
+ "version": "1.1.2",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -1,4 +1,2 @@
1
1
  -- enable the "pg_trgm" extension for fuzzy text search
2
2
  CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA extensions;
3
- -- enable the "vector" extension for embeddings
4
- CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA extensions;