@seedprotocol/sdk 0.1.47 → 0.1.49

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.
Files changed (141) hide show
  1. package/dist/bin.js.map +1 -1
  2. package/dist/constants-BLctWkrn.js.map +1 -1
  3. package/dist/{index-DWf9Ls94.js → index-DMIKRod-.js} +3995 -3995
  4. package/dist/index-DMIKRod-.js.map +1 -0
  5. package/dist/{index-B2WbNudj.js → index-wKss7188.js} +10 -10
  6. package/dist/index-wKss7188.js.map +1 -0
  7. package/dist/main.js +7 -7
  8. package/dist/{seed.schema.config-mBqth17w.js → seed.schema.config-C0M8Rcti.js} +7 -7
  9. package/dist/seed.schema.config-C0M8Rcti.js.map +1 -0
  10. package/dist/src/AppStateSchema.ts +10 -0
  11. package/dist/src/Attestation.ts +21 -0
  12. package/dist/src/ConfigSchema.ts +15 -0
  13. package/dist/src/ItemProperty.ts +383 -0
  14. package/dist/src/MetadataSchema.ts +28 -0
  15. package/dist/src/ModelSchema.ts +46 -0
  16. package/dist/src/ModelUidSchema.ts +16 -0
  17. package/dist/src/PropertyUidSchema.ts +16 -0
  18. package/dist/src/Schema.ts +17 -0
  19. package/dist/src/SeedSchema.ts +29 -0
  20. package/dist/src/VersionSchema.ts +16 -0
  21. package/dist/src/actors.ts +280 -0
  22. package/dist/src/addModelsToDb.ts +150 -0
  23. package/dist/src/allItems.ts +23 -0
  24. package/dist/src/arweave.ts +37 -0
  25. package/dist/src/browser.app.db.config.ts +27 -0
  26. package/dist/src/browser.seed.db.config.ts +33 -0
  27. package/dist/src/browser.ts +30 -0
  28. package/dist/src/checkStatus.ts +50 -0
  29. package/dist/src/client.ts +85 -0
  30. package/dist/src/configureFs.ts +81 -0
  31. package/dist/src/connectToDb.ts +74 -0
  32. package/dist/src/connectionManager.ts +67 -0
  33. package/dist/src/constants.ts +118 -0
  34. package/dist/src/create.ts +39 -0
  35. package/dist/src/createItem.ts +15 -0
  36. package/dist/src/createItemMachine.ts +37 -0
  37. package/dist/src/createPublishAttempt.ts +16 -0
  38. package/dist/src/createSeeds.ts +24 -0
  39. package/dist/src/createVersion.ts +33 -0
  40. package/dist/src/db.ts +247 -0
  41. package/dist/src/dbMachine.ts +181 -0
  42. package/dist/src/deleteItem.ts +19 -0
  43. package/dist/src/download.ts +289 -0
  44. package/dist/src/drizzle.ts +82 -0
  45. package/dist/src/environment.ts +15 -0
  46. package/dist/src/eventBus.ts +5 -0
  47. package/dist/src/events.ts +14 -0
  48. package/dist/src/fetchDataFromEas.ts +90 -0
  49. package/dist/src/fetchDbData.ts +16 -0
  50. package/dist/src/fetchRelatedItems.ts +179 -0
  51. package/dist/src/fetchSeeds.ts +44 -0
  52. package/dist/src/fetchVersions.ts +41 -0
  53. package/dist/src/files.ts +16 -0
  54. package/dist/src/fragment-masking.ts +87 -0
  55. package/dist/src/fsProxy.ts +36 -0
  56. package/dist/src/getItem.ts +189 -0
  57. package/dist/src/getItemProperties.ts +162 -0
  58. package/dist/src/getItems.ts +75 -0
  59. package/dist/src/getMetadata.ts +40 -0
  60. package/dist/src/getModelSchemas.ts +88 -0
  61. package/dist/src/getSchemaForModel.ts +42 -0
  62. package/dist/src/getSeedData.ts +34 -0
  63. package/dist/src/getVersionData.ts +58 -0
  64. package/dist/src/getVersionsForVersionUids.ts +39 -0
  65. package/dist/src/globalMachine.ts +259 -0
  66. package/dist/src/gql.ts +113 -0
  67. package/dist/src/graphql.ts +3201 -0
  68. package/dist/src/helpers.ts +150 -0
  69. package/dist/src/hydrateExistingItem.ts +137 -0
  70. package/dist/src/hydrateFromDb.ts +254 -0
  71. package/dist/src/hydrateNewItem.ts +34 -0
  72. package/dist/src/index.d.ts +5 -0
  73. package/dist/src/index.ts +73 -0
  74. package/dist/src/init.ts +61 -0
  75. package/dist/src/initialize.ts +127 -0
  76. package/dist/src/internalMachine.ts +220 -0
  77. package/dist/src/item.ts +324 -0
  78. package/dist/src/itemMachineAll.ts +158 -0
  79. package/dist/src/itemMachineSingle.ts +175 -0
  80. package/dist/src/loadAppDb.ts +47 -0
  81. package/dist/src/logger.ts +33 -0
  82. package/dist/src/machine.ts +55 -0
  83. package/dist/src/machines.ts +58 -0
  84. package/dist/src/migrate.ts +288 -0
  85. package/dist/src/model.ts +71 -0
  86. package/dist/src/modelClass.ts +19 -0
  87. package/dist/src/node.app.db.config.ts +40 -0
  88. package/dist/src/prepareDb.ts +34 -0
  89. package/dist/src/preparePublishRequestData.ts +81 -0
  90. package/dist/src/processItems.ts +71 -0
  91. package/dist/src/property.ts +161 -0
  92. package/dist/src/propertyMachine.ts +154 -0
  93. package/dist/src/publish.ts +31 -0
  94. package/dist/src/publishMachine.ts +77 -0
  95. package/dist/src/queries.ts +13 -0
  96. package/dist/src/read.ts +174 -0
  97. package/dist/src/recoverDeletedItem.ts +14 -0
  98. package/dist/src/request.ts +54 -0
  99. package/dist/src/requestAll.ts +157 -0
  100. package/dist/src/resolveRelatedValue.ts +348 -0
  101. package/dist/src/resolveRemoteStorage.ts +87 -0
  102. package/dist/src/save.ts +183 -0
  103. package/dist/src/saveConfig.ts +79 -0
  104. package/dist/src/saveDataToDb.ts +145 -0
  105. package/dist/src/saveMetadata.ts +18 -0
  106. package/dist/src/saveValueToDb.ts +94 -0
  107. package/dist/src/seed.schema.config.ts +25 -0
  108. package/dist/src/seed.ts +37 -0
  109. package/dist/src/seedData.ts +0 -0
  110. package/dist/src/seedProtocol.ts +17 -0
  111. package/dist/src/services.ts +359 -0
  112. package/dist/src/sqlWasmClient.ts +88 -0
  113. package/dist/src/syncDbWithEas.ts +686 -0
  114. package/dist/src/trash.ts +29 -0
  115. package/dist/src/ts-to-proto.ts +101 -0
  116. package/dist/src/types.ts +12 -0
  117. package/dist/src/upload.ts +86 -0
  118. package/dist/src/validate.ts +42 -0
  119. package/dist/src/validateInput.ts +33 -0
  120. package/dist/src/validateItemData.ts +20 -0
  121. package/dist/src/waitForDb.ts +23 -0
  122. package/dist/src/wasm.d.ts +8300 -0
  123. package/dist/src/write.ts +366 -0
  124. package/dist/types/src/browser/db/read/getModelSchemas.d.ts.map +1 -1
  125. package/dist/types/src/browser/item/single/actors/hydrateExistingItem.d.ts +3 -1
  126. package/dist/types/src/browser/item/single/actors/hydrateExistingItem.d.ts.map +1 -1
  127. package/dist/types/src/browser/item/single/actors/saveDataToDb.d.ts +3 -3
  128. package/dist/types/src/browser/item/single/itemMachineSingle.d.ts +3 -3
  129. package/dist/types/src/browser/property/ItemProperty.d.ts +7 -7
  130. package/dist/types/src/browser/property/ItemProperty.d.ts.map +1 -1
  131. package/dist/types/src/browser/property/actors/resolveRemoteStorage.d.ts +3 -3
  132. package/dist/types/src/browser/react/trash.d.ts +1 -1
  133. package/dist/types/src/browser/react/trash.d.ts.map +1 -1
  134. package/dist/types/src/browser/services/db/dbMachine.d.ts +6 -6
  135. package/dist/types/src/browser/services/publish/publishMachine.d.ts +17 -17
  136. package/dist/types/src/types/machines.d.ts +4 -0
  137. package/dist/types/src/types/machines.d.ts.map +1 -1
  138. package/package.json +2 -2
  139. package/dist/index-B2WbNudj.js.map +0 -1
  140. package/dist/index-DWf9Ls94.js.map +0 -1
  141. package/dist/seed.schema.config-mBqth17w.js.map +0 -1
@@ -0,0 +1,88 @@
1
+ import { getModels } from '@/browser/stores/modelClass'
2
+ import { GetSchemasQuery, Schema } from '@/browser/gql/graphql'
3
+ import { getAppDb } from '../sqlWasmClient'
4
+ import { models as modelsTable, modelUids } from '@/shared/seedSchema'
5
+ import { eq } from 'drizzle-orm'
6
+ import pluralize from 'pluralize'
7
+ import { toSnakeCase } from '@/shared/helpers'
8
+ import { easClient, queryClient } from '@/browser/helpers'
9
+ import { GET_SCHEMAS } from '@/browser/item/queries'
10
+
11
+ type GetModelSchemasReturn = {
12
+ modelSchemas: GetSchemasQuery
13
+ schemaStringToModelRecord: Map<string, Schema>
14
+ modelRecords: Record<string, unknown>
15
+ }
16
+ type GetModelSchemas = () => Promise<GetModelSchemasReturn>
17
+
18
+ export const getModelSchemas: GetModelSchemas = async () => {
19
+ const models = getModels()
20
+ const modelRecords = [] as Record<string, unknown>[]
21
+
22
+ const schemaStringToModelRecord = new Map<string, Schema>()
23
+
24
+ const appDb = getAppDb()
25
+
26
+ const OR: Record<string, unknown>[] = []
27
+
28
+ for (const [modelName, _] of Object.entries(models)) {
29
+ const foundModelQuery = await appDb
30
+ .select({
31
+ id: modelsTable.id,
32
+ name: modelsTable.name,
33
+ uid: modelUids.uid,
34
+ })
35
+ .from(modelsTable)
36
+ .leftJoin(modelUids, eq(modelsTable.id, modelUids.modelId))
37
+ .where(eq(modelsTable.name, modelName))
38
+ .limit(1)
39
+
40
+ const foundModel: {
41
+ id: number
42
+ name: string
43
+ uid: string | null
44
+ tableName?: string
45
+ } = { ...foundModelQuery[0] }
46
+
47
+ if (!foundModel) {
48
+ console.error(
49
+ `[item/events] [syncDbWithEas] model ${modelName} not found in SDK DB`,
50
+ )
51
+ return
52
+ }
53
+
54
+ foundModel.tableName = pluralize(foundModel.name).toLowerCase()
55
+
56
+ modelRecords!.push(foundModel)
57
+
58
+ if (modelName === 'Seed' || modelName === 'Version') {
59
+ continue
60
+ }
61
+
62
+ const schemaString = `bytes32 ${toSnakeCase(modelName)}`
63
+
64
+ OR.push({
65
+ schema: {
66
+ equals: `bytes32 ${toSnakeCase(modelName)}`,
67
+ },
68
+ })
69
+
70
+ schemaStringToModelRecord.set(schemaString, foundModel)
71
+ }
72
+
73
+ const modelSchemas = await queryClient.fetchQuery({
74
+ queryKey: [`getSchemasAllModels`],
75
+ queryFn: async () =>
76
+ easClient.request(GET_SCHEMAS, {
77
+ where: {
78
+ OR,
79
+ },
80
+ }),
81
+ })
82
+
83
+ return {
84
+ modelSchemas,
85
+ schemaStringToModelRecord,
86
+ modelRecords,
87
+ }
88
+ }
@@ -0,0 +1,42 @@
1
+ import { EventObject, fromCallback } from 'xstate'
2
+ import {
3
+ FromCallbackInput,
4
+ GetSchemaForModelEvent,
5
+ GlobalMachineContext,
6
+ } from '@/types'
7
+ import debug from 'debug'
8
+
9
+ const logger = debug('app:services:global:actors:getSchemaForModel')
10
+
11
+ export const getSchemaForModel = fromCallback<
12
+ EventObject,
13
+ FromCallbackInput<GlobalMachineContext, GetSchemaForModelEvent>
14
+ >(({ sendBack, input: { context, event } }) => {
15
+ const { modelName } = event
16
+
17
+ if (!modelName) {
18
+ console.warn('No modelName found')
19
+ return
20
+ }
21
+
22
+ const { models } = context
23
+
24
+ if (!models) {
25
+ console.warn('No models found')
26
+ return
27
+ }
28
+
29
+ const model = Object.entries(models).find(
30
+ ([modelNameFromConfig]) => modelNameFromConfig === modelName,
31
+ )
32
+
33
+ if (!model) {
34
+ throw new Error(`Model ${modelName} not found`)
35
+ }
36
+
37
+ logger('[service/actor] [getSchemaForModel] model:', model)
38
+
39
+ sendBack({ type: 'schemaForModel', schema: model.schema })
40
+
41
+ return () => {}
42
+ })
@@ -0,0 +1,34 @@
1
+ import { getAppDb } from '../sqlWasmClient'
2
+ import { seeds, SeedType } from '@/shared/seedSchema'
3
+ import { eq } from 'drizzle-orm'
4
+
5
+ type GetSeedDataProps = {
6
+ seedLocalId?: string
7
+ seedUid?: string
8
+ }
9
+
10
+ type GetSeedData = (props: GetSeedDataProps) => Promise<SeedType | undefined>
11
+
12
+ export const getSeedData: GetSeedData = async ({ seedLocalId, seedUid }) => {
13
+ const appDb = getAppDb()
14
+
15
+ let query
16
+
17
+ const queryBase = appDb.select().from(seeds)
18
+
19
+ if (seedLocalId) {
20
+ query = queryBase.where(eq(seeds.localId, seedLocalId))
21
+ }
22
+
23
+ if (seedUid) {
24
+ query = queryBase.where(eq(seeds.uid, seedUid))
25
+ }
26
+
27
+ const rows = await query
28
+
29
+ if (!rows || !rows.length) {
30
+ return
31
+ }
32
+
33
+ return rows[0]
34
+ }
@@ -0,0 +1,58 @@
1
+ import { runQueryForStatement } from '../sqlWasmClient'
2
+
3
+ type VersionData = {
4
+ localId: string
5
+ uid: string
6
+ seedLocalId: string
7
+ seedUid: string
8
+ seedType: string
9
+ note: string
10
+ attestationCreatedAt: string
11
+ attestationRaw: string
12
+ createdAt: string
13
+ updatedAt: string
14
+ }
15
+
16
+ type GetVersionDataProps = {
17
+ seedLocalId: string
18
+ }
19
+
20
+ type GetVersionData = (
21
+ props: GetVersionDataProps,
22
+ ) => Promise<VersionData | undefined>
23
+
24
+ export const getVersionData: GetVersionData = async ({ seedLocalId }) => {
25
+ const getVersionStatement = `SELECT local_id,
26
+ uid,
27
+ seed_local_id,
28
+ seed_uid,
29
+ seed_type,
30
+ note,
31
+ attestation_created_at,
32
+ attestation_raw,
33
+ created_at,
34
+ updated_at
35
+ FROM versions
36
+ WHERE local_id = '${seedLocalId}';`
37
+
38
+ const { rows } = await runQueryForStatement(getVersionStatement)
39
+
40
+ if (!rows || !rows.length) {
41
+ return
42
+ }
43
+
44
+ const seedValues = rows[0]
45
+
46
+ return {
47
+ localId: seedValues[0],
48
+ uid: seedValues[1],
49
+ seedLocalId: seedValues[2],
50
+ seedUid: seedValues[3],
51
+ seedType: seedValues[4],
52
+ note: seedValues[5],
53
+ attestationCreatedAt: seedValues[6],
54
+ attestationRaw: seedValues[7],
55
+ createdAt: seedValues[8],
56
+ updatedAt: seedValues[9],
57
+ }
58
+ }
@@ -0,0 +1,39 @@
1
+ import { runQueryForStatement } from '../sqlWasmClient'
2
+
3
+ type VersionData = {
4
+ localId: string
5
+ uid: string
6
+ seedUid: string
7
+ seedLocalId: string
8
+ }
9
+ type GetVersionsForVersionUids = (
10
+ versionUids: string[],
11
+ ) => Promise<VersionData[]>
12
+ export const getVersionsForVersionUids: GetVersionsForVersionUids = async (
13
+ versionUids: string[],
14
+ ) => {
15
+ const queryStatement = `
16
+ SELECT local_id, uid, seed_uid, seed_local_id
17
+ FROM versions
18
+ WHERE uid IN ('${versionUids.join("','")}');
19
+ `
20
+
21
+ const { rows } = await runQueryForStatement(queryStatement)
22
+
23
+ if (!rows || rows.length === 0) {
24
+ return []
25
+ }
26
+
27
+ const versionsData: VersionData[] = []
28
+
29
+ for (const row of rows) {
30
+ versionsData.push({
31
+ localId: row[0],
32
+ uid: row[1],
33
+ seedUid: row[2],
34
+ seedLocalId: row[3],
35
+ })
36
+ }
37
+
38
+ return versionsData
39
+ }
@@ -0,0 +1,259 @@
1
+ import { ActorRefFrom, assign, createActor, raise, setup } from 'xstate'
2
+ import { createBrowserInspector } from '@statelyai/inspect'
3
+ import {
4
+ GLOBAL_ADDING_MODELS_TO_DB_SUCCESS,
5
+ GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES,
6
+ GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY,
7
+ GLOBAL_INITIALIZING_SEND_CONFIG,
8
+ GlobalState,
9
+ MachineIds,
10
+ } from '@/browser/services/internal/constants'
11
+ import { GlobalMachineContext, ModelClassType } from '@/types'
12
+ import { eventEmitter } from '@/eventBus'
13
+ import { initialize } from '@/browser/services/global/actors/initialize'
14
+ import { getSchemaForModel } from '@/browser/services/global/actors/getSchemaForModel'
15
+ import { addModelsToDb } from '@/browser/services/global/actors/addModelsToDb'
16
+ import { internalMachine } from '@/browser/services/internal/internalMachine'
17
+ import { itemMachineAll } from '@/browser/item/all/itemMachineAll'
18
+ import { publishMachine } from '@/browser/services/publish/publishMachine'
19
+
20
+ const {
21
+ UNINITIALIZED,
22
+ INITIALIZING,
23
+ INITIALIZED,
24
+ PUBLISHING_ITEM,
25
+ ADDING_MODELS_TO_DB,
26
+ } = GlobalState
27
+
28
+ const { inspect } = createBrowserInspector({
29
+ autoStart: false,
30
+ })
31
+
32
+ const globalMachine = setup({
33
+ types: {
34
+ context: {} as GlobalMachineContext,
35
+ input: {} as GlobalMachineContext | undefined,
36
+ },
37
+ actors: {
38
+ initialize,
39
+ addModelsToDb,
40
+ getSchemaForModel,
41
+ },
42
+ }).createMachine({
43
+ id: MachineIds.GLOBAL,
44
+ initial: UNINITIALIZED,
45
+ context: ({ input }) => input as GlobalMachineContext,
46
+ states: {
47
+ [UNINITIALIZED]: {
48
+ on: {
49
+ init: {
50
+ target: INITIALIZING,
51
+ guard: ({ context }) => {
52
+ return typeof window !== 'undefined'
53
+ },
54
+ actions: [
55
+ assign({
56
+ isInitialized: false,
57
+ addedModelRecordsToDb: false,
58
+ models: ({ event }) => event.models,
59
+ endpoints: ({ event }) => event.endpoints,
60
+ internalService: ({ spawn, context }) => {
61
+ return spawn(internalMachine, {
62
+ systemId: MachineIds.INTERNAL,
63
+ input: {
64
+ endpoints: context.endpoints,
65
+ },
66
+ })
67
+ },
68
+ }),
69
+ ],
70
+ },
71
+ },
72
+ meta: {
73
+ displayText: 'Booting up',
74
+ percentComplete: 5,
75
+ },
76
+ tags: ['loading'],
77
+ },
78
+ [INITIALIZING]: {
79
+ on: {
80
+ [GLOBAL_INITIALIZING_SEND_CONFIG]: {
81
+ actions: assign({
82
+ endpoints: ({ event }) => event.endpoints,
83
+ environment: ({ event }) => event.environment,
84
+ addresses: ({ event }) => event.addresses,
85
+ isInitialized: true,
86
+ }),
87
+ },
88
+ [GLOBAL_INITIALIZING_INTERNAL_SERVICE_READY]: ADDING_MODELS_TO_DB,
89
+ [GLOBAL_INITIALIZING_CREATE_ALL_ITEMS_SERVICES]: {
90
+ actions: [
91
+ assign(({ event, spawn }) => {
92
+ const allItemsServices: Record<
93
+ string,
94
+ ActorRefFrom<typeof itemMachineAll>
95
+ > = {}
96
+ for (const [modelName, ModelClass] of Object.entries(
97
+ event.create,
98
+ )) {
99
+ const service = spawn(itemMachineAll, {
100
+ systemId: modelName,
101
+ input: {
102
+ modelName,
103
+ ModelClass,
104
+ modelSchema: (ModelClass as ModelClassType)!.schema,
105
+ items: [],
106
+ },
107
+ })
108
+ allItemsServices[`${modelName}Service`] = service
109
+ }
110
+
111
+ for (const [modelName, snapshot] of Object.entries(
112
+ event.restore,
113
+ )) {
114
+ const service = createActor(itemMachineAll, {
115
+ snapshot,
116
+ })
117
+ service.start()
118
+ allItemsServices[`${modelName}Service`] = service
119
+ }
120
+ return allItemsServices
121
+ }),
122
+ raise({ type: 'allItemsServicesCreated' }),
123
+ ],
124
+ },
125
+ },
126
+ invoke: {
127
+ src: 'initialize',
128
+ input: ({ event, context }) => ({ event, context }),
129
+ meta: {
130
+ displayText: 'Initializing Seed SDK',
131
+ percentComplete: 10,
132
+ },
133
+ tags: ['loading'],
134
+ },
135
+ },
136
+ [ADDING_MODELS_TO_DB]: {
137
+ on: {
138
+ [GLOBAL_ADDING_MODELS_TO_DB_SUCCESS]: {
139
+ target: INITIALIZED,
140
+ actions: assign({
141
+ addedModelRecordsToDb: true,
142
+ }),
143
+ },
144
+ },
145
+ invoke: {
146
+ src: 'addModelsToDb',
147
+ input: ({ context }) => ({ context }),
148
+ meta: {
149
+ displayText: 'Adding models to database',
150
+ },
151
+ tags: ['loading'],
152
+ },
153
+ },
154
+ [INITIALIZED]: {
155
+ type: 'parallel',
156
+ on: {
157
+ publishItemRequest: `.${PUBLISHING_ITEM}`,
158
+ },
159
+ meta: {
160
+ displayText: 'Global service ready',
161
+ percentComplete: 40,
162
+ },
163
+ tags: ['loading'],
164
+ states: {
165
+ [PUBLISHING_ITEM]: {
166
+ entry: [
167
+ assign({
168
+ publishItemService: ({ spawn, event }) =>
169
+ spawn(publishMachine, {
170
+ id: 'publishService',
171
+ input: {
172
+ modelName: event.modelName,
173
+ localId: event.seedLocalId,
174
+ },
175
+ }),
176
+ }),
177
+ ],
178
+ meta: {
179
+ displayText: 'Publishing item',
180
+ },
181
+ tags: ['publishing'],
182
+ },
183
+ },
184
+ },
185
+ },
186
+ // on: {
187
+ // '*': {
188
+ // actions: emit(({ event }) => {
189
+ // return event
190
+ // }),
191
+ // },
192
+ // },
193
+ })
194
+
195
+ const globalService = createActor(globalMachine, {
196
+ input: {},
197
+ // inspect,
198
+ inspect: (inspEvent) => {
199
+ eventEmitter.emit('inspect.globalService', inspEvent)
200
+ // console.log('[sdk] [service/index] inspEvent', inspEvent)
201
+ // eventEmitter.emit('globalService', inspEvent)
202
+ // let eventType: string = inspEvent.type
203
+ // if (inspEvent.event && inspEvent.event.type) {
204
+ // eventType = inspEvent.event.type
205
+ // }
206
+ //
207
+ // if (typeof eventType === 'object') {
208
+ // eventType = JSON.stringify(eventType)
209
+ // }
210
+ //
211
+ // let srcId = inspEvent.actorRef.id
212
+ //
213
+ // if (!srcId.includes('seedSdk')) {
214
+ // srcId = inspEvent.actorRef.logic.config.id
215
+ // }
216
+ //
217
+ // if (inspEvent.type === '@xstate.snapshot') {
218
+ // if (
219
+ // inspEvent.event.type === CHILD_SNAPSHOT &&
220
+ // inspEvent.snapshot &&
221
+ // inspEvent.snapshot.machine.id === MachineIds.GLOBAL
222
+ // ) {
223
+ // return
224
+ // }
225
+ // if (inspEvent.snapshot && inspEvent.snapshot.value) {
226
+ // if (typeof window !== 'undefined') {
227
+ // eventEmitter.emit('globalService', {
228
+ // type: eventType,
229
+ // src: srcId,
230
+ // snapshot: inspEvent.snapshot,
231
+ // })
232
+ // }
233
+ // }
234
+ // } else {
235
+ // if (typeof window !== 'undefined') {
236
+ // let snapshot
237
+ //
238
+ // try {
239
+ // snapshot = inspEvent.actorRef.getSnapshot()
240
+ // } catch (e) {
241
+ // // This fails if the actor hasn't initialized yet, but that's OK I think
242
+ // // console.log('[sdk] [service/index] ERROR', e)
243
+ // }
244
+ //
245
+ // eventEmitter.emit('globalService', {
246
+ // type: eventType,
247
+ // src: srcId,
248
+ // snapshot,
249
+ // })
250
+ // }
251
+ // }
252
+ },
253
+ })
254
+
255
+ globalService.start()
256
+
257
+ const getGlobalService = (): ActorRefFrom<typeof globalMachine> => globalService
258
+
259
+ export { globalMachine, getGlobalService, globalService }
@@ -0,0 +1,113 @@
1
+ /* eslint-disable */
2
+ import * as types from './graphql';
3
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
4
+
5
+ /**
6
+ * Map of all GraphQL operations in the project.
7
+ *
8
+ * This map has several performance disadvantages:
9
+ * 1. It is not tree-shakeable, so it will include all operations in the project.
10
+ * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
11
+ * 3. It does not support dead code elimination, so it will add unused operations.
12
+ *
13
+ * Therefore it is highly recommended to use the babel or swc plugin for production.
14
+ * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
15
+ */
16
+ const documents = {
17
+ "\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n": types.GetTransactionTagsDocument,
18
+ "\n fragment attestationFields on Attestation {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n": types.AttestationFieldsFragmentDoc,
19
+ "\n fragment schemaFields on Schema {\n id\n resolver\n revocable\n schema\n index\n schemaNames {\n name\n }\n time\n txid\n creator\n }\n": types.SchemaFieldsFragmentDoc,
20
+ "\n query GetSchemas($where: SchemaWhereInput!) {\n schemas: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n": types.GetSchemasDocument,
21
+ "\n query GetSeeds($where: AttestationWhereInput!) {\n itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n timeCreated\n isOffchain\n }\n }\n": types.GetSeedsDocument,
22
+ "\n query GetSeedIds($where: AttestationWhereInput!) {\n itemSeedIds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n }\n }\n": types.GetSeedIdsDocument,
23
+ "\n query GetStorageTransactionId($where: AttestationWhereInput!) {\n storageTransactionId: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n id\n decodedDataJson\n }\n }\n": types.GetStorageTransactionIdDocument,
24
+ "\n query GetVersions($where: AttestationWhereInput!) {\n itemVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n": types.GetVersionsDocument,
25
+ "\n query GetProperties($where: AttestationWhereInput!) {\n itemProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n": types.GetPropertiesDocument,
26
+ "\n query GetAllPropertiesForAllVersions($where: AttestationWhereInput!) {\n allProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n": types.GetAllPropertiesForAllVersionsDocument,
27
+ "\n query GetFilesMetadata($where: AttestationWhereInput!) {\n filesMetadata: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n": types.GetFilesMetadataDocument,
28
+ "\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n": types.GetArweaveTransactionsDocument,
29
+ "\n query GetImageSeeds($where: AttestationWhereInput!) {\n imageSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n }\n": types.GetImageSeedsDocument,
30
+ "\n query GetImageVersions($where: AttestationWhereInput!) {\n imageVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n": types.GetImageVersionsDocument,
31
+ "\n query GetSchemaUids($where: SchemaWhereInput!) {\n schemaUids: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n": types.GetSchemaUidsDocument,
32
+ };
33
+
34
+ /**
35
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
36
+ *
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
41
+ * ```
42
+ *
43
+ * The query argument is unknown!
44
+ * Please regenerate the types.
45
+ */
46
+ export function graphql(source: string): unknown;
47
+
48
+ /**
49
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
50
+ */
51
+ export function graphql(source: "\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"): (typeof documents)["\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"];
52
+ /**
53
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
54
+ */
55
+ export function graphql(source: "\n fragment attestationFields on Attestation {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n"): (typeof documents)["\n fragment attestationFields on Attestation {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n"];
56
+ /**
57
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
58
+ */
59
+ export function graphql(source: "\n fragment schemaFields on Schema {\n id\n resolver\n revocable\n schema\n index\n schemaNames {\n name\n }\n time\n txid\n creator\n }\n"): (typeof documents)["\n fragment schemaFields on Schema {\n id\n resolver\n revocable\n schema\n index\n schemaNames {\n name\n }\n time\n txid\n creator\n }\n"];
60
+ /**
61
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
62
+ */
63
+ export function graphql(source: "\n query GetSchemas($where: SchemaWhereInput!) {\n schemas: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n"): (typeof documents)["\n query GetSchemas($where: SchemaWhereInput!) {\n schemas: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n"];
64
+ /**
65
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
66
+ */
67
+ export function graphql(source: "\n query GetSeeds($where: AttestationWhereInput!) {\n itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n timeCreated\n isOffchain\n }\n }\n"): (typeof documents)["\n query GetSeeds($where: AttestationWhereInput!) {\n itemSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n timeCreated\n isOffchain\n }\n }\n"];
68
+ /**
69
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
70
+ */
71
+ export function graphql(source: "\n query GetSeedIds($where: AttestationWhereInput!) {\n itemSeedIds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n }\n }\n"): (typeof documents)["\n query GetSeedIds($where: AttestationWhereInput!) {\n itemSeedIds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n }\n }\n"];
72
+ /**
73
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
74
+ */
75
+ export function graphql(source: "\n query GetStorageTransactionId($where: AttestationWhereInput!) {\n storageTransactionId: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n id\n decodedDataJson\n }\n }\n"): (typeof documents)["\n query GetStorageTransactionId($where: AttestationWhereInput!) {\n storageTransactionId: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n id\n decodedDataJson\n }\n }\n"];
76
+ /**
77
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
78
+ */
79
+ export function graphql(source: "\n query GetVersions($where: AttestationWhereInput!) {\n itemVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"): (typeof documents)["\n query GetVersions($where: AttestationWhereInput!) {\n itemVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"];
80
+ /**
81
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
82
+ */
83
+ export function graphql(source: "\n query GetProperties($where: AttestationWhereInput!) {\n itemProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"): (typeof documents)["\n query GetProperties($where: AttestationWhereInput!) {\n itemProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"];
84
+ /**
85
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
86
+ */
87
+ export function graphql(source: "\n query GetAllPropertiesForAllVersions($where: AttestationWhereInput!) {\n allProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"): (typeof documents)["\n query GetAllPropertiesForAllVersions($where: AttestationWhereInput!) {\n allProperties: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"];
88
+ /**
89
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
90
+ */
91
+ export function graphql(source: "\n query GetFilesMetadata($where: AttestationWhereInput!) {\n filesMetadata: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"): (typeof documents)["\n query GetFilesMetadata($where: AttestationWhereInput!) {\n filesMetadata: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"];
92
+ /**
93
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
94
+ */
95
+ export function graphql(source: "\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"): (typeof documents)["\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"];
96
+ /**
97
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
98
+ */
99
+ export function graphql(source: "\n query GetImageSeeds($where: AttestationWhereInput!) {\n imageSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n }\n"): (typeof documents)["\n query GetImageSeeds($where: AttestationWhereInput!) {\n imageSeeds: attestations(where: $where, orderBy: [{ timeCreated: desc }]) {\n id\n decodedDataJson\n attester\n schema {\n schemaNames {\n name\n }\n }\n refUID\n revoked\n schemaId\n txid\n timeCreated\n time\n isOffchain\n }\n }\n"];
100
+ /**
101
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
102
+ */
103
+ export function graphql(source: "\n query GetImageVersions($where: AttestationWhereInput!) {\n imageVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"): (typeof documents)["\n query GetImageVersions($where: AttestationWhereInput!) {\n imageVersions: attestations(\n where: $where\n orderBy: [{ timeCreated: desc }]\n ) {\n ...attestationFields\n }\n }\n"];
104
+ /**
105
+ * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
106
+ */
107
+ export function graphql(source: "\n query GetSchemaUids($where: SchemaWhereInput!) {\n schemaUids: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n"): (typeof documents)["\n query GetSchemaUids($where: SchemaWhereInput!) {\n schemaUids: schemata(where: $where) {\n id\n schema\n schemaNames {\n name\n }\n }\n }\n"];
108
+
109
+ export function graphql(source: string) {
110
+ return (documents as any)[source] ?? {};
111
+ }
112
+
113
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;