@seedprotocol/sdk 0.1.116 → 0.1.118

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.
@@ -1,4 +1,4 @@
1
- export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-fACn9sTT.js';
1
+ export { g as GET_ALL_PROPERTIES_FOR_ALL_VERSIONS, f as GET_PROPERTIES, G as GET_SCHEMAS, a as GET_SCHEMA_BY_NAME, b as GET_SEEDS, c as GET_SEED_IDS, d as GET_STORAGE_TRANSACTION_ID, e as GET_VERSIONS, I as Item, h as itemMachineAll, i as itemMachineSingle } from './index-BPIesZ_6.js';
2
2
  import 'tslib';
3
3
  import 'path';
4
4
  import 'reflect-metadata';
@@ -25,9 +25,12 @@ import 'pluralize';
25
25
  import '@statelyai/inspect';
26
26
  import 'rxjs';
27
27
  import 'drizzle-orm/sqlite-proxy';
28
+ import 'drizzle-orm/sqlite-proxy/migrator';
29
+ import 'drizzle-orm/migrator';
28
30
  import '@zenfs/dom';
31
+ import 'node:fs';
29
32
  import 'arweave';
30
33
  import './constants-B6s6tGup.js';
31
34
  import '@ethereum-attestation-service/eas-sdk';
32
35
  import 'thirdweb';
33
- //# sourceMappingURL=index-BtxxSQ3G.js.map
36
+ //# sourceMappingURL=index-B_TEG7RD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B_TEG7RD.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
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-fACn9sTT.js';
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-BPIesZ_6.js';
2
2
  import 'immer';
3
3
  import 'reflect-metadata';
4
4
  import 'tslib';
@@ -26,7 +26,10 @@ import 'pluralize';
26
26
  import '@statelyai/inspect';
27
27
  import 'rxjs';
28
28
  import 'drizzle-orm/sqlite-proxy';
29
+ import 'drizzle-orm/sqlite-proxy/migrator';
30
+ import 'drizzle-orm/migrator';
29
31
  import '@zenfs/dom';
32
+ import 'node:fs';
30
33
  import './constants-B6s6tGup.js';
31
34
  import '@ethereum-attestation-service/eas-sdk';
32
35
  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,6 +1,6 @@
1
1
  import { __decorate, __metadata } from 'tslib';
2
2
  import 'drizzle-orm';
3
- import { T as Text, M as Model } from './index-fACn9sTT.js';
3
+ import { T as Text, M as Model } from './index-BPIesZ_6.js';
4
4
  import 'react';
5
5
  import 'reflect-metadata';
6
6
  import 'xstate';
@@ -27,6 +27,9 @@ import 'pluralize';
27
27
  import '@statelyai/inspect';
28
28
  import 'rxjs';
29
29
  import 'drizzle-orm/sqlite-proxy';
30
+ import 'drizzle-orm/sqlite-proxy/migrator';
31
+ import 'drizzle-orm/migrator';
32
+ import 'node:fs';
30
33
  import './constants-B6s6tGup.js';
31
34
  import '@ethereum-attestation-service/eas-sdk';
32
35
  import 'thirdweb';
@@ -77,4 +80,4 @@ const models = {
77
80
  };
78
81
 
79
82
  export { models };
80
- //# sourceMappingURL=seed.schema.config-DLrHziQY.js.map
83
+ //# sourceMappingURL=seed.schema.config-BB6-tbUU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.schema.config-BB6-tbUU.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;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,IAAI,GAAA,UAAA,CAAA;IADT;AACK,CAAA,EAAA,IAAI,CAGT;AAGD,IAAM,OAAO,GAAb,MAAM,OAAO,CAAA;CAGZ;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAiB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,OAAO,GAAA,UAAA,CAAA;IADZ;AACK,CAAA,EAAA,OAAO,CAGZ;AAGD,IAAM,QAAQ,GAAd,MAAM,QAAQ,CAAA;CAGb;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}
package/dist/src/files.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { fs } from '@zenfs/core'
2
+ import retry from 'async-es/retry'
3
+
1
4
  export const listFilesInOPFSRoot = async () => {
2
5
  // Get the root directory handle
3
6
  const rootDirHandle = await navigator.storage.getDirectory()
@@ -14,3 +17,43 @@ export const listFilesInOPFSRoot = async () => {
14
17
 
15
18
  return fileNames
16
19
  }
20
+
21
+ /**
22
+ * Waits for a file to exist at the specified path.
23
+ * @param {string} filePath - The path of the file to check.
24
+ * @param {number} interval - The interval in milliseconds between checks (default: 500ms).
25
+ * @param {number} timeout - The maximum time in milliseconds to wait (default: 10000ms).
26
+ * @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
27
+ */
28
+ export const waitForFile = (
29
+ filePath: string,
30
+ interval = 500,
31
+ timeout = 10000,
32
+ ) => {
33
+ return new Promise((resolve, reject) => {
34
+ const startTime = Date.now()
35
+
36
+ retry(
37
+ {
38
+ times: Math.ceil(timeout / interval),
39
+ interval: interval,
40
+ errorFilter: () => !fs.existsSync(filePath), // Retry only if file does not exist
41
+ },
42
+ (callback) => {
43
+ if (fs.existsSync(filePath)) {
44
+ return callback(null, true) // File exists, finish with success
45
+ }
46
+ if (Date.now() - startTime >= timeout) {
47
+ return callback(new Error('Timeout exceeded while waiting for file'))
48
+ }
49
+ callback(new Error('File does not exist yet')) // Retry with this error
50
+ },
51
+ (err, result) => {
52
+ if (err) {
53
+ return resolve(false) // Resolve as false if timeout or error occurs
54
+ }
55
+ resolve(result) // Resolve as true if file exists
56
+ },
57
+ )
58
+ })
59
+ }
package/dist/src/index.ts CHANGED
@@ -1,4 +1,21 @@
1
- export * from './analyzeInput'
2
- export * from './saveImageSrc'
3
- export * from './saveRelation'
4
- export * from './saveItemStorage'
1
+ import { setup } from 'xstate'
2
+ import {
3
+ uploadBinaryData,
4
+ uploadMetadata,
5
+ } from '@/browser/schema/file/upload/actors'
6
+
7
+ export const uploadMachine = setup({
8
+ actors: {
9
+ uploadBinaryData,
10
+ uploadMetadata,
11
+ },
12
+ }).createMachine({
13
+ id: 'upload',
14
+ initial: 'idle',
15
+ context: {
16
+ file: '',
17
+ },
18
+ states: {
19
+ idle: {},
20
+ },
21
+ })
@@ -7,8 +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 { fs } from '@zenfs/core'
10
+ import { configureSingle, fs } from '@zenfs/core'
11
11
  import debug from 'debug'
12
+ import { migrate as drizzleMigrate } from 'drizzle-orm/sqlite-proxy/migrator'
13
+ import { readMigrationFiles } from 'drizzle-orm/migrator'
14
+ import { WebAccess } from '@zenfs/dom'
15
+ import * as fsNode from 'node:fs'
12
16
 
13
17
  const logger = debug('app:services:db:actors:migrate')
14
18
 
@@ -79,6 +83,7 @@ export const dbExec = async (dbId, params, sql, dbName, retries = 2) => {
79
83
 
80
84
  return rowsToReturn || []
81
85
  }
86
+
82
87
  export const migrate = fromCallback<
83
88
  EventObject,
84
89
  FromCallbackInput<DbServiceContext>
@@ -103,12 +108,30 @@ export const migrate = fromCallback<
103
108
  // _initFs()
104
109
 
105
110
  const _checkForFiles = async (): Promise<void> => {
106
- journalExists = await fs.promises.exists(
107
- `/${pathToDbDir}/meta/_journal.json`,
108
- )
111
+ const journalPath = `/${pathToDbDir}/meta/_journal.json`
112
+
113
+ journalExists = await fs.promises.exists(journalPath)
114
+
115
+ const journalExistsAsync = journalExists
116
+
117
+ const journalExistsSync = fs.existsSync(journalPath)
118
+
119
+ const journalExistsSyncNode = fsNode.existsSync(journalPath)
120
+
121
+ console.log('journalExistsAsync', journalExistsAsync)
122
+ console.log('journalExistsSync', journalExistsSync)
123
+ console.log('journalExistsSyncNode', journalExistsSyncNode)
109
124
 
110
125
  if (!journalExists) {
111
- window.location.reload()
126
+ const handle = await navigator.storage.getDirectory()
127
+
128
+ await configureSingle({
129
+ backend: WebAccess,
130
+ handle,
131
+ })
132
+
133
+ // window.location.reload()
134
+
112
135
  // setTimeout(() => {
113
136
  // _checkForFiles().then(() => {
114
137
  // return
@@ -146,11 +169,6 @@ export const migrate = fromCallback<
146
169
  },
147
170
  )
148
171
 
149
- const { migrate: drizzleMigrate } = await import(
150
- 'drizzle-orm/sqlite-proxy/migrator'
151
- )
152
- const { readMigrationFiles } = await import('drizzle-orm/migrator')
153
-
154
172
  try {
155
173
  const migrations = readMigrationFiles({
156
174
  migrationsFolder: pathToDbDir,
@@ -209,8 +227,16 @@ export const migrate = fromCallback<
209
227
  },
210
228
  )
211
229
  } catch (error) {
212
- console.error('Error migrating database: ', error)
213
- window.location.reload()
230
+ // console.error('Error migrating database: ', error)
231
+ // window.location.reload()
232
+ const handle = await navigator.storage.getDirectory()
233
+
234
+ await configureSingle({
235
+ backend: WebAccess,
236
+ handle,
237
+ })
238
+
239
+ return _migrate()
214
240
  }
215
241
 
216
242
  setAppDb(drizzleDb)
@@ -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;AAa/E,eAAO,MAAM,MAAM,kFAkElB,CAAA;AACD,eAAO,MAAM,OAAO,oGA4MlB,CAAA"}
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,oGAiOlB,CAAA"}
@@ -2,11 +2,6 @@ import { DbServiceContext } from '@/types';
2
2
  declare const dbMachine: import("xstate").StateMachine<Partial<DbServiceContext>, import("xstate").AnyEventObject, {
3
3
  [x: string]: import("xstate").ActorRefFromLogic<import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>> | undefined;
4
4
  }, import("xstate").Values<{
5
- migrate: {
6
- src: "migrate";
7
- logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
8
- id: string | undefined;
9
- };
10
5
  checkStatus: {
11
6
  src: "checkStatus";
12
7
  logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
@@ -22,12 +17,12 @@ declare const dbMachine: import("xstate").StateMachine<Partial<DbServiceContext>
22
17
  logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
23
18
  id: string | undefined;
24
19
  };
25
- }>, never, never, never, {}, string, Partial<DbServiceContext>, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").MachineConfig<Partial<DbServiceContext>, import("xstate").AnyEventObject, import("xstate").Values<{
26
20
  migrate: {
27
21
  src: "migrate";
28
22
  logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
29
23
  id: string | undefined;
30
24
  };
25
+ }>, never, never, never, {}, string, Partial<DbServiceContext>, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject, import("xstate").MachineConfig<Partial<DbServiceContext>, import("xstate").AnyEventObject, import("xstate").Values<{
31
26
  checkStatus: {
32
27
  src: "checkStatus";
33
28
  logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
@@ -43,6 +38,11 @@ declare const dbMachine: import("xstate").StateMachine<Partial<DbServiceContext>
43
38
  logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
44
39
  id: string | undefined;
45
40
  };
41
+ migrate: {
42
+ src: "migrate";
43
+ logic: import("xstate").CallbackActorLogic<import("xstate").EventObject, import("@/types").FromCallbackInput<DbServiceContext>, import("xstate").EventObject>;
44
+ id: string | undefined;
45
+ };
46
46
  }>, never, never, never, string, Partial<DbServiceContext>, import("xstate").NonReducibleUnknown, import("xstate").EventObject, import("xstate").MetaObject>>;
47
47
  export { dbMachine };
48
48
  //# sourceMappingURL=dbMachine.d.ts.map
@@ -1,2 +1,10 @@
1
1
  export declare const listFilesInOPFSRoot: () => Promise<any[]>;
2
+ /**
3
+ * Waits for a file to exist at the specified path.
4
+ * @param {string} filePath - The path of the file to check.
5
+ * @param {number} interval - The interval in milliseconds between checks (default: 500ms).
6
+ * @param {number} timeout - The maximum time in milliseconds to wait (default: 10000ms).
7
+ * @returns {Promise<boolean>} - Resolves to true if the file exists within the timeout period, otherwise false.
8
+ */
9
+ export declare const waitForFile: (filePath: string, interval?: number, timeout?: number) => Promise<unknown>;
2
10
  //# sourceMappingURL=files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../src/shared/helpers/files.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,sBAe/B,CAAA"}
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../../src/shared/helpers/files.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,sBAe/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aACZ,MAAM,0DA8BjB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedprotocol/sdk",
3
- "version": "0.1.116",
3
+ "version": "0.1.118",
4
4
  "description": "The SDK for Seed Protocol",
5
5
  "type": "module",
6
6
  "types": "./dist/types/src/index.d.ts",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BtxxSQ3G.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"seed.schema.config-DLrHziQY.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;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,IAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,IAAI,GAAA,UAAA,CAAA;IADT;AACK,CAAA,EAAA,IAAI,CAGT;AAGD,IAAM,OAAO,GAAb,MAAM,OAAO,CAAA;CAGZ;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAiB,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AAChB,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAc,CAAA,EAAA,OAAA,CAAA,SAAA,EAAA,MAAA,EAAA,KAAA,CAAA,CAAA;AAFjB,OAAO,GAAA,UAAA,CAAA;IADZ;AACK,CAAA,EAAA,OAAO,CAGZ;AAGD,IAAM,QAAQ,GAAd,MAAM,QAAQ,CAAA;CAGb;AAFS,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAa,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AACZ,UAAA,CAAA;AAAP,IAAA,IAAI,EAAE;;AAAe,CAAA,EAAA,QAAA,CAAA,SAAA,EAAA,OAAA,EAAA,KAAA,CAAA,CAAA;AAFlB,QAAQ,GAAA,UAAA,CAAA;IADb;AACK,CAAA,EAAA,QAAQ,CAGb;AAEY,MAAA,MAAM,GAAG;IACpB,IAAI;IACJ,OAAO;IACP,QAAQ;;;;;"}