@reactionary/core 0.0.30 → 0.0.32
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/index.js +199 -329
- package/package.json +2 -2
- package/src/cache/cache-evaluation.interface.d.ts +17 -0
- package/src/cache/cache.interface.d.ts +36 -0
- package/src/cache/noop-cache.d.ts +18 -0
- package/src/cache/redis-cache.d.ts +13 -9
- package/src/client/client-builder.d.ts +14 -0
- package/src/client/client.d.ts +6 -1
- package/src/decorators/trpc.decorators.d.ts +88 -0
- package/src/index.d.ts +5 -1
- package/src/providers/analytics.provider.d.ts +1 -3
- package/src/providers/base.provider.d.ts +7 -28
- package/src/providers/cart.provider.d.ts +8 -3
- package/src/providers/identity.provider.d.ts +7 -3
- package/src/providers/inventory.provider.d.ts +3 -2
- package/src/providers/price.provider.d.ts +4 -3
- package/src/providers/product.provider.d.ts +5 -3
- package/src/providers/search.provider.d.ts +4 -3
- package/src/schemas/mutations/analytics.mutation.d.ts +4 -12
- package/src/schemas/mutations/base.mutation.d.ts +1 -3
- package/src/schemas/mutations/cart.mutation.d.ts +3 -94
- package/src/schemas/mutations/identity.mutation.d.ts +3 -38
- package/src/schemas/queries/base.query.d.ts +1 -3
- package/src/schemas/queries/cart.query.d.ts +2 -9
- package/src/schemas/queries/identity.query.d.ts +2 -20
- package/src/schemas/queries/inventory.query.d.ts +1 -4
- package/src/schemas/queries/price.query.d.ts +1 -25
- package/src/schemas/queries/product.query.d.ts +2 -36
- package/src/schemas/queries/search.query.d.ts +1 -41
- package/src/cache/caching-strategy.d.ts +0 -13
package/index.js
CHANGED
|
@@ -1,47 +1,95 @@
|
|
|
1
|
-
// core/src/cache/caching-strategy.ts
|
|
2
|
-
var BaseCachingStrategy = class {
|
|
3
|
-
get(query, session) {
|
|
4
|
-
const q = query;
|
|
5
|
-
return {
|
|
6
|
-
key: q.sku,
|
|
7
|
-
cacheDurationInSeconds: 300,
|
|
8
|
-
canCache: true
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
1
|
// core/src/cache/redis-cache.ts
|
|
14
2
|
import { Redis } from "@upstash/redis";
|
|
15
3
|
var RedisCache = class {
|
|
16
|
-
constructor(
|
|
17
|
-
this.strategy = strategy;
|
|
4
|
+
constructor() {
|
|
18
5
|
this.redis = Redis.fromEnv();
|
|
19
6
|
}
|
|
20
|
-
async get(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
7
|
+
async get(key, schema) {
|
|
8
|
+
if (!key) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const unvalidated = await this.redis.get(key);
|
|
12
|
+
const parsed = schema.safeParse(unvalidated);
|
|
13
|
+
if (parsed.success) {
|
|
14
|
+
return parsed.data;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
async put(key, value, ttlSeconds) {
|
|
19
|
+
if (!key) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const options = ttlSeconds ? { ex: ttlSeconds } : void 0;
|
|
23
|
+
await this.redis.set(key, value, options);
|
|
24
|
+
}
|
|
25
|
+
async del(keys) {
|
|
26
|
+
const keyArray = Array.isArray(keys) ? keys : [keys];
|
|
27
|
+
for (const key of keyArray) {
|
|
28
|
+
if (key.includes("*")) {
|
|
29
|
+
const matchingKeys = await this.redis.keys(key);
|
|
30
|
+
if (matchingKeys.length > 0) {
|
|
31
|
+
await this.redis.del(...matchingKeys);
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
await this.redis.del(key);
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
|
-
return result;
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
async keys(pattern) {
|
|
39
|
+
return await this.redis.keys(pattern);
|
|
40
|
+
}
|
|
41
|
+
async clear(pattern) {
|
|
42
|
+
const searchPattern = pattern || "*";
|
|
43
|
+
const keys = await this.redis.keys(searchPattern);
|
|
44
|
+
if (keys.length > 0) {
|
|
45
|
+
await this.redis.del(...keys);
|
|
36
46
|
}
|
|
37
47
|
}
|
|
48
|
+
async getStats() {
|
|
49
|
+
const keys = await this.redis.keys("*");
|
|
50
|
+
return {
|
|
51
|
+
hits: 0,
|
|
52
|
+
// Would need to track this separately
|
|
53
|
+
misses: 0,
|
|
54
|
+
// Would need to track this separately
|
|
55
|
+
size: keys.length
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// core/src/cache/noop-cache.ts
|
|
61
|
+
var NoOpCache = class {
|
|
62
|
+
async get(_key, _schema) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
async put(_key, _value, _ttlSeconds) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
async del(_keys) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
async keys(_pattern) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
async clear(_pattern) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
async getStats() {
|
|
78
|
+
return {
|
|
79
|
+
hits: 0,
|
|
80
|
+
misses: 0,
|
|
81
|
+
size: 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
38
84
|
};
|
|
39
85
|
|
|
40
86
|
// core/src/client/client.ts
|
|
41
|
-
function buildClient(
|
|
87
|
+
function buildClient(providerFactories, options = {}) {
|
|
42
88
|
let client = {};
|
|
89
|
+
const sharedCache = options.cache || new RedisCache();
|
|
43
90
|
const mergedAnalytics = [];
|
|
44
|
-
for (const
|
|
91
|
+
for (const factory of providerFactories) {
|
|
92
|
+
const provider = factory(sharedCache);
|
|
45
93
|
client = {
|
|
46
94
|
...client,
|
|
47
95
|
...provider
|
|
@@ -51,247 +99,119 @@ function buildClient(providers) {
|
|
|
51
99
|
}
|
|
52
100
|
}
|
|
53
101
|
client.analytics = mergedAnalytics;
|
|
54
|
-
|
|
102
|
+
const completeClient = {
|
|
103
|
+
...client,
|
|
104
|
+
cache: sharedCache
|
|
105
|
+
};
|
|
106
|
+
return completeClient;
|
|
55
107
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
import { TRPCError } from "@trpc/server";
|
|
59
|
-
import {
|
|
60
|
-
SpanKind as SpanKind2,
|
|
61
|
-
SpanStatusCode as SpanStatusCode3
|
|
62
|
-
} from "@opentelemetry/api";
|
|
63
|
-
|
|
64
|
-
// otel/src/tracer.ts
|
|
65
|
-
import {
|
|
66
|
-
trace,
|
|
67
|
-
SpanStatusCode,
|
|
68
|
-
context as otelContext
|
|
69
|
-
} from "@opentelemetry/api";
|
|
70
|
-
|
|
71
|
-
// otel/src/sdk.ts
|
|
72
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
73
|
-
var sdk = null;
|
|
74
|
-
var isInitialized = false;
|
|
75
|
-
var initializationPromise = null;
|
|
76
|
-
function isBrowser() {
|
|
77
|
-
return typeof window !== "undefined" && typeof process === "undefined";
|
|
108
|
+
function createCache() {
|
|
109
|
+
return new RedisCache();
|
|
78
110
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
isInitialized = true;
|
|
85
|
-
return;
|
|
111
|
+
|
|
112
|
+
// core/src/client/client-builder.ts
|
|
113
|
+
var ClientBuilder = class _ClientBuilder {
|
|
114
|
+
constructor() {
|
|
115
|
+
this.factories = [];
|
|
86
116
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
await shutdownOtel();
|
|
94
|
-
if (process.env["OTEL_LOG_LEVEL"] === "debug") {
|
|
95
|
-
console.log("OpenTelemetry terminated successfully");
|
|
96
|
-
}
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("Error terminating OpenTelemetry", error);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async function shutdownOtel() {
|
|
104
|
-
if (sdk) {
|
|
105
|
-
await sdk.shutdown();
|
|
106
|
-
sdk = null;
|
|
107
|
-
isInitialized = false;
|
|
117
|
+
withCapability(factory) {
|
|
118
|
+
const newBuilder = new _ClientBuilder();
|
|
119
|
+
newBuilder.factories = [...this.factories, factory];
|
|
120
|
+
newBuilder.cache = this.cache;
|
|
121
|
+
return newBuilder;
|
|
108
122
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// otel/src/tracer.ts
|
|
116
|
-
import { SpanKind, SpanStatusCode as SpanStatusCode2 } from "@opentelemetry/api";
|
|
117
|
-
var TRACER_NAME = "@reactionary/otel";
|
|
118
|
-
var TRACER_VERSION = "0.0.1";
|
|
119
|
-
var globalTracer = null;
|
|
120
|
-
function getTracer() {
|
|
121
|
-
if (!globalTracer) {
|
|
122
|
-
isOtelInitialized();
|
|
123
|
-
globalTracer = trace.getTracer(TRACER_NAME, TRACER_VERSION);
|
|
123
|
+
withCache(cache) {
|
|
124
|
+
const newBuilder = new _ClientBuilder();
|
|
125
|
+
newBuilder.factories = [...this.factories];
|
|
126
|
+
newBuilder.cache = cache;
|
|
127
|
+
return newBuilder;
|
|
124
128
|
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
message: error instanceof Error ? error.message : String(error)
|
|
138
|
-
});
|
|
139
|
-
if (error instanceof Error) {
|
|
140
|
-
span.recordException(error);
|
|
129
|
+
build() {
|
|
130
|
+
let client = {};
|
|
131
|
+
const sharedCache = this.cache || new NoOpCache();
|
|
132
|
+
const mergedAnalytics = [];
|
|
133
|
+
for (const factory of this.factories) {
|
|
134
|
+
const provider = factory(sharedCache);
|
|
135
|
+
client = {
|
|
136
|
+
...client,
|
|
137
|
+
...provider
|
|
138
|
+
};
|
|
139
|
+
if (provider.analytics) {
|
|
140
|
+
mergedAnalytics.push(...provider.analytics);
|
|
141
141
|
}
|
|
142
|
-
throw error;
|
|
143
|
-
} finally {
|
|
144
|
-
span.end();
|
|
145
142
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
function setSpanAttributes(span, attributes) {
|
|
149
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
150
|
-
if (value !== void 0 && value !== null) {
|
|
151
|
-
span.setAttribute(key, value);
|
|
143
|
+
if (mergedAnalytics.length > 0) {
|
|
144
|
+
client["analytics"] = mergedAnalytics;
|
|
152
145
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
var METER_NAME = "@reactionary/otel";
|
|
159
|
-
var METER_VERSION = "0.0.1";
|
|
160
|
-
var globalMeter = null;
|
|
161
|
-
function getMeter() {
|
|
162
|
-
if (!globalMeter) {
|
|
163
|
-
isOtelInitialized();
|
|
164
|
-
globalMeter = metrics.getMeter(METER_NAME, METER_VERSION);
|
|
146
|
+
const completeClient = {
|
|
147
|
+
...client,
|
|
148
|
+
cache: sharedCache
|
|
149
|
+
};
|
|
150
|
+
return completeClient;
|
|
165
151
|
}
|
|
166
|
-
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// core/src/decorators/trpc.decorators.ts
|
|
155
|
+
import "reflect-metadata";
|
|
156
|
+
var TRPC_QUERY_METADATA_KEY = Symbol("trpc:query");
|
|
157
|
+
var TRPC_MUTATION_METADATA_KEY = Symbol("trpc:mutation");
|
|
158
|
+
function trpcQuery(options = {}) {
|
|
159
|
+
return function(target, propertyKey, descriptor) {
|
|
160
|
+
const metadata = {
|
|
161
|
+
methodName: String(propertyKey),
|
|
162
|
+
isQuery: true,
|
|
163
|
+
isMutation: false,
|
|
164
|
+
options
|
|
165
|
+
};
|
|
166
|
+
Reflect.defineMetadata(TRPC_QUERY_METADATA_KEY, metadata, target, propertyKey);
|
|
167
|
+
const existingMethods = Reflect.getMetadata(TRPC_QUERY_METADATA_KEY, target.constructor) || [];
|
|
168
|
+
existingMethods.push({ propertyKey, metadata });
|
|
169
|
+
Reflect.defineMetadata(TRPC_QUERY_METADATA_KEY, existingMethods, target.constructor);
|
|
170
|
+
};
|
|
167
171
|
}
|
|
168
|
-
|
|
169
|
-
function
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
unit: "ms"
|
|
181
|
-
}),
|
|
182
|
-
activeRequests: meter.createUpDownCounter("reactionary.requests.active", {
|
|
183
|
-
description: "Number of active requests"
|
|
184
|
-
}),
|
|
185
|
-
errorCounter: meter.createCounter("reactionary.errors", {
|
|
186
|
-
description: "Total number of errors"
|
|
187
|
-
}),
|
|
188
|
-
providerCallCounter: meter.createCounter("reactionary.provider.calls", {
|
|
189
|
-
description: "Total number of provider calls"
|
|
190
|
-
}),
|
|
191
|
-
providerCallDuration: meter.createHistogram("reactionary.provider.duration", {
|
|
192
|
-
description: "Provider call duration in milliseconds",
|
|
193
|
-
unit: "ms"
|
|
194
|
-
}),
|
|
195
|
-
cacheHitCounter: meter.createCounter("reactionary.cache.hits", {
|
|
196
|
-
description: "Total number of cache hits"
|
|
197
|
-
}),
|
|
198
|
-
cacheMissCounter: meter.createCounter("reactionary.cache.misses", {
|
|
199
|
-
description: "Total number of cache misses"
|
|
200
|
-
})
|
|
172
|
+
function trpcMutation(options = {}) {
|
|
173
|
+
return function(target, propertyKey, descriptor) {
|
|
174
|
+
const metadata = {
|
|
175
|
+
methodName: String(propertyKey),
|
|
176
|
+
isQuery: false,
|
|
177
|
+
isMutation: true,
|
|
178
|
+
options
|
|
179
|
+
};
|
|
180
|
+
Reflect.defineMetadata(TRPC_MUTATION_METADATA_KEY, metadata, target, propertyKey);
|
|
181
|
+
const existingMethods = Reflect.getMetadata(TRPC_MUTATION_METADATA_KEY, target.constructor) || [];
|
|
182
|
+
existingMethods.push({ propertyKey, metadata });
|
|
183
|
+
Reflect.defineMetadata(TRPC_MUTATION_METADATA_KEY, existingMethods, target.constructor);
|
|
201
184
|
};
|
|
202
|
-
return metricsInstance;
|
|
203
185
|
}
|
|
204
|
-
function
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
return metricsInstance;
|
|
186
|
+
function getTRPCQueryMethods(target) {
|
|
187
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
188
|
+
return Reflect.getMetadata(TRPC_QUERY_METADATA_KEY, constructor) || [];
|
|
209
189
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
async function withProviderSpan(options, fn) {
|
|
214
|
-
const { providerName, operationType, operationName, attributes = {} } = options;
|
|
215
|
-
const metrics2 = getMetrics();
|
|
216
|
-
const spanName = `provider.${providerName}.${operationType}${operationName ? `.${operationName}` : ""}`;
|
|
217
|
-
const startTime = Date.now();
|
|
218
|
-
metrics2.providerCallCounter.add(1, {
|
|
219
|
-
"provider.name": providerName,
|
|
220
|
-
"provider.operation.type": operationType,
|
|
221
|
-
"provider.operation.name": operationName || "unknown"
|
|
222
|
-
});
|
|
223
|
-
return withSpan(
|
|
224
|
-
spanName,
|
|
225
|
-
async (span) => {
|
|
226
|
-
setSpanAttributes(span, {
|
|
227
|
-
"provider.name": providerName,
|
|
228
|
-
"provider.operation.type": operationType,
|
|
229
|
-
"provider.operation.name": operationName,
|
|
230
|
-
...attributes
|
|
231
|
-
});
|
|
232
|
-
try {
|
|
233
|
-
const result = await fn(span);
|
|
234
|
-
const duration = Date.now() - startTime;
|
|
235
|
-
metrics2.providerCallDuration.record(duration, {
|
|
236
|
-
"provider.name": providerName,
|
|
237
|
-
"provider.operation.type": operationType,
|
|
238
|
-
"provider.operation.name": operationName || "unknown",
|
|
239
|
-
"status": "success"
|
|
240
|
-
});
|
|
241
|
-
return result;
|
|
242
|
-
} catch (error) {
|
|
243
|
-
const duration = Date.now() - startTime;
|
|
244
|
-
metrics2.providerCallDuration.record(duration, {
|
|
245
|
-
"provider.name": providerName,
|
|
246
|
-
"provider.operation.type": operationType,
|
|
247
|
-
"provider.operation.name": operationName || "unknown",
|
|
248
|
-
"status": "error"
|
|
249
|
-
});
|
|
250
|
-
metrics2.errorCounter.add(1, {
|
|
251
|
-
"provider.name": providerName,
|
|
252
|
-
"provider.operation.type": operationType,
|
|
253
|
-
"provider.operation.name": operationName || "unknown"
|
|
254
|
-
});
|
|
255
|
-
throw error;
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
{ kind: SpanKind3.CLIENT }
|
|
259
|
-
);
|
|
190
|
+
function getTRPCMutationMethods(target) {
|
|
191
|
+
const constructor = typeof target === "function" ? target : target.constructor;
|
|
192
|
+
return Reflect.getMetadata(TRPC_MUTATION_METADATA_KEY, constructor) || [];
|
|
260
193
|
}
|
|
261
|
-
function
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
return withProviderSpan(
|
|
276
|
-
{
|
|
277
|
-
providerName,
|
|
278
|
-
operationType: "mutation",
|
|
279
|
-
operationName,
|
|
280
|
-
attributes
|
|
281
|
-
},
|
|
282
|
-
fn
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
};
|
|
194
|
+
function getAllTRPCMethods(target) {
|
|
195
|
+
return [
|
|
196
|
+
...getTRPCQueryMethods(target),
|
|
197
|
+
...getTRPCMutationMethods(target)
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
function isTRPCQuery(target, methodName) {
|
|
201
|
+
return !!Reflect.getMetadata(TRPC_QUERY_METADATA_KEY, target, methodName);
|
|
202
|
+
}
|
|
203
|
+
function isTRPCMutation(target, methodName) {
|
|
204
|
+
return !!Reflect.getMetadata(TRPC_MUTATION_METADATA_KEY, target, methodName);
|
|
205
|
+
}
|
|
206
|
+
function isTRPCMethod(target, methodName) {
|
|
207
|
+
return isTRPCQuery(target, methodName) || isTRPCMutation(target, methodName);
|
|
286
208
|
}
|
|
287
209
|
|
|
288
210
|
// core/src/providers/base.provider.ts
|
|
289
211
|
var BaseProvider = class {
|
|
290
|
-
constructor(schema,
|
|
212
|
+
constructor(schema, cache) {
|
|
291
213
|
this.schema = schema;
|
|
292
|
-
this.
|
|
293
|
-
this.mutationSchema = mutationSchema;
|
|
294
|
-
this.instrumentation = createProviderInstrumentation(this.constructor.name);
|
|
214
|
+
this.cache = cache;
|
|
295
215
|
}
|
|
296
216
|
/**
|
|
297
217
|
* Validates that the final domain model constructed by the provider
|
|
@@ -307,41 +227,12 @@ var BaseProvider = class {
|
|
|
307
227
|
return this.schema.parse({});
|
|
308
228
|
}
|
|
309
229
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
* result list will never contain nulls or undefined. The order
|
|
313
|
-
* of the results will match the order of the queries.
|
|
314
|
-
*/
|
|
315
|
-
async query(queries, session) {
|
|
316
|
-
return this.instrumentation.traceQuery(
|
|
317
|
-
"query",
|
|
318
|
-
async (span) => {
|
|
319
|
-
span.setAttribute("provider.query.count", queries.length);
|
|
320
|
-
const results = await this.fetch(queries, session);
|
|
321
|
-
for (const result of results) {
|
|
322
|
-
this.assert(result);
|
|
323
|
-
}
|
|
324
|
-
span.setAttribute("provider.result.count", results.length);
|
|
325
|
-
return results;
|
|
326
|
-
},
|
|
327
|
-
{ queryCount: queries.length }
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Executes the listed mutations in order and returns the final state
|
|
332
|
-
* resulting from that set of operations.
|
|
230
|
+
* Handler for parsing a response from a remote provider and converting it
|
|
231
|
+
* into the typed domain model.
|
|
333
232
|
*/
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
async (span) => {
|
|
338
|
-
span.setAttribute("provider.mutation.count", mutations.length);
|
|
339
|
-
const result = await this.process(mutations, session);
|
|
340
|
-
this.assert(result);
|
|
341
|
-
return result;
|
|
342
|
-
},
|
|
343
|
-
{ mutationCount: mutations.length }
|
|
344
|
-
);
|
|
233
|
+
parseSingle(_body) {
|
|
234
|
+
const model = this.newModel();
|
|
235
|
+
return this.assert(model);
|
|
345
236
|
}
|
|
346
237
|
};
|
|
347
238
|
|
|
@@ -718,42 +609,32 @@ var SearchResultSchema = BaseModelSchema.extend({
|
|
|
718
609
|
|
|
719
610
|
// core/src/schemas/mutations/base.mutation.ts
|
|
720
611
|
import { z as z12 } from "zod";
|
|
721
|
-
var BaseMutationSchema = z12.looseInterface({
|
|
722
|
-
mutation: z12.ZodLiteral
|
|
723
|
-
});
|
|
612
|
+
var BaseMutationSchema = z12.looseInterface({});
|
|
724
613
|
|
|
725
614
|
// core/src/schemas/mutations/cart.mutation.ts
|
|
726
615
|
import { z as z13 } from "zod";
|
|
727
616
|
var CartMutationItemAddSchema = BaseMutationSchema.extend({
|
|
728
|
-
mutation: z13.literal("add"),
|
|
729
617
|
cart: CartIdentifierSchema.required(),
|
|
730
618
|
product: ProductIdentifierSchema.required(),
|
|
731
619
|
quantity: z13.number()
|
|
732
620
|
});
|
|
733
621
|
var CartMutationItemRemoveSchema = BaseMutationSchema.extend({
|
|
734
|
-
mutation: z13.literal("remove"),
|
|
735
622
|
cart: CartIdentifierSchema.required(),
|
|
736
623
|
item: CartItemIdentifierSchema.required()
|
|
737
624
|
});
|
|
738
625
|
var CartMutationItemQuantityChangeSchema = BaseMutationSchema.extend({
|
|
739
|
-
mutation: z13.literal("adjustQuantity"),
|
|
740
626
|
cart: CartIdentifierSchema.required(),
|
|
741
627
|
item: CartItemIdentifierSchema.required(),
|
|
742
628
|
quantity: z13.number()
|
|
743
629
|
});
|
|
744
|
-
var CartMutationSchema = z13.union([CartMutationItemAddSchema, CartMutationItemRemoveSchema, CartMutationItemQuantityChangeSchema]);
|
|
745
630
|
|
|
746
631
|
// core/src/schemas/mutations/identity.mutation.ts
|
|
747
632
|
import { z as z14 } from "zod";
|
|
748
633
|
var IdentityMutationLoginSchema = BaseMutationSchema.extend({
|
|
749
|
-
mutation: z14.literal("login"),
|
|
750
634
|
username: z14.string(),
|
|
751
635
|
password: z14.string()
|
|
752
636
|
});
|
|
753
|
-
var IdentityMutationLogoutSchema = BaseMutationSchema.extend({
|
|
754
|
-
mutation: z14.literal("logout")
|
|
755
|
-
});
|
|
756
|
-
var IdentityMutationSchema = z14.union([IdentityMutationLoginSchema, IdentityMutationLogoutSchema]);
|
|
637
|
+
var IdentityMutationLogoutSchema = BaseMutationSchema.extend({});
|
|
757
638
|
|
|
758
639
|
// core/src/schemas/mutations/inventory.mutation.ts
|
|
759
640
|
import { z as z15 } from "zod";
|
|
@@ -773,62 +654,44 @@ var SearchMutationSchema = z18.union([]);
|
|
|
773
654
|
|
|
774
655
|
// core/src/schemas/queries/base.query.ts
|
|
775
656
|
import { z as z19 } from "zod";
|
|
776
|
-
var BaseQuerySchema = z19.looseInterface({
|
|
777
|
-
query: z19.ZodLiteral
|
|
778
|
-
});
|
|
657
|
+
var BaseQuerySchema = z19.looseInterface({});
|
|
779
658
|
|
|
780
659
|
// core/src/schemas/queries/cart.query.ts
|
|
781
660
|
import { z as z20 } from "zod";
|
|
782
661
|
var CartQueryByIdSchema = BaseQuerySchema.extend({
|
|
783
|
-
query: z20.literal("id"),
|
|
784
662
|
cart: CartIdentifierSchema.required()
|
|
785
663
|
});
|
|
786
664
|
var CartQuerySchema = z20.union([CartQueryByIdSchema]);
|
|
787
665
|
|
|
788
666
|
// core/src/schemas/queries/identity.query.ts
|
|
789
|
-
|
|
790
|
-
var IdentityQuerySelfSchema = BaseQuerySchema.extend({
|
|
791
|
-
query: z21.literal("self")
|
|
792
|
-
});
|
|
793
|
-
var IdentityQuerySchema = z21.union([IdentityQuerySelfSchema]);
|
|
667
|
+
var IdentityQuerySelfSchema = BaseQuerySchema.extend({});
|
|
794
668
|
|
|
795
669
|
// core/src/schemas/queries/inventory.query.ts
|
|
796
|
-
import { z as
|
|
670
|
+
import { z as z21 } from "zod";
|
|
797
671
|
var InventoryQuerySchema = BaseQuerySchema.extend({
|
|
798
|
-
|
|
799
|
-
sku: z22.string()
|
|
672
|
+
sku: z21.string()
|
|
800
673
|
});
|
|
801
674
|
|
|
802
675
|
// core/src/schemas/queries/price.query.ts
|
|
803
|
-
import { z as z23 } from "zod";
|
|
804
676
|
var PriceQueryBySkuSchema = BaseQuerySchema.extend({
|
|
805
|
-
query: z23.literal("sku"),
|
|
806
677
|
sku: SKUIdentifierSchema.required()
|
|
807
678
|
});
|
|
808
|
-
var PriceQuerySchema = z23.union([PriceQueryBySkuSchema]);
|
|
809
679
|
|
|
810
680
|
// core/src/schemas/queries/product.query.ts
|
|
811
|
-
import { z as
|
|
681
|
+
import { z as z22 } from "zod";
|
|
812
682
|
var ProductQueryBySlugSchema = BaseQuerySchema.extend({
|
|
813
|
-
|
|
814
|
-
slug: z24.string()
|
|
683
|
+
slug: z22.string()
|
|
815
684
|
});
|
|
816
685
|
var ProductQueryByIdSchema = BaseQuerySchema.extend({
|
|
817
|
-
|
|
818
|
-
id: z24.string()
|
|
686
|
+
id: z22.string()
|
|
819
687
|
});
|
|
820
|
-
var ProductQuerySchema = z24.union([ProductQueryBySlugSchema, ProductQueryByIdSchema]);
|
|
821
688
|
|
|
822
689
|
// core/src/schemas/queries/search.query.ts
|
|
823
|
-
import { z as z25 } from "zod";
|
|
824
690
|
var SearchQueryByTermSchema = BaseQuerySchema.extend({
|
|
825
|
-
query: z25.literal("term"),
|
|
826
691
|
search: SearchIdentifierSchema.required()
|
|
827
692
|
});
|
|
828
|
-
var SearchQuerySchema = z25.union([SearchQueryByTermSchema]);
|
|
829
693
|
export {
|
|
830
694
|
AnalyticsProvider,
|
|
831
|
-
BaseCachingStrategy,
|
|
832
695
|
BaseModelSchema,
|
|
833
696
|
BaseMutationSchema,
|
|
834
697
|
BaseProvider,
|
|
@@ -841,19 +704,17 @@ export {
|
|
|
841
704
|
CartMutationItemAddSchema,
|
|
842
705
|
CartMutationItemQuantityChangeSchema,
|
|
843
706
|
CartMutationItemRemoveSchema,
|
|
844
|
-
CartMutationSchema,
|
|
845
707
|
CartProvider,
|
|
846
708
|
CartQueryByIdSchema,
|
|
847
709
|
CartQuerySchema,
|
|
848
710
|
CartSchema,
|
|
711
|
+
ClientBuilder,
|
|
849
712
|
CurrencySchema,
|
|
850
713
|
FacetIdentifierSchema,
|
|
851
714
|
FacetValueIdentifierSchema,
|
|
852
715
|
IdentityMutationLoginSchema,
|
|
853
716
|
IdentityMutationLogoutSchema,
|
|
854
|
-
IdentityMutationSchema,
|
|
855
717
|
IdentityProvider,
|
|
856
|
-
IdentityQuerySchema,
|
|
857
718
|
IdentityQuerySelfSchema,
|
|
858
719
|
IdentitySchema,
|
|
859
720
|
IdentityTypeSchema,
|
|
@@ -863,11 +724,11 @@ export {
|
|
|
863
724
|
InventorySchema,
|
|
864
725
|
MetaSchema,
|
|
865
726
|
MonetaryAmountSchema,
|
|
727
|
+
NoOpCache,
|
|
866
728
|
PriceIdentifierSchema,
|
|
867
729
|
PriceMutationSchema,
|
|
868
730
|
PriceProvider,
|
|
869
731
|
PriceQueryBySkuSchema,
|
|
870
|
-
PriceQuerySchema,
|
|
871
732
|
PriceSchema,
|
|
872
733
|
ProductAttributeSchema,
|
|
873
734
|
ProductIdentifierSchema,
|
|
@@ -875,7 +736,6 @@ export {
|
|
|
875
736
|
ProductProvider,
|
|
876
737
|
ProductQueryByIdSchema,
|
|
877
738
|
ProductQueryBySlugSchema,
|
|
878
|
-
ProductQuerySchema,
|
|
879
739
|
ProductSchema,
|
|
880
740
|
RedisCache,
|
|
881
741
|
SKUIdentifierSchema,
|
|
@@ -884,11 +744,21 @@ export {
|
|
|
884
744
|
SearchMutationSchema,
|
|
885
745
|
SearchProvider,
|
|
886
746
|
SearchQueryByTermSchema,
|
|
887
|
-
SearchQuerySchema,
|
|
888
747
|
SearchResultFacetSchema,
|
|
889
748
|
SearchResultFacetValueSchema,
|
|
890
749
|
SearchResultProductSchema,
|
|
891
750
|
SearchResultSchema,
|
|
892
751
|
SessionSchema,
|
|
893
|
-
|
|
752
|
+
TRPC_MUTATION_METADATA_KEY,
|
|
753
|
+
TRPC_QUERY_METADATA_KEY,
|
|
754
|
+
buildClient,
|
|
755
|
+
createCache,
|
|
756
|
+
getAllTRPCMethods,
|
|
757
|
+
getTRPCMutationMethods,
|
|
758
|
+
getTRPCQueryMethods,
|
|
759
|
+
isTRPCMethod,
|
|
760
|
+
isTRPCMutation,
|
|
761
|
+
isTRPCQuery,
|
|
762
|
+
trpcMutation,
|
|
763
|
+
trpcQuery
|
|
894
764
|
};
|