@graphprotocol/hypergraph 0.4.2 → 0.5.0-alpha.1
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/cli/Cli.js +1 -1
- package/dist/cli/bin.js +0 -0
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/bun.js +0 -0
- package/dist/cli/services/Model.d.ts +99 -0
- package/dist/cli/services/Model.d.ts.map +1 -0
- package/dist/cli/services/Model.js +52 -0
- package/dist/cli/services/Model.js.map +1 -0
- package/dist/cli/services/Typesync.d.ts +7 -4
- package/dist/cli/services/Typesync.d.ts.map +1 -1
- package/dist/cli/services/Typesync.js +106 -4
- package/dist/cli/services/Typesync.js.map +1 -1
- package/dist/cli/services/Utils.d.ts +81 -0
- package/dist/cli/services/Utils.d.ts.map +1 -1
- package/dist/cli/services/Utils.js +198 -8
- package/dist/cli/services/Utils.js.map +1 -1
- package/dist/cli/subcommands/typesync.d.ts +13 -2
- package/dist/cli/subcommands/typesync.d.ts.map +1 -1
- package/dist/cli/subcommands/typesync.js +141 -21
- package/dist/cli/subcommands/typesync.js.map +1 -1
- package/dist/entity/findMany.d.ts.map +1 -1
- package/dist/entity/findMany.js +21 -13
- package/dist/entity/findMany.js.map +1 -1
- package/dist/entity/types.d.ts +0 -6
- package/dist/entity/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mapping/Mapping.d.ts +24 -12
- package/dist/mapping/Mapping.d.ts.map +1 -1
- package/dist/mapping/Mapping.js +12 -4
- package/dist/mapping/Mapping.js.map +1 -1
- package/dist/typesync-studio/dist/assets/authenticate-callback-XTxFqKgn.js +1 -0
- package/dist/typesync-studio/dist/assets/ccip-_s3urR1L.js +1 -0
- package/dist/typesync-studio/dist/assets/index-B-tctDXW.js +88 -0
- package/dist/typesync-studio/dist/assets/index-BHBkzpXd.css +1 -0
- package/dist/typesync-studio/dist/assets/index-bioTPE3q.js +215 -0
- package/dist/typesync-studio/dist/index.html +30 -0
- package/dist/typesync-studio/dist/manifest.json +20 -0
- package/dist/typesync-studio/dist/robots.txt +3 -0
- package/package.json +15 -8
- package/src/cli/Cli.ts +1 -1
- package/src/cli/bin.ts +0 -1
- package/src/cli/services/Model.ts +87 -0
- package/src/cli/services/Typesync.ts +137 -9
- package/src/cli/services/Utils.ts +231 -11
- package/src/cli/subcommands/typesync.ts +251 -42
- package/src/entity/findMany.ts +27 -15
- package/src/entity/types.ts +0 -6
- package/src/index.ts +1 -0
- package/src/mapping/Mapping.ts +21 -6
package/src/entity/findMany.ts
CHANGED
|
@@ -255,20 +255,11 @@ export function findMany<const S extends AnyNoContext>(
|
|
|
255
255
|
const filtered: Array<Entity<S>> = [];
|
|
256
256
|
|
|
257
257
|
const evaluateFilter = <T>(fieldFilter: EntityFieldFilter<T>, fieldValue: T): boolean => {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return !evaluateFilter(fieldFilter.not, fieldValue);
|
|
258
|
+
if ('not' in fieldFilter || 'or' in fieldFilter) {
|
|
259
|
+
throw new Error("Logical operators 'not', 'or' are only allowed at the root (cross-field) level.");
|
|
261
260
|
}
|
|
262
261
|
|
|
263
|
-
//
|
|
264
|
-
if ('or' in fieldFilter) {
|
|
265
|
-
const orFilters = fieldFilter.or;
|
|
266
|
-
if (Array.isArray(orFilters)) {
|
|
267
|
-
return orFilters.some((orFilter) => evaluateFilter(orFilter as EntityFieldFilter<T>, fieldValue));
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// Handle basic filters
|
|
262
|
+
// handle basic filters
|
|
272
263
|
if ('is' in fieldFilter) {
|
|
273
264
|
if (typeof fieldValue === 'boolean') {
|
|
274
265
|
return fieldValue === fieldFilter.is;
|
|
@@ -324,14 +315,28 @@ export function findMany<const S extends AnyNoContext>(
|
|
|
324
315
|
crossFieldFilter: CrossFieldFilter<Schema.Schema.Type<S>>,
|
|
325
316
|
entity: Entity<S>,
|
|
326
317
|
): boolean => {
|
|
318
|
+
// evaluate regular field filters with AND semantics
|
|
327
319
|
for (const fieldName in crossFieldFilter) {
|
|
320
|
+
if (fieldName === 'or' || fieldName === 'not') continue;
|
|
328
321
|
const fieldFilter = crossFieldFilter[fieldName];
|
|
322
|
+
if (!fieldFilter) continue;
|
|
329
323
|
const fieldValue = entity[fieldName];
|
|
330
|
-
|
|
331
|
-
if (fieldFilter && !evaluateFilter(fieldFilter, fieldValue)) {
|
|
324
|
+
if (!evaluateFilter(fieldFilter, fieldValue)) {
|
|
332
325
|
return false;
|
|
333
326
|
}
|
|
334
327
|
}
|
|
328
|
+
|
|
329
|
+
// evaluate nested OR at cross-field level (if present)
|
|
330
|
+
if (Array.isArray(crossFieldFilter.or)) {
|
|
331
|
+
const orSatisfied = crossFieldFilter.or.some((orFilter) => evaluateCrossFieldFilter(orFilter, entity));
|
|
332
|
+
if (!orSatisfied) return false;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// evaluate nested NOT at cross-field level (if present)
|
|
336
|
+
if (crossFieldFilter.not && evaluateCrossFieldFilter(crossFieldFilter.not, entity)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
|
|
335
340
|
return true;
|
|
336
341
|
};
|
|
337
342
|
|
|
@@ -367,7 +372,14 @@ export function findMany<const S extends AnyNoContext>(
|
|
|
367
372
|
decoded.__schema = type;
|
|
368
373
|
filtered.push(decoded);
|
|
369
374
|
}
|
|
370
|
-
} catch (
|
|
375
|
+
} catch (error) {
|
|
376
|
+
// rethrow in case it's filter error
|
|
377
|
+
if (
|
|
378
|
+
error instanceof Error &&
|
|
379
|
+
error.message.includes("Logical operators 'not', 'or' are only allowed at the root (cross-field) level")
|
|
380
|
+
) {
|
|
381
|
+
throw error;
|
|
382
|
+
}
|
|
371
383
|
corruptEntityIds.push(id);
|
|
372
384
|
}
|
|
373
385
|
}
|
package/src/entity/types.ts
CHANGED
|
@@ -55,8 +55,6 @@ export type EntityNumberFilter = {
|
|
|
55
55
|
is?: number;
|
|
56
56
|
greaterThan?: number;
|
|
57
57
|
lessThan?: number;
|
|
58
|
-
not?: EntityNumberFilter;
|
|
59
|
-
or?: EntityNumberFilter[];
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
export type EntityStringFilter = {
|
|
@@ -64,8 +62,6 @@ export type EntityStringFilter = {
|
|
|
64
62
|
startsWith?: string;
|
|
65
63
|
endsWith?: string;
|
|
66
64
|
contains?: string;
|
|
67
|
-
not?: EntityStringFilter;
|
|
68
|
-
or?: EntityStringFilter[];
|
|
69
65
|
};
|
|
70
66
|
|
|
71
67
|
export type CrossFieldFilter<T> = {
|
|
@@ -77,8 +73,6 @@ export type CrossFieldFilter<T> = {
|
|
|
77
73
|
|
|
78
74
|
export type EntityFieldFilter<T> = {
|
|
79
75
|
is?: T;
|
|
80
|
-
not?: EntityFieldFilter<T>;
|
|
81
|
-
or?: Array<EntityFieldFilter<T>>;
|
|
82
76
|
} & (T extends boolean
|
|
83
77
|
? {
|
|
84
78
|
is?: boolean;
|
package/src/index.ts
CHANGED
package/src/mapping/Mapping.ts
CHANGED
|
@@ -129,12 +129,21 @@ export function getDataType(val: string): SchemaDataType {
|
|
|
129
129
|
}
|
|
130
130
|
throw new Error(`Passed dataType ${val} is not supported`);
|
|
131
131
|
}
|
|
132
|
+
|
|
133
|
+
const BaseSchemaTypeProperty = EffectSchema.Struct({
|
|
134
|
+
name: EffectSchema.NonEmptyTrimmedString,
|
|
135
|
+
knowledgeGraphId: EffectSchema.NullOr(EffectSchema.UUID),
|
|
136
|
+
/**
|
|
137
|
+
* @since 0.4.0
|
|
138
|
+
*/
|
|
139
|
+
optional: EffectSchema.optional(EffectSchema.NullishOr(EffectSchema.Boolean)),
|
|
140
|
+
});
|
|
141
|
+
|
|
132
142
|
/**
|
|
133
143
|
* @since 0.2.0
|
|
134
144
|
*/
|
|
135
145
|
export const SchemaTypePropertyRelation = EffectSchema.Struct({
|
|
136
|
-
|
|
137
|
-
knowledgeGraphId: EffectSchema.NullOr(EffectSchema.UUID),
|
|
146
|
+
...BaseSchemaTypeProperty.fields,
|
|
138
147
|
dataType: SchemaDataTypeRelation,
|
|
139
148
|
relationType: EffectSchema.NonEmptyTrimmedString.annotations({
|
|
140
149
|
identifier: 'SchemaTypePropertyRelation.relationType',
|
|
@@ -150,8 +159,7 @@ export type SchemaTypePropertyRelation = typeof SchemaTypePropertyRelation.Type;
|
|
|
150
159
|
* @since 0.2.0
|
|
151
160
|
*/
|
|
152
161
|
export const SchemaTypePropertyPrimitive = EffectSchema.Struct({
|
|
153
|
-
|
|
154
|
-
knowledgeGraphId: EffectSchema.NullOr(EffectSchema.UUID),
|
|
162
|
+
...BaseSchemaTypeProperty.fields,
|
|
155
163
|
dataType: SchemaDataTypePrimitive,
|
|
156
164
|
});
|
|
157
165
|
/**
|
|
@@ -217,7 +225,7 @@ export const Schema = EffectSchema.Struct({
|
|
|
217
225
|
{
|
|
218
226
|
name: 'Account',
|
|
219
227
|
knowledgeGraphId: null,
|
|
220
|
-
properties: [{ name: 'username', knowledgeGraphId: null, dataType: 'String' }],
|
|
228
|
+
properties: [{ name: 'username', optional: null, knowledgeGraphId: null, dataType: 'String' }],
|
|
221
229
|
},
|
|
222
230
|
],
|
|
223
231
|
},
|
|
@@ -226,7 +234,14 @@ export const Schema = EffectSchema.Struct({
|
|
|
226
234
|
{
|
|
227
235
|
name: 'Account',
|
|
228
236
|
knowledgeGraphId: 'a5fd07b1-120f-46c6-b46f-387ef98396a6',
|
|
229
|
-
properties: [
|
|
237
|
+
properties: [
|
|
238
|
+
{
|
|
239
|
+
name: 'name',
|
|
240
|
+
optional: true,
|
|
241
|
+
knowledgeGraphId: 'a126ca53-0c8e-48d5-b888-82c734c38935',
|
|
242
|
+
dataType: 'String',
|
|
243
|
+
},
|
|
244
|
+
],
|
|
230
245
|
},
|
|
231
246
|
],
|
|
232
247
|
},
|