@seedprotocol/sdk 0.1.118 → 0.1.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-B_TEG7RD.js → index-CXivX9-v.js} +5 -4
- package/dist/index-CXivX9-v.js.map +1 -0
- package/dist/{index-BPIesZ_6.js → index-lYH32Ucm.js} +74 -23
- package/dist/index-lYH32Ucm.js.map +1 -0
- package/dist/main.js +4 -3
- package/dist/main.js.map +1 -1
- package/dist/{seed.schema.config-BB6-tbUU.js → seed.schema.config-y0omDTDZ.js} +4 -3
- package/dist/seed.schema.config-y0omDTDZ.js.map +1 -0
- package/dist/src/files.ts +8 -8
- package/dist/src/migrate.ts +17 -14
- package/dist/src/seed.ts +31 -4
- package/dist/types/src/browser/services/db/actors/migrate.d.ts.map +1 -1
- package/dist/types/src/node/webpack/index.d.ts.map +1 -1
- package/dist/types/src/shared/helpers/files.d.ts +2 -2
- package/dist/types/src/shared/helpers/files.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/index-BPIesZ_6.js.map +0 -1
- package/dist/index-B_TEG7RD.js.map +0 -1
- package/dist/seed.schema.config-BB6-tbUU.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export { j as ImageSrc, I as Item, k as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, v as getCorrectId, s as getGlobalService, n as useCreateItem, p as useDeleteItem, q as useGlobalServiceStatus, l as useItem, m as useItemProperties, o as useItemProperty, u as useItems, r as useServices, w as withSeed } from './index-
|
|
1
|
+
export { j as ImageSrc, I as Item, k as ItemProperty, J as Json, L as List, M as Model, P as Property, R as Relation, T as Text, t as client, v as getCorrectId, s as getGlobalService, n as useCreateItem, p as useDeleteItem, q as useGlobalServiceStatus, l as useItem, m as useItemProperties, o as useItemProperty, u as useItems, r as useServices, w as withSeed } from './index-lYH32Ucm.js';
|
|
2
2
|
import 'immer';
|
|
3
3
|
import 'reflect-metadata';
|
|
4
4
|
import 'tslib';
|
|
5
5
|
import 'xstate';
|
|
6
6
|
import 'arweave';
|
|
7
7
|
import 'drizzle-orm';
|
|
8
|
-
import 'path';
|
|
9
8
|
import '@sinclair/typebox';
|
|
10
9
|
import '@zenfs/core';
|
|
11
10
|
import 'dayjs';
|
|
@@ -18,6 +17,7 @@ import '@tanstack/react-query';
|
|
|
18
17
|
import 'graphql-request';
|
|
19
18
|
import '@tanstack/query-sync-storage-persister';
|
|
20
19
|
import '@tanstack/react-query-persist-client';
|
|
20
|
+
import 'path';
|
|
21
21
|
import 'use-immer';
|
|
22
22
|
import '@xstate/react';
|
|
23
23
|
import 'eventemitter3';
|
|
@@ -28,8 +28,9 @@ import 'rxjs';
|
|
|
28
28
|
import 'drizzle-orm/sqlite-proxy';
|
|
29
29
|
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
30
30
|
import 'drizzle-orm/migrator';
|
|
31
|
-
import '@zenfs/dom';
|
|
32
31
|
import 'node:fs';
|
|
32
|
+
import 'async-es/retry';
|
|
33
|
+
import '@zenfs/dom';
|
|
33
34
|
import './constants-B6s6tGup.js';
|
|
34
35
|
import '@ethereum-attestation-service/eas-sdk';
|
|
35
36
|
import 'thirdweb';
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { __decorate, __metadata } from 'tslib';
|
|
2
2
|
import 'drizzle-orm';
|
|
3
|
-
import { T as Text, M as Model } from './index-
|
|
3
|
+
import { T as Text, M as Model } from './index-lYH32Ucm.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'reflect-metadata';
|
|
6
6
|
import 'xstate';
|
|
7
7
|
import 'arweave';
|
|
8
8
|
import '@zenfs/core';
|
|
9
9
|
import '@zenfs/dom';
|
|
10
|
-
import 'path';
|
|
11
10
|
import '@sinclair/typebox';
|
|
12
11
|
import 'dayjs';
|
|
13
12
|
import 'nanoid';
|
|
@@ -18,6 +17,7 @@ import '@tanstack/react-query';
|
|
|
18
17
|
import 'graphql-request';
|
|
19
18
|
import '@tanstack/query-sync-storage-persister';
|
|
20
19
|
import '@tanstack/react-query-persist-client';
|
|
20
|
+
import 'path';
|
|
21
21
|
import 'use-immer';
|
|
22
22
|
import '@xstate/react';
|
|
23
23
|
import 'eventemitter3';
|
|
@@ -30,6 +30,7 @@ import 'drizzle-orm/sqlite-proxy';
|
|
|
30
30
|
import 'drizzle-orm/sqlite-proxy/migrator';
|
|
31
31
|
import 'drizzle-orm/migrator';
|
|
32
32
|
import 'node:fs';
|
|
33
|
+
import 'async-es/retry';
|
|
33
34
|
import './constants-B6s6tGup.js';
|
|
34
35
|
import '@ethereum-attestation-service/eas-sdk';
|
|
35
36
|
import 'thirdweb';
|
|
@@ -80,4 +81,4 @@ const models = {
|
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
export { models };
|
|
83
|
-
//# sourceMappingURL=seed.schema.config-
|
|
84
|
+
//# sourceMappingURL=seed.schema.config-y0omDTDZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seed.schema.config-y0omDTDZ.js","sources":["../../src/shared/configs/seed.schema.config.ts"],"sourcesContent":["import { Model, Text } from '@/browser'\n\n@Model\nclass Seed {\n @Text() uid!: string\n @Text() type!: string\n}\n\n@Model\nclass Version {\n @Text() seedUid!: string\n @Text() note!: string\n}\n\n@Model\nclass Metadata {\n @Text() key!: string\n @Text() value!: string\n}\n\nexport const models = {\n Seed,\n Version,\n Metadata,\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,IAAI,GAAV,MAAM,IAAI,CAAA;CAGT;AAF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PFSRoot = async () => {
|
|
@@ -22,14 +23,14 @@ export const listFilesInOPFSRoot = async () => {
|
|
|
22
23
|
* Waits for a file to exist at the specified path.
|
|
23
24
|
* @param {string} filePath - The path of the file to check.
|
|
24
25
|
* @param {number} interval - The interval in milliseconds between checks (default: 500ms).
|
|
25
|
-
* @param {number} timeout - The
|
|
26
|
+
* @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
|
|
26
27
|
* @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
|
|
27
28
|
*/
|
|
28
29
|
export const waitForFile = (
|
|
29
30
|
filePath: string,
|
|
30
|
-
interval = 500,
|
|
31
|
-
timeout = 10000,
|
|
32
|
-
) => {
|
|
31
|
+
interval: number = 500,
|
|
32
|
+
timeout: number = 10000,
|
|
33
|
+
): Promise<boolean> => {
|
|
33
34
|
return new Promise((resolve, reject) => {
|
|
34
35
|
const startTime = Date.now()
|
|
35
36
|
|
|
@@ -37,10 +38,9 @@ export const waitForFile = (
|
|
|
37
38
|
{
|
|
38
39
|
times: Math.ceil(timeout / interval),
|
|
39
40
|
interval: interval,
|
|
40
|
-
errorFilter: () => !fs.existsSync(filePath), // Retry only if file does not exist
|
|
41
41
|
},
|
|
42
|
-
(callback) => {
|
|
43
|
-
if (fs.existsSync(filePath)) {
|
|
42
|
+
(callback: Function) => {
|
|
43
|
+
if (fs.existsSync(filePath) && fsNode.existsSync(filePath)) {
|
|
44
44
|
return callback(null, true) // File exists, finish with success
|
|
45
45
|
}
|
|
46
46
|
if (Date.now() - startTime >= timeout) {
|
|
@@ -48,7 +48,7 @@ export const waitForFile = (
|
|
|
48
48
|
}
|
|
49
49
|
callback(new Error('File does not exist yet')) // Retry with this error
|
|
50
50
|
},
|
|
51
|
-
(err, result) => {
|
|
51
|
+
(err: Error, result: boolean) => {
|
|
52
52
|
if (err) {
|
|
53
53
|
return resolve(false) // Resolve as false if timeout or error occurs
|
|
54
54
|
}
|
package/dist/src/migrate.ts
CHANGED
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import { getSqliteWasmClient, setAppDb } from '@/browser/db/sqlWasmClient'
|
|
8
8
|
import { drizzle } from 'drizzle-orm/sqlite-proxy'
|
|
9
9
|
import { sql } from 'drizzle-orm'
|
|
10
|
-
import {
|
|
10
|
+
import { fs } from '@zenfs/core'
|
|
11
11
|
import debug from 'debug'
|
|
12
12
|
import { migrate as drizzleMigrate } from 'drizzle-orm/sqlite-proxy/migrator'
|
|
13
13
|
import { readMigrationFiles } from 'drizzle-orm/migrator'
|
|
14
|
-
import { WebAccess } from '@zenfs/dom'
|
|
15
14
|
import * as fsNode from 'node:fs'
|
|
15
|
+
import { waitForFile } from '@/shared/helpers/files'
|
|
16
16
|
|
|
17
17
|
const logger = debug('app:services:db:actors:migrate')
|
|
18
18
|
|
|
@@ -123,12 +123,13 @@ export const migrate = fromCallback<
|
|
|
123
123
|
console.log('journalExistsSyncNode', journalExistsSyncNode)
|
|
124
124
|
|
|
125
125
|
if (!journalExists) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
await waitForFile(journalPath)
|
|
127
|
+
// const handle = await navigator.storage.getDirectory()
|
|
128
|
+
//
|
|
129
|
+
// await configureSingle({
|
|
130
|
+
// backend: WebAccess,
|
|
131
|
+
// handle,
|
|
132
|
+
// })
|
|
132
133
|
|
|
133
134
|
// window.location.reload()
|
|
134
135
|
|
|
@@ -229,12 +230,14 @@ export const migrate = fromCallback<
|
|
|
229
230
|
} catch (error) {
|
|
230
231
|
// console.error('Error migrating database: ', error)
|
|
231
232
|
// window.location.reload()
|
|
232
|
-
const handle = await navigator.storage.getDirectory()
|
|
233
|
-
|
|
234
|
-
await configureSingle({
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
})
|
|
233
|
+
// const handle = await navigator.storage.getDirectory()
|
|
234
|
+
//
|
|
235
|
+
// await configureSingle({
|
|
236
|
+
// backend: WebAccess,
|
|
237
|
+
// handle,
|
|
238
|
+
// })
|
|
239
|
+
|
|
240
|
+
await waitForFile(`${pathToDbDir}/meta/_journal.json`)
|
|
238
241
|
|
|
239
242
|
return _migrate()
|
|
240
243
|
}
|
package/dist/src/seed.ts
CHANGED
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isBrowser, isNode, isReactNative } from '@/shared/environment'
|
|
2
|
+
import { Endpoints, SeedConstructorOptions } from '@/types/types'
|
|
3
|
+
import { Subject } from 'rxjs'
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
type Environment = 'node' | 'browser' | 'react-native'
|
|
6
|
+
|
|
7
|
+
abstract class SeedBase {
|
|
8
|
+
private readonly _env: Environment = 'browser'
|
|
9
|
+
protected _subject: Subject<void> = new Subject<void>()
|
|
10
|
+
|
|
11
|
+
constructor(props: { endpoints: Endpoints }) {
|
|
12
|
+
console.log('Seed constructor called')
|
|
13
|
+
if (isNode()) {
|
|
14
|
+
this._env = 'node'
|
|
15
|
+
}
|
|
16
|
+
if (isBrowser()) {
|
|
17
|
+
this._env = 'browser'
|
|
18
|
+
}
|
|
19
|
+
if (isReactNative()) {
|
|
20
|
+
this._env = 'react-native'
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async initialize() {}
|
|
25
|
+
|
|
26
|
+
subscribe(callback: (event: any) => void) {
|
|
27
|
+
return this._subject.subscribe(callback)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class SeedSync extends SeedBase {
|
|
5
32
|
constructor(props: SeedConstructorOptions) {
|
|
6
33
|
super(props)
|
|
7
34
|
}
|
|
8
35
|
}
|
|
9
36
|
|
|
10
|
-
export {
|
|
37
|
+
export { SeedBase, SeedSync }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/services/db/actors/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAA;AAiB/E,eAAO,MAAM,MAAM,kFAkElB,CAAA;AAED,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../../../../../src/browser/services/db/actors/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,QAAQ,CAAA;AAClD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAA;AAiB/E,eAAO,MAAM,MAAM,kFAkElB,CAAA;AAED,eAAO,MAAM,OAAO,oGAoOlB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/node/webpack/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/node/webpack/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,WAAY,GAAG,WAAW,GAAG,YAAY,OAAO,QA0EpE,CAAA"}
|
|
@@ -3,8 +3,8 @@ export declare const listFilesInOPFSRoot: () => Promise<any[]>;
|
|
|
3
3
|
* Waits for a file to exist at the specified path.
|
|
4
4
|
* @param {string} filePath - The path of the file to check.
|
|
5
5
|
* @param {number} interval - The interval in milliseconds between checks (default: 500ms).
|
|
6
|
-
* @param {number} timeout - The
|
|
6
|
+
* @param {number} timeout - The timeout in milliseconds to wait for the file to exist (default: 10s).
|
|
7
7
|
* @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
|
|
8
8
|
*/
|
|
9
|
-
export declare const waitForFile: (filePath: string, interval?: number, timeout?: number) => Promise<
|
|
9
|
+
export declare const waitForFile: (filePath: string, interval?: number, timeout?: number) => Promise<boolean>;
|
|
10
10
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../src/shared/helpers/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../src/shared/helpers/files.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,sBAe/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,MAAM,aACN,MAAM,YACP,MAAM,KACd,OAAO,CAAC,OAAO,CA0BjB,CAAA"}
|