@livestore/livestore 0.3.0-dev.5 → 0.3.0-dev.50
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/.tsbuildinfo +1 -1
- package/dist/QueryCache.d.ts.map +1 -1
- package/dist/SqliteDbWrapper.d.ts +60 -0
- package/dist/SqliteDbWrapper.d.ts.map +1 -0
- package/dist/{SynchronousDatabaseWrapper.js → SqliteDbWrapper.js} +69 -34
- package/dist/SqliteDbWrapper.js.map +1 -0
- package/dist/effect/LiveStore.d.ts +6 -34
- package/dist/effect/LiveStore.d.ts.map +1 -1
- package/dist/effect/LiveStore.js +10 -12
- package/dist/effect/LiveStore.js.map +1 -1
- package/dist/effect/mod.d.ts +3 -0
- package/dist/effect/mod.d.ts.map +1 -0
- package/dist/effect/mod.js +3 -0
- package/dist/effect/mod.js.map +1 -0
- package/dist/internal/mod.d.ts +3 -0
- package/dist/internal/mod.d.ts.map +1 -0
- package/dist/internal/mod.js +3 -0
- package/dist/internal/mod.js.map +1 -0
- package/dist/live-queries/base-class.d.ts +65 -27
- package/dist/live-queries/base-class.d.ts.map +1 -1
- package/dist/live-queries/base-class.js +54 -13
- package/dist/live-queries/base-class.js.map +1 -1
- package/dist/live-queries/client-document-get-query.d.ts +12 -0
- package/dist/live-queries/client-document-get-query.d.ts.map +1 -0
- package/dist/live-queries/client-document-get-query.js +18 -0
- package/dist/live-queries/client-document-get-query.js.map +1 -0
- package/dist/live-queries/computed.d.ts +12 -14
- package/dist/live-queries/computed.d.ts.map +1 -1
- package/dist/live-queries/computed.js +37 -15
- package/dist/live-queries/computed.js.map +1 -1
- package/dist/live-queries/db-query.d.ts +93 -0
- package/dist/live-queries/db-query.d.ts.map +1 -0
- package/dist/live-queries/{db.js → db-query.js} +111 -40
- package/dist/live-queries/db-query.js.map +1 -0
- package/dist/live-queries/db-query.test.d.ts +2 -0
- package/dist/live-queries/db-query.test.d.ts.map +1 -0
- package/dist/live-queries/db-query.test.js +133 -0
- package/dist/live-queries/db-query.test.js.map +1 -0
- package/dist/live-queries/mod.d.ts +5 -0
- package/dist/live-queries/mod.d.ts.map +1 -0
- package/dist/live-queries/mod.js +5 -0
- package/dist/live-queries/mod.js.map +1 -0
- package/dist/live-queries/signal.d.ts +20 -0
- package/dist/live-queries/signal.d.ts.map +1 -0
- package/dist/live-queries/signal.js +33 -0
- package/dist/live-queries/signal.js.map +1 -0
- package/dist/live-queries/signal.test.d.ts +2 -0
- package/dist/live-queries/signal.test.d.ts.map +1 -0
- package/dist/live-queries/signal.test.js +25 -0
- package/dist/live-queries/signal.test.js.map +1 -0
- package/dist/mod.d.ts +14 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +13 -0
- package/dist/mod.js.map +1 -0
- package/dist/reactive.d.ts +23 -17
- package/dist/reactive.d.ts.map +1 -1
- package/dist/reactive.js +23 -19
- package/dist/reactive.js.map +1 -1
- package/dist/reactive.test.js +1 -1
- package/dist/reactive.test.js.map +1 -1
- package/dist/store/create-store.d.ts +70 -12
- package/dist/store/create-store.d.ts.map +1 -1
- package/dist/store/create-store.js +68 -19
- package/dist/store/create-store.js.map +1 -1
- package/dist/store/devtools.d.ts +5 -4
- package/dist/store/devtools.d.ts.map +1 -1
- package/dist/store/devtools.js +92 -40
- package/dist/store/devtools.js.map +1 -1
- package/dist/store/store-types.d.ts +54 -42
- package/dist/store/store-types.d.ts.map +1 -1
- package/dist/store/store-types.js +2 -5
- package/dist/store/store-types.js.map +1 -1
- package/dist/store/store.d.ts +141 -35
- package/dist/store/store.d.ts.map +1 -1
- package/dist/store/store.js +319 -153
- package/dist/store/store.js.map +1 -1
- package/dist/utils/data-structures.d.ts.map +1 -1
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +6 -1
- package/dist/utils/dev.js.map +1 -1
- package/dist/utils/function-string.d.ts +7 -0
- package/dist/utils/function-string.d.ts.map +1 -0
- package/dist/utils/function-string.js +9 -0
- package/dist/utils/function-string.js.map +1 -0
- package/dist/utils/stack-info.d.ts.map +1 -1
- package/dist/utils/stack-info.js +6 -1
- package/dist/utils/stack-info.js.map +1 -1
- package/dist/utils/stack-info.test.js +54 -1
- package/dist/utils/stack-info.test.js.map +1 -1
- package/dist/utils/tests/fixture.d.ts +59 -216
- package/dist/utils/tests/fixture.d.ts.map +1 -1
- package/dist/utils/tests/fixture.js +23 -18
- package/dist/utils/tests/fixture.js.map +1 -1
- package/dist/utils/tests/mod.d.ts +1 -0
- package/dist/utils/tests/mod.d.ts.map +1 -1
- package/dist/utils/tests/mod.js +1 -0
- package/dist/utils/tests/mod.js.map +1 -1
- package/dist/utils/tests/otel.d.ts.map +1 -1
- package/dist/utils/tests/otel.js +8 -3
- package/dist/utils/tests/otel.js.map +1 -1
- package/package.json +29 -26
- package/src/{SynchronousDatabaseWrapper.ts → SqliteDbWrapper.ts} +92 -42
- package/src/effect/LiveStore.ts +27 -64
- package/src/effect/{index.ts → mod.ts} +2 -3
- package/src/internal/mod.ts +2 -0
- package/src/live-queries/__snapshots__/{db.test.ts.snap → db-query.test.ts.snap} +241 -45
- package/src/live-queries/base-class.ts +152 -50
- package/src/live-queries/client-document-get-query.ts +52 -0
- package/src/live-queries/computed.ts +51 -33
- package/src/live-queries/db-query.test.ts +192 -0
- package/src/live-queries/{db.ts → db-query.ts} +168 -81
- package/src/live-queries/mod.ts +4 -0
- package/src/live-queries/signal.test.ts +40 -0
- package/src/live-queries/signal.ts +47 -0
- package/src/mod.ts +42 -0
- package/src/reactive.test.ts +1 -1
- package/src/reactive.ts +66 -43
- package/src/store/create-store.ts +188 -62
- package/src/store/devtools.ts +124 -46
- package/src/store/store-types.ts +54 -43
- package/src/store/store.ts +454 -236
- package/src/utils/dev.ts +6 -1
- package/src/utils/function-string.ts +12 -0
- package/src/utils/stack-info.test.ts +58 -1
- package/src/utils/stack-info.ts +6 -1
- package/src/utils/tests/fixture.ts +22 -31
- package/src/utils/tests/mod.ts +1 -0
- package/src/utils/tests/otel.ts +10 -3
- package/dist/SynchronousDatabaseWrapper.d.ts +0 -41
- package/dist/SynchronousDatabaseWrapper.d.ts.map +0 -1
- package/dist/SynchronousDatabaseWrapper.js.map +0 -1
- package/dist/effect/index.d.ts +0 -2
- package/dist/effect/index.d.ts.map +0 -1
- package/dist/effect/index.js +0 -2
- package/dist/effect/index.js.map +0 -1
- package/dist/global-state.d.ts +0 -14
- package/dist/global-state.d.ts.map +0 -1
- package/dist/global-state.js +0 -16
- package/dist/global-state.js.map +0 -1
- package/dist/index.d.ts +0 -20
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +0 -1
- package/dist/live-queries/db.d.ts +0 -66
- package/dist/live-queries/db.d.ts.map +0 -1
- package/dist/live-queries/db.js.map +0 -1
- package/dist/live-queries/db.test.d.ts +0 -2
- package/dist/live-queries/db.test.d.ts.map +0 -1
- package/dist/live-queries/db.test.js +0 -118
- package/dist/live-queries/db.test.js.map +0 -1
- package/dist/live-queries/graphql.d.ts +0 -49
- package/dist/live-queries/graphql.d.ts.map +0 -1
- package/dist/live-queries/graphql.js +0 -122
- package/dist/live-queries/graphql.js.map +0 -1
- package/dist/row-query-utils.d.ts +0 -17
- package/dist/row-query-utils.d.ts.map +0 -1
- package/dist/row-query-utils.js +0 -30
- package/dist/row-query-utils.js.map +0 -1
- package/dist/utils/otel.d.ts +0 -4
- package/dist/utils/otel.d.ts.map +0 -1
- package/dist/utils/otel.js +0 -6
- package/dist/utils/otel.js.map +0 -1
- package/src/global-state.ts +0 -20
- package/src/index.ts +0 -66
- package/src/live-queries/db.test.ts +0 -154
- package/src/live-queries/graphql.ts +0 -219
- package/src/row-query-utils.ts +0 -65
- package/src/utils/otel.ts +0 -9
- package/tsconfig.json +0 -18
- package/vitest.config.js +0 -9
@@ -1,219 +0,0 @@
|
|
1
|
-
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
|
2
|
-
import type { QueryInfo } from '@livestore/common'
|
3
|
-
import { shouldNeverHappen } from '@livestore/utils'
|
4
|
-
import { Schema, TreeFormatter } from '@livestore/utils/effect'
|
5
|
-
import * as otel from '@opentelemetry/api'
|
6
|
-
import * as graphql from 'graphql'
|
7
|
-
|
8
|
-
import { globalReactivityGraph } from '../global-state.js'
|
9
|
-
import { isThunk, type Thunk } from '../reactive.js'
|
10
|
-
import type { Store } from '../store/store.js'
|
11
|
-
import type { BaseGraphQLContext, RefreshReason } from '../store/store-types.js'
|
12
|
-
import { getDurationMsFromSpan } from '../utils/otel.js'
|
13
|
-
import type { GetAtomResult, LiveQuery, QueryContext, ReactivityGraph } from './base-class.js'
|
14
|
-
import { LiveStoreQueryBase, makeGetAtomResult } from './base-class.js'
|
15
|
-
|
16
|
-
export type MapResult<To, From> = ((res: From, get: GetAtomResult) => To) | Schema.Schema<To, From>
|
17
|
-
|
18
|
-
export const queryGraphQL = <
|
19
|
-
TResult extends Record<string, any>,
|
20
|
-
TVariableValues extends Record<string, any>,
|
21
|
-
TResultMapped extends Record<string, any> = TResult,
|
22
|
-
>(
|
23
|
-
document: DocumentNode<TResult, TVariableValues>,
|
24
|
-
genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues),
|
25
|
-
{
|
26
|
-
label,
|
27
|
-
reactivityGraph,
|
28
|
-
map,
|
29
|
-
}: {
|
30
|
-
label?: string
|
31
|
-
reactivityGraph?: ReactivityGraph
|
32
|
-
map?: MapResult<TResultMapped, TResult>
|
33
|
-
} = {},
|
34
|
-
): LiveQuery<TResultMapped, QueryInfo.None> =>
|
35
|
-
new LiveStoreGraphQLQuery({ document, genVariableValues, label, reactivityGraph, map })
|
36
|
-
|
37
|
-
export class LiveStoreGraphQLQuery<
|
38
|
-
TResult extends Record<string, any>,
|
39
|
-
TVariableValues extends Record<string, any>,
|
40
|
-
TContext extends BaseGraphQLContext,
|
41
|
-
TResultMapped extends Record<string, any> = TResult,
|
42
|
-
> extends LiveStoreQueryBase<TResultMapped, QueryInfo.None> {
|
43
|
-
_tag: 'graphql' = 'graphql'
|
44
|
-
|
45
|
-
/** The abstract GraphQL query */
|
46
|
-
document: DocumentNode<TResult, TVariableValues>
|
47
|
-
|
48
|
-
/** A reactive thunk representing the query results */
|
49
|
-
results$: Thunk<TResultMapped, QueryContext, RefreshReason>
|
50
|
-
|
51
|
-
variableValues$: Thunk<TVariableValues, QueryContext, RefreshReason> | undefined
|
52
|
-
|
53
|
-
label: string
|
54
|
-
|
55
|
-
protected reactivityGraph: ReactivityGraph
|
56
|
-
|
57
|
-
queryInfo: QueryInfo.None = { _tag: 'None' }
|
58
|
-
|
59
|
-
private mapResult
|
60
|
-
|
61
|
-
constructor({
|
62
|
-
document,
|
63
|
-
label,
|
64
|
-
genVariableValues,
|
65
|
-
reactivityGraph,
|
66
|
-
map,
|
67
|
-
}: {
|
68
|
-
document: DocumentNode<TResult, TVariableValues>
|
69
|
-
genVariableValues: TVariableValues | ((get: GetAtomResult) => TVariableValues)
|
70
|
-
label?: string
|
71
|
-
reactivityGraph?: ReactivityGraph
|
72
|
-
map?: MapResult<TResultMapped, TResult>
|
73
|
-
}) {
|
74
|
-
super()
|
75
|
-
|
76
|
-
const labelWithDefault = label ?? graphql.getOperationAST(document)?.name?.value ?? 'graphql'
|
77
|
-
|
78
|
-
this.label = labelWithDefault
|
79
|
-
this.document = document
|
80
|
-
|
81
|
-
this.reactivityGraph = reactivityGraph ?? globalReactivityGraph
|
82
|
-
|
83
|
-
this.mapResult =
|
84
|
-
map === undefined
|
85
|
-
? (res: TResult) => res as any as TResultMapped
|
86
|
-
: Schema.isSchema(map)
|
87
|
-
? (res: TResult) => {
|
88
|
-
const parseResult = Schema.decodeEither(map as Schema.Schema<TResultMapped, TResult>)(res)
|
89
|
-
if (parseResult._tag === 'Left') {
|
90
|
-
console.error(`Error parsing GraphQL query result: ${TreeFormatter.formatErrorSync(parseResult.left)}`)
|
91
|
-
return shouldNeverHappen(`Error parsing SQL query result: ${parseResult.left}`)
|
92
|
-
} else {
|
93
|
-
return parseResult.right as TResultMapped
|
94
|
-
}
|
95
|
-
}
|
96
|
-
: typeof map === 'function'
|
97
|
-
? map
|
98
|
-
: shouldNeverHappen(`Invalid map function ${map}`)
|
99
|
-
|
100
|
-
// TODO don't even create a thunk if variables are static
|
101
|
-
let variableValues$OrvariableValues
|
102
|
-
|
103
|
-
if (typeof genVariableValues === 'function') {
|
104
|
-
variableValues$OrvariableValues = this.reactivityGraph.makeThunk(
|
105
|
-
(get, _setDebugInfo, { rootOtelContext }, otelContext) => {
|
106
|
-
return genVariableValues(makeGetAtomResult(get, otelContext ?? rootOtelContext))
|
107
|
-
},
|
108
|
-
{ label: `${labelWithDefault}:variableValues`, meta: { liveStoreThunkType: 'graphql.variables' } },
|
109
|
-
)
|
110
|
-
this.variableValues$ = variableValues$OrvariableValues
|
111
|
-
} else {
|
112
|
-
variableValues$OrvariableValues = genVariableValues
|
113
|
-
}
|
114
|
-
|
115
|
-
const resultsLabel = `${labelWithDefault}:results`
|
116
|
-
this.results$ = this.reactivityGraph.makeThunk<TResultMapped>(
|
117
|
-
(get, setDebugInfo, { store, otelTracer, rootOtelContext }, otelContext) => {
|
118
|
-
const variableValues = isThunk(variableValues$OrvariableValues)
|
119
|
-
? (get(variableValues$OrvariableValues) as TVariableValues)
|
120
|
-
: (variableValues$OrvariableValues as TVariableValues)
|
121
|
-
const { result, queriedTables, durationMs } = this.queryOnce({
|
122
|
-
document,
|
123
|
-
variableValues,
|
124
|
-
otelContext: otelContext ?? rootOtelContext,
|
125
|
-
otelTracer,
|
126
|
-
store: store as Store<TContext>,
|
127
|
-
get: makeGetAtomResult(get, otelContext ?? rootOtelContext),
|
128
|
-
})
|
129
|
-
|
130
|
-
// Add dependencies on any tables that were used
|
131
|
-
for (const tableName of queriedTables) {
|
132
|
-
const tableRef = store.tableRefs[tableName] ?? shouldNeverHappen(`No table ref found for ${tableName}`)
|
133
|
-
get(tableRef)
|
134
|
-
}
|
135
|
-
|
136
|
-
setDebugInfo({ _tag: 'graphql', label: resultsLabel, query: graphql.print(document), durationMs })
|
137
|
-
|
138
|
-
return result
|
139
|
-
},
|
140
|
-
{ label: resultsLabel, meta: { liveStoreThunkType: 'graphql.result' } },
|
141
|
-
// otelContext,
|
142
|
-
)
|
143
|
-
}
|
144
|
-
|
145
|
-
queryOnce = ({
|
146
|
-
document,
|
147
|
-
otelContext,
|
148
|
-
otelTracer,
|
149
|
-
variableValues,
|
150
|
-
store,
|
151
|
-
get,
|
152
|
-
}: {
|
153
|
-
document: graphql.DocumentNode
|
154
|
-
otelContext: otel.Context
|
155
|
-
otelTracer: otel.Tracer
|
156
|
-
variableValues: TVariableValues
|
157
|
-
store: Store<TContext>
|
158
|
-
get: GetAtomResult
|
159
|
-
}) => {
|
160
|
-
const schema =
|
161
|
-
store.graphQLSchema ?? shouldNeverHappen("Can't run a GraphQL query on a store without GraphQL schema")
|
162
|
-
const context =
|
163
|
-
store.graphQLContext ?? shouldNeverHappen("Can't run a GraphQL query on a store without GraphQL context")
|
164
|
-
|
165
|
-
const operationName = graphql.getOperationAST(document)?.name?.value
|
166
|
-
|
167
|
-
return otelTracer.startActiveSpan(`executeGraphQLQuery: ${operationName}`, {}, otelContext, (span) => {
|
168
|
-
span.setAttribute('graphql.variables', JSON.stringify(variableValues))
|
169
|
-
span.setAttribute('graphql.query', graphql.print(document))
|
170
|
-
|
171
|
-
context.queriedTables.clear()
|
172
|
-
|
173
|
-
context.otelContext = otel.trace.setSpan(otel.context.active(), span)
|
174
|
-
|
175
|
-
const res = graphql.executeSync({
|
176
|
-
document,
|
177
|
-
contextValue: context,
|
178
|
-
schema: schema,
|
179
|
-
variableValues,
|
180
|
-
})
|
181
|
-
|
182
|
-
// TODO track number of nested SQL queries via Otel + debug info
|
183
|
-
|
184
|
-
if (res.errors) {
|
185
|
-
span.setStatus({ code: otel.SpanStatusCode.ERROR, message: 'GraphQL error' })
|
186
|
-
span.setAttribute('graphql.error', res.errors.join('\n'))
|
187
|
-
span.setAttribute('graphql.error-detail', JSON.stringify(res.errors))
|
188
|
-
console.error(`graphql error (${operationName}) - ${res.errors.length} errors`)
|
189
|
-
for (const error of res.errors) {
|
190
|
-
console.error(error)
|
191
|
-
}
|
192
|
-
debugger
|
193
|
-
shouldNeverHappen(`GraphQL error: ${res.errors.join('\n')}`)
|
194
|
-
}
|
195
|
-
|
196
|
-
span.end()
|
197
|
-
|
198
|
-
const result = this.mapResult(res.data as unknown as TResult, get)
|
199
|
-
|
200
|
-
const durationMs = getDurationMsFromSpan(span)
|
201
|
-
|
202
|
-
this.executionTimes.push(durationMs)
|
203
|
-
|
204
|
-
return {
|
205
|
-
result,
|
206
|
-
queriedTables: Array.from(context.queriedTables.values()),
|
207
|
-
durationMs,
|
208
|
-
}
|
209
|
-
})
|
210
|
-
}
|
211
|
-
|
212
|
-
destroy = () => {
|
213
|
-
if (this.variableValues$ !== undefined) {
|
214
|
-
this.reactivityGraph.destroyNode(this.variableValues$)
|
215
|
-
}
|
216
|
-
|
217
|
-
this.reactivityGraph.destroyNode(this.results$)
|
218
|
-
}
|
219
|
-
}
|
package/src/row-query-utils.ts
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
import type { PreparedBindValues, QueryInfo } from '@livestore/common'
|
2
|
-
import { SessionIdSymbol } from '@livestore/common'
|
3
|
-
import { DbSchema } from '@livestore/common/schema'
|
4
|
-
import { shouldNeverHappen } from '@livestore/utils'
|
5
|
-
import type * as otel from '@opentelemetry/api'
|
6
|
-
|
7
|
-
import type { LiveQuery, LiveQueryAny, QueryContext } from './live-queries/base-class.js'
|
8
|
-
import { computed } from './live-queries/computed.js'
|
9
|
-
|
10
|
-
export const rowQueryLabel = (table: DbSchema.TableDefBase, id: string | SessionIdSymbol | undefined) =>
|
11
|
-
`row:${table.sqliteDef.name}${id === undefined ? '' : id === SessionIdSymbol ? `:sessionId` : `:${id}`}`
|
12
|
-
|
13
|
-
export const deriveColQuery: {
|
14
|
-
<TQuery extends LiveQuery<any, QueryInfo.None>, TCol extends keyof TQuery['__result!'] & string>(
|
15
|
-
query$: TQuery,
|
16
|
-
colName: TCol,
|
17
|
-
): LiveQuery<TQuery['__result!'][TCol], QueryInfo.None>
|
18
|
-
<TQuery extends LiveQuery<any, QueryInfo.Row>, TCol extends keyof TQuery['__result!'] & string>(
|
19
|
-
query$: TQuery,
|
20
|
-
colName: TCol,
|
21
|
-
): LiveQuery<TQuery['__result!'][TCol], QueryInfo.Col>
|
22
|
-
} = (query$: LiveQueryAny, colName: string) => {
|
23
|
-
return computed((get) => get(query$)[colName], {
|
24
|
-
label: `deriveColQuery:${query$.label}:${colName}`,
|
25
|
-
queryInfo:
|
26
|
-
query$.queryInfo._tag === 'Row'
|
27
|
-
? { _tag: 'Col', table: query$.queryInfo.table, column: colName, id: query$.queryInfo.id }
|
28
|
-
: undefined,
|
29
|
-
}) as any
|
30
|
-
}
|
31
|
-
|
32
|
-
export const makeExecBeforeFirstRun =
|
33
|
-
({
|
34
|
-
id,
|
35
|
-
insertValues,
|
36
|
-
table,
|
37
|
-
otelContext: otelContext_,
|
38
|
-
}: {
|
39
|
-
id?: string | SessionIdSymbol
|
40
|
-
insertValues?: any
|
41
|
-
table: DbSchema.TableDefBase
|
42
|
-
otelContext: otel.Context | undefined
|
43
|
-
}) =>
|
44
|
-
({ store }: QueryContext) => {
|
45
|
-
const otelContext = otelContext_ ?? store.otel.queriesSpanContext
|
46
|
-
|
47
|
-
if (table.options.isSingleton === false) {
|
48
|
-
const idStr = id === SessionIdSymbol ? store.sessionId : id!
|
49
|
-
const rowExists =
|
50
|
-
store.syncDbWrapper.select(`SELECT 1 FROM '${table.sqliteDef.name}' WHERE id = ?`, {
|
51
|
-
bindValues: [idStr] as any as PreparedBindValues,
|
52
|
-
}).length === 1
|
53
|
-
|
54
|
-
if (rowExists) return
|
55
|
-
|
56
|
-
if (DbSchema.tableHasDerivedMutations(table) === false) {
|
57
|
-
return shouldNeverHappen(
|
58
|
-
`Cannot insert row for table "${table.sqliteDef.name}" which does not have 'deriveMutations: true' set`,
|
59
|
-
)
|
60
|
-
}
|
61
|
-
|
62
|
-
// NOTE It's important that we only mutate and don't refresh here, as this function is called during a render
|
63
|
-
store.mutate({ otelContext, skipRefresh: true }, table.insert({ id, ...insertValues }))
|
64
|
-
}
|
65
|
-
}
|
package/src/utils/otel.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import type * as otel from '@opentelemetry/api'
|
2
|
-
|
3
|
-
export const getDurationMsFromSpan = (span: otel.Span): number => {
|
4
|
-
const durationHr: [seconds: number, nanos: number] = (span as any)._duration
|
5
|
-
return durationHr[0] * 1000 + durationHr[1] / 1_000_000
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getStartTimeHighResFromSpan = (span: otel.Span): DOMHighResTimeStamp =>
|
9
|
-
(span as any)._performanceStartTime as DOMHighResTimeStamp
|
package/tsconfig.json
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": "../../../tsconfig.base.json",
|
3
|
-
"compilerOptions": {
|
4
|
-
"outDir": "./dist",
|
5
|
-
"rootDir": "./src",
|
6
|
-
"skipLibCheck": true,
|
7
|
-
"resolveJsonModule": true,
|
8
|
-
// "jsx": "preserve",
|
9
|
-
"tsBuildInfoFile": "./dist/.tsbuildinfo"
|
10
|
-
},
|
11
|
-
"include": ["./src"],
|
12
|
-
"references": [
|
13
|
-
{ "path": "../db-schema" },
|
14
|
-
{ "path": "../common" },
|
15
|
-
{ "path": "../web" },
|
16
|
-
{ "path": "../utils" }
|
17
|
-
]
|
18
|
-
}
|