@graphprotocol/hypergraph 0.1.0 → 0.2.0

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 (41) hide show
  1. package/dist/Entity.d.ts +69 -0
  2. package/dist/Entity.d.ts.map +1 -0
  3. package/dist/Entity.js +174 -0
  4. package/dist/Entity.js.map +1 -0
  5. package/dist/identity/create-identity-keys.d.ts +3 -0
  6. package/dist/identity/create-identity-keys.d.ts.map +1 -0
  7. package/dist/identity/create-identity-keys.js +20 -0
  8. package/dist/identity/create-identity-keys.js.map +1 -0
  9. package/dist/identity/login.d.ts +38 -0
  10. package/dist/identity/login.d.ts.map +1 -0
  11. package/dist/identity/login.js +241 -0
  12. package/dist/identity/login.js.map +1 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/mapping/Mapping.d.ts +418 -0
  18. package/dist/mapping/Mapping.d.ts.map +1 -0
  19. package/dist/mapping/Mapping.js +554 -0
  20. package/dist/mapping/Mapping.js.map +1 -0
  21. package/dist/mapping/Utils.d.ts +74 -0
  22. package/dist/mapping/Utils.d.ts.map +1 -0
  23. package/dist/mapping/Utils.js +144 -0
  24. package/dist/mapping/Utils.js.map +1 -0
  25. package/dist/mapping/index.d.ts +3 -0
  26. package/dist/mapping/index.d.ts.map +1 -0
  27. package/dist/mapping/index.js +3 -0
  28. package/dist/mapping/index.js.map +1 -0
  29. package/dist/store.d.ts +1 -1
  30. package/dist/store.d.ts.map +1 -1
  31. package/dist/store.js.map +1 -1
  32. package/dist/utils/hasArrayField.d.ts +2 -0
  33. package/dist/utils/hasArrayField.d.ts.map +1 -0
  34. package/dist/utils/hasArrayField.js +5 -0
  35. package/dist/utils/hasArrayField.js.map +1 -0
  36. package/package.json +3 -5
  37. package/src/index.ts +1 -0
  38. package/src/mapping/Mapping.ts +771 -0
  39. package/src/mapping/Utils.ts +156 -0
  40. package/src/mapping/index.ts +2 -0
  41. package/src/store.ts +1 -1
@@ -0,0 +1,554 @@
1
+ import { Graph, Id as Grc20Id } from '@graphprotocol/grc-20';
2
+ import { Data, Array as EffectArray, Schema as EffectSchema, Option, pipe } from 'effect';
3
+ import { namesAreUnique, toCamelCase, toPascalCase } from './Utils.js';
4
+ /**
5
+ * @since 0.2.0
6
+ */
7
+ export function isDataTypeRelation(val) {
8
+ return /^Relation\((.+)\)$/.test(val);
9
+ }
10
+ /**
11
+ * @since 0.2.0
12
+ */
13
+ export const SchemaDataTypeRelation = /*#__PURE__*/EffectSchema.NonEmptyTrimmedString.pipe(/*#__PURE__*/EffectSchema.filter(val => isDataTypeRelation(val)));
14
+ /**
15
+ * @since 0.2.0
16
+ */
17
+ export const SchemaDataTypePrimitive = /*#__PURE__*/EffectSchema.Literal('Text', 'Number', 'Checkbox', 'Date', 'Point');
18
+ /**
19
+ * @since 0.2.0
20
+ */
21
+ export const SchemaDataType = /*#__PURE__*/EffectSchema.Union(SchemaDataTypePrimitive, SchemaDataTypeRelation);
22
+ /**
23
+ * @since 0.2.0
24
+ */
25
+ export const SchemaTypePropertyRelation = /*#__PURE__*/EffectSchema.Struct({
26
+ name: EffectSchema.NonEmptyTrimmedString,
27
+ knowledgeGraphId: /*#__PURE__*/EffectSchema.NullOr(EffectSchema.UUID),
28
+ dataType: SchemaDataTypeRelation,
29
+ relationType: /*#__PURE__*/EffectSchema.NonEmptyTrimmedString.annotations({
30
+ identifier: 'SchemaTypePropertyRelation.relationType',
31
+ description: 'name of the type within the schema that this property is related to',
32
+ examples: ['Account']
33
+ })
34
+ });
35
+ /**
36
+ * @since 0.2.0
37
+ */
38
+ export const SchemaTypePropertyPrimitive = /*#__PURE__*/EffectSchema.Struct({
39
+ name: EffectSchema.NonEmptyTrimmedString,
40
+ knowledgeGraphId: /*#__PURE__*/EffectSchema.NullOr(EffectSchema.UUID),
41
+ dataType: SchemaDataTypePrimitive
42
+ });
43
+ /**
44
+ * @since 0.2.0
45
+ */
46
+ export function propertyIsRelation(property) {
47
+ return isDataTypeRelation(property.dataType);
48
+ }
49
+ /**
50
+ * @since 0.2.0
51
+ */
52
+ export const SchemaType = /*#__PURE__*/EffectSchema.Struct({
53
+ name: EffectSchema.NonEmptyTrimmedString,
54
+ knowledgeGraphId: /*#__PURE__*/EffectSchema.NullOr(EffectSchema.UUID),
55
+ properties: /*#__PURE__*/EffectSchema.Array(EffectSchema.Union(SchemaTypePropertyPrimitive, SchemaTypePropertyRelation)).pipe(/*#__PURE__*/EffectSchema.minItems(1), /*#__PURE__*/EffectSchema.filter(namesAreUnique, {
56
+ identifier: 'DuplicatePropertyNames',
57
+ jsonSchema: {},
58
+ description: 'The property.name must be unique across all properties in the type'
59
+ }))
60
+ });
61
+ /**
62
+ * Represents the user-built schema object to generate a `Mappings` definition for
63
+ *
64
+ * @since 0.2.0
65
+ */
66
+ export const Schema = /*#__PURE__*/EffectSchema.Struct({
67
+ types: EffectSchema.Array(SchemaType).pipe(EffectSchema.minItems(1), EffectSchema.filter(namesAreUnique, {
68
+ identifier: 'DuplicateTypeNames',
69
+ jsonSchema: {},
70
+ description: 'The type.name must be unique across all types in the schema'
71
+ }), EffectSchema.filter(allRelationPropertyTypesExist, {
72
+ identifier: 'AllRelationTypesExist',
73
+ jsonSchema: {},
74
+ description: 'Each type property of dataType RELATION must have a type of the same name in the schema'
75
+ }))
76
+ }).annotations({
77
+ identifier: 'typesync/Schema',
78
+ title: 'TypeSync app Schema',
79
+ description: 'An array of types in the schema defined by the user to generate a Mapping object for',
80
+ examples: [{
81
+ types: [{
82
+ name: 'Account',
83
+ knowledgeGraphId: null,
84
+ properties: [{
85
+ name: 'username',
86
+ knowledgeGraphId: null,
87
+ dataType: 'Text'
88
+ }]
89
+ }]
90
+ }, {
91
+ types: [{
92
+ name: 'Account',
93
+ knowledgeGraphId: 'a5fd07b1-120f-46c6-b46f-387ef98396a6',
94
+ properties: [{
95
+ name: 'name',
96
+ knowledgeGraphId: 'a126ca53-0c8e-48d5-b888-82c734c38935',
97
+ dataType: 'Text'
98
+ }]
99
+ }]
100
+ }]
101
+ });
102
+ /**
103
+ * @since 0.2.0
104
+ */
105
+ export const SchemaKnownDecoder = /*#__PURE__*/EffectSchema.decodeSync(Schema);
106
+ /**
107
+ * @since 0.2.0
108
+ */
109
+ export const SchemaUnknownDecoder = /*#__PURE__*/EffectSchema.decodeUnknownSync(Schema);
110
+ /**
111
+ * Iterate through all properties in all types in the schema of `dataType` === `Relation(${string})`
112
+ * and validate that the schema.types have a type for the existing relation
113
+ *
114
+ * @example <caption>All types exist</caption>
115
+ * ```ts
116
+ * import { allRelationPropertyTypesExist, type Mapping } from '@graphprotocol/hypergraph/mapping'
117
+ *
118
+ * const types: Mapping['types'] = [
119
+ * {
120
+ * name: "Account",
121
+ * knowledgeGraphId: null,
122
+ * properties: [
123
+ * {
124
+ * name: "username",
125
+ * dataType: "Text",
126
+ * knowledgeGraphId: null
127
+ * }
128
+ * ]
129
+ * },
130
+ * {
131
+ * name: "Event",
132
+ * knowledgeGraphId: null,
133
+ * properties: [
134
+ * {
135
+ * name: "speaker",
136
+ * dataType: "Relation(Account)"
137
+ * relationType: "Account",
138
+ * knowledgeGraphId: null,
139
+ * }
140
+ * ]
141
+ * }
142
+ * ]
143
+ * expect(allRelationPropertyTypesExist(types)).toEqual(true)
144
+ * ```
145
+ *
146
+ * @example <caption>Account type is missing</caption>
147
+ * ```ts
148
+ * import { allRelationPropertyTypesExist, type Mapping } from '@graphprotocol/hypergraph/mapping'
149
+ *
150
+ * const types: Mapping['types'] = [
151
+ * {
152
+ * name: "Event",
153
+ * knowledgeGraphId: null,
154
+ * properties: [
155
+ * {
156
+ * name: "speaker",
157
+ * dataType: "Relation(Account)",
158
+ * relationType: "Account",
159
+ * knowledgeGraphId: null,
160
+ * }
161
+ * ]
162
+ * }
163
+ * ]
164
+ * expect(allRelationPropertyTypesExist(types)).toEqual(false)
165
+ * ```
166
+ *
167
+ * @since 0.2.0
168
+ *
169
+ * @param types the user-submitted schema types
170
+ */
171
+ export function allRelationPropertyTypesExist(types) {
172
+ const unqTypeNames = EffectArray.reduce(types, new Set(), (names, curr) => names.add(curr.name));
173
+ return pipe(types, EffectArray.flatMap(curr => curr.properties), EffectArray.filter(prop => propertyIsRelation(prop)), EffectArray.every(prop => unqTypeNames.has(prop.relationType)));
174
+ }
175
+ // Helper function to build property map from PropertyIdMappings
176
+ function buildPropertyMap(properties) {
177
+ return pipe(properties, EffectArray.reduce({}, (props, {
178
+ propName,
179
+ id
180
+ }) => {
181
+ props[toCamelCase(propName)] = id;
182
+ return props;
183
+ }));
184
+ }
185
+ // Helper function to build relation map from PropertyIdMappings
186
+ function buildRelationMap(relations) {
187
+ return pipe(relations, EffectArray.reduce({}, (rels, {
188
+ propName,
189
+ id
190
+ }) => {
191
+ rels[toCamelCase(propName)] = id;
192
+ return rels;
193
+ }));
194
+ }
195
+ // Helper function to create a property and return the result
196
+ function createPropertyWithOps(property, typeIdMap) {
197
+ if (property.knowledgeGraphId) {
198
+ return {
199
+ type: 'resolved',
200
+ mapping: {
201
+ propName: property.name,
202
+ id: Grc20Id.Id(property.knowledgeGraphId)
203
+ },
204
+ ops: []
205
+ };
206
+ }
207
+ if (propertyIsRelation(property)) {
208
+ const relationTypeId = typeIdMap.get(property.relationType);
209
+ if (relationTypeId == null) {
210
+ return {
211
+ type: 'deferred',
212
+ property
213
+ };
214
+ }
215
+ const {
216
+ id,
217
+ ops
218
+ } = Graph.createProperty({
219
+ name: property.name,
220
+ dataType: 'RELATION',
221
+ relationValueTypes: [relationTypeId]
222
+ });
223
+ return {
224
+ type: 'resolved',
225
+ mapping: {
226
+ propName: property.name,
227
+ id
228
+ },
229
+ ops
230
+ };
231
+ }
232
+ const {
233
+ id,
234
+ ops
235
+ } = Graph.createProperty({
236
+ name: property.name,
237
+ dataType: mapSchemaDataTypeToGRC20PropDataType(property.dataType)
238
+ });
239
+ return {
240
+ type: 'resolved',
241
+ mapping: {
242
+ propName: property.name,
243
+ id
244
+ },
245
+ ops
246
+ };
247
+ }
248
+ // Helper function to process a single type
249
+ function processType(type, typeIdMap) {
250
+ const processedProperties = pipe(type.properties, EffectArray.map(prop => createPropertyWithOps(prop, typeIdMap)));
251
+ const resolvedProperties = pipe(processedProperties, EffectArray.filterMap(p => p.type === 'resolved' ? Option.some(p) : Option.none()));
252
+ const deferredProperties = pipe(processedProperties, EffectArray.filterMap(p => p.type === 'deferred' ? Option.some(p.property) : Option.none()));
253
+ // Separate resolved properties into primitive properties and relations
254
+ const primitiveProperties = pipe(resolvedProperties, EffectArray.filter(p => {
255
+ const originalProp = type.properties.find(prop => prop.name === p.mapping.propName);
256
+ return originalProp ? !propertyIsRelation(originalProp) : false;
257
+ }), EffectArray.map(p => p.mapping));
258
+ const relationProperties = pipe(resolvedProperties, EffectArray.filter(p => {
259
+ const originalProp = type.properties.find(prop => prop.name === p.mapping.propName);
260
+ return originalProp ? propertyIsRelation(originalProp) : false;
261
+ }), EffectArray.map(p => p.mapping));
262
+ const propertyOps = pipe(resolvedProperties, EffectArray.flatMap(p => p.ops));
263
+ // If type exists in knowledge graph, return complete entry
264
+ if (type.knowledgeGraphId) {
265
+ const entry = {
266
+ typeName: toPascalCase(type.name),
267
+ typeIds: [Grc20Id.Id(type.knowledgeGraphId)]
268
+ };
269
+ if (EffectArray.isNonEmptyArray(primitiveProperties)) {
270
+ entry.properties = buildPropertyMap(primitiveProperties);
271
+ }
272
+ if (EffectArray.isNonEmptyArray(relationProperties)) {
273
+ entry.relations = buildRelationMap(relationProperties);
274
+ }
275
+ return {
276
+ type: 'complete',
277
+ entry,
278
+ ops: propertyOps
279
+ };
280
+ }
281
+ // If there are deferred properties, defer type creation
282
+ if (EffectArray.isNonEmptyArray(deferredProperties)) {
283
+ return {
284
+ type: 'deferred',
285
+ schemaType: type,
286
+ properties: primitiveProperties,
287
+ relations: relationProperties
288
+ };
289
+ }
290
+ // Create the type with all resolved properties (both primitive and relations)
291
+ const allPropertyIds = [...primitiveProperties, ...relationProperties];
292
+ const {
293
+ id,
294
+ ops: typeOps
295
+ } = Graph.createType({
296
+ name: type.name,
297
+ properties: pipe(allPropertyIds, EffectArray.map(p => p.id))
298
+ });
299
+ typeIdMap.set(type.name, id);
300
+ const entry = {
301
+ typeName: toPascalCase(type.name),
302
+ typeIds: [id]
303
+ };
304
+ if (EffectArray.isNonEmptyArray(primitiveProperties)) {
305
+ entry.properties = buildPropertyMap(primitiveProperties);
306
+ }
307
+ if (EffectArray.isNonEmptyArray(relationProperties)) {
308
+ entry.relations = buildRelationMap(relationProperties);
309
+ }
310
+ return {
311
+ type: 'complete',
312
+ entry,
313
+ ops: [...propertyOps, ...typeOps]
314
+ };
315
+ }
316
+ /**
317
+ * Takes the user-submitted schema, validates it, and build the `Mapping` definition for the schema as well as the GRC-20 Ops needed to publish the schema/schema changes to the Knowledge Graph.
318
+ *
319
+ * @example
320
+ * ```ts
321
+ * import { Id } from "@graphprotocol/grc-20"
322
+ * import { generateMapping } from "@graphprotocol/typesync"
323
+ *
324
+ * const schema: Schema = {
325
+ * types: [
326
+ * {
327
+ * name: "Account",
328
+ * knowledgeGraphId: "a5fd07b1-120f-46c6-b46f-387ef98396a6",
329
+ * properties: [
330
+ * {
331
+ * name: "username",
332
+ * dataType: "Text",
333
+ * knowledgeGraphId: "994edcff-6996-4a77-9797-a13e5e3efad8"
334
+ * },
335
+ * {
336
+ * name: "createdAt",
337
+ * dataType: "Date",
338
+ * knowledgeGraphId: null
339
+ * }
340
+ * ]
341
+ * },
342
+ * {
343
+ * name: "Event",
344
+ * knowledgeGraphId: null,
345
+ * properties: [
346
+ * {
347
+ * name: "name",
348
+ * dataType: "Text",
349
+ * knowledgeGraphId: "3808e060-fb4a-4d08-8069-35b8c8a1902b"
350
+ * },
351
+ * {
352
+ * name: "description",
353
+ * dataType: "Text",
354
+ * knowledgeGraphId: null
355
+ * },
356
+ * {
357
+ * name: "speaker",
358
+ * dataType: "Relation(Account)",
359
+ * relationType: "Account",
360
+ * knowledgeGraphId: null
361
+ * }
362
+ * ]
363
+ * }
364
+ * ],
365
+ * }
366
+ * const [mapping, ops] = generateMapping(schema)
367
+ *
368
+ * expect(mapping).toEqual({
369
+ * Account: {
370
+ * typeIds: [Id.Id("a5fd07b1-120f-46c6-b46f-387ef98396a6")], // comes from input schema
371
+ * properties: {
372
+ * username: Id.Id("994edcff-6996-4a77-9797-a13e5e3efad8"), // comes from input schema
373
+ * createdAt: Id.Id("8cd7d9ac-a878-4287-8000-e71e6f853117"), // generated from Graph.createProperty Op
374
+ * }
375
+ * },
376
+ * Event: {
377
+ * typeIds: [Id.Id("20b3fe39-8e62-41a0-b9cb-92743fd760da")], // generated from Graph.createType Op
378
+ * properties: {
379
+ * name: Id.Id("3808e060-fb4a-4d08-8069-35b8c8a1902b"), // comes from input schema
380
+ * description: Id.Id("8fc4e17c-7581-4d6c-a712-943385afc7b5"), // generated from Graph.createProperty Op
381
+ * },
382
+ * relations: {
383
+ * speaker: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"), // generated from Graph.createProperty Op
384
+ * }
385
+ * }
386
+ * })
387
+ * expect(ops).toEqual([
388
+ * // Graph.createProperty Op for Account.createdAt property
389
+ * {
390
+ * type: "CREATE_PROPERTY",
391
+ * property: {
392
+ * id: Id.Id("8cd7d9ac-a878-4287-8000-e71e6f853117"),
393
+ * dataType: "TEXT"
394
+ * }
395
+ * },
396
+ * // Graph.createProperty Op for Event.description property
397
+ * {
398
+ * type: "CREATE_PROPERTY",
399
+ * property: {
400
+ * id: Id.Id("8fc4e17c-7581-4d6c-a712-943385afc7b5"),
401
+ * dataType: "TEXT"
402
+ * }
403
+ * },
404
+ * // Graph.createProperty Op for Event.speaker property
405
+ * {
406
+ * type: "CREATE_PROPERTY",
407
+ * property: {
408
+ * id: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"),
409
+ * dataType: "RELATION"
410
+ * }
411
+ * },
412
+ * // Graph.createType Op for Event type
413
+ * {
414
+ * type: "CREATE_PROPERTY",
415
+ * property: {
416
+ * id: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"),
417
+ * dataType: "RELATION"
418
+ * }
419
+ * },
420
+ * ])
421
+ * ```
422
+ *
423
+ * @since 0.2.0
424
+ *
425
+ * @param input user-built and submitted schema
426
+ * @returns the generated [Mapping] definition from the submitted schema as well as the GRC-20 Ops required to publish the schema to the Knowledge Graph
427
+ */
428
+ export function generateMapping(input) {
429
+ // Validate the schema
430
+ const schema = SchemaKnownDecoder(input);
431
+ // Build initial type ID map
432
+ const typeIdMap = pipe(schema.types, EffectArray.reduce(new Map(), (map, type) => map.set(type.name, type.knowledgeGraphId != null ? Grc20Id.Id(type.knowledgeGraphId) : null)));
433
+ // First pass: process all types
434
+ const processedTypes = pipe(schema.types, EffectArray.map(type => processType(type, typeIdMap)));
435
+ // Separate complete and deferred types
436
+ const [deferredTypes, completeTypes] = pipe(processedTypes, EffectArray.partition(result => result.type === 'complete'));
437
+ // Collect all operations from first pass
438
+ const firstPassOps = pipe(completeTypes, EffectArray.flatMap(t => t.ops));
439
+ // Second pass: resolve deferred relation properties and create deferred types
440
+ const {
441
+ entries: deferredEntries,
442
+ ops: secondPassOps
443
+ } = pipe(deferredTypes, EffectArray.reduce({
444
+ entries: [],
445
+ ops: []
446
+ }, (acc, deferred) => {
447
+ // Resolve all deferred relation properties for this type
448
+ const resolvedRelations = pipe(deferred.schemaType.properties, EffectArray.filterMap(prop => {
449
+ if (!propertyIsRelation(prop) || prop.knowledgeGraphId != null) {
450
+ return Option.none();
451
+ }
452
+ const relationTypeId = typeIdMap.get(prop.relationType);
453
+ if (relationTypeId == null) {
454
+ throw new RelationValueTypeDoesNotExistError({
455
+ message: `Failed to resolve type ID for relation type: ${prop.relationType}`,
456
+ property: prop.name,
457
+ relatedType: prop.relationType
458
+ });
459
+ }
460
+ const {
461
+ id,
462
+ ops
463
+ } = Graph.createProperty({
464
+ name: prop.name,
465
+ dataType: 'RELATION',
466
+ relationValueTypes: [relationTypeId]
467
+ });
468
+ return Option.some({
469
+ mapping: {
470
+ propName: prop.name,
471
+ id
472
+ },
473
+ ops
474
+ });
475
+ }));
476
+ // Combine resolved relations with existing relations
477
+ const allRelations = [...deferred.relations, ...pipe(resolvedRelations, EffectArray.map(r => r.mapping))];
478
+ // Combine all property IDs for type creation
479
+ const allPropertyIds = [...deferred.properties, ...allRelations];
480
+ // Create the type with all properties
481
+ const {
482
+ id,
483
+ ops: typeOps
484
+ } = Graph.createType({
485
+ name: deferred.schemaType.name,
486
+ properties: pipe(allPropertyIds, EffectArray.map(p => p.id))
487
+ });
488
+ typeIdMap.set(deferred.schemaType.name, id);
489
+ // Collect all operations
490
+ const allOps = [...pipe(resolvedRelations, EffectArray.flatMap(r => r.ops)), ...typeOps];
491
+ // Build the entry with properties and relations separated
492
+ const entry = {
493
+ typeName: toPascalCase(deferred.schemaType.name),
494
+ typeIds: [id]
495
+ };
496
+ if (EffectArray.isNonEmptyArray(deferred.properties)) {
497
+ entry.properties = buildPropertyMap(deferred.properties);
498
+ }
499
+ if (EffectArray.isNonEmptyArray(allRelations)) {
500
+ entry.relations = buildRelationMap(allRelations);
501
+ }
502
+ return {
503
+ entries: [...acc.entries, entry],
504
+ ops: [...acc.ops, ...allOps]
505
+ };
506
+ }));
507
+ // Combine all entries and build final mapping
508
+ const allEntries = [...pipe(completeTypes, EffectArray.map(t => t.entry)), ...deferredEntries];
509
+ const mapping = pipe(allEntries, EffectArray.reduce({}, (mapping, entry) => {
510
+ const {
511
+ typeName,
512
+ ...rest
513
+ } = entry;
514
+ mapping[typeName] = rest;
515
+ return mapping;
516
+ }));
517
+ return [mapping, [...firstPassOps, ...secondPassOps]];
518
+ }
519
+ export class RelationValueTypeDoesNotExistError extends /*#__PURE__*/Data.TaggedError('/typesync/errors/RelationValueTypeDoesNotExistError') {}
520
+ /**
521
+ * @since 0.2.0
522
+ *
523
+ * @param dataType the dataType from the user-submitted schema
524
+ * @returns the mapped to GRC-20 dataType for the GRC-20 ops
525
+ */
526
+ export function mapSchemaDataTypeToGRC20PropDataType(dataType) {
527
+ switch (true) {
528
+ case dataType === 'Checkbox':
529
+ {
530
+ return 'CHECKBOX';
531
+ }
532
+ case dataType === 'Date':
533
+ {
534
+ return 'TIME';
535
+ }
536
+ case dataType === 'Number':
537
+ {
538
+ return 'NUMBER';
539
+ }
540
+ case dataType === 'Point':
541
+ {
542
+ return 'POINT';
543
+ }
544
+ case isDataTypeRelation(dataType):
545
+ {
546
+ return 'RELATION';
547
+ }
548
+ default:
549
+ {
550
+ return 'TEXT';
551
+ }
552
+ }
553
+ }
554
+ //# sourceMappingURL=Mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mapping.js","names":["Graph","Id","Grc20Id","Data","Array","EffectArray","Schema","EffectSchema","Option","pipe","namesAreUnique","toCamelCase","toPascalCase","isDataTypeRelation","val","test","SchemaDataTypeRelation","NonEmptyTrimmedString","filter","SchemaDataTypePrimitive","Literal","SchemaDataType","Union","SchemaTypePropertyRelation","Struct","name","knowledgeGraphId","NullOr","UUID","dataType","relationType","annotations","identifier","description","examples","SchemaTypePropertyPrimitive","propertyIsRelation","property","SchemaType","properties","minItems","jsonSchema","types","allRelationPropertyTypesExist","title","SchemaKnownDecoder","decodeSync","SchemaUnknownDecoder","decodeUnknownSync","unqTypeNames","reduce","Set","names","curr","add","flatMap","prop","every","has","buildPropertyMap","props","propName","id","buildRelationMap","relations","rels","createPropertyWithOps","typeIdMap","type","mapping","ops","relationTypeId","get","createProperty","relationValueTypes","mapSchemaDataTypeToGRC20PropDataType","processType","processedProperties","map","resolvedProperties","filterMap","p","some","none","deferredProperties","primitiveProperties","originalProp","find","relationProperties","propertyOps","entry","typeName","typeIds","isNonEmptyArray","schemaType","allPropertyIds","typeOps","createType","set","generateMapping","input","schema","Map","processedTypes","deferredTypes","completeTypes","partition","result","firstPassOps","t","entries","deferredEntries","secondPassOps","acc","deferred","resolvedRelations","RelationValueTypeDoesNotExistError","message","relatedType","allRelations","r","allOps","allEntries","rest","TaggedError"],"sources":["../../src/mapping/Mapping.ts"],"sourcesContent":[null],"mappings":"AAAA,SAAoCA,KAAK,EAAEC,EAAE,IAAIC,OAAO,QAAiB,uBAAuB;AAChG,SAASC,IAAI,EAAEC,KAAK,IAAIC,WAAW,EAAEC,MAAM,IAAIC,YAAY,EAAEC,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAEzF,SAASC,cAAc,EAAEC,WAAW,EAAEC,YAAY,QAAQ,YAAY;AA0EtE;;;AAGA,OAAM,SAAUC,kBAAkBA,CAACC,GAAW;EAC5C,OAAO,oBAAoB,CAACC,IAAI,CAACD,GAAG,CAAC;AACvC;AACA;;;AAGA,OAAO,MAAME,sBAAsB,gBAAGT,YAAY,CAACU,qBAAqB,CAACR,IAAI,cAC3EF,YAAY,CAACW,MAAM,CAAEJ,GAAG,IAAKD,kBAAkB,CAACC,GAAG,CAAC,CAAC,CACtD;AAKD;;;AAGA,OAAO,MAAMK,uBAAuB,gBAAGZ,YAAY,CAACa,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC;AAK1G;;;AAGA,OAAO,MAAMC,cAAc,gBAAGd,YAAY,CAACe,KAAK,CAACH,uBAAuB,EAAEH,sBAAsB,CAAC;AAKjG;;;AAGA,OAAO,MAAMO,0BAA0B,gBAAGhB,YAAY,CAACiB,MAAM,CAAC;EAC5DC,IAAI,EAAElB,YAAY,CAACU,qBAAqB;EACxCS,gBAAgB,eAAEnB,YAAY,CAACoB,MAAM,CAACpB,YAAY,CAACqB,IAAI,CAAC;EACxDC,QAAQ,EAAEb,sBAAsB;EAChCc,YAAY,eAAEvB,YAAY,CAACU,qBAAqB,CAACc,WAAW,CAAC;IAC3DC,UAAU,EAAE,yCAAyC;IACrDC,WAAW,EAAE,qEAAqE;IAClFC,QAAQ,EAAE,CAAC,SAAS;GACrB;CACF,CAAC;AAKF;;;AAGA,OAAO,MAA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AAO,QAAQ;MACjB;IACA,KAAKA,QAAQ,KAAK,OAAO;MAAE;QACzB,OAAO,OAAO;MAChB;IACA,KAAKhB,kBAAkB,CAACgB,QAAQ,CAAC;MAAE;QACjC,OAAO,UAAU;MACnB;IACA;MAAS;QACP,OAAO,MAAM;MACf;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Takes the input string and returns the camelCase equivalent
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { toCamelCase } from '@graphprotocol/hypergraph/mapping'
7
+ *
8
+ * expect(toCamelCase('Address line 1')).toEqual('addressLine1');
9
+ * expect(toCamelCase('AddressLine1')).toEqual('addressLine1');
10
+ * expect(toCamelCase('addressLine1')).toEqual('addressLine1');
11
+ * expect(toCamelCase('address_line_1')).toEqual('addressLine1');
12
+ * expect(toCamelCase('address-line-1')).toEqual('addressLine1');
13
+ * expect(toCamelCase('address-line_1')).toEqual('addressLine1');
14
+ * expect(toCamelCase('address-line 1')).toEqual('addressLine1');
15
+ * expect(toCamelCase('ADDRESS_LINE_1')).toEqual('addressLine1');
16
+ * ```
17
+ *
18
+ * @since 0.2.0
19
+ *
20
+ * @param str input string
21
+ * @returns camelCased value of the input string
22
+ */
23
+ export declare function toCamelCase(str: string): string;
24
+ /**
25
+ * Takes the input string and returns the PascalCase equivalent
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * iimport { toPascalCase } from '@graphprotocol/hypergraph/mapping'
30
+ *
31
+ * expect(toPascalCase('Address line 1')).toEqual('AddressLine1');
32
+ * expect(toPascalCase('AddressLine1')).toEqual('AddressLine1');
33
+ * expect(toPascalCase('addressLine1')).toEqual('AddressLine1');
34
+ * expect(toPascalCase('address_line_1')).toEqual('AddressLine1');
35
+ * expect(toPascalCase('address-line-1')).toEqual('AddressLine1');
36
+ * expect(toPascalCase('address-line_1')).toEqual('AddressLine1');
37
+ * expect(toPascalCase('address-line 1')).toEqual('AddressLine1');
38
+ * expect(toPascalCase('ADDRESS_LINE_1')).toEqual('AddressLine1');
39
+ * ```
40
+ *
41
+ * @since 0.2.0
42
+ *
43
+ * @param str input string
44
+ * @returns PascalCased value of the input string
45
+ */
46
+ export declare function toPascalCase(str: string): string;
47
+ declare const InvalidInputError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
48
+ readonly _tag: "/typesync/errors/InvalidInputError";
49
+ } & Readonly<A>;
50
+ export declare class InvalidInputError extends InvalidInputError_base<{
51
+ readonly input: string;
52
+ readonly cause: unknown;
53
+ }> {
54
+ }
55
+ /**
56
+ * Adds schema validation that the array of objects with property `name` only has unique names
57
+ *
58
+ * @example <caption>only unique names -> returns true</caption>
59
+ * ```ts
60
+ * const types = [{name:'Account'}, {name:'Event'}]
61
+ * expect(namesAreUnique(types)).toEqual(true)
62
+ * ```
63
+ *
64
+ * @example <caption>duplicate name -> returns false</caption>
65
+ * ```ts
66
+ * const types = [{name:'Account'}, {name:'Event'}, {name:'Account'}]
67
+ * expect(namesAreUnique(types)).toEqual(false)
68
+ * ```
69
+ */
70
+ export declare function namesAreUnique<T extends {
71
+ readonly name: string;
72
+ }>(entries: ReadonlyArray<T>): boolean;
73
+ export {};
74
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/mapping/Utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsC/C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmChD;;;;AAED,qBAAa,iBAAkB,SAAQ,uBAAuD;IAC5F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,CAAC;CAAG;AAEL;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAYtG"}