@contractspec/lib.files 1.56.1 → 1.57.0
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/contracts/index.d.ts +291 -291
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/entities/index.d.ts +133 -133
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/files.capability.d.ts +3 -3
- package/dist/files.capability.d.ts.map +1 -1
- package/dist/files.feature.d.ts +2 -3
- package/dist/files.feature.d.ts.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/contracts/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/contracts/index.ts"],"mappings":";;;;cAOa,SAAA,4BAAS,WAAA;;UAwBpB,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,gBAAA,4BAAgB,WAAA;;UAc3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,eAAA,4BAAe,WAAA;;UAoB1B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAEW,iBAAA,4BAAiB,WAAA;;UAU5B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;cAqLW,kBAAA,+BAAkB,aAAA,2BAAA,WAAA;;UAgC7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAhC6B,yBAAA,CAAA,SAAA;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BnB,kBAAA,+BAAkB,aAAA,2BAAA,WAAA;;UAgC7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAhC6B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqClB,kBAAA,+BAAkB,aAAA,2BAAA,WAAA;;UA0B7B,yBAAA,CAAA,SAAA;;;;;UA1B6B,yBAAA,CAAA,SAAA;;;;;;;cA+BlB,uBAAA,+BAAuB,aAAA,2BAAA,WAAA;;UAkBlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;cAlBkC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuBvB,0BAAA,+BAA0B,aAAA,2BAAA,WAAA;;UAgCrC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;UAhCqC,yBAAA,CAAA,SAAA"}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
|
|
2
2
|
import { ModuleSchemaContribution } from "@contractspec/lib.schema";
|
|
3
3
|
|
|
4
4
|
//#region src/entities/index.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* Storage provider enum.
|
|
7
7
|
*/
|
|
8
|
-
declare const StorageProviderEnum:
|
|
8
|
+
declare const StorageProviderEnum: _contractspec_lib_schema0.EntityEnumDef;
|
|
9
9
|
/**
|
|
10
10
|
* File status enum.
|
|
11
11
|
*/
|
|
12
|
-
declare const FileStatusEnum:
|
|
12
|
+
declare const FileStatusEnum: _contractspec_lib_schema0.EntityEnumDef;
|
|
13
13
|
/**
|
|
14
14
|
* File entity - represents an uploaded file.
|
|
15
15
|
*/
|
|
16
|
-
declare const FileEntity:
|
|
17
|
-
id:
|
|
18
|
-
name:
|
|
19
|
-
mimeType:
|
|
20
|
-
size:
|
|
21
|
-
storageProvider:
|
|
22
|
-
storagePath:
|
|
23
|
-
storageKey:
|
|
24
|
-
checksum:
|
|
25
|
-
etag:
|
|
26
|
-
status:
|
|
27
|
-
isPublic:
|
|
28
|
-
expiresAt:
|
|
29
|
-
ownerId:
|
|
30
|
-
orgId:
|
|
31
|
-
metadata:
|
|
32
|
-
tags:
|
|
33
|
-
width:
|
|
34
|
-
height:
|
|
35
|
-
createdAt:
|
|
36
|
-
updatedAt:
|
|
37
|
-
versions:
|
|
38
|
-
attachments:
|
|
16
|
+
declare const FileEntity: _contractspec_lib_schema0.EntitySpec<{
|
|
17
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
18
|
+
name: _contractspec_lib_schema0.EntityScalarField;
|
|
19
|
+
mimeType: _contractspec_lib_schema0.EntityScalarField;
|
|
20
|
+
size: _contractspec_lib_schema0.EntityScalarField;
|
|
21
|
+
storageProvider: _contractspec_lib_schema0.EntityEnumField;
|
|
22
|
+
storagePath: _contractspec_lib_schema0.EntityScalarField;
|
|
23
|
+
storageKey: _contractspec_lib_schema0.EntityScalarField;
|
|
24
|
+
checksum: _contractspec_lib_schema0.EntityScalarField;
|
|
25
|
+
etag: _contractspec_lib_schema0.EntityScalarField;
|
|
26
|
+
status: _contractspec_lib_schema0.EntityEnumField;
|
|
27
|
+
isPublic: _contractspec_lib_schema0.EntityScalarField;
|
|
28
|
+
expiresAt: _contractspec_lib_schema0.EntityScalarField;
|
|
29
|
+
ownerId: _contractspec_lib_schema0.EntityScalarField;
|
|
30
|
+
orgId: _contractspec_lib_schema0.EntityScalarField;
|
|
31
|
+
metadata: _contractspec_lib_schema0.EntityScalarField;
|
|
32
|
+
tags: _contractspec_lib_schema0.EntityScalarField;
|
|
33
|
+
width: _contractspec_lib_schema0.EntityScalarField;
|
|
34
|
+
height: _contractspec_lib_schema0.EntityScalarField;
|
|
35
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
36
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
37
|
+
versions: _contractspec_lib_schema0.EntityRelationField;
|
|
38
|
+
attachments: _contractspec_lib_schema0.EntityRelationField;
|
|
39
39
|
}>;
|
|
40
40
|
/**
|
|
41
41
|
* FileVersion entity - version history for files.
|
|
42
42
|
*/
|
|
43
|
-
declare const FileVersionEntity:
|
|
44
|
-
id:
|
|
45
|
-
fileId:
|
|
46
|
-
version:
|
|
47
|
-
size:
|
|
48
|
-
storagePath:
|
|
49
|
-
checksum:
|
|
50
|
-
comment:
|
|
51
|
-
changes:
|
|
52
|
-
createdBy:
|
|
53
|
-
createdAt:
|
|
54
|
-
file:
|
|
43
|
+
declare const FileVersionEntity: _contractspec_lib_schema0.EntitySpec<{
|
|
44
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
45
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
46
|
+
version: _contractspec_lib_schema0.EntityScalarField;
|
|
47
|
+
size: _contractspec_lib_schema0.EntityScalarField;
|
|
48
|
+
storagePath: _contractspec_lib_schema0.EntityScalarField;
|
|
49
|
+
checksum: _contractspec_lib_schema0.EntityScalarField;
|
|
50
|
+
comment: _contractspec_lib_schema0.EntityScalarField;
|
|
51
|
+
changes: _contractspec_lib_schema0.EntityScalarField;
|
|
52
|
+
createdBy: _contractspec_lib_schema0.EntityScalarField;
|
|
53
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
54
|
+
file: _contractspec_lib_schema0.EntityRelationField;
|
|
55
55
|
}>;
|
|
56
56
|
/**
|
|
57
57
|
* Attachment entity - polymorphic link between files and entities.
|
|
58
58
|
*/
|
|
59
|
-
declare const AttachmentEntity:
|
|
60
|
-
id:
|
|
61
|
-
fileId:
|
|
62
|
-
entityType:
|
|
63
|
-
entityId:
|
|
64
|
-
attachmentType:
|
|
65
|
-
name:
|
|
66
|
-
description:
|
|
67
|
-
order:
|
|
68
|
-
metadata:
|
|
69
|
-
createdBy:
|
|
70
|
-
createdAt:
|
|
71
|
-
updatedAt:
|
|
72
|
-
file:
|
|
59
|
+
declare const AttachmentEntity: _contractspec_lib_schema0.EntitySpec<{
|
|
60
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
61
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
62
|
+
entityType: _contractspec_lib_schema0.EntityScalarField;
|
|
63
|
+
entityId: _contractspec_lib_schema0.EntityScalarField;
|
|
64
|
+
attachmentType: _contractspec_lib_schema0.EntityScalarField;
|
|
65
|
+
name: _contractspec_lib_schema0.EntityScalarField;
|
|
66
|
+
description: _contractspec_lib_schema0.EntityScalarField;
|
|
67
|
+
order: _contractspec_lib_schema0.EntityScalarField;
|
|
68
|
+
metadata: _contractspec_lib_schema0.EntityScalarField;
|
|
69
|
+
createdBy: _contractspec_lib_schema0.EntityScalarField;
|
|
70
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
71
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
72
|
+
file: _contractspec_lib_schema0.EntityRelationField;
|
|
73
73
|
}>;
|
|
74
74
|
/**
|
|
75
75
|
* UploadSession entity - tracks multipart uploads.
|
|
76
76
|
*/
|
|
77
|
-
declare const UploadSessionEntity:
|
|
78
|
-
id:
|
|
79
|
-
fileName:
|
|
80
|
-
mimeType:
|
|
81
|
-
totalSize:
|
|
82
|
-
uploadId:
|
|
83
|
-
uploadedBytes:
|
|
84
|
-
uploadedParts:
|
|
85
|
-
status:
|
|
86
|
-
error:
|
|
87
|
-
fileId:
|
|
88
|
-
ownerId:
|
|
89
|
-
orgId:
|
|
90
|
-
expiresAt:
|
|
91
|
-
createdAt:
|
|
92
|
-
updatedAt:
|
|
77
|
+
declare const UploadSessionEntity: _contractspec_lib_schema0.EntitySpec<{
|
|
78
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
79
|
+
fileName: _contractspec_lib_schema0.EntityScalarField;
|
|
80
|
+
mimeType: _contractspec_lib_schema0.EntityScalarField;
|
|
81
|
+
totalSize: _contractspec_lib_schema0.EntityScalarField;
|
|
82
|
+
uploadId: _contractspec_lib_schema0.EntityScalarField;
|
|
83
|
+
uploadedBytes: _contractspec_lib_schema0.EntityScalarField;
|
|
84
|
+
uploadedParts: _contractspec_lib_schema0.EntityScalarField;
|
|
85
|
+
status: _contractspec_lib_schema0.EntityScalarField;
|
|
86
|
+
error: _contractspec_lib_schema0.EntityScalarField;
|
|
87
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
88
|
+
ownerId: _contractspec_lib_schema0.EntityScalarField;
|
|
89
|
+
orgId: _contractspec_lib_schema0.EntityScalarField;
|
|
90
|
+
expiresAt: _contractspec_lib_schema0.EntityScalarField;
|
|
91
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
92
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
93
93
|
}>;
|
|
94
94
|
/**
|
|
95
95
|
* All file entities for schema composition.
|
|
96
96
|
*/
|
|
97
|
-
declare const fileEntities: (
|
|
98
|
-
id:
|
|
99
|
-
name:
|
|
100
|
-
mimeType:
|
|
101
|
-
size:
|
|
102
|
-
storageProvider:
|
|
103
|
-
storagePath:
|
|
104
|
-
storageKey:
|
|
105
|
-
checksum:
|
|
106
|
-
etag:
|
|
107
|
-
status:
|
|
108
|
-
isPublic:
|
|
109
|
-
expiresAt:
|
|
110
|
-
ownerId:
|
|
111
|
-
orgId:
|
|
112
|
-
metadata:
|
|
113
|
-
tags:
|
|
114
|
-
width:
|
|
115
|
-
height:
|
|
116
|
-
createdAt:
|
|
117
|
-
updatedAt:
|
|
118
|
-
versions:
|
|
119
|
-
attachments:
|
|
120
|
-
}> |
|
|
121
|
-
id:
|
|
122
|
-
fileId:
|
|
123
|
-
version:
|
|
124
|
-
size:
|
|
125
|
-
storagePath:
|
|
126
|
-
checksum:
|
|
127
|
-
comment:
|
|
128
|
-
changes:
|
|
129
|
-
createdBy:
|
|
130
|
-
createdAt:
|
|
131
|
-
file:
|
|
132
|
-
}> |
|
|
133
|
-
id:
|
|
134
|
-
fileId:
|
|
135
|
-
entityType:
|
|
136
|
-
entityId:
|
|
137
|
-
attachmentType:
|
|
138
|
-
name:
|
|
139
|
-
description:
|
|
140
|
-
order:
|
|
141
|
-
metadata:
|
|
142
|
-
createdBy:
|
|
143
|
-
createdAt:
|
|
144
|
-
updatedAt:
|
|
145
|
-
file:
|
|
146
|
-
}> |
|
|
147
|
-
id:
|
|
148
|
-
fileName:
|
|
149
|
-
mimeType:
|
|
150
|
-
totalSize:
|
|
151
|
-
uploadId:
|
|
152
|
-
uploadedBytes:
|
|
153
|
-
uploadedParts:
|
|
154
|
-
status:
|
|
155
|
-
error:
|
|
156
|
-
fileId:
|
|
157
|
-
ownerId:
|
|
158
|
-
orgId:
|
|
159
|
-
expiresAt:
|
|
160
|
-
createdAt:
|
|
161
|
-
updatedAt:
|
|
97
|
+
declare const fileEntities: (_contractspec_lib_schema0.EntitySpec<{
|
|
98
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
99
|
+
name: _contractspec_lib_schema0.EntityScalarField;
|
|
100
|
+
mimeType: _contractspec_lib_schema0.EntityScalarField;
|
|
101
|
+
size: _contractspec_lib_schema0.EntityScalarField;
|
|
102
|
+
storageProvider: _contractspec_lib_schema0.EntityEnumField;
|
|
103
|
+
storagePath: _contractspec_lib_schema0.EntityScalarField;
|
|
104
|
+
storageKey: _contractspec_lib_schema0.EntityScalarField;
|
|
105
|
+
checksum: _contractspec_lib_schema0.EntityScalarField;
|
|
106
|
+
etag: _contractspec_lib_schema0.EntityScalarField;
|
|
107
|
+
status: _contractspec_lib_schema0.EntityEnumField;
|
|
108
|
+
isPublic: _contractspec_lib_schema0.EntityScalarField;
|
|
109
|
+
expiresAt: _contractspec_lib_schema0.EntityScalarField;
|
|
110
|
+
ownerId: _contractspec_lib_schema0.EntityScalarField;
|
|
111
|
+
orgId: _contractspec_lib_schema0.EntityScalarField;
|
|
112
|
+
metadata: _contractspec_lib_schema0.EntityScalarField;
|
|
113
|
+
tags: _contractspec_lib_schema0.EntityScalarField;
|
|
114
|
+
width: _contractspec_lib_schema0.EntityScalarField;
|
|
115
|
+
height: _contractspec_lib_schema0.EntityScalarField;
|
|
116
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
117
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
118
|
+
versions: _contractspec_lib_schema0.EntityRelationField;
|
|
119
|
+
attachments: _contractspec_lib_schema0.EntityRelationField;
|
|
120
|
+
}> | _contractspec_lib_schema0.EntitySpec<{
|
|
121
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
122
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
123
|
+
version: _contractspec_lib_schema0.EntityScalarField;
|
|
124
|
+
size: _contractspec_lib_schema0.EntityScalarField;
|
|
125
|
+
storagePath: _contractspec_lib_schema0.EntityScalarField;
|
|
126
|
+
checksum: _contractspec_lib_schema0.EntityScalarField;
|
|
127
|
+
comment: _contractspec_lib_schema0.EntityScalarField;
|
|
128
|
+
changes: _contractspec_lib_schema0.EntityScalarField;
|
|
129
|
+
createdBy: _contractspec_lib_schema0.EntityScalarField;
|
|
130
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
131
|
+
file: _contractspec_lib_schema0.EntityRelationField;
|
|
132
|
+
}> | _contractspec_lib_schema0.EntitySpec<{
|
|
133
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
134
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
135
|
+
entityType: _contractspec_lib_schema0.EntityScalarField;
|
|
136
|
+
entityId: _contractspec_lib_schema0.EntityScalarField;
|
|
137
|
+
attachmentType: _contractspec_lib_schema0.EntityScalarField;
|
|
138
|
+
name: _contractspec_lib_schema0.EntityScalarField;
|
|
139
|
+
description: _contractspec_lib_schema0.EntityScalarField;
|
|
140
|
+
order: _contractspec_lib_schema0.EntityScalarField;
|
|
141
|
+
metadata: _contractspec_lib_schema0.EntityScalarField;
|
|
142
|
+
createdBy: _contractspec_lib_schema0.EntityScalarField;
|
|
143
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
144
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
145
|
+
file: _contractspec_lib_schema0.EntityRelationField;
|
|
146
|
+
}> | _contractspec_lib_schema0.EntitySpec<{
|
|
147
|
+
id: _contractspec_lib_schema0.EntityScalarField;
|
|
148
|
+
fileName: _contractspec_lib_schema0.EntityScalarField;
|
|
149
|
+
mimeType: _contractspec_lib_schema0.EntityScalarField;
|
|
150
|
+
totalSize: _contractspec_lib_schema0.EntityScalarField;
|
|
151
|
+
uploadId: _contractspec_lib_schema0.EntityScalarField;
|
|
152
|
+
uploadedBytes: _contractspec_lib_schema0.EntityScalarField;
|
|
153
|
+
uploadedParts: _contractspec_lib_schema0.EntityScalarField;
|
|
154
|
+
status: _contractspec_lib_schema0.EntityScalarField;
|
|
155
|
+
error: _contractspec_lib_schema0.EntityScalarField;
|
|
156
|
+
fileId: _contractspec_lib_schema0.EntityScalarField;
|
|
157
|
+
ownerId: _contractspec_lib_schema0.EntityScalarField;
|
|
158
|
+
orgId: _contractspec_lib_schema0.EntityScalarField;
|
|
159
|
+
expiresAt: _contractspec_lib_schema0.EntityScalarField;
|
|
160
|
+
createdAt: _contractspec_lib_schema0.EntityScalarField;
|
|
161
|
+
updatedAt: _contractspec_lib_schema0.EntityScalarField;
|
|
162
162
|
}>)[];
|
|
163
163
|
/**
|
|
164
164
|
* Module schema contribution for files.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/entities/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/entities/index.ts"],"mappings":";;;;;;;cAWa,mBAAA,EAKX,yBAAA,CAL8B,aAAA;;;;cAUnB,cAAA,EAYX,yBAAA,CAZyB,aAAA;AAA3B;;;AAAA,cAiBa,UAAA,4BAAU,UAAA;MA0FrB,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,iBAAA,4BAAiB,UAAA;MAwC5B,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;cAKW,gBAAA,4BAAgB,UAAA;MAwD3B,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;cAKW,mBAAA,4BAAmB,UAAA;MA0D9B,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;cAKW,YAAA,6BAAY,UAAA;MAKxB,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;;;;;MALwB,yBAAA,CAAA,iBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAUZ,uBAAA,EAAyB,wBAAA"}
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"
|
|
1
|
+
{"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"mappings":";;;;;;;cA6Ha,iBAAA,EAAiB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU5B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,gBAAA,EAAgB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;cAKW,gBAAA,EAAgB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,uBAAA,EAAuB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,uBAAA,EAAuB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,uBAAA,EAAuB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;AAzBF;;;AAAA,cA8Ba,yBAAA,EAAyB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUpC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,2BAAA,EAA2B,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUtC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;cAKW,UAAA;;;YASZ,yBAAA,CAAA,SAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
|
|
2
2
|
|
|
3
3
|
//#region src/files.capability.d.ts
|
|
4
|
-
declare const FilesCapability:
|
|
5
|
-
declare const AttachmentsCapability:
|
|
4
|
+
declare const FilesCapability: _contractspec_lib_contracts0.CapabilitySpec;
|
|
5
|
+
declare const AttachmentsCapability: _contractspec_lib_contracts0.CapabilitySpec;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { AttachmentsCapability, FilesCapability };
|
|
8
8
|
//# sourceMappingURL=files.capability.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.capability.d.ts","names":[],"sources":["../src/files.capability.ts"],"
|
|
1
|
+
{"version":3,"file":"files.capability.d.ts","names":[],"sources":["../src/files.capability.ts"],"mappings":";;;cAEa,eAAA,EAUX,4BAAA,CAV0B,cAAA;AAAA,cAYf,qBAAA,EAUX,4BAAA,CAVgC,cAAA"}
|
package/dist/files.feature.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
|
|
2
2
|
|
|
3
3
|
//#region src/files.feature.d.ts
|
|
4
|
-
|
|
5
4
|
/**
|
|
6
5
|
* Files feature module that bundles file storage,
|
|
7
6
|
* attachments, and media processing capabilities.
|
|
8
7
|
*/
|
|
9
|
-
declare const FilesFeature:
|
|
8
|
+
declare const FilesFeature: _contractspec_lib_contracts0.FeatureModuleSpec;
|
|
10
9
|
//#endregion
|
|
11
10
|
export { FilesFeature };
|
|
12
11
|
//# sourceMappingURL=files.feature.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.feature.d.ts","names":[],"sources":["../src/files.feature.ts"],"
|
|
1
|
+
{"version":3,"file":"files.feature.d.ts","names":[],"sources":["../src/files.feature.ts"],"mappings":";;;;;;AAWA;cAAa,YAAA,EAgEX,4BAAA,CAhEuB,iBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/storage/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/storage/index.ts"],"mappings":";;AAMA;;KAAY,eAAA;AAAA,UAEK,WAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA;EACA,QAAA;EACA,IAAA;EACA,QAAA,GAAW,MAAA;AAAA;AAAA,UAGI,aAAA;EALf;EAOA,IAAA;EALA;EAOA,OAAA,EAAS,MAAA;EAPQ;EASjB,QAAA;EANe;EAQf,QAAA,GAAW,MAAA;;EAEX,QAAA;AAAA;AAAA,UAGe,sBAAA;EATN;EAWT,IAAA;EAPA;EASA,QAAA;EAPA;EASA,IAAA;EATQ;EAWR,SAAA;EARqC;EAUrC,UAAA,GAAa,MAAA;AAAA;AAAA,UAGE,wBAAA;EATf;EAWA,IAAA;EAPA;EASA,SAAA;EAPa;EASb,kBAAA;AAAA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AkC,cAAA;EAAA,SACpC,QAAA,EAAU,eAAA;EAAA,QACX,KAAA;EAEF,MAAA,CAAO,OAAA,EAAS,aAAA,GAAgB,OAAA,CAAQ,WAAA;EAoBxC,QAAA,CAAS,QAAA,WAAmB,OAAA,CAAQ,MAAA;EAQpC,MAAA,CAAO,QAAA,WAAmB,OAAA;EAI1B,MAAA,CAAO,QAAA,WAAmB,OAAA;EAI1B,WAAA,CAAY,QAAA,WAAmB,OAAA,CAAQ,WAAA;EAKvC,IAAA,CAAK,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,UAAA;EAiBrC,qBAAA,CACJ,OAAA,EAAS,sBAAA,GACR,OAAA,CAAQ,YAAA;EASL,uBAAA,CACJ,OAAA,EAAS,wBAAA,GACR,OAAA,CAAQ,YAAA;EAQX,YAAA,CAAa,QAAA;EAIP,IAAA,CACJ,UAAA,UACA,eAAA,WACC,OAAA,CAAQ,WAAA;EAeX,KAAA,CAAA;AAAA;AAAA,UAOe,aAAA;EACf,QAAA,EAAU,eAAA;EACV,KAAA,GAAQ,mBAAA;EACR,EAAA,GAAK,gBAAA;AAAA;;;;iBAMS,oBAAA,CAAqB,MAAA,EAAQ,aAAA,GAAgB,cAAA"}
|
package/dist/storage/index.js
CHANGED
|
@@ -207,7 +207,7 @@ var InMemoryStorageAdapter = class {
|
|
|
207
207
|
async list(options) {
|
|
208
208
|
const prefix = options?.prefix || "";
|
|
209
209
|
const files = [];
|
|
210
|
-
for (const [path
|
|
210
|
+
for (const [path, file] of this.files) if (path.startsWith(prefix)) files.push(file.metadata);
|
|
211
211
|
const limit = options?.limit || files.length;
|
|
212
212
|
return {
|
|
213
213
|
files: files.slice(0, limit),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path"],"sources":["../../src/storage/index.ts"],"sourcesContent":["/**\n * File storage adapters for different backends.\n */\n\n// ============ Types ============\n\nexport type StorageProvider = 'LOCAL' | 'S3' | 'GCS' | 'AZURE' | 'CLOUDFLARE';\n\nexport interface StorageFile {\n path: string;\n size: number;\n mimeType: string;\n checksum?: string;\n etag?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface UploadOptions {\n /** Target path in storage */\n path: string;\n /** File content */\n content: Buffer | string;\n /** MIME type */\n mimeType: string;\n /** Additional metadata */\n metadata?: Record<string, string>;\n /** Whether file should be publicly accessible */\n isPublic?: boolean;\n}\n\nexport interface PresignedUploadOptions {\n /** Target path in storage */\n path: string;\n /** MIME type */\n mimeType: string;\n /** File size in bytes */\n size: number;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Additional conditions */\n conditions?: Record<string, unknown>[];\n}\n\nexport interface PresignedDownloadOptions {\n /** File path in storage */\n path: string;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Response content disposition */\n contentDisposition?: string;\n}\n\nexport interface PresignedUrl {\n url: string;\n fields?: Record<string, string>;\n expiresAt: Date;\n}\n\nexport interface ListOptions {\n /** Path prefix */\n prefix?: string;\n /** Maximum results */\n limit?: number;\n /** Continuation token */\n cursor?: string;\n}\n\nexport interface ListResult {\n files: StorageFile[];\n cursor?: string;\n hasMore: boolean;\n}\n\n// ============ Storage Adapter Interface ============\n\nexport interface StorageAdapter {\n /** Storage provider type */\n readonly provider: StorageProvider;\n\n /**\n * Upload a file to storage.\n */\n upload(options: UploadOptions): Promise<StorageFile>;\n\n /**\n * Download a file from storage.\n */\n download(path: string): Promise<Buffer>;\n\n /**\n * Delete a file from storage.\n */\n delete(path: string): Promise<void>;\n\n /**\n * Check if a file exists.\n */\n exists(path: string): Promise<boolean>;\n\n /**\n * Get file metadata.\n */\n getMetadata(path: string): Promise<StorageFile | null>;\n\n /**\n * List files in a directory.\n */\n list(options?: ListOptions): Promise<ListResult>;\n\n /**\n * Generate a presigned URL for uploading.\n */\n createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;\n\n /**\n * Generate a presigned URL for downloading.\n */\n createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl>;\n\n /**\n * Get public URL for a file (if applicable).\n */\n getPublicUrl(path: string): string | null;\n\n /**\n * Copy a file within storage.\n */\n copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;\n}\n\n// ============ Local Storage Adapter ============\n\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\n\nexport interface LocalStorageOptions {\n /** Base directory for file storage */\n basePath: string;\n /** Base URL for serving files (optional) */\n baseUrl?: string;\n}\n\n/**\n * Local filesystem storage adapter.\n * For development and testing purposes.\n */\nexport class LocalStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private basePath: string;\n private baseUrl?: string;\n\n constructor(options: LocalStorageOptions) {\n this.basePath = options.basePath;\n this.baseUrl = options.baseUrl;\n }\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const fullPath = path.join(this.basePath, options.path);\n const dir = path.dirname(fullPath);\n\n // Ensure directory exists\n await fs.mkdir(dir, { recursive: true });\n\n // Write file\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n await fs.writeFile(fullPath, content);\n\n // Calculate checksum\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n return {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n }\n\n async download(filePath: string): Promise<Buffer> {\n const fullPath = path.join(this.basePath, filePath);\n return fs.readFile(fullPath);\n }\n\n async delete(filePath: string): Promise<void> {\n const fullPath = path.join(this.basePath, filePath);\n await fs.unlink(fullPath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n await fs.access(fullPath);\n return true;\n } catch {\n return false;\n }\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n const stat = await fs.stat(fullPath);\n return {\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream', // Would need mime type detection\n };\n } catch {\n return null;\n }\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const dir = options?.prefix\n ? path.join(this.basePath, options.prefix)\n : this.basePath;\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n const files: StorageFile[] = [];\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const filePath = options?.prefix\n ? path.join(options.prefix, entry.name)\n : entry.name;\n const stat = await fs.stat(path.join(dir, entry.name));\n files.push({\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n });\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n } catch {\n return { files: [], hasMore: false };\n }\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n // Local storage doesn't support real presigned URLs\n // Return a placeholder that would work with a local upload endpoint\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}`\n : `/upload?path=${encodeURIComponent(options.path)}`,\n fields: {\n path: options.path,\n mimeType: options.mimeType,\n },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/download/${options.path}`\n : `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n if (!this.baseUrl) return null;\n return `${this.baseUrl}/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const sourceFullPath = path.join(this.basePath, sourcePath);\n const destFullPath = path.join(this.basePath, destinationPath);\n const destDir = path.dirname(destFullPath);\n\n await fs.mkdir(destDir, { recursive: true });\n await fs.copyFile(sourceFullPath, destFullPath);\n\n const stat = await fs.stat(destFullPath);\n return {\n path: destinationPath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n };\n }\n}\n\n// ============ S3 Storage Adapter Interface ============\n\nexport interface S3StorageOptions {\n /** S3 bucket name */\n bucket: string;\n /** AWS region */\n region: string;\n /** AWS access key ID */\n accessKeyId?: string;\n /** AWS secret access key */\n secretAccessKey?: string;\n /** Endpoint URL (for S3-compatible services) */\n endpoint?: string;\n /** Force path style (for S3-compatible services) */\n forcePathStyle?: boolean;\n /** Default ACL for uploads */\n defaultAcl?: 'private' | 'public-read';\n}\n\n/**\n * S3 storage adapter interface.\n * Implementation would use AWS SDK or compatible client.\n *\n * This is a placeholder that defines the interface.\n * Actual implementation would require @aws-sdk/client-s3 dependency.\n */\nexport class S3StorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'S3';\n private config: S3StorageOptions;\n\n constructor(options: S3StorageOptions) {\n this.config = options;\n }\n\n async upload(_options: UploadOptions): Promise<StorageFile> {\n // Placeholder - actual implementation would use S3 SDK\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.'\n );\n }\n\n async download(_filePath: string): Promise<Buffer> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.'\n );\n }\n\n async delete(_filePath: string): Promise<void> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.'\n );\n }\n\n async exists(_filePath: string): Promise<boolean> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.'\n );\n }\n\n async getMetadata(_filePath: string): Promise<StorageFile | null> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.'\n );\n }\n\n async list(_options?: ListOptions): Promise<ListResult> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.'\n );\n }\n\n async createPresignedUpload(\n _options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.'\n );\n }\n\n async createPresignedDownload(\n _options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.'\n );\n }\n\n getPublicUrl(filePath: string): string | null {\n const { bucket, region, endpoint } = this.config;\n if (endpoint) {\n return `${endpoint}/${bucket}/${filePath}`;\n }\n return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;\n }\n\n async copy(\n _sourcePath: string,\n _destinationPath: string\n ): Promise<StorageFile> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.'\n );\n }\n}\n\n// ============ In-Memory Storage Adapter ============\n\n/**\n * In-memory storage adapter for testing.\n */\nexport class InMemoryStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private files = new Map<string, { content: Buffer; metadata: StorageFile }>();\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n const metadata: StorageFile = {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n\n this.files.set(options.path, { content, metadata });\n return metadata;\n }\n\n async download(filePath: string): Promise<Buffer> {\n const file = this.files.get(filePath);\n if (!file) {\n throw new Error(`File not found: ${filePath}`);\n }\n return file.content;\n }\n\n async delete(filePath: string): Promise<void> {\n this.files.delete(filePath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n return this.files.has(filePath);\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const file = this.files.get(filePath);\n return file?.metadata || null;\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const prefix = options?.prefix || '';\n const files: StorageFile[] = [];\n\n for (const [path, file] of this.files) {\n if (path.startsWith(prefix)) {\n files.push(file.metadata);\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/upload?path=${encodeURIComponent(options.path)}`,\n fields: { path: options.path },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n return `/files/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const source = this.files.get(sourcePath);\n if (!source) {\n throw new Error(`Source file not found: ${sourcePath}`);\n }\n\n const metadata: StorageFile = {\n ...source.metadata,\n path: destinationPath,\n };\n\n this.files.set(destinationPath, { content: source.content, metadata });\n return metadata;\n }\n\n clear(): void {\n this.files.clear();\n }\n}\n\n// ============ Factory ============\n\nexport interface StorageConfig {\n provider: StorageProvider;\n local?: LocalStorageOptions;\n s3?: S3StorageOptions;\n}\n\n/**\n * Create a storage adapter based on configuration.\n */\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n switch (config.provider) {\n case 'LOCAL':\n if (!config.local) {\n throw new Error('Local storage configuration required');\n }\n return new LocalStorageAdapter(config.local);\n\n case 'S3':\n if (!config.s3) {\n throw new Error('S3 storage configuration required');\n }\n return new S3StorageAdapter(config.s3);\n\n default:\n throw new Error(`Unsupported storage provider: ${config.provider}`);\n }\n}\n"],"mappings":";;;;;;;;;AAqJA,IAAa,sBAAb,MAA2D;CACzD,AAAS,WAA4B;CACrC,AAAQ;CACR,AAAQ;CAER,YAAY,SAA8B;AACxC,OAAK,WAAW,QAAQ;AACxB,OAAK,UAAU,QAAQ;;CAGzB,MAAM,OAAO,SAA8C;EACzD,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,QAAQ,KAAK;EACvD,MAAM,MA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AAM,0BAA0B,aAAa;EAGzD,MAAM,WAAwB;GAC5B,GAAG,OAAO;GACV,MAAM;GACP;AAED,OAAK,MAAM,IAAI,iBAAiB;GAAE,SAAS,OAAO;GAAS;GAAU,CAAC;AACtE,SAAO;;CAGT,QAAc;AACZ,OAAK,MAAM,OAAO;;;;;;AAetB,SAAgB,qBAAqB,QAAuC;AAC1E,SAAQ,OAAO,UAAf;EACE,KAAK;AACH,OAAI,CAAC,OAAO,MACV,OAAM,IAAI,MAAM,uCAAuC;AAEzD,UAAO,IAAI,oBAAoB,OAAO,MAAM;EAE9C,KAAK;AACH,OAAI,CAAC,OAAO,GACV,OAAM,IAAI,MAAM,oCAAoC;AAEtD,UAAO,IAAI,iBAAiB,OAAO,GAAG;EAExC,QACE,OAAM,IAAI,MAAM,iCAAiC,OAAO,WAAW"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/storage/index.ts"],"sourcesContent":["/**\n * File storage adapters for different backends.\n */\n\n// ============ Types ============\n\nexport type StorageProvider = 'LOCAL' | 'S3' | 'GCS' | 'AZURE' | 'CLOUDFLARE';\n\nexport interface StorageFile {\n path: string;\n size: number;\n mimeType: string;\n checksum?: string;\n etag?: string;\n metadata?: Record<string, string>;\n}\n\nexport interface UploadOptions {\n /** Target path in storage */\n path: string;\n /** File content */\n content: Buffer | string;\n /** MIME type */\n mimeType: string;\n /** Additional metadata */\n metadata?: Record<string, string>;\n /** Whether file should be publicly accessible */\n isPublic?: boolean;\n}\n\nexport interface PresignedUploadOptions {\n /** Target path in storage */\n path: string;\n /** MIME type */\n mimeType: string;\n /** File size in bytes */\n size: number;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Additional conditions */\n conditions?: Record<string, unknown>[];\n}\n\nexport interface PresignedDownloadOptions {\n /** File path in storage */\n path: string;\n /** Expiration time in seconds */\n expiresIn?: number;\n /** Response content disposition */\n contentDisposition?: string;\n}\n\nexport interface PresignedUrl {\n url: string;\n fields?: Record<string, string>;\n expiresAt: Date;\n}\n\nexport interface ListOptions {\n /** Path prefix */\n prefix?: string;\n /** Maximum results */\n limit?: number;\n /** Continuation token */\n cursor?: string;\n}\n\nexport interface ListResult {\n files: StorageFile[];\n cursor?: string;\n hasMore: boolean;\n}\n\n// ============ Storage Adapter Interface ============\n\nexport interface StorageAdapter {\n /** Storage provider type */\n readonly provider: StorageProvider;\n\n /**\n * Upload a file to storage.\n */\n upload(options: UploadOptions): Promise<StorageFile>;\n\n /**\n * Download a file from storage.\n */\n download(path: string): Promise<Buffer>;\n\n /**\n * Delete a file from storage.\n */\n delete(path: string): Promise<void>;\n\n /**\n * Check if a file exists.\n */\n exists(path: string): Promise<boolean>;\n\n /**\n * Get file metadata.\n */\n getMetadata(path: string): Promise<StorageFile | null>;\n\n /**\n * List files in a directory.\n */\n list(options?: ListOptions): Promise<ListResult>;\n\n /**\n * Generate a presigned URL for uploading.\n */\n createPresignedUpload(options: PresignedUploadOptions): Promise<PresignedUrl>;\n\n /**\n * Generate a presigned URL for downloading.\n */\n createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl>;\n\n /**\n * Get public URL for a file (if applicable).\n */\n getPublicUrl(path: string): string | null;\n\n /**\n * Copy a file within storage.\n */\n copy(sourcePath: string, destinationPath: string): Promise<StorageFile>;\n}\n\n// ============ Local Storage Adapter ============\n\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\n\nexport interface LocalStorageOptions {\n /** Base directory for file storage */\n basePath: string;\n /** Base URL for serving files (optional) */\n baseUrl?: string;\n}\n\n/**\n * Local filesystem storage adapter.\n * For development and testing purposes.\n */\nexport class LocalStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private basePath: string;\n private baseUrl?: string;\n\n constructor(options: LocalStorageOptions) {\n this.basePath = options.basePath;\n this.baseUrl = options.baseUrl;\n }\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const fullPath = path.join(this.basePath, options.path);\n const dir = path.dirname(fullPath);\n\n // Ensure directory exists\n await fs.mkdir(dir, { recursive: true });\n\n // Write file\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n await fs.writeFile(fullPath, content);\n\n // Calculate checksum\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n return {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n }\n\n async download(filePath: string): Promise<Buffer> {\n const fullPath = path.join(this.basePath, filePath);\n return fs.readFile(fullPath);\n }\n\n async delete(filePath: string): Promise<void> {\n const fullPath = path.join(this.basePath, filePath);\n await fs.unlink(fullPath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n await fs.access(fullPath);\n return true;\n } catch {\n return false;\n }\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const fullPath = path.join(this.basePath, filePath);\n try {\n const stat = await fs.stat(fullPath);\n return {\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream', // Would need mime type detection\n };\n } catch {\n return null;\n }\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const dir = options?.prefix\n ? path.join(this.basePath, options.prefix)\n : this.basePath;\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true });\n const files: StorageFile[] = [];\n\n for (const entry of entries) {\n if (entry.isFile()) {\n const filePath = options?.prefix\n ? path.join(options.prefix, entry.name)\n : entry.name;\n const stat = await fs.stat(path.join(dir, entry.name));\n files.push({\n path: filePath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n });\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n } catch {\n return { files: [], hasMore: false };\n }\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n // Local storage doesn't support real presigned URLs\n // Return a placeholder that would work with a local upload endpoint\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/upload?path=${encodeURIComponent(options.path)}`\n : `/upload?path=${encodeURIComponent(options.path)}`,\n fields: {\n path: options.path,\n mimeType: options.mimeType,\n },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresIn = options.expiresIn || 3600;\n const expiresAt = new Date(Date.now() + expiresIn * 1000);\n\n return {\n url: this.baseUrl\n ? `${this.baseUrl}/download/${options.path}`\n : `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n if (!this.baseUrl) return null;\n return `${this.baseUrl}/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const sourceFullPath = path.join(this.basePath, sourcePath);\n const destFullPath = path.join(this.basePath, destinationPath);\n const destDir = path.dirname(destFullPath);\n\n await fs.mkdir(destDir, { recursive: true });\n await fs.copyFile(sourceFullPath, destFullPath);\n\n const stat = await fs.stat(destFullPath);\n return {\n path: destinationPath,\n size: stat.size,\n mimeType: 'application/octet-stream',\n };\n }\n}\n\n// ============ S3 Storage Adapter Interface ============\n\nexport interface S3StorageOptions {\n /** S3 bucket name */\n bucket: string;\n /** AWS region */\n region: string;\n /** AWS access key ID */\n accessKeyId?: string;\n /** AWS secret access key */\n secretAccessKey?: string;\n /** Endpoint URL (for S3-compatible services) */\n endpoint?: string;\n /** Force path style (for S3-compatible services) */\n forcePathStyle?: boolean;\n /** Default ACL for uploads */\n defaultAcl?: 'private' | 'public-read';\n}\n\n/**\n * S3 storage adapter interface.\n * Implementation would use AWS SDK or compatible client.\n *\n * This is a placeholder that defines the interface.\n * Actual implementation would require @aws-sdk/client-s3 dependency.\n */\nexport class S3StorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'S3';\n private config: S3StorageOptions;\n\n constructor(options: S3StorageOptions) {\n this.config = options;\n }\n\n async upload(_options: UploadOptions): Promise<StorageFile> {\n // Placeholder - actual implementation would use S3 SDK\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the upload method.'\n );\n }\n\n async download(_filePath: string): Promise<Buffer> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the download method.'\n );\n }\n\n async delete(_filePath: string): Promise<void> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the delete method.'\n );\n }\n\n async exists(_filePath: string): Promise<boolean> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the exists method.'\n );\n }\n\n async getMetadata(_filePath: string): Promise<StorageFile | null> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the getMetadata method.'\n );\n }\n\n async list(_options?: ListOptions): Promise<ListResult> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the list method.'\n );\n }\n\n async createPresignedUpload(\n _options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedUpload method.'\n );\n }\n\n async createPresignedDownload(\n _options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the createPresignedDownload method.'\n );\n }\n\n getPublicUrl(filePath: string): string | null {\n const { bucket, region, endpoint } = this.config;\n if (endpoint) {\n return `${endpoint}/${bucket}/${filePath}`;\n }\n return `https://${bucket}.s3.${region}.amazonaws.com/${filePath}`;\n }\n\n async copy(\n _sourcePath: string,\n _destinationPath: string\n ): Promise<StorageFile> {\n throw new Error(\n 'S3 adapter requires @aws-sdk/client-s3. Install it and implement the copy method.'\n );\n }\n}\n\n// ============ In-Memory Storage Adapter ============\n\n/**\n * In-memory storage adapter for testing.\n */\nexport class InMemoryStorageAdapter implements StorageAdapter {\n readonly provider: StorageProvider = 'LOCAL';\n private files = new Map<string, { content: Buffer; metadata: StorageFile }>();\n\n async upload(options: UploadOptions): Promise<StorageFile> {\n const content =\n typeof options.content === 'string'\n ? Buffer.from(options.content, 'base64')\n : options.content;\n\n const checksum = crypto.createHash('sha256').update(content).digest('hex');\n\n const metadata: StorageFile = {\n path: options.path,\n size: content.length,\n mimeType: options.mimeType,\n checksum,\n metadata: options.metadata,\n };\n\n this.files.set(options.path, { content, metadata });\n return metadata;\n }\n\n async download(filePath: string): Promise<Buffer> {\n const file = this.files.get(filePath);\n if (!file) {\n throw new Error(`File not found: ${filePath}`);\n }\n return file.content;\n }\n\n async delete(filePath: string): Promise<void> {\n this.files.delete(filePath);\n }\n\n async exists(filePath: string): Promise<boolean> {\n return this.files.has(filePath);\n }\n\n async getMetadata(filePath: string): Promise<StorageFile | null> {\n const file = this.files.get(filePath);\n return file?.metadata || null;\n }\n\n async list(options?: ListOptions): Promise<ListResult> {\n const prefix = options?.prefix || '';\n const files: StorageFile[] = [];\n\n for (const [path, file] of this.files) {\n if (path.startsWith(prefix)) {\n files.push(file.metadata);\n }\n }\n\n const limit = options?.limit || files.length;\n return {\n files: files.slice(0, limit),\n hasMore: files.length > limit,\n };\n }\n\n async createPresignedUpload(\n options: PresignedUploadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/upload?path=${encodeURIComponent(options.path)}`,\n fields: { path: options.path },\n expiresAt,\n };\n }\n\n async createPresignedDownload(\n options: PresignedDownloadOptions\n ): Promise<PresignedUrl> {\n const expiresAt = new Date(Date.now() + (options.expiresIn || 3600) * 1000);\n return {\n url: `/download/${options.path}`,\n expiresAt,\n };\n }\n\n getPublicUrl(filePath: string): string | null {\n return `/files/${filePath}`;\n }\n\n async copy(\n sourcePath: string,\n destinationPath: string\n ): Promise<StorageFile> {\n const source = this.files.get(sourcePath);\n if (!source) {\n throw new Error(`Source file not found: ${sourcePath}`);\n }\n\n const metadata: StorageFile = {\n ...source.metadata,\n path: destinationPath,\n };\n\n this.files.set(destinationPath, { content: source.content, metadata });\n return metadata;\n }\n\n clear(): void {\n this.files.clear();\n }\n}\n\n// ============ Factory ============\n\nexport interface StorageConfig {\n provider: StorageProvider;\n local?: LocalStorageOptions;\n s3?: S3StorageOptions;\n}\n\n/**\n * Create a storage adapter based on configuration.\n */\nexport function createStorageAdapter(config: StorageConfig): StorageAdapter {\n switch (config.provider) {\n case 'LOCAL':\n if (!config.local) {\n throw new Error('Local storage configuration required');\n }\n return new LocalStorageAdapter(config.local);\n\n case 'S3':\n if (!config.s3) {\n throw new Error('S3 storage configuration required');\n }\n return new S3StorageAdapter(config.s3);\n\n default:\n throw new Error(`Unsupported storage provider: ${config.provider}`);\n }\n}\n"],"mappings":";;;;;;;;;AAqJA,IAAa,sBAAb,MAA2D;CACzD,AAAS,WAA4B;CACrC,AAAQ;CACR,AAAQ;CAER,YAAY,SAA8B;AACxC,OAAK,WAAW,QAAQ;AACxB,OAAK,UAAU,QAAQ;;CAGzB,MAAM,OAAO,SAA8C;EACzD,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,QAAQ,KAAK;EACvD,MAAM,MAAM,KAAK,QAAQ,SAAS;AAGlC,QAAM,GAAG,MAAM,KAAK,EAAE,WAAW,MAAM,CAAC;EAGxC,MAAM,UACJ,OAAO,QAAQ,YAAY,WACvB,OAAO,KAAK,QAAQ,SAAS,SAAS,GACtC,QAAQ;AAEd,QAAM,GAAG,UAAU,UAAU,QAAQ;EAGrC,MAAM,WAAW,OAAO,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM;AAE1E,SAAO;GACL,MAAM,QAAQ;GACd,MAAM,QAAQ;GACd,UAAU,QAAQ;GAClB;GACA,UAAU,QAAQ;GACnB;;CAGH,MAAM,SAAS,UAAmC;EAChD,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU,SAAS;AACnD,SAAO,GAAG,SAAS,SAAS;;CAG9B,MAAM,OAAO,UAAiC;EAC5C,MAAM,WAAW,KAAK,KAAK,KAAK,UAAU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@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/lib.files",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.57.0",
|
|
4
4
|
"description": "Files, documents and attachments module for ContractSpec applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"lint:check": "eslint src"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@contractspec/lib.schema": "1.
|
|
29
|
-
"@contractspec/lib.contracts": "1.
|
|
28
|
+
"@contractspec/lib.schema": "1.57.0",
|
|
29
|
+
"@contractspec/lib.contracts": "1.57.0",
|
|
30
30
|
"zod": "^4.3.5"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@contractspec/tool.typescript": "1.
|
|
34
|
-
"@contractspec/tool.tsdown": "1.
|
|
33
|
+
"@contractspec/tool.typescript": "1.57.0",
|
|
34
|
+
"@contractspec/tool.tsdown": "1.57.0",
|
|
35
35
|
"typescript": "^5.9.3"
|
|
36
36
|
},
|
|
37
37
|
"exports": {
|