MCPcopy Create free account
hub / github.com/instantdb/instant / apiSchemaToInstantSchemaDef

Function apiSchemaToInstantSchemaDef

client/packages/platform/src/api.ts:446–461  ·  view source on GitHub ↗
(
  apiSchema: InstantAPIPlatformSchema,
)

Source from the content-addressed store, hash-verified

444}
445
446export function apiSchemaToInstantSchemaDef(
447 apiSchema: InstantAPIPlatformSchema,
448): InstantSchemaDef<EntitiesDef, LinksDef<EntitiesDef>, RoomsDef> {
449 const entities: EntitiesDef = {};
450 for (const [etype, attrs] of sortedEntries(apiSchema.blobs)) {
451 entities[etype] = apiSchemaBlobToEntityDef(attrs);
452 }
453 const links: LinksDef<EntitiesDef> = {};
454 for (const [_name, attr] of sortedEntries(apiSchema.refs)) {
455 const link = apiSchemaAttrToLinkDef(attr);
456 const linkName = apiSchemaAttrToLinkName(attr);
457 links[linkName] = link;
458 }
459
460 return i.schema({ entities, links });
461}
462
463function coerceApp<Opts extends AppDataOpts>(
464 app: AppResponseJSON<Opts>,

Callers 11

attrsToTsFileFunction · 0.90
schemaTsFunction · 0.90
dbForAttrsFunction · 0.90
dbForAttrsFunction · 0.90
pushSchemaFunction · 0.90
pullSchemaFunction · 0.90
schema.test.tsFile · 0.90
coerceAppFunction · 0.85
getAppSchemaFunction · 0.85
planSchemaPushFunction · 0.85

Calls 4

sortedEntriesFunction · 0.90
apiSchemaBlobToEntityDefFunction · 0.85
apiSchemaAttrToLinkDefFunction · 0.85
apiSchemaAttrToLinkNameFunction · 0.85

Tested by

no test coverage detected