@xyo-network/archivist-s3 7.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 +165 -0
- package/README.md +114 -0
- package/dist/node/Archivist.d.ts +75 -0
- package/dist/node/Archivist.d.ts.map +1 -0
- package/dist/node/AutoDriveStorageError.d.ts +6 -0
- package/dist/node/AutoDriveStorageError.d.ts.map +1 -0
- package/dist/node/Config.d.ts +22 -0
- package/dist/node/Config.d.ts.map +1 -0
- package/dist/node/Params.d.ts +11 -0
- package/dist/node/Params.d.ts.map +1 -0
- package/dist/node/Schema.d.ts +5 -0
- package/dist/node/Schema.d.ts.map +1 -0
- package/dist/node/auto-drive.d.ts +21 -0
- package/dist/node/auto-drive.d.ts.map +1 -0
- package/dist/node/auto-drive.mjs +60 -0
- package/dist/node/auto-drive.mjs.map +7 -0
- package/dist/node/chunk-GULFSNYC.mjs +494 -0
- package/dist/node/chunk-GULFSNYC.mjs.map +7 -0
- package/dist/node/index.d.ts +5 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +13 -0
- package/dist/node/index.mjs.map +7 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @xyo-network/archivist-s3
|
|
2
|
+
|
|
3
|
+
An XYO framework archivist for S3-compatible object stores. The same `S3Archivist`
|
|
4
|
+
serves AWS S3, compatible services, and Auto Drive. Runtime clients and credentials
|
|
5
|
+
stay outside the serialized module config.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { S3Client } from '@aws-sdk/client-s3'
|
|
9
|
+
import { S3Archivist, S3ArchivistConfigSchema } from '@xyo-network/archivist-s3'
|
|
10
|
+
import { asSchema, PayloadBuilder } from '@xyo-network/sdk-protocol'
|
|
11
|
+
|
|
12
|
+
const client = new S3Client({ region: 'us-east-1' })
|
|
13
|
+
const archivist = await S3Archivist.create({
|
|
14
|
+
account: 'random',
|
|
15
|
+
client,
|
|
16
|
+
config: {
|
|
17
|
+
schema: S3ArchivistConfigSchema,
|
|
18
|
+
bucket: 'my-payloads',
|
|
19
|
+
keyPrefix: 'application/tenant',
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
const payload = { schema: asSchema('com.example.reading', true), value: 42 }
|
|
23
|
+
await archivist.insert([payload])
|
|
24
|
+
const hash = await PayloadBuilder.hash(payload)
|
|
25
|
+
const retrieved = await archivist.get([hash])
|
|
26
|
+
await archivist.stop()
|
|
27
|
+
client.destroy() // Borrowed clients remain caller owned.
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Auto Drive
|
|
31
|
+
|
|
32
|
+
The `/auto-drive` entry point creates an ordinary `S3Archivist` configured with
|
|
33
|
+
Auto Drive's endpoint, individual logical deletion, credential-safe errors, and a
|
|
34
|
+
required admission policy. API keys must remain on the server.
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { createAutoDriveArchivist } from '@xyo-network/archivist-s3/auto-drive'
|
|
38
|
+
import { asSchema, PayloadBuilder } from '@xyo-network/sdk-protocol'
|
|
39
|
+
|
|
40
|
+
const archivist = await createAutoDriveArchivist({
|
|
41
|
+
apiKey: process.env.AUTODRIVE_API_KEY!,
|
|
42
|
+
bucket: 'my-payloads',
|
|
43
|
+
keyPrefix: 'application/selected',
|
|
44
|
+
admission: {
|
|
45
|
+
allowedSchemas: ['com.example.reading'],
|
|
46
|
+
maxPayloadBytes: 1024,
|
|
47
|
+
schemaMaxPayloadBytes: { 'com.example.reading': 512 },
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
const payload = { schema: asSchema('com.example.reading', true), value: 42 }
|
|
51
|
+
await archivist.insert([payload])
|
|
52
|
+
const hash = await PayloadBuilder.hash(payload)
|
|
53
|
+
const receipt = await archivist.getObjectReceipt(hash)
|
|
54
|
+
await archivist.stop() // The factory owns and destroys its client.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Admission rejects an entire mixed batch before any provider access. An empty
|
|
58
|
+
allowlist admits nothing. Limits apply to UTF-8 JSON after storage metadata is
|
|
59
|
+
removed; client metadata remains included. Per-schema limits only tighten the
|
|
60
|
+
global limit. Direct insertion, signed insert queries, and parent-read caching
|
|
61
|
+
all pass through the shared framework insertion boundary. Applications may
|
|
62
|
+
filter batches before calling the archivist when intentional exclusion is their
|
|
63
|
+
preferred behavior.
|
|
64
|
+
|
|
65
|
+
For multiple namespaces, `createAutoDriveS3Client({ apiKey })` allows one shared
|
|
66
|
+
client. Pass it to `S3Archivist.create` with `provider: 'auto-drive'`,
|
|
67
|
+
`deleteMode: 'individual'`, and a required `admission` config. The caller then
|
|
68
|
+
owns the client. An archivist whose owned client has stopped must be recreated.
|
|
69
|
+
|
|
70
|
+
## Storage and recovery
|
|
71
|
+
|
|
72
|
+
Within `keyPrefix`, primary JSON objects live at `by-hash/{hash}`, sequence keys
|
|
73
|
+
at `by-seq/{sequence}-{hash}`, and data-hash aliases at `by-data/{dataHash}`.
|
|
74
|
+
Bodies retain client metadata and exclude `_hash`, `_dataHash`, and `_sequence`;
|
|
75
|
+
identity and ordering metadata travel in object metadata. Retrieval verifies
|
|
76
|
+
canonical XYO hashes. A CID is a provider locator, not an XYO identity or evidence
|
|
77
|
+
of completed network archival.
|
|
78
|
+
|
|
79
|
+
Repeated insertion checks exact local primary objects. It repairs missing indexes
|
|
80
|
+
before reporting duplicates, without rewriting an existing primary body. A
|
|
81
|
+
metadata-bearing payload's data-hash view does not establish that its data-only
|
|
82
|
+
payload is stored as an independent primary object. Full enumeration and commit
|
|
83
|
+
read primary objects, so incomplete indexes cannot hide persisted payloads.
|
|
84
|
+
|
|
85
|
+
Local storage mutations serialize per archivist instance. Parent calls and
|
|
86
|
+
lifecycle events run after the local lock is released, so listeners may await
|
|
87
|
+
further mutations. Separate instances or processes writing the same prefix
|
|
88
|
+
require external coordination. S3 operations are not a
|
|
89
|
+
transaction: a failed operation can have persisted part of its work. Auto Drive
|
|
90
|
+
uses one transport attempt because retrying an ambiguous upload can create
|
|
91
|
+
additional permanent storage. Reconcile by reinserting the same payload identity;
|
|
92
|
+
do not assume a timeout means nothing was stored.
|
|
93
|
+
|
|
94
|
+
`commit()` captures a consistent local snapshot and copies it to each configured commit parent and verifies complete
|
|
95
|
+
acknowledgment, including read-back of previously stored duplicates. It never
|
|
96
|
+
clears local data, including after successful copies. With no commit parents it
|
|
97
|
+
returns an empty receipt list. Parent failure rejects the commit and leaves local
|
|
98
|
+
records available. This differs deliberately from transient archivists that
|
|
99
|
+
flush and clear on commit.
|
|
100
|
+
|
|
101
|
+
Deletion on Auto Drive only removes logical provider access. It does not erase
|
|
102
|
+
permanent network data. `capabilities` reports this distinction and whether bulk
|
|
103
|
+
or individual delete operations are used. Costs, durable budgets, structural
|
|
104
|
+
schema validation, and network archival monitoring belong to the integrating
|
|
105
|
+
application and are not implied by a successful insert or returned CID.
|
|
106
|
+
|
|
107
|
+
## Tests
|
|
108
|
+
|
|
109
|
+
Offline framework and provider qualification lives under `src/spec`. It covers
|
|
110
|
+
canonical identities, direct and signed operations, admission, provider error
|
|
111
|
+
redaction, client ownership, index recovery, concurrency, and commit behavior.
|
|
112
|
+
Live Auto Drive qualification is kept in the consuming Aries application's
|
|
113
|
+
separately invoked `pnpm test:autodrive` suite; ordinary SDK tests do not load an
|
|
114
|
+
API key or upload permanent data.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Hash } from '@ariestools/sdk';
|
|
2
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
3
|
+
import { AbstractArchivist } from '@xyo-network/sdk/archivist-abstract';
|
|
4
|
+
import type { ArchivistModuleEventData, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model';
|
|
5
|
+
import type { BoundWitness, Payload, Schema, WithStorageMeta } from '@xyo-network/sdk-protocol';
|
|
6
|
+
import type { S3ArchivistParams } from './Params.ts';
|
|
7
|
+
export interface S3ObjectReceipt {
|
|
8
|
+
/** Optional provider locator; never an XYO identity or archival confirmation. */
|
|
9
|
+
cid?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface S3ArchivistCapabilities {
|
|
12
|
+
deleteMode: 'bulk' | 'individual';
|
|
13
|
+
deletion: 'provider-defined' | 'logical';
|
|
14
|
+
permanent: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* S3-compatible remote archivist. JSON bodies preserve client metadata and omit
|
|
18
|
+
* storage metadata. XYO identities are verified on retrieval. Under keyPrefix:
|
|
19
|
+
* by-hash/{hash} holds bodies, by-seq/{sequence}-{hash} orders records, and
|
|
20
|
+
* by-data/{dataHash} points to one stored variant. Mutation serialization is
|
|
21
|
+
* per instance; separate instances/processes sharing a namespace need coordination.
|
|
22
|
+
*/
|
|
23
|
+
export declare class S3Archivist<TParams extends S3ArchivistParams = S3ArchivistParams, TEventData extends ArchivistModuleEventData = ArchivistModuleEventData> extends AbstractArchivist<TParams, TEventData> {
|
|
24
|
+
static readonly configSchemas: Schema[];
|
|
25
|
+
static readonly defaultConfigSchema: Schema;
|
|
26
|
+
static readonly labels: {
|
|
27
|
+
'network.xyo.storage.class': string;
|
|
28
|
+
};
|
|
29
|
+
private clientClosed;
|
|
30
|
+
private mutation;
|
|
31
|
+
get bucket(): string;
|
|
32
|
+
get capabilities(): S3ArchivistCapabilities;
|
|
33
|
+
get client(): S3Client;
|
|
34
|
+
get keyPrefix(): string;
|
|
35
|
+
get queries(): Schema[];
|
|
36
|
+
/** Count persisted primary objects, including writes awaiting index repair. */
|
|
37
|
+
count(): Promise<number>;
|
|
38
|
+
getObjectReceipt(hash: string): Promise<S3ObjectReceipt>;
|
|
39
|
+
/** Only real primary objects satisfy deduplication; a synthetic data-hash view does not. */
|
|
40
|
+
getStoredPayloads(hashes: string[]): Promise<WithStorageMeta<Payload>[]>;
|
|
41
|
+
protected allHandler(): Promise<WithStorageMeta<Payload>[]>;
|
|
42
|
+
protected clearHandler(): Promise<void>;
|
|
43
|
+
/** Durable remote storage is never cleared by commit, including successful copies. */
|
|
44
|
+
protected commitHandler(): Promise<BoundWitness[]>;
|
|
45
|
+
protected deleteHandler(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]>;
|
|
46
|
+
protected getExistingLocalPayloads(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]>;
|
|
47
|
+
protected getHandler(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]>;
|
|
48
|
+
protected insertHandler(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<Payload>[]>;
|
|
49
|
+
protected nextHandler(options?: ArchivistNextOptions): Promise<WithStorageMeta<Payload>[]>;
|
|
50
|
+
protected repairExistingPayloads(payloads: WithStorageMeta<Payload>[]): Promise<void>;
|
|
51
|
+
/** Complete interrupted inserts without rewriting the permanent payload body. */
|
|
52
|
+
protected repairIndexes(payloads: WithStorageMeta<Payload>[]): Promise<void>;
|
|
53
|
+
protected startHandler(): Promise<void>;
|
|
54
|
+
protected stopHandler(): Promise<void>;
|
|
55
|
+
protected validateInsertPayloads(payloads: Payload[]): void;
|
|
56
|
+
protected withStorageMutation<T>(operation: () => Promise<T>): Promise<T>;
|
|
57
|
+
private dataHashKey;
|
|
58
|
+
private dataHashPrefix;
|
|
59
|
+
private deleteByPrefix;
|
|
60
|
+
private deleteKeys;
|
|
61
|
+
private findByEitherHash;
|
|
62
|
+
private findDataHashAlternative;
|
|
63
|
+
private getByHash;
|
|
64
|
+
private hashFromSequenceKey;
|
|
65
|
+
private hashKey;
|
|
66
|
+
private hashPrefix;
|
|
67
|
+
private listSequenceKeysSorted;
|
|
68
|
+
private nextPageToken;
|
|
69
|
+
private request;
|
|
70
|
+
private sequenceKey;
|
|
71
|
+
private sequencePrefix;
|
|
72
|
+
private tryHead;
|
|
73
|
+
private withMutation;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=Archivist.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Archivist.d.ts","sourceRoot":"","sources":["../../src/Archivist.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AASlD,OAAO,EACL,iBAAiB,EAClB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAA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Ac;YAqBd,UAAU;YAYV,gBAAgB;YAahB,uBAAuB;YASvB,SAAS;IAqCvB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,UAAU;YAIJ,sBAAsB;IAkBpC,OAAO,CAAC,aAAa;YAOP,OAAO;IAYrB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,cAAc;YAIR,OAAO;YAUP,YAAY;CAM3B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Credential-safe provider error. No response body, request headers or original cause. */
|
|
2
|
+
export declare class AutoDriveStorageError extends Error {
|
|
3
|
+
readonly statusCode?: number;
|
|
4
|
+
constructor(error: unknown);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AutoDriveStorageError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AutoDriveStorageError.d.ts","sourceRoot":"","sources":["../../src/AutoDriveStorageError.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;gBAEhB,KAAK,EAAE,OAAO;CAS3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PayloadAdmissionPolicy } from '@xyo-network/sdk/archivist-abstract';
|
|
2
|
+
import type { ArchivistConfig } from '@xyo-network/sdk/archivist-model';
|
|
3
|
+
export declare const S3ArchivistConfigSchema: string & {
|
|
4
|
+
readonly __schema: true;
|
|
5
|
+
};
|
|
6
|
+
export type S3ArchivistConfigSchema = typeof S3ArchivistConfigSchema;
|
|
7
|
+
export type S3ArchivistConfig = ArchivistConfig<{
|
|
8
|
+
/** Optional fail-closed admission before any provider access. */
|
|
9
|
+
admission?: PayloadAdmissionPolicy;
|
|
10
|
+
/** Bucket must already exist and allow the configured operations. */
|
|
11
|
+
bucket: string;
|
|
12
|
+
/** Individual deletes support providers without DeleteObjects. */
|
|
13
|
+
deleteMode?: 'bulk' | 'individual';
|
|
14
|
+
/** Complete namespace prefix; the archivist appends by-hash, by-data and by-seq. */
|
|
15
|
+
keyPrefix?: string;
|
|
16
|
+
/** Provider profile controls permanent-storage admission and error redaction. */
|
|
17
|
+
provider?: 's3' | 'auto-drive';
|
|
18
|
+
schema: S3ArchivistConfigSchema;
|
|
19
|
+
}>;
|
|
20
|
+
/** Validate serializable storage constraints without creating a client or making requests. */
|
|
21
|
+
export declare function validateS3ArchivistConfig(config: Partial<Pick<S3ArchivistConfig, 'admission' | 'bucket' | 'deleteMode' | 'provider'>>): void;
|
|
22
|
+
//# sourceMappingURL=Config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAEjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AAKvE,eAAO,MAAM,uBAAuB,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAAkD,CAAA;AAC1H,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAA;AAEpE,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;IAC9C,iEAAiE;IACjE,SAAS,CAAC,EAAE,sBAAsB,CAAA;IAClC,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAA;IACd,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IAClC,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,IAAI,GAAG,YAAY,CAAA;IAC9B,MAAM,EAAE,uBAAuB,CAAA;CAChC,CAAC,CAAA;AAEF,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC,CAAC,GAAG,IAAI,CAU5I"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import type { ArchivistParams } from '@xyo-network/sdk/archivist-model';
|
|
3
|
+
import type { AnyConfigSchema } from '@xyo-network/sdk/module-model';
|
|
4
|
+
import type { S3ArchivistConfig } from './Config.ts';
|
|
5
|
+
export interface S3ArchivistParams extends ArchivistParams<AnyConfigSchema<S3ArchivistConfig>> {
|
|
6
|
+
/** Runtime dependency, deliberately outside serialized module configuration. */
|
|
7
|
+
client: S3Client;
|
|
8
|
+
/** Destroy the client on module stop; omitted/false leaves ownership with the caller. */
|
|
9
|
+
ownsClient?: boolean;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Params.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Params.d.ts","sourceRoot":"","sources":["../../src/Params.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,WAAW,iBAAkB,SAAQ,eAAe,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IAC5F,gFAAgF;IAChF,MAAM,EAAE,QAAQ,CAAA;IAChB,yFAAyF;IACzF,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../../src/Schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,EAAE,0BAA0B,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAA+C,CAAA;AACrI,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
|
2
|
+
import type { PayloadAdmissionPolicy } from '@xyo-network/sdk/archivist-abstract';
|
|
3
|
+
import { S3Archivist } from './Archivist.ts';
|
|
4
|
+
import type { S3ArchivistParams } from './Params.ts';
|
|
5
|
+
export { AutoDriveStorageError } from './AutoDriveStorageError.ts';
|
|
6
|
+
export declare const AutoDriveS3Endpoint = "https://s3.auto-drive.autonomys.xyz";
|
|
7
|
+
export interface AutoDriveS3ClientOptions {
|
|
8
|
+
/** Server-side credential; never include in serialized module config. */
|
|
9
|
+
apiKey: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AutoDriveArchivistOptions extends AutoDriveS3ClientOptions {
|
|
12
|
+
account?: S3ArchivistParams['account'];
|
|
13
|
+
admission: PayloadAdmissionPolicy;
|
|
14
|
+
bucket: string;
|
|
15
|
+
keyPrefix?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A shared client remains caller-owned when passed to S3Archivist.create. */
|
|
18
|
+
export declare function createAutoDriveS3Client(options: AutoDriveS3ClientOptions): S3Client;
|
|
19
|
+
/** One S3Archivist with the Auto Drive profile; stop() closes its owned client. */
|
|
20
|
+
export declare function createAutoDriveArchivist(options: AutoDriveArchivistOptions): Promise<S3Archivist>;
|
|
21
|
+
//# sourceMappingURL=auto-drive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-drive.d.ts","sourceRoot":"","sources":["../../src/auto-drive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAElE,eAAO,MAAM,mBAAmB,wCAAwC,CAAA;AAExE,MAAM,WAAW,wBAAwB;IACvC,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,yBAA0B,SAAQ,wBAAwB;IACzE,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IACtC,SAAS,EAAE,sBAAsB,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,8EAA8E;AAC9E,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,QAAQ,CAanF;AAED,mFAAmF;AACnF,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,WAAW,CAAC,CAyBvG"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoDriveStorageError,
|
|
3
|
+
S3Archivist,
|
|
4
|
+
S3ArchivistConfigSchema,
|
|
5
|
+
validateS3ArchivistConfig
|
|
6
|
+
} from "./chunk-GULFSNYC.mjs";
|
|
7
|
+
|
|
8
|
+
// src/auto-drive.ts
|
|
9
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
10
|
+
var AutoDriveS3Endpoint = "https://s3.auto-drive.autonomys.xyz";
|
|
11
|
+
function createAutoDriveS3Client(options) {
|
|
12
|
+
if (!options.apiKey?.trim()) throw new Error("Auto Drive API key is required");
|
|
13
|
+
return new S3Client({
|
|
14
|
+
endpoint: AutoDriveS3Endpoint,
|
|
15
|
+
region: "us-east-1",
|
|
16
|
+
forcePathStyle: true,
|
|
17
|
+
credentials: { accessKeyId: options.apiKey, secretAccessKey: "autodrive" },
|
|
18
|
+
// A timed-out write can already exist permanently; reconcile before retrying.
|
|
19
|
+
maxAttempts: 1,
|
|
20
|
+
requestChecksumCalculation: "WHEN_REQUIRED",
|
|
21
|
+
responseChecksumValidation: "WHEN_REQUIRED",
|
|
22
|
+
requestHandler: { connectionTimeout: 1e4, requestTimeout: 6e4 }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function createAutoDriveArchivist(options) {
|
|
26
|
+
validateS3ArchivistConfig({
|
|
27
|
+
bucket: options.bucket,
|
|
28
|
+
admission: options.admission,
|
|
29
|
+
provider: "auto-drive",
|
|
30
|
+
deleteMode: "individual"
|
|
31
|
+
});
|
|
32
|
+
const client = createAutoDriveS3Client(options);
|
|
33
|
+
try {
|
|
34
|
+
const archivist = await S3Archivist.create({
|
|
35
|
+
account: options.account ?? "random",
|
|
36
|
+
client,
|
|
37
|
+
ownsClient: true,
|
|
38
|
+
config: {
|
|
39
|
+
schema: S3ArchivistConfigSchema,
|
|
40
|
+
bucket: options.bucket,
|
|
41
|
+
keyPrefix: options.keyPrefix,
|
|
42
|
+
provider: "auto-drive",
|
|
43
|
+
deleteMode: "individual",
|
|
44
|
+
admission: structuredClone(options.admission)
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
await archivist.start();
|
|
48
|
+
return archivist;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
client.destroy();
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
AutoDriveS3Endpoint,
|
|
56
|
+
AutoDriveStorageError,
|
|
57
|
+
createAutoDriveArchivist,
|
|
58
|
+
createAutoDriveS3Client
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=auto-drive.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/auto-drive.ts"],
|
|
4
|
+
"sourcesContent": ["import { S3Client } from '@aws-sdk/client-s3'\nimport type { PayloadAdmissionPolicy } from '@xyo-network/sdk/archivist-abstract'\n\nimport { S3Archivist } from './Archivist.ts'\nimport { S3ArchivistConfigSchema, validateS3ArchivistConfig } from './Config.ts'\nimport type { S3ArchivistParams } from './Params.ts'\n\nexport { AutoDriveStorageError } from './AutoDriveStorageError.ts'\n\nexport const AutoDriveS3Endpoint = 'https://s3.auto-drive.autonomys.xyz'\n\nexport interface AutoDriveS3ClientOptions {\n /** Server-side credential; never include in serialized module config. */\n apiKey: string\n}\n\nexport interface AutoDriveArchivistOptions extends AutoDriveS3ClientOptions {\n account?: S3ArchivistParams['account']\n admission: PayloadAdmissionPolicy\n bucket: string\n keyPrefix?: string\n}\n\n/** A shared client remains caller-owned when passed to S3Archivist.create. */\nexport function createAutoDriveS3Client(options: AutoDriveS3ClientOptions): S3Client {\n if (!options.apiKey?.trim()) throw new Error('Auto Drive API key is required')\n return new S3Client({\n endpoint: AutoDriveS3Endpoint,\n region: 'us-east-1',\n forcePathStyle: true,\n credentials: { accessKeyId: options.apiKey, secretAccessKey: 'autodrive' },\n // A timed-out write can already exist permanently; reconcile before retrying.\n maxAttempts: 1,\n requestChecksumCalculation: 'WHEN_REQUIRED',\n responseChecksumValidation: 'WHEN_REQUIRED',\n requestHandler: { connectionTimeout: 10_000, requestTimeout: 60_000 },\n })\n}\n\n/** One S3Archivist with the Auto Drive profile; stop() closes its owned client. */\nexport async function createAutoDriveArchivist(options: AutoDriveArchivistOptions): Promise<S3Archivist> {\n validateS3ArchivistConfig({\n bucket: options.bucket, admission: options.admission, provider: 'auto-drive', deleteMode: 'individual',\n })\n const client = createAutoDriveS3Client(options)\n try {\n const archivist = await S3Archivist.create({\n account: options.account ?? 'random',\n client,\n ownsClient: true,\n config: {\n schema: S3ArchivistConfigSchema,\n bucket: options.bucket,\n keyPrefix: options.keyPrefix,\n provider: 'auto-drive',\n deleteMode: 'individual',\n admission: structuredClone(options.admission),\n },\n })\n await archivist.start()\n return archivist\n } catch (error) {\n client.destroy()\n throw error\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA,SAAS,gBAAgB;AASlB,IAAM,sBAAsB;AAe5B,SAAS,wBAAwB,SAA6C;AACnF,MAAI,CAAC,QAAQ,QAAQ,KAAK,EAAG,OAAM,IAAI,MAAM,gCAAgC;AAC7E,SAAO,IAAI,SAAS;AAAA,IAClB,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB;AAAA,IAChB,aAAa,EAAE,aAAa,QAAQ,QAAQ,iBAAiB,YAAY;AAAA;AAAA,IAEzE,aAAa;AAAA,IACb,4BAA4B;AAAA,IAC5B,4BAA4B;AAAA,IAC5B,gBAAgB,EAAE,mBAAmB,KAAQ,gBAAgB,IAAO;AAAA,EACtE,CAAC;AACH;AAGA,eAAsB,yBAAyB,SAA0D;AACvG,4BAA0B;AAAA,IACxB,QAAQ,QAAQ;AAAA,IAAQ,WAAW,QAAQ;AAAA,IAAW,UAAU;AAAA,IAAc,YAAY;AAAA,EAC5F,CAAC;AACD,QAAM,SAAS,wBAAwB,OAAO;AAC9C,MAAI;AACF,UAAM,YAAY,MAAM,YAAY,OAAO;AAAA,MACzC,SAAS,QAAQ,WAAW;AAAA,MAC5B;AAAA,MACA,YAAY;AAAA,MACZ,QAAQ;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ,QAAQ;AAAA,QAChB,WAAW,QAAQ;AAAA,QACnB,UAAU;AAAA,QACV,YAAY;AAAA,QACZ,WAAW,gBAAgB,QAAQ,SAAS;AAAA,MAC9C;AAAA,IACF,CAAC;AACD,UAAM,UAAU,MAAM;AACtB,WAAO;AAAA,EACT,SAAS,OAAO;AACd,WAAO,QAAQ;AACf,UAAM;AAAA,EACR;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __reflectGet = Reflect.get;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
16
|
+
|
|
17
|
+
// src/AutoDriveStorageError.ts
|
|
18
|
+
var AutoDriveStorageError = class extends Error {
|
|
19
|
+
statusCode;
|
|
20
|
+
constructor(error) {
|
|
21
|
+
const status = typeof error === "object" && error !== null && "$metadata" in error ? error.$metadata?.httpStatusCode : void 0;
|
|
22
|
+
const statusCode = typeof status === "number" && Number.isSafeInteger(status) ? status : void 0;
|
|
23
|
+
super(`Auto Drive storage request failed${statusCode === void 0 ? "" : ` (HTTP ${statusCode})`}`);
|
|
24
|
+
this.name = "AutoDriveStorageError";
|
|
25
|
+
this.statusCode = statusCode;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// src/Schema.ts
|
|
30
|
+
import { asSchema } from "@xyo-network/sdk-protocol";
|
|
31
|
+
var S3ArchivistSchema = asSchema("network.xyo.archivist.s3", true);
|
|
32
|
+
|
|
33
|
+
// src/Config.ts
|
|
34
|
+
import { validatePayloadAdmissionPolicy } from "@xyo-network/sdk/archivist-abstract";
|
|
35
|
+
import { asSchema as asSchema2 } from "@xyo-network/sdk-protocol";
|
|
36
|
+
var S3ArchivistConfigSchema = asSchema2(`${S3ArchivistSchema}.config`, true);
|
|
37
|
+
function validateS3ArchivistConfig(config) {
|
|
38
|
+
if (typeof config.bucket !== "string" || !config.bucket.trim()) throw new Error("S3 bucket is required");
|
|
39
|
+
if (config.provider !== void 0 && config.provider !== "s3" && config.provider !== "auto-drive") throw new Error("Unsupported S3 provider profile");
|
|
40
|
+
if (config.deleteMode !== void 0 && config.deleteMode !== "bulk" && config.deleteMode !== "individual") throw new Error("Unsupported S3 deletion mode");
|
|
41
|
+
if (config.provider === "auto-drive") {
|
|
42
|
+
if (!/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/.test(config.bucket)) throw new Error("Auto Drive bucket must be a plain bucket name");
|
|
43
|
+
if (!config.admission) throw new Error("Auto Drive requires an explicit admission policy");
|
|
44
|
+
if (config.deleteMode !== "individual") throw new Error("Auto Drive requires individual deletion");
|
|
45
|
+
}
|
|
46
|
+
if (config.admission) validatePayloadAdmissionPolicy(config.admission);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/Archivist.ts
|
|
50
|
+
import { assertEx, exists } from "@ariestools/sdk";
|
|
51
|
+
import {
|
|
52
|
+
DeleteObjectCommand,
|
|
53
|
+
DeleteObjectsCommand,
|
|
54
|
+
GetObjectCommand,
|
|
55
|
+
HeadObjectCommand,
|
|
56
|
+
ListObjectsV2Command,
|
|
57
|
+
PutObjectCommand
|
|
58
|
+
} from "@aws-sdk/client-s3";
|
|
59
|
+
import {
|
|
60
|
+
AbstractArchivist,
|
|
61
|
+
StorageClassLabel,
|
|
62
|
+
validatePayloadAdmission
|
|
63
|
+
} from "@xyo-network/sdk/archivist-abstract";
|
|
64
|
+
import {
|
|
65
|
+
ArchivistAllQuerySchema,
|
|
66
|
+
ArchivistClearQuerySchema,
|
|
67
|
+
ArchivistCommitQuerySchema,
|
|
68
|
+
ArchivistDeleteQuerySchema,
|
|
69
|
+
ArchivistInsertQuerySchema,
|
|
70
|
+
ArchivistNextQuerySchema
|
|
71
|
+
} from "@xyo-network/sdk/archivist-model";
|
|
72
|
+
import { creatableModule } from "@xyo-network/sdk/module-model";
|
|
73
|
+
import { PayloadBuilder } from "@xyo-network/sdk-protocol";
|
|
74
|
+
var S3Archivist = class extends AbstractArchivist {
|
|
75
|
+
clientClosed = false;
|
|
76
|
+
mutation = Promise.resolve();
|
|
77
|
+
get bucket() {
|
|
78
|
+
return assertEx(this.config.bucket, () => "No bucket specified");
|
|
79
|
+
}
|
|
80
|
+
get capabilities() {
|
|
81
|
+
return {
|
|
82
|
+
deletion: this.config.provider === "auto-drive" ? "logical" : "provider-defined",
|
|
83
|
+
deleteMode: this.config.deleteMode ?? "bulk",
|
|
84
|
+
permanent: this.config.provider === "auto-drive"
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
get client() {
|
|
88
|
+
return assertEx(this.params.client, () => "No S3 client specified");
|
|
89
|
+
}
|
|
90
|
+
get keyPrefix() {
|
|
91
|
+
const trimmed = (this.config.keyPrefix ?? "").replaceAll(/^\/+|\/+$/g, "");
|
|
92
|
+
return trimmed.length > 0 ? `${trimmed}/` : "";
|
|
93
|
+
}
|
|
94
|
+
get queries() {
|
|
95
|
+
return [
|
|
96
|
+
ArchivistAllQuerySchema,
|
|
97
|
+
ArchivistDeleteQuerySchema,
|
|
98
|
+
ArchivistClearQuerySchema,
|
|
99
|
+
ArchivistInsertQuerySchema,
|
|
100
|
+
ArchivistCommitQuerySchema,
|
|
101
|
+
ArchivistNextQuerySchema,
|
|
102
|
+
...super.queries
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
/** Count persisted primary objects, including writes awaiting index repair. */
|
|
106
|
+
async count() {
|
|
107
|
+
await this.startedAsync("throw");
|
|
108
|
+
let count = 0;
|
|
109
|
+
let token;
|
|
110
|
+
do {
|
|
111
|
+
const response = await this.request(() => this.client.send(new ListObjectsV2Command({
|
|
112
|
+
Bucket: this.bucket,
|
|
113
|
+
Prefix: this.hashPrefix(),
|
|
114
|
+
ContinuationToken: token
|
|
115
|
+
})));
|
|
116
|
+
count += response.KeyCount ?? response.Contents?.length ?? 0;
|
|
117
|
+
token = this.nextPageToken(response, token);
|
|
118
|
+
} while (token);
|
|
119
|
+
return count;
|
|
120
|
+
}
|
|
121
|
+
async getObjectReceipt(hash) {
|
|
122
|
+
try {
|
|
123
|
+
await this.startedAsync("throw");
|
|
124
|
+
const response = await this.request(() => this.client.send(new HeadObjectCommand({ Bucket: this.bucket, Key: this.hashKey(hash) })));
|
|
125
|
+
return { cid: response.Metadata?.cid };
|
|
126
|
+
} catch (error) {
|
|
127
|
+
if (this.config.provider === "auto-drive" && !(error instanceof AutoDriveStorageError)) throw new AutoDriveStorageError(error);
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Only real primary objects satisfy deduplication; a synthetic data-hash view does not. */
|
|
132
|
+
async getStoredPayloads(hashes) {
|
|
133
|
+
await this.startedAsync("throw");
|
|
134
|
+
const payloads = [];
|
|
135
|
+
for (const hash of hashes) {
|
|
136
|
+
const payload = await this.getByHash(hash);
|
|
137
|
+
if (payload) payloads.push(payload);
|
|
138
|
+
}
|
|
139
|
+
return payloads;
|
|
140
|
+
}
|
|
141
|
+
async allHandler() {
|
|
142
|
+
const payloads = [];
|
|
143
|
+
let token;
|
|
144
|
+
do {
|
|
145
|
+
const response = await this.request(() => this.client.send(new ListObjectsV2Command({
|
|
146
|
+
Bucket: this.bucket,
|
|
147
|
+
Prefix: this.hashPrefix(),
|
|
148
|
+
ContinuationToken: token
|
|
149
|
+
})));
|
|
150
|
+
for (const entry of response.Contents ?? []) {
|
|
151
|
+
if (!entry.Key) continue;
|
|
152
|
+
const payload = await this.getByHash(entry.Key.slice(this.hashPrefix().length));
|
|
153
|
+
if (payload) payloads.push(payload);
|
|
154
|
+
}
|
|
155
|
+
token = this.nextPageToken(response, token);
|
|
156
|
+
} while (token);
|
|
157
|
+
return payloads.toSorted((a, b) => PayloadBuilder.compareStorageMeta(a, b));
|
|
158
|
+
}
|
|
159
|
+
async clearHandler() {
|
|
160
|
+
for (const prefix of [this.sequencePrefix(), this.dataHashPrefix(), this.hashPrefix()]) {
|
|
161
|
+
await this.deleteByPrefix(prefix);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/** Durable remote storage is never cleared by commit, including successful copies. */
|
|
165
|
+
async commitHandler() {
|
|
166
|
+
const parents = Object.values((await this.parentArchivists()).commit ?? {}).filter(exists);
|
|
167
|
+
if (parents.length === 0) return [];
|
|
168
|
+
const payloads = await this.withMutation(async () => {
|
|
169
|
+
const snapshot = await this.allHandler();
|
|
170
|
+
await this.repairIndexes(snapshot);
|
|
171
|
+
return snapshot;
|
|
172
|
+
});
|
|
173
|
+
const receipts = [];
|
|
174
|
+
for (const parent of parents) {
|
|
175
|
+
const query = await this.bindQuery({ schema: ArchivistInsertQuerySchema }, payloads);
|
|
176
|
+
const [receipt, acknowledged, errors] = await parent.query(query[0], query[1]);
|
|
177
|
+
if (errors.length > 0) throw new Error("S3 commit parent rejected payloads");
|
|
178
|
+
const received = new Set(await Promise.all(acknowledged.map((payload) => PayloadBuilder.hash(payload))));
|
|
179
|
+
const missing = payloads.filter((payload) => !received.has(payload._hash)).map((payload) => payload._hash);
|
|
180
|
+
if (missing.length > 0) {
|
|
181
|
+
const stored = await parent.get(missing);
|
|
182
|
+
const verified = new Set(await Promise.all(stored.map((payload) => PayloadBuilder.hash(payload))));
|
|
183
|
+
if (missing.some((hash) => !verified.has(hash))) throw new Error("S3 commit parent did not acknowledge every payload");
|
|
184
|
+
}
|
|
185
|
+
receipts.push(receipt);
|
|
186
|
+
}
|
|
187
|
+
return receipts;
|
|
188
|
+
}
|
|
189
|
+
async deleteHandler(hashes) {
|
|
190
|
+
const deleted = [];
|
|
191
|
+
for (const hash of hashes) {
|
|
192
|
+
const payload = await this.findByEitherHash(hash);
|
|
193
|
+
if (!payload) continue;
|
|
194
|
+
const keys = [this.sequenceKey(payload._sequence, payload._hash)];
|
|
195
|
+
const pointer = await this.tryHead(this.dataHashKey(payload._dataHash));
|
|
196
|
+
if (pointer?.Metadata?.hash === payload._hash) {
|
|
197
|
+
const alternative = await this.findDataHashAlternative(payload);
|
|
198
|
+
if (alternative) {
|
|
199
|
+
await this.request(() => this.client.send(new PutObjectCommand({
|
|
200
|
+
Bucket: this.bucket,
|
|
201
|
+
Key: this.dataHashKey(payload._dataHash),
|
|
202
|
+
Body: "",
|
|
203
|
+
Metadata: { hash: alternative._hash }
|
|
204
|
+
})));
|
|
205
|
+
} else keys.push(this.dataHashKey(payload._dataHash));
|
|
206
|
+
}
|
|
207
|
+
keys.push(this.hashKey(payload._hash));
|
|
208
|
+
await this.deleteKeys(keys);
|
|
209
|
+
deleted.push(payload);
|
|
210
|
+
}
|
|
211
|
+
return deleted;
|
|
212
|
+
}
|
|
213
|
+
async getExistingLocalPayloads(hashes) {
|
|
214
|
+
return await this.getStoredPayloads(hashes);
|
|
215
|
+
}
|
|
216
|
+
async getHandler(hashes) {
|
|
217
|
+
const found = [];
|
|
218
|
+
for (const hash of hashes) {
|
|
219
|
+
const payload = await this.findByEitherHash(hash);
|
|
220
|
+
if (payload) found.push(payload);
|
|
221
|
+
}
|
|
222
|
+
return found;
|
|
223
|
+
}
|
|
224
|
+
async insertHandler(payloads) {
|
|
225
|
+
for (const payload of payloads) {
|
|
226
|
+
const dataOnly = PayloadBuilder.omitStorageMeta(payload);
|
|
227
|
+
const body = Buffer.from(JSON.stringify(dataOnly), "utf8");
|
|
228
|
+
await this.request(() => this.client.send(new PutObjectCommand({
|
|
229
|
+
Bucket: this.bucket,
|
|
230
|
+
Key: this.hashKey(payload._hash),
|
|
231
|
+
Body: body,
|
|
232
|
+
ContentType: "application/json",
|
|
233
|
+
Metadata: {
|
|
234
|
+
"data-hash": payload._dataHash,
|
|
235
|
+
"sequence": payload._sequence,
|
|
236
|
+
"schema": payload.schema
|
|
237
|
+
}
|
|
238
|
+
})));
|
|
239
|
+
await this.repairIndexes([payload]);
|
|
240
|
+
}
|
|
241
|
+
return payloads;
|
|
242
|
+
}
|
|
243
|
+
async nextHandler(options) {
|
|
244
|
+
const {
|
|
245
|
+
limit = 100,
|
|
246
|
+
cursor,
|
|
247
|
+
order,
|
|
248
|
+
open = cursor ? true : false
|
|
249
|
+
} = options ?? {};
|
|
250
|
+
const sorted = await this.listSequenceKeysSorted(order === "desc" ? "desc" : "asc");
|
|
251
|
+
let startIndex = 0;
|
|
252
|
+
if (cursor !== void 0) {
|
|
253
|
+
const index = sorted.findIndex((key) => key.startsWith(`${this.sequencePrefix()}${cursor}-`));
|
|
254
|
+
startIndex = index === -1 ? sorted.length : index + (open ? 1 : 0);
|
|
255
|
+
}
|
|
256
|
+
const window = sorted.slice(startIndex, startIndex + limit);
|
|
257
|
+
const payloads = [];
|
|
258
|
+
for (const key of window) {
|
|
259
|
+
const hash = this.hashFromSequenceKey(key);
|
|
260
|
+
if (!hash) continue;
|
|
261
|
+
const payload = await this.getByHash(hash);
|
|
262
|
+
if (payload) payloads.push(payload);
|
|
263
|
+
}
|
|
264
|
+
return payloads;
|
|
265
|
+
}
|
|
266
|
+
async repairExistingPayloads(payloads) {
|
|
267
|
+
await this.repairIndexes(payloads);
|
|
268
|
+
}
|
|
269
|
+
/** Complete interrupted inserts without rewriting the permanent payload body. */
|
|
270
|
+
async repairIndexes(payloads) {
|
|
271
|
+
for (const payload of payloads) {
|
|
272
|
+
const sequenceKey = this.sequenceKey(payload._sequence, payload._hash);
|
|
273
|
+
if (!await this.tryHead(sequenceKey)) {
|
|
274
|
+
await this.request(() => this.client.send(new PutObjectCommand({
|
|
275
|
+
Bucket: this.bucket,
|
|
276
|
+
Key: sequenceKey,
|
|
277
|
+
Body: ""
|
|
278
|
+
})));
|
|
279
|
+
}
|
|
280
|
+
if (payload._dataHash !== payload._hash) {
|
|
281
|
+
const pointer = await this.tryHead(this.dataHashKey(payload._dataHash));
|
|
282
|
+
const targetHash = pointer?.Metadata?.hash;
|
|
283
|
+
const target = targetHash ? await this.getByHash(targetHash) : void 0;
|
|
284
|
+
if (target?._dataHash !== payload._dataHash) {
|
|
285
|
+
await this.request(() => this.client.send(new PutObjectCommand({
|
|
286
|
+
Bucket: this.bucket,
|
|
287
|
+
Key: this.dataHashKey(payload._dataHash),
|
|
288
|
+
Body: "",
|
|
289
|
+
Metadata: { hash: payload._hash }
|
|
290
|
+
})));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
async startHandler() {
|
|
296
|
+
validateS3ArchivistConfig(this.config);
|
|
297
|
+
if (this.clientClosed) throw new Error("An owned S3 client cannot restart after stop; create a new archivist");
|
|
298
|
+
await super.startHandler();
|
|
299
|
+
}
|
|
300
|
+
async stopHandler() {
|
|
301
|
+
await this.mutation;
|
|
302
|
+
if (this.params.ownsClient && !this.clientClosed) {
|
|
303
|
+
this.client.destroy();
|
|
304
|
+
this.clientClosed = true;
|
|
305
|
+
}
|
|
306
|
+
await super.stopHandler();
|
|
307
|
+
}
|
|
308
|
+
validateInsertPayloads(payloads) {
|
|
309
|
+
validateS3ArchivistConfig(this.config);
|
|
310
|
+
if (this.config.admission) validatePayloadAdmission(payloads, this.config.admission);
|
|
311
|
+
}
|
|
312
|
+
async withStorageMutation(operation) {
|
|
313
|
+
return await this.withMutation(operation);
|
|
314
|
+
}
|
|
315
|
+
dataHashKey(dataHash) {
|
|
316
|
+
return `${this.keyPrefix}by-data/${dataHash}`;
|
|
317
|
+
}
|
|
318
|
+
dataHashPrefix() {
|
|
319
|
+
return `${this.keyPrefix}by-data/`;
|
|
320
|
+
}
|
|
321
|
+
async deleteByPrefix(prefix) {
|
|
322
|
+
const keys = [];
|
|
323
|
+
let continuationToken;
|
|
324
|
+
do {
|
|
325
|
+
const response = await this.request(() => this.client.send(new ListObjectsV2Command({
|
|
326
|
+
Bucket: this.bucket,
|
|
327
|
+
Prefix: prefix,
|
|
328
|
+
ContinuationToken: continuationToken
|
|
329
|
+
})));
|
|
330
|
+
for (const entry of response.Contents ?? []) {
|
|
331
|
+
if (entry.Key) keys.push(entry.Key);
|
|
332
|
+
}
|
|
333
|
+
continuationToken = this.nextPageToken(response, continuationToken);
|
|
334
|
+
} while (continuationToken);
|
|
335
|
+
for (let offset = 0; offset < keys.length; offset += 1e3) {
|
|
336
|
+
await this.deleteKeys(keys.slice(offset, offset + 1e3));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
async deleteKeys(keys) {
|
|
340
|
+
if (this.config.deleteMode === "individual") {
|
|
341
|
+
for (const Key of keys) await this.request(() => this.client.send(new DeleteObjectCommand({ Bucket: this.bucket, Key })));
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const response = await this.request(() => this.client.send(new DeleteObjectsCommand({
|
|
345
|
+
Bucket: this.bucket,
|
|
346
|
+
Delete: { Objects: keys.map((Key) => ({ Key })) }
|
|
347
|
+
})));
|
|
348
|
+
if (response.Errors?.length) throw new Error("S3 could not delete every requested object");
|
|
349
|
+
}
|
|
350
|
+
async findByEitherHash(hash) {
|
|
351
|
+
const direct = await this.getByHash(hash);
|
|
352
|
+
if (direct) return direct;
|
|
353
|
+
const indirect = await this.tryHead(this.dataHashKey(hash));
|
|
354
|
+
const target = indirect?.Metadata?.hash;
|
|
355
|
+
if (!target) return void 0;
|
|
356
|
+
const payload = await this.getByHash(target);
|
|
357
|
+
if (payload?._dataHash !== hash) throw new Error("Stored data-hash alias does not match its target");
|
|
358
|
+
return payload;
|
|
359
|
+
}
|
|
360
|
+
async findDataHashAlternative(payload) {
|
|
361
|
+
for (const key of await this.listSequenceKeysSorted("asc")) {
|
|
362
|
+
const hash = this.hashFromSequenceKey(key);
|
|
363
|
+
if (!hash || hash === payload._hash) continue;
|
|
364
|
+
const candidate = await this.getByHash(hash);
|
|
365
|
+
if (candidate?._dataHash === payload._dataHash) return candidate;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
async getByHash(hash) {
|
|
369
|
+
try {
|
|
370
|
+
const response = await this.request(() => this.client.send(new GetObjectCommand({
|
|
371
|
+
Bucket: this.bucket,
|
|
372
|
+
Key: this.hashKey(hash)
|
|
373
|
+
})));
|
|
374
|
+
const body = response.Body;
|
|
375
|
+
if (!body) throw new Error("Stored payload is missing its body");
|
|
376
|
+
const bytes = await this.request(() => body.transformToByteArray());
|
|
377
|
+
let dataOnly;
|
|
378
|
+
try {
|
|
379
|
+
dataOnly = JSON.parse(Buffer.from(bytes).toString("utf8"));
|
|
380
|
+
} catch {
|
|
381
|
+
throw new Error("Stored payload is not valid JSON");
|
|
382
|
+
}
|
|
383
|
+
const metadata = response.Metadata ?? {};
|
|
384
|
+
const dataHash = metadata["data-hash"] ?? hash;
|
|
385
|
+
const sequence = metadata.sequence;
|
|
386
|
+
if (!sequence) throw new Error("Stored payload is missing sequence metadata");
|
|
387
|
+
if (await PayloadBuilder.hash(dataOnly) !== hash || await PayloadBuilder.dataHash(dataOnly) !== dataHash) {
|
|
388
|
+
throw new Error("Stored payload does not match its XYO hash metadata");
|
|
389
|
+
}
|
|
390
|
+
return {
|
|
391
|
+
...dataOnly,
|
|
392
|
+
_hash: hash,
|
|
393
|
+
_dataHash: dataHash,
|
|
394
|
+
_sequence: sequence
|
|
395
|
+
};
|
|
396
|
+
} catch (error) {
|
|
397
|
+
if (isNotFoundError(error)) return void 0;
|
|
398
|
+
if (this.config.provider === "auto-drive" && !(error instanceof AutoDriveStorageError)) throw new AutoDriveStorageError(error);
|
|
399
|
+
throw error;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
hashFromSequenceKey(key) {
|
|
403
|
+
const tail = key.slice(this.sequencePrefix().length);
|
|
404
|
+
const dashIndex = tail.indexOf("-");
|
|
405
|
+
if (dashIndex === -1) return void 0;
|
|
406
|
+
return tail.slice(dashIndex + 1);
|
|
407
|
+
}
|
|
408
|
+
hashKey(hash) {
|
|
409
|
+
return `${this.keyPrefix}by-hash/${hash}`;
|
|
410
|
+
}
|
|
411
|
+
hashPrefix() {
|
|
412
|
+
return `${this.keyPrefix}by-hash/`;
|
|
413
|
+
}
|
|
414
|
+
async listSequenceKeysSorted(direction) {
|
|
415
|
+
const keys = [];
|
|
416
|
+
let continuationToken;
|
|
417
|
+
do {
|
|
418
|
+
const response = await this.request(() => this.client.send(new ListObjectsV2Command({
|
|
419
|
+
Bucket: this.bucket,
|
|
420
|
+
Prefix: this.sequencePrefix(),
|
|
421
|
+
ContinuationToken: continuationToken
|
|
422
|
+
})));
|
|
423
|
+
for (const entry of response.Contents ?? []) {
|
|
424
|
+
if (entry.Key) keys.push(entry.Key);
|
|
425
|
+
}
|
|
426
|
+
continuationToken = this.nextPageToken(response, continuationToken);
|
|
427
|
+
} while (continuationToken);
|
|
428
|
+
keys.sort();
|
|
429
|
+
return direction === "desc" ? keys.toReversed() : keys;
|
|
430
|
+
}
|
|
431
|
+
nextPageToken(response, previous) {
|
|
432
|
+
if (!response.IsTruncated) return void 0;
|
|
433
|
+
const token = response.NextContinuationToken;
|
|
434
|
+
if (!token || token === previous) throw new Error("S3 listing did not provide a valid continuation token");
|
|
435
|
+
return token;
|
|
436
|
+
}
|
|
437
|
+
async request(operation) {
|
|
438
|
+
if (this.clientClosed) throw new Error("S3 client is closed");
|
|
439
|
+
try {
|
|
440
|
+
return await operation();
|
|
441
|
+
} catch (error) {
|
|
442
|
+
if (this.config.provider === "auto-drive") {
|
|
443
|
+
throw new AutoDriveStorageError(isNotFoundError(error) ? { $metadata: { httpStatusCode: 404 } } : error);
|
|
444
|
+
}
|
|
445
|
+
throw error;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
sequenceKey(sequence, hash) {
|
|
449
|
+
return `${this.keyPrefix}by-seq/${sequence}-${hash}`;
|
|
450
|
+
}
|
|
451
|
+
sequencePrefix() {
|
|
452
|
+
return `${this.keyPrefix}by-seq/`;
|
|
453
|
+
}
|
|
454
|
+
async tryHead(key) {
|
|
455
|
+
try {
|
|
456
|
+
const response = await this.request(() => this.client.send(new HeadObjectCommand({ Bucket: this.bucket, Key: key })));
|
|
457
|
+
return { Metadata: response.Metadata };
|
|
458
|
+
} catch (error) {
|
|
459
|
+
if (isNotFoundError(error)) return void 0;
|
|
460
|
+
throw error;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
async withMutation(operation) {
|
|
464
|
+
const previous = this.mutation;
|
|
465
|
+
const result = previous.then(operation);
|
|
466
|
+
this.mutation = result.then(() => {
|
|
467
|
+
}, () => {
|
|
468
|
+
});
|
|
469
|
+
return await result;
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
__publicField(S3Archivist, "configSchemas", [...__superGet(S3Archivist, S3Archivist, "configSchemas"), S3ArchivistConfigSchema]);
|
|
473
|
+
__publicField(S3Archivist, "defaultConfigSchema", S3ArchivistConfigSchema);
|
|
474
|
+
__publicField(S3Archivist, "labels", { ...__superGet(S3Archivist, S3Archivist, "labels"), [StorageClassLabel]: "object-store" });
|
|
475
|
+
S3Archivist = __decorateClass([
|
|
476
|
+
creatableModule()
|
|
477
|
+
], S3Archivist);
|
|
478
|
+
function isNotFoundError(error) {
|
|
479
|
+
if (error instanceof AutoDriveStorageError) return error.statusCode === 404;
|
|
480
|
+
if (typeof error !== "object" || error === null) return false;
|
|
481
|
+
const name = error.name;
|
|
482
|
+
const code = error.Code;
|
|
483
|
+
const status = error.$metadata?.httpStatusCode;
|
|
484
|
+
return name === "NotFound" || name === "NoSuchKey" || code === "NoSuchKey" || status === 404;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export {
|
|
488
|
+
AutoDriveStorageError,
|
|
489
|
+
S3ArchivistSchema,
|
|
490
|
+
S3ArchivistConfigSchema,
|
|
491
|
+
validateS3ArchivistConfig,
|
|
492
|
+
S3Archivist
|
|
493
|
+
};
|
|
494
|
+
//# sourceMappingURL=chunk-GULFSNYC.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/AutoDriveStorageError.ts", "../../src/Schema.ts", "../../src/Config.ts", "../../src/Archivist.ts"],
|
|
4
|
+
"sourcesContent": ["/** Credential-safe provider error. No response body, request headers or original cause. */\nexport class AutoDriveStorageError extends Error {\n readonly statusCode?: number\n\n constructor(error: unknown) {\n const status = typeof error === 'object' && error !== null && '$metadata' in error\n ? (error as { $metadata?: { httpStatusCode?: unknown } }).$metadata?.httpStatusCode\n : undefined\n const statusCode = typeof status === 'number' && Number.isSafeInteger(status) ? status : undefined\n super(`Auto Drive storage request failed${statusCode === undefined ? '' : ` (HTTP ${statusCode})`}`)\n this.name = 'AutoDriveStorageError'\n this.statusCode = statusCode\n }\n}\n", "import { asSchema } from '@xyo-network/sdk-protocol'\n\nexport const S3ArchivistSchema: 'network.xyo.archivist.s3' & { readonly __schema: true } = asSchema('network.xyo.archivist.s3', true)\nexport type S3ArchivistSchema = typeof S3ArchivistSchema\n", "import type { PayloadAdmissionPolicy } from '@xyo-network/sdk/archivist-abstract'\nimport { validatePayloadAdmissionPolicy } from '@xyo-network/sdk/archivist-abstract'\nimport type { ArchivistConfig } from '@xyo-network/sdk/archivist-model'\nimport { asSchema } from '@xyo-network/sdk-protocol'\n\nimport { S3ArchivistSchema } from './Schema.ts'\n\nexport const S3ArchivistConfigSchema: string & { readonly __schema: true } = asSchema(`${S3ArchivistSchema}.config`, true)\nexport type S3ArchivistConfigSchema = typeof S3ArchivistConfigSchema\n\nexport type S3ArchivistConfig = ArchivistConfig<{\n /** Optional fail-closed admission before any provider access. */\n admission?: PayloadAdmissionPolicy\n /** Bucket must already exist and allow the configured operations. */\n bucket: string\n /** Individual deletes support providers without DeleteObjects. */\n deleteMode?: 'bulk' | 'individual'\n /** Complete namespace prefix; the archivist appends by-hash, by-data and by-seq. */\n keyPrefix?: string\n /** Provider profile controls permanent-storage admission and error redaction. */\n provider?: 's3' | 'auto-drive'\n schema: S3ArchivistConfigSchema\n}>\n\n/** Validate serializable storage constraints without creating a client or making requests. */\nexport function validateS3ArchivistConfig(config: Partial<Pick<S3ArchivistConfig, 'admission' | 'bucket' | 'deleteMode' | 'provider'>>): void {\n if (typeof config.bucket !== 'string' || !config.bucket.trim()) throw new Error('S3 bucket is required')\n if (config.provider !== undefined && config.provider !== 's3' && config.provider !== 'auto-drive') throw new Error('Unsupported S3 provider profile')\n if (config.deleteMode !== undefined && config.deleteMode !== 'bulk' && config.deleteMode !== 'individual') throw new Error('Unsupported S3 deletion mode')\n if (config.provider === 'auto-drive') {\n if (!/^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$/.test(config.bucket)) throw new Error('Auto Drive bucket must be a plain bucket name')\n if (!config.admission) throw new Error('Auto Drive requires an explicit admission policy')\n if (config.deleteMode !== 'individual') throw new Error('Auto Drive requires individual deletion')\n }\n if (config.admission) validatePayloadAdmissionPolicy(config.admission)\n}\n", "import type { Hash } from '@ariestools/sdk'\nimport { assertEx, exists } from '@ariestools/sdk'\nimport type { S3Client } from '@aws-sdk/client-s3'\nimport {\n DeleteObjectCommand,\n DeleteObjectsCommand,\n GetObjectCommand,\n HeadObjectCommand,\n ListObjectsV2Command,\n PutObjectCommand,\n} from '@aws-sdk/client-s3'\nimport {\n AbstractArchivist, StorageClassLabel, validatePayloadAdmission,\n} from '@xyo-network/sdk/archivist-abstract'\nimport type { ArchivistModuleEventData, ArchivistNextOptions } from '@xyo-network/sdk/archivist-model'\nimport {\n ArchivistAllQuerySchema, ArchivistClearQuerySchema, ArchivistCommitQuerySchema,\n ArchivistDeleteQuerySchema, ArchivistInsertQuerySchema, ArchivistNextQuerySchema,\n} from '@xyo-network/sdk/archivist-model'\nimport { creatableModule } from '@xyo-network/sdk/module-model'\nimport type {\n BoundWitness, Payload, Schema, Sequence, WithStorageMeta,\n} from '@xyo-network/sdk-protocol'\nimport { PayloadBuilder } from '@xyo-network/sdk-protocol'\n\nimport { AutoDriveStorageError } from './AutoDriveStorageError.ts'\nimport { S3ArchivistConfigSchema, validateS3ArchivistConfig } from './Config.ts'\nimport type { S3ArchivistParams } from './Params.ts'\n\nexport interface S3ObjectReceipt {\n /** Optional provider locator; never an XYO identity or archival confirmation. */\n cid?: string\n}\n\nexport interface S3ArchivistCapabilities {\n deleteMode: 'bulk' | 'individual'\n deletion: 'provider-defined' | 'logical'\n permanent: boolean\n}\n\n/**\n * S3-compatible remote archivist. JSON bodies preserve client metadata and omit\n * storage metadata. XYO identities are verified on retrieval. Under keyPrefix:\n * by-hash/{hash} holds bodies, by-seq/{sequence}-{hash} orders records, and\n * by-data/{dataHash} points to one stored variant. Mutation serialization is\n * per instance; separate instances/processes sharing a namespace need coordination.\n */\n@creatableModule()\nexport class S3Archivist<\n TParams extends S3ArchivistParams = S3ArchivistParams,\n TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,\n> extends AbstractArchivist<TParams, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, S3ArchivistConfigSchema]\n static override readonly defaultConfigSchema: Schema = S3ArchivistConfigSchema\n static override readonly labels: { 'network.xyo.storage.class': string } = { ...super.labels, [StorageClassLabel]: 'object-store' }\n\n private clientClosed = false\n private mutation: Promise<void> = Promise.resolve()\n\n get bucket(): string {\n return assertEx(this.config.bucket, () => 'No bucket specified')\n }\n\n get capabilities(): S3ArchivistCapabilities {\n return {\n deletion: this.config.provider === 'auto-drive' ? 'logical' : 'provider-defined',\n deleteMode: this.config.deleteMode ?? 'bulk',\n permanent: this.config.provider === 'auto-drive',\n }\n }\n\n get client(): S3Client {\n return assertEx(this.params.client, () => 'No S3 client specified')\n }\n\n get keyPrefix(): string {\n const trimmed = (this.config.keyPrefix ?? '').replaceAll(/^\\/+|\\/+$/g, '')\n return trimmed.length > 0 ? `${trimmed}/` : ''\n }\n\n override get queries(): Schema[] {\n return [\n ArchivistAllQuerySchema,\n ArchivistDeleteQuerySchema,\n ArchivistClearQuerySchema,\n ArchivistInsertQuerySchema,\n ArchivistCommitQuerySchema,\n ArchivistNextQuerySchema,\n ...super.queries,\n ]\n }\n\n /** Count persisted primary objects, including writes awaiting index repair. */\n async count(): Promise<number> {\n await this.startedAsync('throw')\n let count = 0\n let token: string | undefined\n do {\n const response = await this.request(() => this.client.send(new ListObjectsV2Command({\n Bucket: this.bucket, Prefix: this.hashPrefix(), ContinuationToken: token,\n })))\n count += response.KeyCount ?? response.Contents?.length ?? 0\n token = this.nextPageToken(response, token)\n } while (token)\n return count\n }\n\n async getObjectReceipt(hash: string): Promise<S3ObjectReceipt> {\n try {\n await this.startedAsync('throw')\n const response = await this.request(() => this.client.send(new HeadObjectCommand({ Bucket: this.bucket, Key: this.hashKey(hash) })))\n return { cid: response.Metadata?.cid }\n } catch (error) {\n // This public metadata API must also sanitize missing-object failures.\n if (this.config.provider === 'auto-drive' && !(error instanceof AutoDriveStorageError)) throw new AutoDriveStorageError(error)\n throw error\n }\n }\n\n /** Only real primary objects satisfy deduplication; a synthetic data-hash view does not. */\n async getStoredPayloads(hashes: string[]): Promise<WithStorageMeta<Payload>[]> {\n await this.startedAsync('throw')\n const payloads: WithStorageMeta<Payload>[] = []\n for (const hash of hashes) {\n const payload = await this.getByHash(hash)\n if (payload) payloads.push(payload)\n }\n return payloads\n }\n\n protected override async allHandler(): Promise<WithStorageMeta<Payload>[]> {\n // Enumerate primary objects so interrupted index writes cannot disappear from\n // a full enumeration or a commit to another archivist.\n const payloads: WithStorageMeta<Payload>[] = []\n let token: string | undefined\n do {\n const response = await this.request(() => this.client.send(new ListObjectsV2Command({\n Bucket: this.bucket, Prefix: this.hashPrefix(), ContinuationToken: token,\n })))\n for (const entry of response.Contents ?? []) {\n if (!entry.Key) continue\n const payload = await this.getByHash(entry.Key.slice(this.hashPrefix().length))\n if (payload) payloads.push(payload)\n }\n token = this.nextPageToken(response, token)\n } while (token)\n return payloads.toSorted((a, b) => PayloadBuilder.compareStorageMeta(a, b))\n }\n\n protected override async clearHandler(): Promise<void> {\n // Keep primary metadata until secondary keys are gone, so an interrupted clear\n // cannot leave an old sequence pointing at a newly inserted primary object.\n for (const prefix of [this.sequencePrefix(), this.dataHashPrefix(), this.hashPrefix()]) {\n await this.deleteByPrefix(prefix)\n }\n }\n\n /** Durable remote storage is never cleared by commit, including successful copies. */\n protected override async commitHandler(): Promise<BoundWitness[]> {\n const parents = Object.values((await this.parentArchivists()).commit ?? {}).filter(exists)\n if (parents.length === 0) return []\n const payloads = await this.withMutation(async () => {\n const snapshot = await this.allHandler()\n await this.repairIndexes(snapshot)\n return snapshot\n })\n // Parent queries can trigger callbacks into this archivist. Local storage is\n // consistent at the snapshot boundary; no mutation lock spans external calls.\n const receipts: BoundWitness[] = []\n for (const parent of parents) {\n const query = await this.bindQuery({ schema: ArchivistInsertQuerySchema }, payloads)\n const [receipt, acknowledged, errors] = await parent.query(query[0], query[1])\n if (errors.length > 0) throw new Error('S3 commit parent rejected payloads')\n const received = new Set(await Promise.all(acknowledged.map(payload => PayloadBuilder.hash(payload))))\n const missing = payloads.filter(payload => !received.has(payload._hash)).map(payload => payload._hash)\n if (missing.length > 0) {\n const stored = await parent.get(missing)\n const verified = new Set(await Promise.all(stored.map(payload => PayloadBuilder.hash(payload))))\n if (missing.some(hash => !verified.has(hash))) throw new Error('S3 commit parent did not acknowledge every payload')\n }\n receipts.push(receipt)\n }\n return receipts\n }\n\n protected override async deleteHandler(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]> {\n const deleted: WithStorageMeta<Payload>[] = []\n for (const hash of hashes) {\n const payload = await this.findByEitherHash(hash)\n if (!payload) continue\n const keys = [this.sequenceKey(payload._sequence, payload._hash)]\n const pointer = await this.tryHead(this.dataHashKey(payload._dataHash))\n if (pointer?.Metadata?.hash === payload._hash) {\n const alternative = await this.findDataHashAlternative(payload)\n if (alternative) {\n await this.request(() => this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: this.dataHashKey(payload._dataHash),\n Body: '',\n Metadata: { hash: alternative._hash },\n })))\n } else keys.push(this.dataHashKey(payload._dataHash))\n }\n keys.push(this.hashKey(payload._hash))\n await this.deleteKeys(keys)\n deleted.push(payload)\n }\n return deleted\n }\n\n protected override async getExistingLocalPayloads(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]> {\n return await this.getStoredPayloads(hashes)\n }\n\n protected override async getHandler(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]> {\n const found: WithStorageMeta<Payload>[] = []\n for (const hash of hashes) {\n const payload = await this.findByEitherHash(hash)\n if (payload) found.push(payload)\n }\n return found\n }\n\n protected override async insertHandler(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<Payload>[]> {\n for (const payload of payloads) {\n const dataOnly = PayloadBuilder.omitStorageMeta(payload)\n const body = Buffer.from(JSON.stringify(dataOnly), 'utf8')\n await this.request(() => this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: this.hashKey(payload._hash),\n Body: body,\n ContentType: 'application/json',\n Metadata: {\n 'data-hash': payload._dataHash,\n 'sequence': payload._sequence,\n 'schema': payload.schema,\n },\n })))\n await this.repairIndexes([payload])\n }\n return payloads\n }\n\n protected override async nextHandler(options?: ArchivistNextOptions): Promise<WithStorageMeta<Payload>[]> {\n const {\n limit = 100, cursor, order, open = cursor ? true : false,\n } = options ?? {}\n const sorted = await this.listSequenceKeysSorted(order === 'desc' ? 'desc' : 'asc')\n let startIndex = 0\n if (cursor !== undefined) {\n const index = sorted.findIndex(key => key.startsWith(`${this.sequencePrefix()}${cursor}-`))\n startIndex = index === -1 ? sorted.length : index + (open ? 1 : 0)\n }\n const window = sorted.slice(startIndex, startIndex + limit)\n const payloads: WithStorageMeta<Payload>[] = []\n for (const key of window) {\n const hash = this.hashFromSequenceKey(key)\n if (!hash) continue\n const payload = await this.getByHash(hash)\n if (payload) payloads.push(payload)\n }\n return payloads\n }\n\n protected override async repairExistingPayloads(payloads: WithStorageMeta<Payload>[]): Promise<void> {\n await this.repairIndexes(payloads)\n }\n\n /** Complete interrupted inserts without rewriting the permanent payload body. */\n protected async repairIndexes(payloads: WithStorageMeta<Payload>[]): Promise<void> {\n for (const payload of payloads) {\n const sequenceKey = this.sequenceKey(payload._sequence, payload._hash)\n if (!await this.tryHead(sequenceKey)) {\n await this.request(() => this.client.send(new PutObjectCommand({\n Bucket: this.bucket, Key: sequenceKey, Body: '',\n })))\n }\n if (payload._dataHash !== payload._hash) {\n const pointer = await this.tryHead(this.dataHashKey(payload._dataHash))\n const targetHash = pointer?.Metadata?.hash\n const target = targetHash ? await this.getByHash(targetHash) : undefined\n if (target?._dataHash !== payload._dataHash) {\n await this.request(() => this.client.send(new PutObjectCommand({\n Bucket: this.bucket,\n Key: this.dataHashKey(payload._dataHash),\n Body: '',\n Metadata: { hash: payload._hash },\n })))\n }\n }\n }\n }\n\n protected override async startHandler(): Promise<void> {\n validateS3ArchivistConfig(this.config)\n if (this.clientClosed) throw new Error('An owned S3 client cannot restart after stop; create a new archivist')\n await super.startHandler()\n }\n\n protected override async stopHandler(): Promise<void> {\n await this.mutation\n if (this.params.ownsClient && !this.clientClosed) {\n this.client.destroy()\n this.clientClosed = true\n }\n await super.stopHandler()\n }\n\n protected override validateInsertPayloads(payloads: Payload[]): void {\n validateS3ArchivistConfig(this.config)\n if (this.config.admission) validatePayloadAdmission(payloads, this.config.admission)\n }\n\n protected override async withStorageMutation<T>(operation: () => Promise<T>): Promise<T> {\n return await this.withMutation(operation)\n }\n\n private dataHashKey(dataHash: string): string {\n return `${this.keyPrefix}by-data/${dataHash}`\n }\n\n private dataHashPrefix(): string {\n return `${this.keyPrefix}by-data/`\n }\n\n private async deleteByPrefix(prefix: string): Promise<void> {\n // Snapshot the full listing before mutating it. Some compatible providers use\n // positional continuation tokens that skip records if earlier pages are deleted.\n const keys: string[] = []\n let continuationToken: string | undefined\n do {\n const response = await this.request(() => this.client.send(new ListObjectsV2Command({\n Bucket: this.bucket,\n Prefix: prefix,\n ContinuationToken: continuationToken,\n })))\n for (const entry of response.Contents ?? []) {\n if (entry.Key) keys.push(entry.Key)\n }\n continuationToken = this.nextPageToken(response, continuationToken)\n } while (continuationToken)\n for (let offset = 0; offset < keys.length; offset += 1000) {\n await this.deleteKeys(keys.slice(offset, offset + 1000))\n }\n }\n\n private async deleteKeys(keys: string[]): Promise<void> {\n if (this.config.deleteMode === 'individual') {\n for (const Key of keys) await this.request(() => this.client.send(new DeleteObjectCommand({ Bucket: this.bucket, Key })))\n return\n }\n const response = await this.request(() => this.client.send(new DeleteObjectsCommand({\n Bucket: this.bucket,\n Delete: { Objects: keys.map(Key => ({ Key })) },\n })))\n if (response.Errors?.length) throw new Error('S3 could not delete every requested object')\n }\n\n private async findByEitherHash(hash: string): Promise<WithStorageMeta<Payload> | undefined> {\n // by-hash hit covers the equal-hash case (binary blobs) and the normal\n // structured case alike.\n const direct = await this.getByHash(hash)\n if (direct) return direct\n const indirect = await this.tryHead(this.dataHashKey(hash))\n const target = indirect?.Metadata?.hash\n if (!target) return undefined\n const payload = await this.getByHash(target)\n if (payload?._dataHash !== hash) throw new Error('Stored data-hash alias does not match its target')\n return payload\n }\n\n private async findDataHashAlternative(payload: WithStorageMeta<Payload>): Promise<WithStorageMeta<Payload> | undefined> {\n for (const key of await this.listSequenceKeysSorted('asc')) {\n const hash = this.hashFromSequenceKey(key)\n if (!hash || hash === payload._hash) continue\n const candidate = await this.getByHash(hash)\n if (candidate?._dataHash === payload._dataHash) return candidate\n }\n }\n\n private async getByHash(hash: string): Promise<WithStorageMeta<Payload> | undefined> {\n try {\n const response = await this.request(() => this.client.send(new GetObjectCommand({\n Bucket: this.bucket,\n Key: this.hashKey(hash),\n })))\n const body = response.Body\n if (!body) throw new Error('Stored payload is missing its body')\n const bytes = await this.request(() => body.transformToByteArray())\n let dataOnly: Payload\n try {\n dataOnly = JSON.parse(Buffer.from(bytes).toString('utf8')) as Payload\n } catch {\n throw new Error('Stored payload is not valid JSON')\n }\n const metadata = response.Metadata ?? {}\n const dataHash = metadata['data-hash'] ?? hash\n const sequence = metadata.sequence\n if (!sequence) throw new Error('Stored payload is missing sequence metadata')\n if (await PayloadBuilder.hash(dataOnly) !== hash || await PayloadBuilder.dataHash(dataOnly) !== dataHash) {\n throw new Error('Stored payload does not match its XYO hash metadata')\n }\n return {\n ...dataOnly,\n _hash: hash,\n _dataHash: dataHash,\n _sequence: sequence as Sequence,\n }\n } catch (error) {\n if (isNotFoundError(error)) return undefined\n // Decoding and identity validation happen after the transport response.\n // Keep all provider reads behind the same credential/body-safe error surface.\n if (this.config.provider === 'auto-drive' && !(error instanceof AutoDriveStorageError)) throw new AutoDriveStorageError(error)\n throw error\n }\n }\n\n private hashFromSequenceKey(key: string): string | undefined {\n const tail = key.slice(this.sequencePrefix().length)\n const dashIndex = tail.indexOf('-')\n if (dashIndex === -1) return undefined\n return tail.slice(dashIndex + 1)\n }\n\n private hashKey(hash: string): string {\n return `${this.keyPrefix}by-hash/${hash}`\n }\n\n private hashPrefix(): string {\n return `${this.keyPrefix}by-hash/`\n }\n\n private async listSequenceKeysSorted(direction: 'asc' | 'desc'): Promise<string[]> {\n const keys: string[] = []\n let continuationToken: string | undefined\n do {\n const response = await this.request(() => this.client.send(new ListObjectsV2Command({\n Bucket: this.bucket,\n Prefix: this.sequencePrefix(),\n ContinuationToken: continuationToken,\n })))\n for (const entry of response.Contents ?? []) {\n if (entry.Key) keys.push(entry.Key)\n }\n continuationToken = this.nextPageToken(response, continuationToken)\n } while (continuationToken)\n keys.sort()\n return direction === 'desc' ? keys.toReversed() : keys\n }\n\n private nextPageToken(response: { IsTruncated?: boolean; NextContinuationToken?: string }, previous?: string): string | undefined {\n if (!response.IsTruncated) return undefined\n const token = response.NextContinuationToken\n if (!token || token === previous) throw new Error('S3 listing did not provide a valid continuation token')\n return token\n }\n\n private async request<T>(operation: () => Promise<T>): Promise<T> {\n if (this.clientClosed) throw new Error('S3 client is closed')\n try {\n return await operation()\n } catch (error) {\n if (this.config.provider === 'auto-drive') {\n throw new AutoDriveStorageError(isNotFoundError(error) ? { $metadata: { httpStatusCode: 404 } } : error)\n }\n throw error\n }\n }\n\n private sequenceKey(sequence: string, hash: string): string {\n return `${this.keyPrefix}by-seq/${sequence}-${hash}`\n }\n\n private sequencePrefix(): string {\n return `${this.keyPrefix}by-seq/`\n }\n\n private async tryHead(key: string): Promise<{ Metadata?: Record<string, string> } | undefined> {\n try {\n const response = await this.request(() => this.client.send(new HeadObjectCommand({ Bucket: this.bucket, Key: key })))\n return { Metadata: response.Metadata }\n } catch (error) {\n if (isNotFoundError(error)) return undefined\n throw error\n }\n }\n\n private async withMutation<T>(operation: () => Promise<T>): Promise<T> {\n const previous = this.mutation\n const result = previous.then(operation)\n this.mutation = result.then(() => { /* The next mutation may proceed. */ }, () => { /* Failure belongs to the caller. */ })\n return await result\n }\n}\n\nfunction isNotFoundError(error: unknown): boolean {\n if (error instanceof AutoDriveStorageError) return error.statusCode === 404\n if (typeof error !== 'object' || error === null) return false\n const name = (error as { name?: string }).name\n const code = (error as { Code?: string }).Code\n const status = (error as { $metadata?: { httpStatusCode?: number } }).$metadata?.httpStatusCode\n return name === 'NotFound' || name === 'NoSuchKey' || code === 'NoSuchKey' || status === 404\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AACO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EACtC;AAAA,EAET,YAAY,OAAgB;AAC1B,UAAM,SAAS,OAAO,UAAU,YAAY,UAAU,QAAQ,eAAe,QACxE,MAAuD,WAAW,iBACnE;AACJ,UAAM,aAAa,OAAO,WAAW,YAAY,OAAO,cAAc,MAAM,IAAI,SAAS;AACzF,UAAM,oCAAoC,eAAe,SAAY,KAAK,UAAU,UAAU,GAAG,EAAE;AACnG,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;;;ACbA,SAAS,gBAAgB;AAElB,IAAM,oBAA8E,SAAS,4BAA4B,IAAI;;;ACDpI,SAAS,sCAAsC;AAE/C,SAAS,YAAAA,iBAAgB;AAIlB,IAAM,0BAAgEC,UAAS,GAAG,iBAAiB,WAAW,IAAI;AAkBlH,SAAS,0BAA0B,QAAoG;AAC5I,MAAI,OAAO,OAAO,WAAW,YAAY,CAAC,OAAO,OAAO,KAAK,EAAG,OAA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xD,QAAM,OAAQ,MAA4B;AAC1C,QAAM,OAAQ,MAA4B;AAC1C,QAAM,SAAU,MAAsD,WAAW;AACjF,SAAO,SAAS,cAAc,SAAS,eAAe,SAAS,eAAe,WAAW;AAC3F;",
|
|
6
|
+
"names": ["asSchema", "asSchema"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
S3Archivist,
|
|
3
|
+
S3ArchivistConfigSchema,
|
|
4
|
+
S3ArchivistSchema,
|
|
5
|
+
validateS3ArchivistConfig
|
|
6
|
+
} from "./chunk-GULFSNYC.mjs";
|
|
7
|
+
export {
|
|
8
|
+
S3Archivist,
|
|
9
|
+
S3ArchivistConfigSchema,
|
|
10
|
+
S3ArchivistSchema,
|
|
11
|
+
validateS3ArchivistConfig
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.mjs.map
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@xyo-network/archivist-s3",
|
|
3
|
+
"version": "7.4.1",
|
|
4
|
+
"description": "S3-compatible XYO archivist with provider profiles and recoverable indexes",
|
|
5
|
+
"homepage": "https://xyo.network",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js/issues",
|
|
8
|
+
"email": "support@xyo.network"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/XYOracleNetwork/sdk-xyo-client-js.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "LGPL-3.0-only",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "XYO Development Team",
|
|
17
|
+
"email": "support@xyo.network",
|
|
18
|
+
"url": "https://xyo.network"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/node/index.d.ts",
|
|
25
|
+
"browser": {},
|
|
26
|
+
"module": "./dist/node/index.mjs",
|
|
27
|
+
"default": "./dist/node/index.mjs"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./auto-drive": {
|
|
31
|
+
"types": "./dist/node/auto-drive.d.ts",
|
|
32
|
+
"browser": {},
|
|
33
|
+
"module": "./dist/node/auto-drive.mjs",
|
|
34
|
+
"default": "./dist/node/auto-drive.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"!**/*.bench.*",
|
|
40
|
+
"!**/*.spec.*",
|
|
41
|
+
"!**/*.test.*",
|
|
42
|
+
"!**/spec/**",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@aws-sdk/client-s3": "~3.1128.0",
|
|
47
|
+
"@xyo-network/sdk": "~7.4.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@ariestools/sdk": "~8.3.0",
|
|
51
|
+
"@ariestools/toolchain": "~9.2.1",
|
|
52
|
+
"@ariestools/tsconfig": "~9.2.1",
|
|
53
|
+
"@opentelemetry/api": "~1.9.1",
|
|
54
|
+
"@xyo-network/sdk-protocol": "~7.4.2",
|
|
55
|
+
"eslint": "~10.10.0",
|
|
56
|
+
"eslint-import-resolver-typescript": "~4.4.5",
|
|
57
|
+
"tslib": "~2.8.1",
|
|
58
|
+
"typescript": "~6.0.3",
|
|
59
|
+
"vite": "~8.2.2",
|
|
60
|
+
"vitest": "~5.0.0",
|
|
61
|
+
"zod": "~4.5.4"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@ariestools/sdk": "^8.1",
|
|
65
|
+
"@xyo-network/sdk-protocol": "^7.4"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": "^24"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
}
|
|
73
|
+
}
|