@uniformdev/files 19.49.1 → 19.49.4-alpha.67

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
@@ -1,38 +1,192 @@
1
1
  import { ApiClient, ClientOptions } from '@uniformdev/context/api';
2
2
 
3
- type GetFileOptions = {
4
- id: string;
5
- } | {
6
- url: string;
7
- projectId?: string;
8
- } | {
9
- sourceId: string;
10
- projectId: string;
11
- };
12
- interface NewFileOptions {
13
- name: string;
14
- size: number;
15
- mediaType: string;
16
- width?: number;
17
- height?: number;
18
- sourceId?: string;
19
- projectId?: string;
3
+ /**
4
+ * This file was auto-generated by openapi-typescript.
5
+ * Do not make direct changes to the file.
6
+ */
7
+ interface paths {
8
+ "/api/v1/files": {
9
+ /** Gets a single file */
10
+ get: {
11
+ parameters: {
12
+ query: {
13
+ id?: string;
14
+ url?: string;
15
+ sourceId?: string;
16
+ projectId?: string;
17
+ };
18
+ };
19
+ responses: {
20
+ /** 200 response */
21
+ 200: {
22
+ content: {
23
+ "application/json": {
24
+ /** Format: uuid */
25
+ id: string;
26
+ state: number;
27
+ url?: string;
28
+ name: string;
29
+ mediaType: string;
30
+ metadata?: unknown;
31
+ size: number;
32
+ };
33
+ };
34
+ };
35
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
36
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
37
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
38
+ /** 404 response */
39
+ 404: unknown;
40
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
41
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
42
+ };
43
+ };
44
+ /** Creates a new file */
45
+ post: {
46
+ responses: {
47
+ /** 202 response */
48
+ 202: {
49
+ content: {
50
+ "application/json": {
51
+ /** Format: uuid */
52
+ id: string;
53
+ uploadUrl: string;
54
+ /** @enum {string} */
55
+ method: "POST" | "PUT";
56
+ };
57
+ };
58
+ };
59
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
60
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
61
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
62
+ /** 404 response */
63
+ 404: unknown;
64
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
65
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
66
+ };
67
+ requestBody: {
68
+ content: {
69
+ "application/json": {
70
+ /** Format: uuid */
71
+ projectId?: string;
72
+ sourceId?: string;
73
+ /** Format: uuid */
74
+ teamId?: string;
75
+ name: string;
76
+ size: number;
77
+ mediaType: string;
78
+ width?: number;
79
+ height?: number;
80
+ };
81
+ };
82
+ };
83
+ };
84
+ /** Deletes a file */
85
+ delete: {
86
+ responses: {
87
+ /** 200 response */
88
+ 200: {
89
+ content: {
90
+ "application/json": {
91
+ /** Format: uuid */
92
+ id: string;
93
+ };
94
+ };
95
+ };
96
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
97
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
98
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
99
+ /** 404 response */
100
+ 404: unknown;
101
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
102
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
103
+ };
104
+ requestBody: {
105
+ content: {
106
+ "application/json": {
107
+ url: string;
108
+ };
109
+ };
110
+ };
111
+ };
112
+ };
20
113
  }
21
- interface NewFileResponse {
22
- id: string;
23
- uploadUrl: string;
24
- method: string;
25
- }
26
- interface FileStateResponse {
27
- id: string;
28
- state: number;
29
- url: string;
114
+ interface external {
115
+ "swagger.yml": {
116
+ paths: {};
117
+ components: {
118
+ schemas: {
119
+ Error: {
120
+ /** @description Error message(s) that occurred while processing the request */
121
+ errorMessage?: string[] | string;
122
+ };
123
+ };
124
+ responses: {
125
+ /** Request input validation failed */
126
+ BadRequestError: {
127
+ content: {
128
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
129
+ };
130
+ };
131
+ /** API key or token was not valid */
132
+ UnauthorizedError: {
133
+ content: {
134
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
135
+ };
136
+ };
137
+ /** Permission was denied */
138
+ ForbiddenError: {
139
+ content: {
140
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
141
+ };
142
+ };
143
+ /** Resource not found */
144
+ NotFoundError: {
145
+ content: {
146
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
147
+ };
148
+ };
149
+ /** Too many requests in allowed time period */
150
+ RateLimitError: unknown;
151
+ /** Execution error occurred */
152
+ InternalServerError: unknown;
153
+ };
154
+ };
155
+ operations: {};
156
+ };
30
157
  }
158
+
159
+ type FileInsertRequest = paths['/api/v1/files']['post']['requestBody']['content']['application/json'];
160
+ type FileInsertResponse = paths['/api/v1/files']['post']['responses']['202']['content']['application/json'];
161
+ type FileDeleteRequest = paths['/api/v1/files']['delete']['requestBody']['content']['application/json'];
162
+ type FileDeleteResponse = paths['/api/v1/files']['delete']['responses']['200']['content']['application/json'];
163
+ type FileGetRequest = paths['/api/v1/files']['get']['parameters']['query'];
164
+ type FileGetByIDRequest = Pick<FileGetRequest, 'id'>;
165
+ type FileGetByURLRequest = Pick<FileGetRequest, 'url' | 'projectId'>;
166
+ type FileGetBySourceIDRequest = Pick<FileGetRequest, 'sourceId' | 'projectId'>;
167
+ type FileGetResponse = paths['/api/v1/files']['get']['responses']['200']['content']['application/json'];
168
+
169
+ type WithoutProjectId<T extends {
170
+ projectId?: string;
171
+ }> = Omit<T, 'projectId'>;
31
172
  declare class FileClient extends ApiClient {
32
- constructor(options: ClientOptions);
33
- createNewProjectFile(options: NewFileOptions): Promise<NewFileResponse>;
34
- getFile(options: GetFileOptions): Promise<FileStateResponse>;
35
- deleteFileByUrl(url: string): Promise<FileStateResponse>;
173
+ constructor(options: ClientOptions & {
174
+ projectId: NonNullable<ClientOptions['projectId']>;
175
+ });
176
+ get(options: FileGetByIDRequest | WithoutProjectId<FileGetBySourceIDRequest> | WithoutProjectId<FileGetByURLRequest>): Promise<FileGetResponse>;
177
+ insert(options: WithoutProjectId<FileInsertRequest>): Promise<{
178
+ id: string;
179
+ uploadUrl: string;
180
+ method: "POST" | "PUT";
181
+ }>;
182
+ delete(options: FileDeleteRequest): Promise<{
183
+ id: string;
184
+ }>;
185
+ }
186
+ declare class UncachedFileClient extends FileClient {
187
+ constructor(options: Omit<ClientOptions & {
188
+ projectId: NonNullable<ClientOptions['projectId']>;
189
+ }, 'bypassCache'>);
36
190
  }
37
191
 
38
192
  declare const getFileNameFromUrl: (fileUrl: string) => string;
@@ -43,5 +197,6 @@ declare const FILE_IN_PROGRESS_STATE = 0;
43
197
  declare const FILE_READY_STATE = 64;
44
198
  /** Constant for a max file size in bytes. Subject to change. */
45
199
  declare const FILE_MAX_SIZE: number;
200
+ declare const FILE_TYPES_IMAGE: string[];
46
201
 
47
- export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FileClient, FileStateResponse, NewFileOptions, NewFileResponse, getFileNameFromUrl };
202
+ export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FILE_TYPES_IMAGE, FileClient, FileDeleteRequest, FileDeleteResponse, FileGetByIDRequest, FileGetBySourceIDRequest, FileGetByURLRequest, FileGetRequest, FileGetResponse, FileInsertRequest, FileInsertResponse, UncachedFileClient, getFileNameFromUrl };
package/dist/index.d.ts CHANGED
@@ -1,38 +1,192 @@
1
1
  import { ApiClient, ClientOptions } from '@uniformdev/context/api';
2
2
 
3
- type GetFileOptions = {
4
- id: string;
5
- } | {
6
- url: string;
7
- projectId?: string;
8
- } | {
9
- sourceId: string;
10
- projectId: string;
11
- };
12
- interface NewFileOptions {
13
- name: string;
14
- size: number;
15
- mediaType: string;
16
- width?: number;
17
- height?: number;
18
- sourceId?: string;
19
- projectId?: string;
3
+ /**
4
+ * This file was auto-generated by openapi-typescript.
5
+ * Do not make direct changes to the file.
6
+ */
7
+ interface paths {
8
+ "/api/v1/files": {
9
+ /** Gets a single file */
10
+ get: {
11
+ parameters: {
12
+ query: {
13
+ id?: string;
14
+ url?: string;
15
+ sourceId?: string;
16
+ projectId?: string;
17
+ };
18
+ };
19
+ responses: {
20
+ /** 200 response */
21
+ 200: {
22
+ content: {
23
+ "application/json": {
24
+ /** Format: uuid */
25
+ id: string;
26
+ state: number;
27
+ url?: string;
28
+ name: string;
29
+ mediaType: string;
30
+ metadata?: unknown;
31
+ size: number;
32
+ };
33
+ };
34
+ };
35
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
36
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
37
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
38
+ /** 404 response */
39
+ 404: unknown;
40
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
41
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
42
+ };
43
+ };
44
+ /** Creates a new file */
45
+ post: {
46
+ responses: {
47
+ /** 202 response */
48
+ 202: {
49
+ content: {
50
+ "application/json": {
51
+ /** Format: uuid */
52
+ id: string;
53
+ uploadUrl: string;
54
+ /** @enum {string} */
55
+ method: "POST" | "PUT";
56
+ };
57
+ };
58
+ };
59
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
60
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
61
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
62
+ /** 404 response */
63
+ 404: unknown;
64
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
65
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
66
+ };
67
+ requestBody: {
68
+ content: {
69
+ "application/json": {
70
+ /** Format: uuid */
71
+ projectId?: string;
72
+ sourceId?: string;
73
+ /** Format: uuid */
74
+ teamId?: string;
75
+ name: string;
76
+ size: number;
77
+ mediaType: string;
78
+ width?: number;
79
+ height?: number;
80
+ };
81
+ };
82
+ };
83
+ };
84
+ /** Deletes a file */
85
+ delete: {
86
+ responses: {
87
+ /** 200 response */
88
+ 200: {
89
+ content: {
90
+ "application/json": {
91
+ /** Format: uuid */
92
+ id: string;
93
+ };
94
+ };
95
+ };
96
+ 400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
97
+ 401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
98
+ 403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
99
+ /** 404 response */
100
+ 404: unknown;
101
+ 429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
102
+ 500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
103
+ };
104
+ requestBody: {
105
+ content: {
106
+ "application/json": {
107
+ url: string;
108
+ };
109
+ };
110
+ };
111
+ };
112
+ };
20
113
  }
21
- interface NewFileResponse {
22
- id: string;
23
- uploadUrl: string;
24
- method: string;
25
- }
26
- interface FileStateResponse {
27
- id: string;
28
- state: number;
29
- url: string;
114
+ interface external {
115
+ "swagger.yml": {
116
+ paths: {};
117
+ components: {
118
+ schemas: {
119
+ Error: {
120
+ /** @description Error message(s) that occurred while processing the request */
121
+ errorMessage?: string[] | string;
122
+ };
123
+ };
124
+ responses: {
125
+ /** Request input validation failed */
126
+ BadRequestError: {
127
+ content: {
128
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
129
+ };
130
+ };
131
+ /** API key or token was not valid */
132
+ UnauthorizedError: {
133
+ content: {
134
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
135
+ };
136
+ };
137
+ /** Permission was denied */
138
+ ForbiddenError: {
139
+ content: {
140
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
141
+ };
142
+ };
143
+ /** Resource not found */
144
+ NotFoundError: {
145
+ content: {
146
+ "application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
147
+ };
148
+ };
149
+ /** Too many requests in allowed time period */
150
+ RateLimitError: unknown;
151
+ /** Execution error occurred */
152
+ InternalServerError: unknown;
153
+ };
154
+ };
155
+ operations: {};
156
+ };
30
157
  }
158
+
159
+ type FileInsertRequest = paths['/api/v1/files']['post']['requestBody']['content']['application/json'];
160
+ type FileInsertResponse = paths['/api/v1/files']['post']['responses']['202']['content']['application/json'];
161
+ type FileDeleteRequest = paths['/api/v1/files']['delete']['requestBody']['content']['application/json'];
162
+ type FileDeleteResponse = paths['/api/v1/files']['delete']['responses']['200']['content']['application/json'];
163
+ type FileGetRequest = paths['/api/v1/files']['get']['parameters']['query'];
164
+ type FileGetByIDRequest = Pick<FileGetRequest, 'id'>;
165
+ type FileGetByURLRequest = Pick<FileGetRequest, 'url' | 'projectId'>;
166
+ type FileGetBySourceIDRequest = Pick<FileGetRequest, 'sourceId' | 'projectId'>;
167
+ type FileGetResponse = paths['/api/v1/files']['get']['responses']['200']['content']['application/json'];
168
+
169
+ type WithoutProjectId<T extends {
170
+ projectId?: string;
171
+ }> = Omit<T, 'projectId'>;
31
172
  declare class FileClient extends ApiClient {
32
- constructor(options: ClientOptions);
33
- createNewProjectFile(options: NewFileOptions): Promise<NewFileResponse>;
34
- getFile(options: GetFileOptions): Promise<FileStateResponse>;
35
- deleteFileByUrl(url: string): Promise<FileStateResponse>;
173
+ constructor(options: ClientOptions & {
174
+ projectId: NonNullable<ClientOptions['projectId']>;
175
+ });
176
+ get(options: FileGetByIDRequest | WithoutProjectId<FileGetBySourceIDRequest> | WithoutProjectId<FileGetByURLRequest>): Promise<FileGetResponse>;
177
+ insert(options: WithoutProjectId<FileInsertRequest>): Promise<{
178
+ id: string;
179
+ uploadUrl: string;
180
+ method: "POST" | "PUT";
181
+ }>;
182
+ delete(options: FileDeleteRequest): Promise<{
183
+ id: string;
184
+ }>;
185
+ }
186
+ declare class UncachedFileClient extends FileClient {
187
+ constructor(options: Omit<ClientOptions & {
188
+ projectId: NonNullable<ClientOptions['projectId']>;
189
+ }, 'bypassCache'>);
36
190
  }
37
191
 
38
192
  declare const getFileNameFromUrl: (fileUrl: string) => string;
@@ -43,5 +197,6 @@ declare const FILE_IN_PROGRESS_STATE = 0;
43
197
  declare const FILE_READY_STATE = 64;
44
198
  /** Constant for a max file size in bytes. Subject to change. */
45
199
  declare const FILE_MAX_SIZE: number;
200
+ declare const FILE_TYPES_IMAGE: string[];
46
201
 
47
- export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FileClient, FileStateResponse, NewFileOptions, NewFileResponse, getFileNameFromUrl };
202
+ export { FILE_IN_PROGRESS_STATE, FILE_MAX_SIZE, FILE_READY_STATE, FILE_TYPES_IMAGE, FileClient, FileDeleteRequest, FileDeleteResponse, FileGetByIDRequest, FileGetBySourceIDRequest, FileGetByURLRequest, FileGetRequest, FileGetResponse, FileInsertRequest, FileInsertResponse, UncachedFileClient, getFileNameFromUrl };
package/dist/index.esm.js CHANGED
@@ -1,36 +1,39 @@
1
1
  // src/FileClient.ts
2
2
  import { ApiClient } from "@uniformdev/context/api";
3
- var FILE_BASE_PATH = "/api/v1/file";
3
+ var FILE_BASE_PATH = "/api/v1/files";
4
4
  var FileClient = class extends ApiClient {
5
5
  constructor(options) {
6
6
  super(options);
7
7
  }
8
- async createNewProjectFile(options) {
9
- if (!this.options.projectId)
10
- throw new Error("A project ID must exist to upload a file to a project");
11
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
12
- return await this.apiClient(fetchUrl, {
13
- method: "POST",
14
- body: JSON.stringify({
15
- projectId: this.options.projectId,
16
- ...options
17
- })
8
+ async get(options) {
9
+ const { projectId } = this.options;
10
+ const fetchUri = this.createUrl(FILE_BASE_PATH, {
11
+ ...options,
12
+ projectId
18
13
  });
14
+ return this.apiClient(fetchUri);
19
15
  }
20
- async getFile(options) {
21
- const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
22
- return await this.apiClient(fetchUrl);
16
+ async insert(options) {
17
+ const { projectId } = this.options;
18
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
19
+ return this.apiClient(fetchUri, {
20
+ method: "POST",
21
+ body: JSON.stringify({ ...options, projectId })
22
+ });
23
23
  }
24
- async deleteFileByUrl(url) {
25
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
26
- return await this.apiClient(fetchUrl, {
24
+ async delete(options) {
25
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
26
+ return this.apiClient(fetchUri, {
27
27
  method: "DELETE",
28
- body: JSON.stringify({
29
- url
30
- })
28
+ body: JSON.stringify(options)
31
29
  });
32
30
  }
33
31
  };
32
+ var UncachedFileClient = class extends FileClient {
33
+ constructor(options) {
34
+ super({ ...options, bypassCache: true });
35
+ }
36
+ };
34
37
 
35
38
  // src/fileUrl.ts
36
39
  var getFileNameFromUrl = (fileUrl) => {
@@ -43,10 +46,25 @@ var getFileNameFromUrl = (fileUrl) => {
43
46
  var FILE_IN_PROGRESS_STATE = 0;
44
47
  var FILE_READY_STATE = 64;
45
48
  var FILE_MAX_SIZE = 1024 * 1024 * 10;
49
+ var FILE_TYPES_IMAGE = [
50
+ ".jpg",
51
+ ".jpeg",
52
+ ".jfif",
53
+ ".pjpeg",
54
+ ".pjp",
55
+ ".png",
56
+ ".gif",
57
+ ".svg",
58
+ ".webp",
59
+ ".apng",
60
+ ".avif"
61
+ ];
46
62
  export {
47
63
  FILE_IN_PROGRESS_STATE,
48
64
  FILE_MAX_SIZE,
49
65
  FILE_READY_STATE,
66
+ FILE_TYPES_IMAGE,
50
67
  FileClient,
68
+ UncachedFileClient,
51
69
  getFileNameFromUrl
52
70
  };
package/dist/index.js CHANGED
@@ -23,44 +23,49 @@ __export(src_exports, {
23
23
  FILE_IN_PROGRESS_STATE: () => FILE_IN_PROGRESS_STATE,
24
24
  FILE_MAX_SIZE: () => FILE_MAX_SIZE,
25
25
  FILE_READY_STATE: () => FILE_READY_STATE,
26
+ FILE_TYPES_IMAGE: () => FILE_TYPES_IMAGE,
26
27
  FileClient: () => FileClient,
28
+ UncachedFileClient: () => UncachedFileClient,
27
29
  getFileNameFromUrl: () => getFileNameFromUrl
28
30
  });
29
31
  module.exports = __toCommonJS(src_exports);
30
32
 
31
33
  // src/FileClient.ts
32
34
  var import_api = require("@uniformdev/context/api");
33
- var FILE_BASE_PATH = "/api/v1/file";
35
+ var FILE_BASE_PATH = "/api/v1/files";
34
36
  var FileClient = class extends import_api.ApiClient {
35
37
  constructor(options) {
36
38
  super(options);
37
39
  }
38
- async createNewProjectFile(options) {
39
- if (!this.options.projectId)
40
- throw new Error("A project ID must exist to upload a file to a project");
41
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
42
- return await this.apiClient(fetchUrl, {
43
- method: "POST",
44
- body: JSON.stringify({
45
- projectId: this.options.projectId,
46
- ...options
47
- })
40
+ async get(options) {
41
+ const { projectId } = this.options;
42
+ const fetchUri = this.createUrl(FILE_BASE_PATH, {
43
+ ...options,
44
+ projectId
48
45
  });
46
+ return this.apiClient(fetchUri);
49
47
  }
50
- async getFile(options) {
51
- const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
52
- return await this.apiClient(fetchUrl);
48
+ async insert(options) {
49
+ const { projectId } = this.options;
50
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
51
+ return this.apiClient(fetchUri, {
52
+ method: "POST",
53
+ body: JSON.stringify({ ...options, projectId })
54
+ });
53
55
  }
54
- async deleteFileByUrl(url) {
55
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
56
- return await this.apiClient(fetchUrl, {
56
+ async delete(options) {
57
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
58
+ return this.apiClient(fetchUri, {
57
59
  method: "DELETE",
58
- body: JSON.stringify({
59
- url
60
- })
60
+ body: JSON.stringify(options)
61
61
  });
62
62
  }
63
63
  };
64
+ var UncachedFileClient = class extends FileClient {
65
+ constructor(options) {
66
+ super({ ...options, bypassCache: true });
67
+ }
68
+ };
64
69
 
65
70
  // src/fileUrl.ts
66
71
  var getFileNameFromUrl = (fileUrl) => {
@@ -73,11 +78,26 @@ var getFileNameFromUrl = (fileUrl) => {
73
78
  var FILE_IN_PROGRESS_STATE = 0;
74
79
  var FILE_READY_STATE = 64;
75
80
  var FILE_MAX_SIZE = 1024 * 1024 * 10;
81
+ var FILE_TYPES_IMAGE = [
82
+ ".jpg",
83
+ ".jpeg",
84
+ ".jfif",
85
+ ".pjpeg",
86
+ ".pjp",
87
+ ".png",
88
+ ".gif",
89
+ ".svg",
90
+ ".webp",
91
+ ".apng",
92
+ ".avif"
93
+ ];
76
94
  // Annotate the CommonJS export names for ESM import in node:
77
95
  0 && (module.exports = {
78
96
  FILE_IN_PROGRESS_STATE,
79
97
  FILE_MAX_SIZE,
80
98
  FILE_READY_STATE,
99
+ FILE_TYPES_IMAGE,
81
100
  FileClient,
101
+ UncachedFileClient,
82
102
  getFileNameFromUrl
83
103
  });
package/dist/index.mjs CHANGED
@@ -1,36 +1,39 @@
1
1
  // src/FileClient.ts
2
2
  import { ApiClient } from "@uniformdev/context/api";
3
- var FILE_BASE_PATH = "/api/v1/file";
3
+ var FILE_BASE_PATH = "/api/v1/files";
4
4
  var FileClient = class extends ApiClient {
5
5
  constructor(options) {
6
6
  super(options);
7
7
  }
8
- async createNewProjectFile(options) {
9
- if (!this.options.projectId)
10
- throw new Error("A project ID must exist to upload a file to a project");
11
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
12
- return await this.apiClient(fetchUrl, {
13
- method: "POST",
14
- body: JSON.stringify({
15
- projectId: this.options.projectId,
16
- ...options
17
- })
8
+ async get(options) {
9
+ const { projectId } = this.options;
10
+ const fetchUri = this.createUrl(FILE_BASE_PATH, {
11
+ ...options,
12
+ projectId
18
13
  });
14
+ return this.apiClient(fetchUri);
19
15
  }
20
- async getFile(options) {
21
- const fetchUrl = this.createUrl(FILE_BASE_PATH, options);
22
- return await this.apiClient(fetchUrl);
16
+ async insert(options) {
17
+ const { projectId } = this.options;
18
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
19
+ return this.apiClient(fetchUri, {
20
+ method: "POST",
21
+ body: JSON.stringify({ ...options, projectId })
22
+ });
23
23
  }
24
- async deleteFileByUrl(url) {
25
- const fetchUrl = this.createUrl(FILE_BASE_PATH);
26
- return await this.apiClient(fetchUrl, {
24
+ async delete(options) {
25
+ const fetchUri = this.createUrl(FILE_BASE_PATH);
26
+ return this.apiClient(fetchUri, {
27
27
  method: "DELETE",
28
- body: JSON.stringify({
29
- url
30
- })
28
+ body: JSON.stringify(options)
31
29
  });
32
30
  }
33
31
  };
32
+ var UncachedFileClient = class extends FileClient {
33
+ constructor(options) {
34
+ super({ ...options, bypassCache: true });
35
+ }
36
+ };
34
37
 
35
38
  // src/fileUrl.ts
36
39
  var getFileNameFromUrl = (fileUrl) => {
@@ -43,10 +46,25 @@ var getFileNameFromUrl = (fileUrl) => {
43
46
  var FILE_IN_PROGRESS_STATE = 0;
44
47
  var FILE_READY_STATE = 64;
45
48
  var FILE_MAX_SIZE = 1024 * 1024 * 10;
49
+ var FILE_TYPES_IMAGE = [
50
+ ".jpg",
51
+ ".jpeg",
52
+ ".jfif",
53
+ ".pjpeg",
54
+ ".pjp",
55
+ ".png",
56
+ ".gif",
57
+ ".svg",
58
+ ".webp",
59
+ ".apng",
60
+ ".avif"
61
+ ];
46
62
  export {
47
63
  FILE_IN_PROGRESS_STATE,
48
64
  FILE_MAX_SIZE,
49
65
  FILE_READY_STATE,
66
+ FILE_TYPES_IMAGE,
50
67
  FileClient,
68
+ UncachedFileClient,
51
69
  getFileNameFromUrl
52
70
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/files",
3
- "version": "19.49.1",
3
+ "version": "19.49.4-alpha.67+9773e3b65",
4
4
  "description": "Uniform Files helpers",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -19,12 +19,15 @@
19
19
  "types": "./dist/index.d.ts",
20
20
  "sideEffects": false,
21
21
  "scripts": {
22
- "build": "tsup",
23
- "dev": "tsup --watch",
22
+ "build": "run-s update-openapi build:ts",
23
+ "build:ts": "tsup",
24
+ "dev": "run-s update-openapi dev:ts",
25
+ "dev:ts": "tsup --watch",
24
26
  "clean": "rimraf dist",
25
27
  "test": "jest --maxWorkers=1 --passWithNoTests",
26
28
  "lint": "eslint \"src/**/*.{js,ts,tsx}\"",
27
- "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
29
+ "format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
30
+ "update-openapi": "tsx ./scripts/update-openapi.cts"
28
31
  },
29
32
  "files": [
30
33
  "/dist"
@@ -33,7 +36,7 @@
33
36
  "access": "public"
34
37
  },
35
38
  "dependencies": {
36
- "@uniformdev/context": "19.49.1"
39
+ "@uniformdev/context": "19.49.4-alpha.67+9773e3b65"
37
40
  },
38
- "gitHead": "a14b97601fb78b44be7f0849841b9828dec0ea96"
41
+ "gitHead": "9773e3b65168255768f5cbecf2536988fa0e03af"
39
42
  }