@taylordb/shared 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 TaylorDB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -4,6 +4,49 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
+ interface FileInformation {
8
+ fieldname: string;
9
+ originalname: string;
10
+ encoding: string;
11
+ mimetype: string;
12
+ destination: string;
13
+ filename: string;
14
+ path: string;
15
+ size: number;
16
+ format: string;
17
+ width: number;
18
+ height: number;
19
+ }
20
+ interface UploadResponse {
21
+ collectionName: string;
22
+ fileInformation: FileInformation;
23
+ metadata: {
24
+ thumbnails: any[];
25
+ clips: any[];
26
+ };
27
+ baseId: string;
28
+ storageAdaptor: string;
29
+ _id: string;
30
+ __v: number;
31
+ }
32
+ export interface AttachmentColumnValue {
33
+ url: string;
34
+ fileType: string;
35
+ size: number;
36
+ }
37
+ export declare class Attachment {
38
+ readonly collectionName: string;
39
+ readonly fileInformation: FileInformation;
40
+ readonly metadata: {
41
+ thumbnails: any[];
42
+ clips: any[];
43
+ };
44
+ readonly baseId: string;
45
+ readonly storageAdaptor: string;
46
+ readonly _id: string;
47
+ constructor(data: UploadResponse);
48
+ toColumnValue(): AttachmentColumnValue;
49
+ }
7
50
  type IsWithinOperatorValue = 'pastWeek' | 'pastMonth' | 'pastYear' | 'nextWeek' | 'nextMonth' | 'nextYear' | 'daysFromNow' | 'daysAgo' | 'currentWeek' | 'currentMonth' | 'currentYear';
8
51
  type DefaultDateFilterValue = ('today' | 'tomorrow' | 'yesterday' | 'oneWeekAgo' | 'oneWeekFromNow' | 'oneMonthAgo' | 'oneMonthFromNow') | ['exactDay' | 'exactTimestamp', string] | ['daysAgo' | 'daysFromNow', number];
9
52
  type DateFilters = {
@@ -101,12 +144,17 @@ export type ColumnType<S, U, I, R extends boolean, F extends {
101
144
  };
102
145
  export type DateColumnType<R extends boolean> = ColumnType<string, string, string, R, DateFilters, DateAggregations>;
103
146
  export type TextColumnType<R extends boolean> = ColumnType<string, string, string, R, TextFilters>;
104
- export type LinkColumnType<T extends string, R extends boolean> = ColumnType<object, number | number[] | {
105
- newIds: number[];
106
- deletedIds: number[];
107
- }, number | number[], R, LinkFilters, LinkAggregations> & {
147
+ export type ALinkColumnType<T extends string, S, U, I, R extends boolean> = ColumnType<S, U, I, R, LinkFilters, LinkAggregations> & {
108
148
  linkedTo: T;
109
149
  };
150
+ export type LinkColumnType<T extends string, R extends boolean> = ALinkColumnType<T, object, number | number[] | {
151
+ newIds: number[];
152
+ deletedIds: number[];
153
+ }, number | number[], R>;
154
+ export type AttachmentColumnType<R extends boolean> = ALinkColumnType<'attachmentTable', Attachment[], Attachment[] | {
155
+ newIds: number[];
156
+ deletedIds: number[];
157
+ } | number[], Attachment[] | number[], R>;
110
158
  export type NumberColumnType<R extends boolean> = ColumnType<number, number, number, R, NumberFilters, NumberAggregations>;
111
159
  export type CheckboxColumnType<R extends boolean> = ColumnType<boolean, boolean, boolean, R, CheckboxFilters>;
112
160
  export type AutoGeneratedNumberColumnType = ColumnType<number, never, never, false, NumberFilters, NumberAggregations>;
@@ -6,4 +6,29 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Attachment = void 0;
10
+ class Attachment {
11
+ collectionName;
12
+ fileInformation;
13
+ metadata;
14
+ baseId;
15
+ storageAdaptor;
16
+ _id;
17
+ constructor(data) {
18
+ this.collectionName = data.collectionName;
19
+ this.fileInformation = data.fileInformation;
20
+ this.metadata = data.metadata;
21
+ this.baseId = data.baseId;
22
+ this.storageAdaptor = data.storageAdaptor;
23
+ this._id = data._id;
24
+ }
25
+ toColumnValue() {
26
+ return {
27
+ url: this.fileInformation.path,
28
+ fileType: this.fileInformation.mimetype,
29
+ size: this.fileInformation.size,
30
+ };
31
+ }
32
+ }
33
+ exports.Attachment = Attachment;
9
34
  //# sourceMappingURL=column-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
1
+ {"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAmCH,MAAa,UAAU;IACL,cAAc,CAAS;IACvB,eAAe,CAAkB;IACjC,QAAQ,CAAsC;IAC9C,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,GAAG,CAAS;IAE5B,YAAY,IAAoB;QAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,aAAa;QACX,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;YACvC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;SAChC,CAAC;IACJ,CAAC;CACF;AAxBD,gCAwBC"}
@@ -4,6 +4,49 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
+ interface FileInformation {
8
+ fieldname: string;
9
+ originalname: string;
10
+ encoding: string;
11
+ mimetype: string;
12
+ destination: string;
13
+ filename: string;
14
+ path: string;
15
+ size: number;
16
+ format: string;
17
+ width: number;
18
+ height: number;
19
+ }
20
+ interface UploadResponse {
21
+ collectionName: string;
22
+ fileInformation: FileInformation;
23
+ metadata: {
24
+ thumbnails: any[];
25
+ clips: any[];
26
+ };
27
+ baseId: string;
28
+ storageAdaptor: string;
29
+ _id: string;
30
+ __v: number;
31
+ }
32
+ export interface AttachmentColumnValue {
33
+ url: string;
34
+ fileType: string;
35
+ size: number;
36
+ }
37
+ export declare class Attachment {
38
+ readonly collectionName: string;
39
+ readonly fileInformation: FileInformation;
40
+ readonly metadata: {
41
+ thumbnails: any[];
42
+ clips: any[];
43
+ };
44
+ readonly baseId: string;
45
+ readonly storageAdaptor: string;
46
+ readonly _id: string;
47
+ constructor(data: UploadResponse);
48
+ toColumnValue(): AttachmentColumnValue;
49
+ }
7
50
  type IsWithinOperatorValue = 'pastWeek' | 'pastMonth' | 'pastYear' | 'nextWeek' | 'nextMonth' | 'nextYear' | 'daysFromNow' | 'daysAgo' | 'currentWeek' | 'currentMonth' | 'currentYear';
8
51
  type DefaultDateFilterValue = ('today' | 'tomorrow' | 'yesterday' | 'oneWeekAgo' | 'oneWeekFromNow' | 'oneMonthAgo' | 'oneMonthFromNow') | ['exactDay' | 'exactTimestamp', string] | ['daysAgo' | 'daysFromNow', number];
9
52
  type DateFilters = {
@@ -101,12 +144,17 @@ export type ColumnType<S, U, I, R extends boolean, F extends {
101
144
  };
102
145
  export type DateColumnType<R extends boolean> = ColumnType<string, string, string, R, DateFilters, DateAggregations>;
103
146
  export type TextColumnType<R extends boolean> = ColumnType<string, string, string, R, TextFilters>;
104
- export type LinkColumnType<T extends string, R extends boolean> = ColumnType<object, number | number[] | {
105
- newIds: number[];
106
- deletedIds: number[];
107
- }, number | number[], R, LinkFilters, LinkAggregations> & {
147
+ export type ALinkColumnType<T extends string, S, U, I, R extends boolean> = ColumnType<S, U, I, R, LinkFilters, LinkAggregations> & {
108
148
  linkedTo: T;
109
149
  };
150
+ export type LinkColumnType<T extends string, R extends boolean> = ALinkColumnType<T, object, number | number[] | {
151
+ newIds: number[];
152
+ deletedIds: number[];
153
+ }, number | number[], R>;
154
+ export type AttachmentColumnType<R extends boolean> = ALinkColumnType<'attachmentTable', Attachment[], Attachment[] | {
155
+ newIds: number[];
156
+ deletedIds: number[];
157
+ } | number[], Attachment[] | number[], R>;
110
158
  export type NumberColumnType<R extends boolean> = ColumnType<number, number, number, R, NumberFilters, NumberAggregations>;
111
159
  export type CheckboxColumnType<R extends boolean> = ColumnType<boolean, boolean, boolean, R, CheckboxFilters>;
112
160
  export type AutoGeneratedNumberColumnType = ColumnType<number, never, never, false, NumberFilters, NumberAggregations>;
@@ -4,5 +4,27 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- export {};
7
+ export class Attachment {
8
+ collectionName;
9
+ fileInformation;
10
+ metadata;
11
+ baseId;
12
+ storageAdaptor;
13
+ _id;
14
+ constructor(data) {
15
+ this.collectionName = data.collectionName;
16
+ this.fileInformation = data.fileInformation;
17
+ this.metadata = data.metadata;
18
+ this.baseId = data.baseId;
19
+ this.storageAdaptor = data.storageAdaptor;
20
+ this._id = data._id;
21
+ }
22
+ toColumnValue() {
23
+ return {
24
+ url: this.fileInformation.path,
25
+ fileType: this.fileInformation.mimetype,
26
+ size: this.fileInformation.size,
27
+ };
28
+ }
29
+ }
8
30
  //# sourceMappingURL=column-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
1
+ {"version":3,"file":"column-types.js","sourceRoot":"","sources":["../../src/column-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmCH,MAAM,OAAO,UAAU;IACL,cAAc,CAAS;IACvB,eAAe,CAAkB;IACjC,QAAQ,CAAsC;IAC9C,MAAM,CAAS;IACf,cAAc,CAAS;IACvB,GAAG,CAAS;IAE5B,YAAY,IAAoB;QAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,aAAa;QACX,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;YAC9B,QAAQ,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ;YACvC,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;SAChC,CAAC;IACJ,CAAC;CACF"}