@xyo-network/archivist-firebase 5.3.20 → 5.3.24
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/package.json +25 -13
- package/src/Archivist.ts +0 -71
- package/src/Config.ts +0 -13
- package/src/Params.ts +0 -9
- package/src/Schema.ts +0 -4
- package/src/index.ts +0 -4
- package/src/spec/firestore.rules +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/archivist-firebase",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.24",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,39 +30,51 @@
|
|
|
30
30
|
"types": "dist/browser/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src",
|
|
34
33
|
"!**/*.bench.*",
|
|
35
34
|
"!**/*.spec.*",
|
|
36
|
-
"!**/*.test.*"
|
|
35
|
+
"!**/*.test.*",
|
|
36
|
+
"README.md"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xyo-network/archivist-abstract": "~5.3.
|
|
40
|
-
"@xyo-network/archivist-model": "~5.3.
|
|
41
|
-
"@xyo-network/module-model": "~5.3.
|
|
42
|
-
"@xyo-network/payload-model": "~5.3.
|
|
39
|
+
"@xyo-network/archivist-abstract": "~5.3.24",
|
|
40
|
+
"@xyo-network/archivist-model": "~5.3.24",
|
|
41
|
+
"@xyo-network/module-model": "~5.3.24",
|
|
42
|
+
"@xyo-network/payload-model": "~5.3.24"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@firebase/app": "~0.14.10",
|
|
46
46
|
"@firebase/firestore": "~4.13.0",
|
|
47
47
|
"@firebase/rules-unit-testing": "~5.0.0",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@xylabs/
|
|
51
|
-
"@xylabs/
|
|
48
|
+
"@opentelemetry/api": "^1.9.1",
|
|
49
|
+
"@types/node": "^25.5.0",
|
|
50
|
+
"@xylabs/sdk-js": "^5.0.93",
|
|
51
|
+
"@xylabs/ts-scripts-common": "~7.6.16",
|
|
52
|
+
"@xylabs/ts-scripts-pnpm": "~7.6.16",
|
|
53
|
+
"@xylabs/tsconfig": "~7.6.16",
|
|
54
|
+
"acorn": "^8.16.0",
|
|
55
|
+
"axios": "^1.14.0",
|
|
56
|
+
"esbuild": "^0.28.0",
|
|
57
|
+
"ethers": "^6.16.0",
|
|
52
58
|
"firebase": "~12.11.0",
|
|
53
59
|
"tslib": "^2.8.1",
|
|
54
60
|
"typescript": "~5.9.3",
|
|
61
|
+
"vite": "^8.0.3",
|
|
55
62
|
"vitest": "~4.1.2",
|
|
56
|
-
"zod": "^4.3.6"
|
|
63
|
+
"zod": "^4.3.6",
|
|
64
|
+
"@xyo-network/archivist-abstract": "~5.3.24",
|
|
65
|
+
"@xyo-network/archivist-model": "~5.3.24",
|
|
66
|
+
"@xyo-network/module-model": "~5.3.24",
|
|
67
|
+
"@xyo-network/payload-model": "~5.3.24"
|
|
57
68
|
},
|
|
58
69
|
"peerDependencies": {
|
|
59
70
|
"@firebase/app": "~0.14",
|
|
60
71
|
"@firebase/firestore": "^4",
|
|
61
72
|
"@xylabs/sdk-js": "^5",
|
|
73
|
+
"ethers": "^6",
|
|
62
74
|
"tslib": "^2.8.1",
|
|
63
75
|
"zod": "^4"
|
|
64
76
|
},
|
|
65
77
|
"publishConfig": {
|
|
66
78
|
"access": "public"
|
|
67
79
|
}
|
|
68
|
-
}
|
|
80
|
+
}
|
package/src/Archivist.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
collection,
|
|
3
|
-
doc,
|
|
4
|
-
getDoc,
|
|
5
|
-
getFirestore,
|
|
6
|
-
setDoc,
|
|
7
|
-
} from '@firebase/firestore'
|
|
8
|
-
import {
|
|
9
|
-
assertEx, exists, Hash,
|
|
10
|
-
} from '@xylabs/sdk-js'
|
|
11
|
-
import { AbstractArchivist, StorageClassLabel } from '@xyo-network/archivist-abstract'
|
|
12
|
-
import { ArchivistInsertQuerySchema, ArchivistModuleEventData } from '@xyo-network/archivist-model'
|
|
13
|
-
import { creatableModule } from '@xyo-network/module-model'
|
|
14
|
-
import {
|
|
15
|
-
Payload, Schema, WithStorageMeta,
|
|
16
|
-
} from '@xyo-network/payload-model'
|
|
17
|
-
|
|
18
|
-
import { FirebaseArchivistConfigSchema } from './Config.ts'
|
|
19
|
-
import { FirebaseArchivistParams } from './Params.ts'
|
|
20
|
-
|
|
21
|
-
@creatableModule()
|
|
22
|
-
export class FirebaseArchivist<
|
|
23
|
-
TParams extends FirebaseArchivistParams = FirebaseArchivistParams,
|
|
24
|
-
TEventData extends ArchivistModuleEventData = ArchivistModuleEventData,
|
|
25
|
-
> extends AbstractArchivist<TParams, TEventData> {
|
|
26
|
-
static override readonly configSchemas: Schema[] = [...super.configSchemas, FirebaseArchivistConfigSchema]
|
|
27
|
-
static override readonly defaultConfigSchema: Schema = FirebaseArchivistConfigSchema
|
|
28
|
-
static override readonly labels = { ...super.labels, [StorageClassLabel]: 'network' }
|
|
29
|
-
|
|
30
|
-
override get queries() {
|
|
31
|
-
return [
|
|
32
|
-
ArchivistInsertQuerySchema,
|
|
33
|
-
...super.queries,
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private get collection() {
|
|
38
|
-
return collection(this.firestore, assertEx(this.config.collection, () => 'Missing collection name'))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private get firebaseApp() {
|
|
42
|
-
return assertEx(this.params.firebaseApp, () => 'Missing FirebaseApp')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
private get firestore() {
|
|
46
|
-
return getFirestore(this.firebaseApp, assertEx(this.config.dbId, () => 'no dbId specified'))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
protected override async getHandler(hashes: Hash[]): Promise<WithStorageMeta<Payload>[]> {
|
|
50
|
-
const payloadCollection = this.collection
|
|
51
|
-
return (await Promise.all(hashes.map(async (hash) => {
|
|
52
|
-
const docRef = doc(payloadCollection, hash)
|
|
53
|
-
const docSnap = await getDoc(docRef)
|
|
54
|
-
if (!docSnap.exists()) {
|
|
55
|
-
return null
|
|
56
|
-
}
|
|
57
|
-
return docSnap.data() as WithStorageMeta<Payload>
|
|
58
|
-
}))).filter(exists)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
protected override async insertHandler(payloads: WithStorageMeta<Payload>[]): Promise<WithStorageMeta<Payload>[]> {
|
|
62
|
-
const payloadCollection = this.collection
|
|
63
|
-
return await Promise.all(payloads.map(
|
|
64
|
-
async (payload) => {
|
|
65
|
-
const docRef = doc(payloadCollection, payload._hash)
|
|
66
|
-
await setDoc(docRef, payload)
|
|
67
|
-
return payload
|
|
68
|
-
},
|
|
69
|
-
))
|
|
70
|
-
}
|
|
71
|
-
}
|
package/src/Config.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ArchivistConfig } from '@xyo-network/archivist-model'
|
|
2
|
-
import { asSchema } from '@xyo-network/payload-model'
|
|
3
|
-
|
|
4
|
-
import { FirebaseArchivistSchema } from './Schema.ts'
|
|
5
|
-
|
|
6
|
-
export const FirebaseArchivistConfigSchema = asSchema(`${FirebaseArchivistSchema}.config`, true)
|
|
7
|
-
export type FirebaseArchivistConfigSchema = typeof FirebaseArchivistConfigSchema
|
|
8
|
-
|
|
9
|
-
export type FirebaseArchivistConfig = ArchivistConfig<{
|
|
10
|
-
collection?: string
|
|
11
|
-
dbId?: string
|
|
12
|
-
schema: FirebaseArchivistConfigSchema
|
|
13
|
-
}>
|
package/src/Params.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FirebaseApp } from '@firebase/app'
|
|
2
|
-
import type { ArchivistParams } from '@xyo-network/archivist-model'
|
|
3
|
-
import type { AnyConfigSchema } from '@xyo-network/module-model'
|
|
4
|
-
|
|
5
|
-
import type { FirebaseArchivistConfig } from './Config.ts'
|
|
6
|
-
|
|
7
|
-
export interface FirebaseArchivistParams extends ArchivistParams<AnyConfigSchema<FirebaseArchivistConfig>> {
|
|
8
|
-
firebaseApp?: FirebaseApp
|
|
9
|
-
}
|
package/src/Schema.ts
DELETED
package/src/index.ts
DELETED
package/src/spec/firestore.rules
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
service cloud.firestore {
|
|
2
|
-
match /databases/{database}/documents {
|
|
3
|
-
|
|
4
|
-
// Match any document in the "users" collection
|
|
5
|
-
match /users/{userId} {
|
|
6
|
-
|
|
7
|
-
// Allow read and write access if the requesting user is authenticated and their UID matches the document ID
|
|
8
|
-
allow read, write: if request.auth != null && request.auth.uid == userId;
|
|
9
|
-
|
|
10
|
-
// Deny all other access
|
|
11
|
-
allow read, write: if false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|