@graphprotocol/hypergraph 0.0.14 → 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.
- package/dist/Entity.d.ts +69 -0
- package/dist/Entity.d.ts.map +1 -0
- package/dist/Entity.js +174 -0
- package/dist/Entity.js.map +1 -0
- package/dist/connect/identity-encryption.d.ts +3 -3
- package/dist/connect/identity-encryption.d.ts.map +1 -1
- package/dist/connect/identity-encryption.js +18 -52
- package/dist/connect/identity-encryption.js.map +1 -1
- package/dist/connect/login.d.ts +1 -1
- package/dist/connect/login.d.ts.map +1 -1
- package/dist/connect/login.js +2 -2
- package/dist/connect/login.js.map +1 -1
- package/dist/connect/parse-auth-params.js +1 -1
- package/dist/connect/parse-auth-params.js.map +1 -1
- package/dist/connect/smart-account.d.ts.map +1 -1
- package/dist/connect/smart-account.js +2 -2
- package/dist/connect/smart-account.js.map +1 -1
- package/dist/connect/types.d.ts +0 -1
- package/dist/connect/types.d.ts.map +1 -1
- package/dist/connect/types.js +0 -1
- package/dist/connect/types.js.map +1 -1
- package/dist/entity/findMany.js +1 -1
- package/dist/entity/findMany.js.map +1 -1
- package/dist/entity/update.js +1 -1
- package/dist/entity/update.js.map +1 -1
- package/dist/identity/create-identity-keys.d.ts +3 -0
- package/dist/identity/create-identity-keys.d.ts.map +1 -0
- package/dist/identity/create-identity-keys.js +20 -0
- package/dist/identity/create-identity-keys.js.map +1 -0
- package/dist/identity/get-verified-identity.d.ts +1 -1
- package/dist/identity/get-verified-identity.d.ts.map +1 -1
- package/dist/identity/get-verified-identity.js +17 -4
- package/dist/identity/get-verified-identity.js.map +1 -1
- package/dist/identity/identity-encryption.js +1 -1
- package/dist/identity/identity-encryption.js.map +1 -1
- package/dist/identity/index.d.ts +1 -1
- package/dist/identity/index.d.ts.map +1 -1
- package/dist/identity/index.js +1 -1
- package/dist/identity/index.js.map +1 -1
- package/dist/identity/login.d.ts +38 -0
- package/dist/identity/login.d.ts.map +1 -0
- package/dist/identity/login.js +241 -0
- package/dist/identity/login.js.map +1 -0
- package/dist/identity/prove-ownership.d.ts +1 -1
- package/dist/identity/prove-ownership.d.ts.map +1 -1
- package/dist/identity/prove-ownership.js +1 -1
- package/dist/identity/prove-ownership.js.map +1 -1
- package/dist/inboxes/index.d.ts +1 -1
- package/dist/inboxes/index.d.ts.map +1 -1
- package/dist/inboxes/index.js +1 -1
- package/dist/inboxes/index.js.map +1 -1
- package/dist/inboxes/message-validation.d.ts.map +1 -1
- package/dist/inboxes/message-validation.js +2 -2
- package/dist/inboxes/message-validation.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mapping/Mapping.d.ts +418 -0
- package/dist/mapping/Mapping.d.ts.map +1 -0
- package/dist/mapping/Mapping.js +554 -0
- package/dist/mapping/Mapping.js.map +1 -0
- package/dist/mapping/Utils.d.ts +74 -0
- package/dist/mapping/Utils.d.ts.map +1 -0
- package/dist/mapping/Utils.js +144 -0
- package/dist/mapping/Utils.js.map +1 -0
- package/dist/mapping/index.d.ts +3 -0
- package/dist/mapping/index.d.ts.map +1 -0
- package/dist/mapping/index.js +3 -0
- package/dist/mapping/index.js.map +1 -0
- package/dist/messages/types.d.ts +1 -1
- package/dist/messages/types.d.ts.map +1 -1
- package/dist/messages/types.js +2 -2
- package/dist/messages/types.js.map +1 -1
- package/dist/space-events/apply-event.d.ts +1 -1
- package/dist/space-events/apply-event.d.ts.map +1 -1
- package/dist/space-events/apply-event.js +1 -1
- package/dist/space-events/apply-event.js.map +1 -1
- package/dist/space-info/decrypt-space-info.d.ts +1 -1
- package/dist/space-info/decrypt-space-info.d.ts.map +1 -1
- package/dist/space-info/decrypt-space-info.js.map +1 -1
- package/dist/store-connect.d.ts.map +1 -1
- package/dist/store-connect.js.map +1 -1
- package/dist/store.d.ts +4 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +23 -3
- package/dist/store.js.map +1 -1
- package/dist/type/type.d.ts +0 -1
- package/dist/type/type.d.ts.map +1 -1
- package/dist/type/type.js +0 -1
- package/dist/type/type.js.map +1 -1
- package/dist/types.d.ts +0 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/hasArrayField.d.ts +2 -0
- package/dist/utils/hasArrayField.d.ts.map +1 -0
- package/dist/utils/hasArrayField.js +5 -0
- package/dist/utils/hasArrayField.js.map +1 -0
- package/package.json +4 -3
- package/src/connect/identity-encryption.ts +33 -69
- package/src/connect/login.ts +3 -3
- package/src/connect/parse-auth-params.ts +1 -1
- package/src/connect/smart-account.ts +12 -12
- package/src/connect/types.ts +0 -1
- package/src/entity/findMany.ts +2 -2
- package/src/entity/update.ts +1 -1
- package/src/identity/get-verified-identity.ts +17 -2
- package/src/identity/identity-encryption.ts +1 -1
- package/src/identity/index.ts +1 -1
- package/src/identity/prove-ownership.ts +2 -3
- package/src/inboxes/index.ts +1 -1
- package/src/inboxes/message-validation.ts +4 -0
- package/src/index.ts +2 -1
- package/src/mapping/Mapping.ts +771 -0
- package/src/mapping/Utils.ts +156 -0
- package/src/mapping/index.ts +2 -0
- package/src/messages/types.ts +1 -1
- package/src/space-events/apply-event.ts +5 -2
- package/src/space-info/decrypt-space-info.ts +1 -7
- package/src/store-connect.ts +1 -1
- package/src/store.ts +39 -9
- package/src/type/type.ts +0 -1
- package/src/types.ts +0 -15
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { type CreatePropertyParams, Id as Grc20Id, type Op } from '@graphprotocol/grc-20';
|
|
2
|
+
import { Schema as EffectSchema } from 'effect';
|
|
3
|
+
/**
|
|
4
|
+
* Mappings for a schema type and its properties/relations
|
|
5
|
+
*
|
|
6
|
+
* @since 0.2.0
|
|
7
|
+
*/
|
|
8
|
+
export type MappingEntry = {
|
|
9
|
+
/**
|
|
10
|
+
* Array of the `Id.Id` of the type in the Knowledge Graph.
|
|
11
|
+
* Is an array because a type can belong to multiple spaces/extend multiple types.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.2.0
|
|
14
|
+
*/
|
|
15
|
+
typeIds: Array<Grc20Id.Id>;
|
|
16
|
+
/**
|
|
17
|
+
* Record of property names to the `Id.Id` of the type in the Knowledge Graph
|
|
18
|
+
*
|
|
19
|
+
* @since 0.2.0
|
|
20
|
+
*/
|
|
21
|
+
properties?: {
|
|
22
|
+
[key: string]: Grc20Id.Id;
|
|
23
|
+
} | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Record of relation properties to the `Id.Id` of the type in the Knowledge Graph
|
|
26
|
+
*
|
|
27
|
+
* @since 0.2.0
|
|
28
|
+
*/
|
|
29
|
+
relations?: {
|
|
30
|
+
[key: string]: Grc20Id.Id;
|
|
31
|
+
} | undefined;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { Id } from '@graphprotocol/grc-20'
|
|
37
|
+
* import type { Mapping } from '@graphprotocol/hypergraph/mapping'
|
|
38
|
+
*
|
|
39
|
+
* const mapping: Mapping = {
|
|
40
|
+
* Account: {
|
|
41
|
+
* typeIds: [Id.Id('a5fd07b1-120f-46c6-b46f-387ef98396a6')],
|
|
42
|
+
* properties: {
|
|
43
|
+
* username: Id.Id('994edcff-6996-4a77-9797-a13e5e3efad8'),
|
|
44
|
+
* createdAt: Id.Id('64bfba51-a69b-4746-be4b-213214a879fe')
|
|
45
|
+
* }
|
|
46
|
+
* },
|
|
47
|
+
* Event: {
|
|
48
|
+
* typeIds: [Id.Id('0349187b-526f-435f-b2bb-9e9caf23127a')],
|
|
49
|
+
* properties: {
|
|
50
|
+
* name: Id.Id('3808e060-fb4a-4d08-8069-35b8c8a1902b'),
|
|
51
|
+
* description: Id.Id('1f0d9007-8da2-4b28-ab9f-3bc0709f4837'),
|
|
52
|
+
* },
|
|
53
|
+
* relations: {
|
|
54
|
+
* speaker: Id.Id('a5fd07b1-120f-46c6-b46f-387ef98396a6')
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @since 0.2.0
|
|
61
|
+
*/
|
|
62
|
+
export type Mapping = {
|
|
63
|
+
[key: string]: MappingEntry;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* @since 0.2.0
|
|
67
|
+
*/
|
|
68
|
+
export type DataTypeRelation = `Relation(${string})`;
|
|
69
|
+
/**
|
|
70
|
+
* @since 0.2.0
|
|
71
|
+
*/
|
|
72
|
+
export declare function isDataTypeRelation(val: string): val is DataTypeRelation;
|
|
73
|
+
/**
|
|
74
|
+
* @since 0.2.0
|
|
75
|
+
*/
|
|
76
|
+
export declare const SchemaDataTypeRelation: EffectSchema.refine<`Relation(${string})`, EffectSchema.Schema<string, string, never>>;
|
|
77
|
+
/**
|
|
78
|
+
* @since 0.2.0
|
|
79
|
+
*/
|
|
80
|
+
export type SchemaDataTypeRelation = typeof SchemaDataTypeRelation.Type;
|
|
81
|
+
/**
|
|
82
|
+
* @since 0.2.0
|
|
83
|
+
*/
|
|
84
|
+
export declare const SchemaDataTypePrimitive: EffectSchema.Literal<["Text", "Number", "Checkbox", "Date", "Point"]>;
|
|
85
|
+
/**
|
|
86
|
+
* @since 0.2.0
|
|
87
|
+
*/
|
|
88
|
+
export type SchemaDataTypePrimitive = typeof SchemaDataTypePrimitive.Type;
|
|
89
|
+
/**
|
|
90
|
+
* @since 0.2.0
|
|
91
|
+
*/
|
|
92
|
+
export declare const SchemaDataType: EffectSchema.Union<[EffectSchema.Literal<["Text", "Number", "Checkbox", "Date", "Point"]>, EffectSchema.refine<`Relation(${string})`, EffectSchema.Schema<string, string, never>>]>;
|
|
93
|
+
/**
|
|
94
|
+
* @since 0.2.0
|
|
95
|
+
*/
|
|
96
|
+
export type SchemaDataType = typeof SchemaDataType.Type;
|
|
97
|
+
/**
|
|
98
|
+
* @since 0.2.0
|
|
99
|
+
*/
|
|
100
|
+
export declare const SchemaTypePropertyRelation: EffectSchema.Struct<{
|
|
101
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
102
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
103
|
+
dataType: EffectSchema.refine<`Relation(${string})`, EffectSchema.Schema<string, string, never>>;
|
|
104
|
+
relationType: EffectSchema.refine<string, typeof EffectSchema.Trimmed>;
|
|
105
|
+
}>;
|
|
106
|
+
/**
|
|
107
|
+
* @since 0.2.0
|
|
108
|
+
*/
|
|
109
|
+
export type SchemaTypePropertyRelation = typeof SchemaTypePropertyRelation.Type;
|
|
110
|
+
/**
|
|
111
|
+
* @since 0.2.0
|
|
112
|
+
*/
|
|
113
|
+
export declare const SchemaTypePropertyPrimitive: EffectSchema.Struct<{
|
|
114
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
115
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
116
|
+
dataType: EffectSchema.Literal<["Text", "Number", "Checkbox", "Date", "Point"]>;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* @since 0.2.0
|
|
120
|
+
*/
|
|
121
|
+
export type SchemaTypePropertyPrimitive = typeof SchemaTypePropertyPrimitive.Type;
|
|
122
|
+
/**
|
|
123
|
+
* @since 0.2.0
|
|
124
|
+
*/
|
|
125
|
+
export declare function propertyIsRelation(property: SchemaTypePropertyPrimitive | SchemaTypePropertyRelation): property is SchemaTypePropertyRelation;
|
|
126
|
+
/**
|
|
127
|
+
* @since 0.2.0
|
|
128
|
+
*/
|
|
129
|
+
export declare const SchemaType: EffectSchema.Struct<{
|
|
130
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
131
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
132
|
+
properties: EffectSchema.filter<EffectSchema.filter<EffectSchema.Array$<EffectSchema.Union<[EffectSchema.Struct<{
|
|
133
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
134
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
135
|
+
dataType: EffectSchema.Literal<["Text", "Number", "Checkbox", "Date", "Point"]>;
|
|
136
|
+
}>, EffectSchema.Struct<{
|
|
137
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
138
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
139
|
+
dataType: EffectSchema.refine<`Relation(${string})`, EffectSchema.Schema<string, string, never>>;
|
|
140
|
+
relationType: EffectSchema.refine<string, typeof EffectSchema.Trimmed>;
|
|
141
|
+
}>]>>>>;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* @since 0.2.0
|
|
145
|
+
*/
|
|
146
|
+
export type SchemaType = typeof SchemaType.Type;
|
|
147
|
+
/**
|
|
148
|
+
* Represents the user-built schema object to generate a `Mappings` definition for
|
|
149
|
+
*
|
|
150
|
+
* @since 0.2.0
|
|
151
|
+
*/
|
|
152
|
+
export declare const Schema: EffectSchema.Struct<{
|
|
153
|
+
types: EffectSchema.filter<EffectSchema.filter<EffectSchema.filter<EffectSchema.Array$<EffectSchema.Struct<{
|
|
154
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
155
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
156
|
+
properties: EffectSchema.filter<EffectSchema.filter<EffectSchema.Array$<EffectSchema.Union<[EffectSchema.Struct<{
|
|
157
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
158
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
159
|
+
dataType: EffectSchema.Literal<["Text", "Number", "Checkbox", "Date", "Point"]>;
|
|
160
|
+
}>, EffectSchema.Struct<{
|
|
161
|
+
name: typeof EffectSchema.NonEmptyTrimmedString;
|
|
162
|
+
knowledgeGraphId: EffectSchema.NullOr<typeof EffectSchema.UUID>;
|
|
163
|
+
dataType: EffectSchema.refine<`Relation(${string})`, EffectSchema.Schema<string, string, never>>;
|
|
164
|
+
relationType: EffectSchema.refine<string, typeof EffectSchema.Trimmed>;
|
|
165
|
+
}>]>>>>;
|
|
166
|
+
}>>>>>;
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* @since 0.2.0
|
|
170
|
+
*/
|
|
171
|
+
export type Schema = typeof Schema.Type;
|
|
172
|
+
/**
|
|
173
|
+
* @since 0.2.0
|
|
174
|
+
*/
|
|
175
|
+
export declare const SchemaKnownDecoder: (i: {
|
|
176
|
+
readonly types: readonly {
|
|
177
|
+
readonly name: string;
|
|
178
|
+
readonly knowledgeGraphId: string | null;
|
|
179
|
+
readonly properties: readonly ({
|
|
180
|
+
readonly name: string;
|
|
181
|
+
readonly knowledgeGraphId: string | null;
|
|
182
|
+
readonly dataType: string;
|
|
183
|
+
readonly relationType: string;
|
|
184
|
+
} | {
|
|
185
|
+
readonly name: string;
|
|
186
|
+
readonly knowledgeGraphId: string | null;
|
|
187
|
+
readonly dataType: "Date" | "Text" | "Number" | "Checkbox" | "Point";
|
|
188
|
+
})[];
|
|
189
|
+
}[];
|
|
190
|
+
}, overrideOptions?: import("effect/SchemaAST").ParseOptions) => {
|
|
191
|
+
readonly types: readonly {
|
|
192
|
+
readonly name: string;
|
|
193
|
+
readonly knowledgeGraphId: string | null;
|
|
194
|
+
readonly properties: readonly ({
|
|
195
|
+
readonly name: string;
|
|
196
|
+
readonly knowledgeGraphId: string | null;
|
|
197
|
+
readonly dataType: `Relation(${string})`;
|
|
198
|
+
readonly relationType: string;
|
|
199
|
+
} | {
|
|
200
|
+
readonly name: string;
|
|
201
|
+
readonly knowledgeGraphId: string | null;
|
|
202
|
+
readonly dataType: "Date" | "Text" | "Number" | "Checkbox" | "Point";
|
|
203
|
+
})[];
|
|
204
|
+
}[];
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* @since 0.2.0
|
|
208
|
+
*/
|
|
209
|
+
export declare const SchemaUnknownDecoder: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions) => {
|
|
210
|
+
readonly types: readonly {
|
|
211
|
+
readonly name: string;
|
|
212
|
+
readonly knowledgeGraphId: string | null;
|
|
213
|
+
readonly properties: readonly ({
|
|
214
|
+
readonly name: string;
|
|
215
|
+
readonly knowledgeGraphId: string | null;
|
|
216
|
+
readonly dataType: `Relation(${string})`;
|
|
217
|
+
readonly relationType: string;
|
|
218
|
+
} | {
|
|
219
|
+
readonly name: string;
|
|
220
|
+
readonly knowledgeGraphId: string | null;
|
|
221
|
+
readonly dataType: "Date" | "Text" | "Number" | "Checkbox" | "Point";
|
|
222
|
+
})[];
|
|
223
|
+
}[];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Iterate through all properties in all types in the schema of `dataType` === `Relation(${string})`
|
|
227
|
+
* and validate that the schema.types have a type for the existing relation
|
|
228
|
+
*
|
|
229
|
+
* @example <caption>All types exist</caption>
|
|
230
|
+
* ```ts
|
|
231
|
+
* import { allRelationPropertyTypesExist, type Mapping } from '@graphprotocol/hypergraph/mapping'
|
|
232
|
+
*
|
|
233
|
+
* const types: Mapping['types'] = [
|
|
234
|
+
* {
|
|
235
|
+
* name: "Account",
|
|
236
|
+
* knowledgeGraphId: null,
|
|
237
|
+
* properties: [
|
|
238
|
+
* {
|
|
239
|
+
* name: "username",
|
|
240
|
+
* dataType: "Text",
|
|
241
|
+
* knowledgeGraphId: null
|
|
242
|
+
* }
|
|
243
|
+
* ]
|
|
244
|
+
* },
|
|
245
|
+
* {
|
|
246
|
+
* name: "Event",
|
|
247
|
+
* knowledgeGraphId: null,
|
|
248
|
+
* properties: [
|
|
249
|
+
* {
|
|
250
|
+
* name: "speaker",
|
|
251
|
+
* dataType: "Relation(Account)"
|
|
252
|
+
* relationType: "Account",
|
|
253
|
+
* knowledgeGraphId: null,
|
|
254
|
+
* }
|
|
255
|
+
* ]
|
|
256
|
+
* }
|
|
257
|
+
* ]
|
|
258
|
+
* expect(allRelationPropertyTypesExist(types)).toEqual(true)
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* @example <caption>Account type is missing</caption>
|
|
262
|
+
* ```ts
|
|
263
|
+
* import { allRelationPropertyTypesExist, type Mapping } from '@graphprotocol/hypergraph/mapping'
|
|
264
|
+
*
|
|
265
|
+
* const types: Mapping['types'] = [
|
|
266
|
+
* {
|
|
267
|
+
* name: "Event",
|
|
268
|
+
* knowledgeGraphId: null,
|
|
269
|
+
* properties: [
|
|
270
|
+
* {
|
|
271
|
+
* name: "speaker",
|
|
272
|
+
* dataType: "Relation(Account)",
|
|
273
|
+
* relationType: "Account",
|
|
274
|
+
* knowledgeGraphId: null,
|
|
275
|
+
* }
|
|
276
|
+
* ]
|
|
277
|
+
* }
|
|
278
|
+
* ]
|
|
279
|
+
* expect(allRelationPropertyTypesExist(types)).toEqual(false)
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @since 0.2.0
|
|
283
|
+
*
|
|
284
|
+
* @param types the user-submitted schema types
|
|
285
|
+
*/
|
|
286
|
+
export declare function allRelationPropertyTypesExist(types: ReadonlyArray<SchemaType>): boolean;
|
|
287
|
+
export type GenerateMappingResult = [mapping: Mapping, ops: ReadonlyArray<Op>];
|
|
288
|
+
/**
|
|
289
|
+
* 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.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { Id } from "@graphprotocol/grc-20"
|
|
294
|
+
* import { generateMapping } from "@graphprotocol/typesync"
|
|
295
|
+
*
|
|
296
|
+
* const schema: Schema = {
|
|
297
|
+
* types: [
|
|
298
|
+
* {
|
|
299
|
+
* name: "Account",
|
|
300
|
+
* knowledgeGraphId: "a5fd07b1-120f-46c6-b46f-387ef98396a6",
|
|
301
|
+
* properties: [
|
|
302
|
+
* {
|
|
303
|
+
* name: "username",
|
|
304
|
+
* dataType: "Text",
|
|
305
|
+
* knowledgeGraphId: "994edcff-6996-4a77-9797-a13e5e3efad8"
|
|
306
|
+
* },
|
|
307
|
+
* {
|
|
308
|
+
* name: "createdAt",
|
|
309
|
+
* dataType: "Date",
|
|
310
|
+
* knowledgeGraphId: null
|
|
311
|
+
* }
|
|
312
|
+
* ]
|
|
313
|
+
* },
|
|
314
|
+
* {
|
|
315
|
+
* name: "Event",
|
|
316
|
+
* knowledgeGraphId: null,
|
|
317
|
+
* properties: [
|
|
318
|
+
* {
|
|
319
|
+
* name: "name",
|
|
320
|
+
* dataType: "Text",
|
|
321
|
+
* knowledgeGraphId: "3808e060-fb4a-4d08-8069-35b8c8a1902b"
|
|
322
|
+
* },
|
|
323
|
+
* {
|
|
324
|
+
* name: "description",
|
|
325
|
+
* dataType: "Text",
|
|
326
|
+
* knowledgeGraphId: null
|
|
327
|
+
* },
|
|
328
|
+
* {
|
|
329
|
+
* name: "speaker",
|
|
330
|
+
* dataType: "Relation(Account)",
|
|
331
|
+
* relationType: "Account",
|
|
332
|
+
* knowledgeGraphId: null
|
|
333
|
+
* }
|
|
334
|
+
* ]
|
|
335
|
+
* }
|
|
336
|
+
* ],
|
|
337
|
+
* }
|
|
338
|
+
* const [mapping, ops] = generateMapping(schema)
|
|
339
|
+
*
|
|
340
|
+
* expect(mapping).toEqual({
|
|
341
|
+
* Account: {
|
|
342
|
+
* typeIds: [Id.Id("a5fd07b1-120f-46c6-b46f-387ef98396a6")], // comes from input schema
|
|
343
|
+
* properties: {
|
|
344
|
+
* username: Id.Id("994edcff-6996-4a77-9797-a13e5e3efad8"), // comes from input schema
|
|
345
|
+
* createdAt: Id.Id("8cd7d9ac-a878-4287-8000-e71e6f853117"), // generated from Graph.createProperty Op
|
|
346
|
+
* }
|
|
347
|
+
* },
|
|
348
|
+
* Event: {
|
|
349
|
+
* typeIds: [Id.Id("20b3fe39-8e62-41a0-b9cb-92743fd760da")], // generated from Graph.createType Op
|
|
350
|
+
* properties: {
|
|
351
|
+
* name: Id.Id("3808e060-fb4a-4d08-8069-35b8c8a1902b"), // comes from input schema
|
|
352
|
+
* description: Id.Id("8fc4e17c-7581-4d6c-a712-943385afc7b5"), // generated from Graph.createProperty Op
|
|
353
|
+
* },
|
|
354
|
+
* relations: {
|
|
355
|
+
* speaker: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"), // generated from Graph.createProperty Op
|
|
356
|
+
* }
|
|
357
|
+
* }
|
|
358
|
+
* })
|
|
359
|
+
* expect(ops).toEqual([
|
|
360
|
+
* // Graph.createProperty Op for Account.createdAt property
|
|
361
|
+
* {
|
|
362
|
+
* type: "CREATE_PROPERTY",
|
|
363
|
+
* property: {
|
|
364
|
+
* id: Id.Id("8cd7d9ac-a878-4287-8000-e71e6f853117"),
|
|
365
|
+
* dataType: "TEXT"
|
|
366
|
+
* }
|
|
367
|
+
* },
|
|
368
|
+
* // Graph.createProperty Op for Event.description property
|
|
369
|
+
* {
|
|
370
|
+
* type: "CREATE_PROPERTY",
|
|
371
|
+
* property: {
|
|
372
|
+
* id: Id.Id("8fc4e17c-7581-4d6c-a712-943385afc7b5"),
|
|
373
|
+
* dataType: "TEXT"
|
|
374
|
+
* }
|
|
375
|
+
* },
|
|
376
|
+
* // Graph.createProperty Op for Event.speaker property
|
|
377
|
+
* {
|
|
378
|
+
* type: "CREATE_PROPERTY",
|
|
379
|
+
* property: {
|
|
380
|
+
* id: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"),
|
|
381
|
+
* dataType: "RELATION"
|
|
382
|
+
* }
|
|
383
|
+
* },
|
|
384
|
+
* // Graph.createType Op for Event type
|
|
385
|
+
* {
|
|
386
|
+
* type: "CREATE_PROPERTY",
|
|
387
|
+
* property: {
|
|
388
|
+
* id: Id.Id("651ce59f-643b-4931-bf7a-5dc0ca0f5a47"),
|
|
389
|
+
* dataType: "RELATION"
|
|
390
|
+
* }
|
|
391
|
+
* },
|
|
392
|
+
* ])
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* @since 0.2.0
|
|
396
|
+
*
|
|
397
|
+
* @param input user-built and submitted schema
|
|
398
|
+
* @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
|
|
399
|
+
*/
|
|
400
|
+
export declare function generateMapping(input: Schema): GenerateMappingResult;
|
|
401
|
+
declare const RelationValueTypeDoesNotExistError_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 & {
|
|
402
|
+
readonly _tag: "/typesync/errors/RelationValueTypeDoesNotExistError";
|
|
403
|
+
} & Readonly<A>;
|
|
404
|
+
export declare class RelationValueTypeDoesNotExistError extends RelationValueTypeDoesNotExistError_base<{
|
|
405
|
+
readonly message: string;
|
|
406
|
+
readonly property: string;
|
|
407
|
+
readonly relatedType: string;
|
|
408
|
+
}> {
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* @since 0.2.0
|
|
412
|
+
*
|
|
413
|
+
* @param dataType the dataType from the user-submitted schema
|
|
414
|
+
* @returns the mapped to GRC-20 dataType for the GRC-20 ops
|
|
415
|
+
*/
|
|
416
|
+
export declare function mapSchemaDataTypeToGRC20PropDataType(dataType: SchemaDataType): CreatePropertyParams['dataType'];
|
|
417
|
+
export {};
|
|
418
|
+
//# sourceMappingURL=Mapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Mapping.d.ts","sourceRoot":"","sources":["../../src/mapping/Mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAS,EAAE,IAAI,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAA8B,MAAM,IAAI,YAAY,EAAgB,MAAM,QAAQ,CAAC;AAI1F;;;;GAIG;AACH,MAAM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