@blockprotocol/type-system-node
Advanced tools
Comparing version 0.0.1 to 0.0.2
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export const memory: WebAssembly.Memory; | ||
export function parseBaseUri(a: number, b: number, c: number): void; | ||
export function isValidVersionedUri(a: number, b: number, c: number): void; | ||
export function __wbg_parsebaseurierror_free(a: number): void; | ||
export function __wbg_parseversionedurierror_free(a: number): void; | ||
export function __wbindgen_add_to_stack_pointer(a: number): number; | ||
export function validateDataType(a: number): number; | ||
export function validateEntityType(a: number): number; | ||
export function validatePropertyType(a: number): number; | ||
export function validateBaseUri(a: number, b: number): number; | ||
export function validateVersionedUri(a: number, b: number): number; | ||
export function extractBaseUri(a: number, b: number, c: number): void; | ||
export function extractVersion(a: number, b: number, c: number): void; | ||
export function __wbindgen_malloc(a: number): number; | ||
export function __wbindgen_realloc(a: number, b: number, c: number): number; | ||
export function __wbindgen_add_to_stack_pointer(a: number): number; | ||
export function __wbindgen_free(a: number, b: number): void; |
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export interface OneOf<T> { | ||
oneOf: [T, ...T[]]; | ||
} | ||
export interface Object<T> { | ||
type: 'object'; | ||
properties: Record<BaseUri, T>; | ||
required?: BaseUri[]; | ||
} | ||
export type ValueOrArray<T> = T | Array<T>; | ||
export interface Array<T> { | ||
type: 'array'; | ||
items: T; | ||
minItems?: number; | ||
maxItems?: number; | ||
} | ||
/** | ||
* Takes a URL string and attempts to parse it into a valid URL, returning it in standardized form | ||
* @param {string} uri | ||
* @returns {string} | ||
*/ | ||
export function parseBaseUri(uri: string): string; | ||
* Checks if a given Data Type is correctly formed | ||
* | ||
* @param {DataType} dataType - The Data Type object to validate. | ||
* @returns {(Result.Ok|Result.Err<ParseDataTypeError>)} - an Ok with null inner if valid, or an Err with an inner ParseDataTypeError | ||
*/ | ||
export function validateDataType(dataType: DataType): Result<undefined, ParseDataTypeError>; | ||
/** | ||
* Checks if a given URL string is a Block Protocol compliant Versioned URI. | ||
* | ||
* If the URL is valid this function returns nothing, otherwise it throws a | ||
* `ParseVersionedUriError` | ||
* @param {string} uri | ||
*/ | ||
export function isValidVersionedUri(uri: string): void; | ||
* Checks if a given Entity Type is correctly formed | ||
* | ||
* @param {EntityType} entityType - The Entity Type object to validate. | ||
* @returns {(Result.Ok|Result.Err<ParseEntityTypeError>)} - an Ok with null inner if valid, or an Err with an inner ParseEntityTypeError | ||
*/ | ||
export function validateEntityType(entityType: EntityType): Result<undefined, ParseEntityTypeError>; | ||
/** | ||
*/ | ||
export class ParseBaseUriError { | ||
free(): void; | ||
* Checks if a given Property Type is correctly formed | ||
* | ||
* @param {PropertyType} propertyType - The Property Type object to validate. | ||
* @returns {(Result.Ok|Result.Err<ParsePropertyTypeError>)} - an Ok with null inner if valid, or an Err with an inner ParsePropertyTypeError | ||
*/ | ||
export function validatePropertyType(propertyType: PropertyType): Result<undefined, ParsePropertyTypeError>; | ||
export type ParseLinksError = { reason: "InvalidLinkKey"; inner: ParseVersionedUriError } | { reason: "InvalidArray"; inner: ParseEntityTypeReferenceArrayError } | { reason: "InvalidRequiredKey"; inner: ParseVersionedUriError } | { reason: "ValidationError"; inner: ValidationError } | { reason: "InvalidJson"; inner: string }; | ||
export type ParseDataTypeError = { reason: "InvalidVersionedUri"; inner: ParseVersionedUriError } | { reason: "InvalidJson"; inner: string }; | ||
export interface PropertyType extends OneOf<PropertyValues> { | ||
kind: 'propertyType'; | ||
$id: VersionedUri; | ||
title: string; | ||
description?: string; | ||
} | ||
export interface PropertyTypeReference { | ||
$ref: VersionedUri; | ||
} | ||
export type PropertyValues = DataTypeReference | Object<ValueOrArray<PropertyTypeReference>> | Array<OneOf<PropertyValues>>; | ||
export type VersionedUri = `${string}/v/${number}`; | ||
/** | ||
*/ | ||
export class ParseVersionedUriError { | ||
free(): void; | ||
* Checks if a given URL string is a valid base URL. | ||
* | ||
* @param {BaseUri} uri - The URL string. | ||
* @returns {(Result.Ok|Result.Err<ParseBaseUriError>)} - an Ok with an inner of the string as a | ||
* BaseUri if valid, or an Err with an inner ParseBaseUriError | ||
*/ | ||
export function validateBaseUri(uri: string): Result<BaseUri, ParseBaseUriError>; | ||
/** | ||
* Checks if a given URL string is a Block Protocol compliant Versioned URI. | ||
* | ||
* @param {string} uri - The URL string. | ||
* @returns {(Result.Ok|Result.Err<ParseVersionedUriError>)} - an Ok with an inner of the string as | ||
* a VersionedUri if valid, or an Err with an inner ParseVersionedUriError | ||
*/ | ||
export function validateVersionedUri(uri: string): Result<VersionedUri, ParseVersionedUriError>; | ||
/** | ||
* Extracts the base URI from a Versioned URI. | ||
* | ||
* @param {VersionedUri} uri - The versioned URI. | ||
* @throws {ParseVersionedUriError} if the versioned URI is invalid. | ||
*/ | ||
export function extractBaseUri(uri: VersionedUri): BaseUri; | ||
/** | ||
* Extracts the version from a Versioned URI. | ||
* | ||
* @param {VersionedUri} uri - The versioned URI. | ||
* @throws {ParseVersionedUriError} if the versioned URI is invalid. | ||
*/ | ||
export function extractVersion(uri: VersionedUri): number; | ||
export type MaybeOneOfEntityTypeReference = OneOf<EntityTypeReference> | {}; | ||
export type BaseUri = string; | ||
export type ParseVersionedUriError = { reason: "IncorrectFormatting" } | { reason: "MissingBaseUri" } | { reason: "MissingVersion" } | { reason: "InvalidVersion"; inner: string } | { reason: "AdditionalEndContent" } | { reason: "InvalidBaseUri"; inner: ParseBaseUriError } | { reason: "InvalidJson"; inner: string }; | ||
export type ParseBaseUriError = { reason: "MissingTrailingSlash" } | { reason: "UrlParseError"; inner: string } | { reason: "CannotBeABase" }; | ||
export interface EntityTypeReference { | ||
$ref: VersionedUri; | ||
} | ||
export interface EntityType extends AllOf<EntityTypeReference>, Object<ValueOrArray<PropertyTypeReference>>, Links { | ||
kind: 'entityType'; | ||
$id: VersionedUri; | ||
title: string; | ||
description?: string; | ||
default?: Record<BaseUri, any>; | ||
examples?: Record<BaseUri, any>[]; | ||
} | ||
export interface Links { | ||
links?: Record<VersionedUri, MaybeOrderedArray<MaybeOneOfEntityTypeReference>>; | ||
requiredLinks?: VersionedUri[]; | ||
} | ||
export interface MaybeOrderedArray<T> extends Array<T> { | ||
ordered: boolean; | ||
} | ||
export type ParseEntityTypeReferenceArrayError = { reason: "InvalidReference"; inner: ParseOneOfError } | { reason: "InvalidJson"; inner: string }; | ||
export type ParsePropertyTypeReferenceArrayError = { reason: "InvalidReference"; inner: ParseVersionedUriError } | { reason: "InvalidJson"; inner: string }; | ||
export type ParseOneOfArrayError = { reason: "InvalidItems"; inner: ParseOneOfError } | { reason: "InvalidJson"; inner: string }; | ||
export interface AllOf<T> { | ||
allOf?: T[]; | ||
} | ||
export type ValidationError = { type: "MissingRequiredProperty"; inner: BaseUri } | { type: "BaseUriMismatch"; inner: { base_uri: BaseUri; versioned_uri: VersionedUri } } | { type: "MissingRequiredLink"; inner: VersionedUri } | { type: "MismatchedPropertyCount"; inner: { actual: number; expected: number } } | { type: "EmptyOneOf" }; | ||
export type ParseOneOfError = { reason: "EntityTypeReferenceError"; inner: ParseVersionedUriError } | { reason: "PropertyValuesError"; inner: ParsePropertyTypeError } | { reason: "ValidationError"; inner: ValidationError }; | ||
export type ParseEntityTypeError = { reason: "InvalidPropertyTypeObject"; inner: ParsePropertyTypeObjectError } | { reason: "InvalidAllOf"; inner: ParseAllOfError } | { reason: "InvalidLinks"; inner: ParseLinksError } | { reason: "InvalidDefaultKey"; inner: ParseBaseUriError } | { reason: "InvalidExamplesKey"; inner: ParseBaseUriError } | { reason: "InvalidVersionedUri"; inner: ParseVersionedUriError } | { reason: "InvalidJson"; inner: string }; | ||
export interface DataTypeReference { | ||
$ref: VersionedUri; | ||
} | ||
export interface DataType extends Record<string, any> { | ||
kind: 'dataType'; | ||
$id: VersionedUri; | ||
title: string; | ||
description?: string; | ||
type: string; | ||
} | ||
export type Result<T, E> = { type: "Ok"; inner: T } | { type: "Err"; inner: E }; | ||
export type ParsePropertyTypeObjectError = { reason: "InvalidPropertyTypeReference"; inner: ParseVersionedUriError } | { reason: "InvalidArray"; inner: ParsePropertyTypeReferenceArrayError } | { reason: "InvalidPropertyKey"; inner: ParseBaseUriError } | { reason: "InvalidRequiredKey"; inner: ParseBaseUriError } | { reason: "ValidationError"; inner: ValidationError } | { reason: "InvalidJson"; inner: string }; | ||
export type ParseAllOfError = { reason: "EntityTypeReferenceError"; inner: ParseVersionedUriError }; | ||
export type ParsePropertyTypeError = { reason: "InvalidVersionedUri"; inner: ParseVersionedUriError } | { reason: "InvalidDataTypeReference"; inner: ParseVersionedUriError } | { reason: "InvalidPropertyTypeObject"; inner: ParsePropertyTypeObjectError } | { reason: "InvalidOneOf"; inner: ParseOneOfError } | { reason: "InvalidArrayItems"; inner: ParseOneOfArrayError } | { reason: "InvalidJson"; inner: string }; | ||
@@ -23,2 +23,19 @@ let imports = {}; | ||
const heap = new Array(32).fill(undefined); | ||
heap.push(undefined, null, true, false); | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let WASM_VECTOR_LEN = 0; | ||
@@ -88,10 +105,10 @@ | ||
const heap = new Array(32).fill(undefined); | ||
let stack_pointer = 32; | ||
heap.push(undefined, null, true, false); | ||
function addBorrowedObject(obj) { | ||
if (stack_pointer == 1) throw new Error('out of js stack'); | ||
heap[--stack_pointer] = obj; | ||
return stack_pointer; | ||
} | ||
function getObject(idx) { return heap[idx]; } | ||
let heap_next = heap.length; | ||
function dropObject(idx) { | ||
@@ -109,7 +126,67 @@ if (idx < 36) return; | ||
/** | ||
* Takes a URL string and attempts to parse it into a valid URL, returning it in standardized form | ||
* @param {any} data_type_obj | ||
* @returns {any} | ||
*/ | ||
module.exports.validateDataType = function(data_type_obj) { | ||
try { | ||
const ret = wasm.validateDataType(addBorrowedObject(data_type_obj)); | ||
return takeObject(ret); | ||
} finally { | ||
heap[stack_pointer++] = undefined; | ||
} | ||
}; | ||
/** | ||
* @param {any} entity_type_obj | ||
* @returns {any} | ||
*/ | ||
module.exports.validateEntityType = function(entity_type_obj) { | ||
try { | ||
const ret = wasm.validateEntityType(addBorrowedObject(entity_type_obj)); | ||
return takeObject(ret); | ||
} finally { | ||
heap[stack_pointer++] = undefined; | ||
} | ||
}; | ||
/** | ||
* @param {any} property_type_obj | ||
* @returns {any} | ||
*/ | ||
module.exports.validatePropertyType = function(property_type_obj) { | ||
try { | ||
const ret = wasm.validatePropertyType(addBorrowedObject(property_type_obj)); | ||
return takeObject(ret); | ||
} finally { | ||
heap[stack_pointer++] = undefined; | ||
} | ||
}; | ||
/** | ||
* @param {string} uri | ||
* @returns {any} | ||
*/ | ||
module.exports.validateBaseUri = function(uri) { | ||
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.validateBaseUri(ptr0, len0); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* @param {string} uri | ||
* @returns {any} | ||
*/ | ||
module.exports.validateVersionedUri = function(uri) { | ||
const ptr0 = passStringToWasm0(uri, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.validateVersionedUri(ptr0, len0); | ||
return takeObject(ret); | ||
}; | ||
/** | ||
* @param {string} uri | ||
* @returns {string} | ||
*/ | ||
module.exports.parseBaseUri = function(uri) { | ||
module.exports.extractBaseUri = function(uri) { | ||
try { | ||
@@ -119,3 +196,3 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.parseBaseUri(retptr, ptr0, len0); | ||
wasm.extractBaseUri(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
@@ -139,9 +216,6 @@ var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
/** | ||
* Checks if a given URL string is a Block Protocol compliant Versioned URI. | ||
* | ||
* If the URL is valid this function returns nothing, otherwise it throws a | ||
* `ParseVersionedUriError` | ||
* @param {string} uri | ||
* @returns {number} | ||
*/ | ||
module.exports.isValidVersionedUri = function(uri) { | ||
module.exports.extractVersion = function(uri) { | ||
try { | ||
@@ -151,8 +225,10 @@ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.isValidVersionedUri(retptr, ptr0, len0); | ||
wasm.extractVersion(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
if (r1) { | ||
throw takeObject(r0); | ||
var r2 = getInt32Memory0()[retptr / 4 + 2]; | ||
if (r2) { | ||
throw takeObject(r1); | ||
} | ||
return r0 >>> 0; | ||
} finally { | ||
@@ -163,67 +239,14 @@ wasm.__wbindgen_add_to_stack_pointer(16); | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
/** | ||
*/ | ||
class ParseBaseUriError { | ||
static __wrap(ptr) { | ||
const obj = Object.create(ParseBaseUriError.prototype); | ||
obj.ptr = ptr; | ||
return obj; | ||
} | ||
__destroy_into_raw() { | ||
const ptr = this.ptr; | ||
this.ptr = 0; | ||
return ptr; | ||
} | ||
free() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_parsebaseurierror_free(ptr); | ||
} | ||
} | ||
module.exports.ParseBaseUriError = ParseBaseUriError; | ||
/** | ||
*/ | ||
class ParseVersionedUriError { | ||
static __wrap(ptr) { | ||
const obj = Object.create(ParseVersionedUriError.prototype); | ||
obj.ptr = ptr; | ||
return obj; | ||
} | ||
__destroy_into_raw() { | ||
const ptr = this.ptr; | ||
this.ptr = 0; | ||
return ptr; | ||
} | ||
free() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_parseversionedurierror_free(ptr); | ||
} | ||
} | ||
module.exports.ParseVersionedUriError = ParseVersionedUriError; | ||
module.exports.__wbg_parsebaseurierror_new = function(arg0) { | ||
const ret = ParseBaseUriError.__wrap(arg0); | ||
module.exports.__wbindgen_json_parse = function(arg0, arg1) { | ||
const ret = JSON.parse(getStringFromWasm0(arg0, arg1)); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_parseversionedurierror_new = function(arg0) { | ||
const ret = ParseVersionedUriError.__wrap(arg0); | ||
return addHeapObject(ret); | ||
module.exports.__wbindgen_json_serialize = function(arg0, arg1) { | ||
const obj = getObject(arg1); | ||
const ret = JSON.stringify(obj === undefined ? null : obj); | ||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
}; | ||
@@ -230,0 +253,0 @@ |
{ | ||
"name": "@blockprotocol/type-system-node", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Definitions of types within the Block Protocol Type System", | ||
@@ -18,2 +18,4 @@ "homepage": "https://blockprotocol.org", | ||
"scripts": { | ||
"fix:eslint": "eslint --fix .", | ||
"lint:eslint": "eslint .", | ||
"lint:tsc": "tsc --noEmit", | ||
@@ -23,5 +25,9 @@ "test": "jest" | ||
"devDependencies": { | ||
"@types/jest": "28.1.4", | ||
"jest": "28.1.2", | ||
"ts-jest": "28.0.5" | ||
"@local/eslint-config": "0.0.0-private", | ||
"@local/tsconfig": "0.0.0-private", | ||
"@types/jest": "29.2.0", | ||
"eslint": "8.26.0", | ||
"jest": "29.2.2", | ||
"ts-jest": "29.0.3", | ||
"typescript": "4.8.4" | ||
}, | ||
@@ -28,0 +34,0 @@ "collaborators": [ |
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"allowJs": true, | ||
"declaration": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"isolatedModules": true, | ||
"jsx": "react-jsx", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"outDir": "dist/esm", | ||
"skipLibCheck": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"target": "es5" | ||
}, | ||
"include": [ | ||
"assets.d.ts", | ||
"./src/**/*.ts", | ||
"./src/**/*.tsx", | ||
"./dev/**/*.ts", | ||
"./dev/**/*.tsx", | ||
"./dist/**/*.ts", | ||
"./dist/**/*.tsx" | ||
], | ||
"exclude": ["node_modules"] | ||
"extends": "@local/tsconfig/dom.json", | ||
"include": ["dist", "test"], | ||
"exclude": ["**/*.js"] | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1175775
14
1453
7
1