Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alge

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alge - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1-next.1

dist/cjs/core/helpers.cjs

6

dist/esm/core/helpers.js

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.is = void 0;
/**

@@ -11,3 +8,3 @@ * Helper for implementing ADT `is` functions.

*/
const is = (value, symbol) => {
export const is = (value, symbol) => {
// TODO waiting for https://github.com/Microsoft/TypeScript/issues/21732

@@ -26,3 +23,2 @@ return (typeof value === `object` &&

};
exports.is = is;
//# sourceMappingURL=helpers.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=internal.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=types.js.map

@@ -1,11 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.data = void 0;
const index_js_1 = require("../Errors/index.js");
const r_js_1 = require("../lib/r.js");
const utils_js_1 = require("../lib/utils.js");
const index_js_2 = require("../lib/z/index.js");
const runtime_js_1 = require("../record/runtime.js");
import { Errors } from '../Errors/index.js';
import { r } from '../lib/r.js';
import { code, inspect, isEmpty } from '../lib/utils.js';
import { z } from '../lib/z/index.js';
import { record } from '../record/runtime.js';
//eslint-disable-next-line
function data(name, shortHandRecordSchemaDefinitionsOrSchemas) {
export function data(name, shortHandRecordSchemaDefinitionsOrSchemas) {
// let currentRecord: null | SomeRecordDefinition = null

@@ -22,7 +19,7 @@ // const records: SomeRecordDefinition[] = []

? // @ts-expect-error null not allowed by consumers
(0, runtime_js_1.record)(nameOrRecord, null, {
record(nameOrRecord, null, {
extensions: builder,
})
: // @ts-expect-error null not allowed by consumers
(0, runtime_js_1.record)(nameOrRecord.name, null, {
record(nameOrRecord.name, null, {
extensions: builder,

@@ -36,5 +33,5 @@ extend: nameOrRecord,

records.push(currentRecordBuilder._.innerChain.done());
if ((0, utils_js_1.isEmpty)(records))
if (isEmpty(records))
throw createEmptyRecordsError({ name });
const recordsMethods = r_js_1.r.pipe(records, r_js_1.r.indexBy(r_js_1.r.prop(`name`)));
const recordsMethods = r.pipe(records, r.indexBy(r.prop(`name`)));
// Get the common codecs. We only need to iterate from the point of view of one

@@ -63,3 +60,3 @@ // record's codecs, so we'll pick the first. We're guaranteed to have at least

if (data === null)
throw new Error(`Failed to decode value \`${(0, utils_js_1.inspect)(string)}\` into any of the records for this ADT.`);
throw new Error(`Failed to decode value \`${inspect(string)}\` into any of the records for this ADT.`);
return data;

@@ -79,3 +76,3 @@ },

}
throw new Error(`Failed to find an encoder for data: "${(0, utils_js_1.inspect)(data)}"`);
throw new Error(`Failed to find an encoder for data: "${inspect(data)}"`);
},

@@ -88,3 +85,3 @@ };

schema: records.length >= 2
? index_js_2.z.union([
? z.union([
// eslint-disable-next-line

@@ -130,4 +127,3 @@ records[0].schema,

}
exports.data = data;
const createEmptyRecordsError = (params) => index_js_1.Errors.UserMistake.create(`No records defined for ADT ${(0, utils_js_1.code)(params.name)} but ${(0, utils_js_1.code)(`.done()`)} was called. You can only call ${(0, utils_js_1.code)(`.done()`)} after your ADT has at least one record defined (via ${(0, utils_js_1.code)(`.record()`)}).`);
const createEmptyRecordsError = (params) => Errors.UserMistake.create(`No records defined for ADT ${code(params.name)} but ${code(`.done()`)} was called. You can only call ${code(`.done()`)} after your ADT has at least one record defined (via ${code(`.record()`)}).`);
//# sourceMappingURL=runtime.js.map

@@ -1,6 +0,5 @@

"use strict";
/**
* This module is concerned with the static types for the API of building up an ADT.
*/
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=Builder.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=Controller.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=internal.js.map

@@ -1,18 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./UserMistake/index.js"), exports);
export * from './UserMistake/index.js';
//# sourceMappingURL=index_.js.map

@@ -1,28 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Errors = void 0;
exports.Errors = __importStar(require("./index_.js"));
export * as Errors from './index_.js';
//# sourceMappingURL=index.js.map

@@ -1,28 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserMistake = void 0;
exports.UserMistake = __importStar(require("./UserMistake.js"));
export * as UserMistake from './UserMistake.js';
//# sourceMappingURL=index.js.map

@@ -1,7 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = void 0;
const utils_js_1 = require("../../lib/utils.js");
const create = (message) => new Error(`Alge User Mistake: ${(0, utils_js_1.ensurePeriod)(message)}`);
exports.create = create;
import { ensurePeriod } from '../../lib/utils.js';
export const create = (message) => new Error(`Alge User Mistake: ${ensurePeriod(message)}`);
//# sourceMappingURL=UserMistake.js.map

@@ -1,22 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.match = void 0;
__exportStar(require("./data/runtime.js"), exports);
var match_js_1 = require("./match.js");
Object.defineProperty(exports, "match", { enumerable: true, get: function () { return match_js_1.match; } });
__exportStar(require("./record/runtime.js"), exports);
export * from './data/runtime.js';
export { match } from './match.js';
export * from './record/runtime.js';
//# sourceMappingURL=index_.js.map

@@ -1,28 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Alge = void 0;
exports.Alge = __importStar(require("./index_.js"));
export * as Alge from './index_.js';
//# sourceMappingURL=index.js.map

@@ -1,28 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.r = void 0;
exports.r = __importStar(require("remeda"));
export * as r from 'remeda';
//# sourceMappingURL=r.js.map

@@ -13,11 +13,11 @@ import type { z } from 'zod';

export declare const isEmptySchema: (schema: z.SomeZodObject) => boolean;
export declare const tryOrNull: <T>(fn: () => T) => T | null;
export declare const tryOrNull: <T extends unknown>(fn: () => T) => T | null;
export declare type Rest<x extends unknown[]> = x extends [infer _first, ...infer rest] ? rest : [];
export declare type IndexKeys<A extends readonly unknown[]> = Exclude<keyof A, keyof []>;
export declare type OnlyStrings<x> = x extends string ? x : never;
export declare type OmitRequired<T> = {
export declare type OnlyStrings<x extends unknown> = x extends string ? x : never;
export declare type OmitRequired<T extends unknown> = {
[K in keyof T as undefined extends T[K] ? never : K]: T[K];
};
export declare type IsUnknown<T> = IsEqual<T, unknown>;
export declare type IsEqual<T, U> = [T] extends [U] ? ([U] extends [T] ? true : false) : false;
export declare type IsUnknown<T extends unknown> = IsEqual<T, unknown>;
export declare type IsEqual<T extends unknown, U extends unknown> = [T] extends [U] ? [U] extends [T] ? true : false : false;
export declare type TupleToObject<T extends [string, any]> = {

@@ -24,0 +24,0 @@ [key in T[0]]: Extract<T, [key, any]>[1];

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyDefaults = exports.extendChain = exports.asAny = exports.code = exports.ensurePeriod = exports.isEmpty = exports.tryOrNull = exports.isEmptySchema = exports.inspect = void 0;
const inspect = (value) => {
export const inspect = (value) => {
try {

@@ -12,11 +9,9 @@ return JSON.stringify(value);

};
exports.inspect = inspect;
/**
* Is the data type schema empty? Empty means it has no properties beyond the standard `_tag` property.
*/
const isEmptySchema = (schema) => {
export const isEmptySchema = (schema) => {
return Object.keys(schema._def.shape()).filter((key) => key !== `_tag`).length > 0;
};
exports.isEmptySchema = isEmptySchema;
const tryOrNull = (fn) => {
export const tryOrNull = (fn) => {
try {

@@ -29,4 +24,3 @@ return fn();

};
exports.tryOrNull = tryOrNull;
const isEmpty = (value) => {
export const isEmpty = (value) => {
if (Array.isArray(value))

@@ -36,7 +30,4 @@ value.length === 0;

};
exports.isEmpty = isEmpty;
const ensurePeriod = (s) => (s.length > 0 ? (s[s.length - 1] === `.` ? s : s + `.`) : s);
exports.ensurePeriod = ensurePeriod;
const code = (s) => `\`${s}\``;
exports.code = code;
export const ensurePeriod = (s) => (s.length > 0 ? (s[s.length - 1] === `.` ? s : s + `.`) : s);
export const code = (s) => `\`${s}\``;
/**

@@ -46,8 +37,7 @@ * Cast the value to `any`

// eslint-disable-next-line
const asAny = (x) => x;
exports.asAny = asAny;
export const asAny = (x) => x;
/**
* Extend a chaining API with new methods.
*/
const extendChain = (params) => {
export const extendChain = (params) => {
const wrapperChain = {

@@ -70,7 +60,6 @@ _: {

};
exports.extendChain = extendChain;
const applyDefaults = (input, defaults) => {
export const applyDefaults = (input, defaults) => {
const input_ = { ...input };
for (const entry of Object.entries(defaults)) {
// @ts-expect-error dynammic
// @ts-expect-error dynamic
// eslint-disable-next-line

@@ -81,3 +70,2 @@ input_[entry[0]] = input_[entry[0]] === undefined ? entry[1] : input_[entry[0]];

};
exports.applyDefaults = applyDefaults;
//# sourceMappingURL=utils.js.map

@@ -1,28 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.z = void 0;
exports.z = __importStar(require("./z.js"));
export * as z from './z.js';
//# sourceMappingURL=index.js.map

@@ -1,18 +0,2 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("zod"), exports);
export * from 'zod';
//# sourceMappingURL=z.js.map

@@ -20,3 +20,3 @@ import { OmitTag } from './core/types.js';

declare type PreMatcher<ADT extends SomeRecord, Result> = {
[Tag in ADT['_tag']]: (<ThisResult, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>, test: Pattern) => ThisResult) => PostMatcher<ADT, never, ThisResult | Result>) & (<ThisResult>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag, ThisResult | Result>);
[Tag in ADT['_tag']]: (<ThisResult extends unknown, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>, test: Pattern) => ThisResult) => PostMatcher<ADT, never, ThisResult | Result>) & (<ThisResult extends unknown>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag, ThisResult | Result>);
};

@@ -29,9 +29,9 @@ /**

declare type PostMatcher<ADT extends SomeRecord, PreviousTagsMatched extends string, Result> = {
[Tag in Exclude<ADT['_tag'], PreviousTagsMatched>]: ((<ThisResult, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, PreviousTagsMatched, '__init__' extends Result ? ThisResult : ThisResult | Result>) & (<ThisResult>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag | PreviousTagsMatched, ThisResult | Result>));
[Tag in Exclude<ADT['_tag'], PreviousTagsMatched>]: ((<ThisResult extends unknown, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, PreviousTagsMatched, '__init__' extends Result ? ThisResult : ThisResult | Result>) & (<ThisResult extends unknown>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag | PreviousTagsMatched, ThisResult | Result>));
} & (ADT['_tag'] extends PreviousTagsMatched ? {
done: () => Result;
} : {
else: <ThisResult>(value: ThisResult | ((data: ADT) => ThisResult)) => Result | ThisResult;
else: <ThisResult extends unknown>(value: ThisResult | ((data: ADT) => ThisResult)) => Result | ThisResult;
});
export {};
//# sourceMappingURL=match.d.ts.map

@@ -1,2 +0,1 @@

"use strict";
/*

@@ -15,10 +14,5 @@

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.match = void 0;
const utils_js_1 = require("./lib/utils.js");
const lodash_ismatch_1 = __importDefault(require("lodash.ismatch"));
const match = (algebraicDataType) => {
import { inspect } from './lib/utils.js';
import isMatch from 'lodash.ismatch';
export const match = (algebraicDataType) => {
const elseBranch = {

@@ -36,3 +30,3 @@ defined: false,

if (matcher._tag === `DataMatcherDefinition`) {
if ((0, lodash_ismatch_1.default)(algebraicDataType, matcher.dataPattern)) {
if (isMatch(algebraicDataType, matcher.dataPattern)) {
return matcher.handler(algebraicDataType);

@@ -51,3 +45,3 @@ }

}
throw new Error(`No matcher matched on the given data. This should be impossible. Are you sure the runtime is not different than the static types? Please report a bug at https://todo. The given data was:\n${(0, utils_js_1.inspect)(algebraicDataType)}`);
throw new Error(`No matcher matched on the given data. This should be impossible. Are you sure the runtime is not different than the static types? Please report a bug at https://todo. The given data was:\n${inspect(algebraicDataType)}`);
};

@@ -84,3 +78,3 @@ const proxy = new Proxy({}, {

}
throw new Error(`Cannot define this data matcher:\n${(0, utils_js_1.inspect)(args[0])}\nfor ${property} because it will never match because it comes after matching on ${property} generally.`);
throw new Error(`Cannot define this data matcher:\n${inspect(args[0])}\nfor ${property} because it will never match because it comes after matching on ${property} generally.`);
}

@@ -101,3 +95,2 @@ matcherStack.push(matcher);

};
exports.match = match;
//# sourceMappingURL=match.js.map

@@ -1,11 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.record = void 0;
const helpers_js_1 = require("../core/helpers.js");
const utils_js_1 = require("../lib/utils.js");
const index_js_1 = require("../lib/z/index.js");
import { is } from '../core/helpers.js';
import { applyDefaults, extendChain, isEmptySchema, tryOrNull } from '../lib/utils.js';
import { z } from '../lib/z/index.js';
//eslint-disable-next-line
function record(name, schemaOrSchemaDef, _ = {}) {
export function record(name, schemaOrSchemaDef, _ = {}) {
const chainTerminus = `done`;
const initialSchema = index_js_1.z.object({ _tag: index_js_1.z.literal(name) });
const initialSchema = z.object({ _tag: z.literal(name) });
const current = {

@@ -31,6 +28,6 @@ name,

// eslint-disable-next-line
current.schema = schemaOrSchemaDef.extend({ _tag: index_js_1.z.literal(current.name) });
current.schema = schemaOrSchemaDef.extend({ _tag: z.literal(current.name) });
}
else {
current.schema = index_js_1.z.object({ ...schemaOrSchemaDef, _tag: index_js_1.z.literal(current.name) });
current.schema = z.object({ ...schemaOrSchemaDef, _tag: z.literal(current.name) });
}

@@ -48,3 +45,3 @@ return chain;

// TODO optimize this check to be O(1)
if (!(0, utils_js_1.isEmptySchema)(current.schema))
if (!isEmptySchema(current.schema))
throw new Error(`A codec cannot be defined without a schema.`);

@@ -75,3 +72,3 @@ if (current.codecs.find((codec) => codec[0] === name))

const data = {
...(0, utils_js_1.applyDefaults)(input ?? {}, current.defaultsProvider?.(input ?? {}) ?? {}),
...applyDefaults(input ?? {}, current.defaultsProvider?.(input ?? {}) ?? {}),
_tag: current.name,

@@ -86,4 +83,4 @@ _: {

//eslint-disable-next-line
is$: (value) => (0, helpers_js_1.is)(value, symbol),
is: (record) => (0, helpers_js_1.is)(record, symbol),
is$: (value) => is(value, symbol),
is: (record) => is(record, symbol),
update: (record, changes) => {

@@ -97,3 +94,3 @@ return controller.create({

json: (json) => {
const data = (0, utils_js_1.tryOrNull)(() => JSON.parse(json));
const data = tryOrNull(() => JSON.parse(json));
if (data === null || typeof data !== `object`)

@@ -150,3 +147,3 @@ return null;

const chainWrapped = _.extensions
? (0, utils_js_1.extendChain)({
? extendChain({
chain: {

@@ -168,3 +165,2 @@ terminus: chainTerminus,

}
exports.record = record;
//# sourceMappingURL=runtime.js.map

@@ -1,6 +0,5 @@

"use strict";
/**
* This module is concerned with the static types for the API of building up an ADT.
*/
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=builder.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=controller.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=internal.js.map

@@ -1,4 +0,3 @@

"use strict";
// prettier-ignore
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=StoredRecord.js.map
{
"name": "alge",
"version": "0.5.0",
"version": "0.5.1-next.1",
"repository": "git@github.com:jasonkuhrt/alge.git",
"author": "Jason Kuhrt",
"packageManager": "pnpm@7.9.5",
"packageManager": "pnpm@7.11.0",
"license": "MIT",
"type": "module",
"files": [

@@ -32,6 +33,6 @@ "src",

"lint:check": "eslint . --ext .ts,.tsx --max-warnings 0",
"type-check": "pnpm tsc --noEmit",
"types:check": "pnpm tsc --noEmit",
"dev": "pnpm clean && tsc --build --watch tsconfig.cjs.json tsconfig.esm.json",
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm",
"build:cjs": "tsc --project tsconfig.cjs.json",
"build:cjs": "ts-node scripts/build-cjs",
"build:esm": "tsc --project tsconfig.esm.json",

@@ -51,5 +52,5 @@ "test": "jest",

"devDependencies": {
"@jest/types": "29.0.1",
"@jest/types": "29.0.2",
"@prisma-labs/prettier-config": "0.1.0",
"@swc/core": "1.2.244",
"@swc/core": "1.2.247",
"@swc/helpers": "0.4.11",

@@ -64,4 +65,4 @@ "@swc/jest": "0.2.22",

"@types/semver-utils": "1.1.1",
"@typescript-eslint/eslint-plugin": "5.36.0",
"@typescript-eslint/parser": "5.36.0",
"@typescript-eslint/eslint-plugin": "5.36.1",
"@typescript-eslint/parser": "5.36.1",
"dripip": "0.10.0",

@@ -74,5 +75,8 @@ "eslint": "8.23.0",

"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-simple-import-sort": "8.0.0",
"eslint-plugin-tsdoc": "0.2.16",
"jest": "29.0.1",
"execa": "^6.1.0",
"fast-glob": "^3.2.11",
"fs-jetpack": "^4.3.1",
"jest": "29.0.2",
"jest-watch-select-projects": "2.0.0",

@@ -79,0 +83,0 @@ "jest-watch-suspend": "1.1.2",

@@ -29,3 +29,3 @@ import type { z } from 'zod'

export const tryOrNull = <T>(fn: () => T): T | null => {
export const tryOrNull = <T extends unknown>(fn: () => T): T | null => {
try {

@@ -42,11 +42,15 @@ return fn()

export type OnlyStrings<x> = x extends string ? x : never
export type OnlyStrings<x extends unknown> = x extends string ? x : never
export type OmitRequired<T> = {
export type OmitRequired<T extends unknown> = {
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
}
export type IsUnknown<T> = IsEqual<T, unknown>
export type IsUnknown<T extends unknown> = IsEqual<T, unknown>
export type IsEqual<T, U> = [T] extends [U] ? ([U] extends [T] ? true : false) : false
export type IsEqual<T extends unknown, U extends unknown> = [T] extends [U]
? [U] extends [T]
? true
: false
: false

@@ -111,3 +115,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any

for (const entry of Object.entries(defaults)) {
// @ts-expect-error dynammic
// @ts-expect-error dynamic
// eslint-disable-next-line

@@ -114,0 +118,0 @@ input_[entry[0]] = input_[entry[0]] === undefined ? entry[1] : input_[entry[0]]

@@ -133,4 +133,4 @@ /*

[Tag in ADT['_tag']]:
(<ThisResult, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>, test:Pattern) => ThisResult) => PostMatcher<ADT, never, ThisResult | Result>) &
(<ThisResult>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag, ThisResult | Result>)
(<ThisResult extends unknown, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>, test:Pattern) => ThisResult) => PostMatcher<ADT, never, ThisResult | Result>) &
(<ThisResult extends unknown>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag, ThisResult | Result>)
}

@@ -147,4 +147,4 @@

(
(<ThisResult, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, PreviousTagsMatched, '__init__' extends Result ? ThisResult : ThisResult | Result>) &
(<ThisResult>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag|PreviousTagsMatched, ThisResult | Result>)
(<ThisResult extends unknown, Pattern extends Partial<OmitTag<PickRecordHavingTag<Tag, ADT>>>>(dataPattern: Pattern, handler: (data: Pattern & PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, PreviousTagsMatched, '__init__' extends Result ? ThisResult : ThisResult | Result>) &
(<ThisResult extends unknown>(handler: (data: PickRecordHavingTag<Tag, ADT>) => ThisResult) => PostMatcher<ADT, Tag|PreviousTagsMatched, ThisResult | Result>)
)

@@ -156,4 +156,4 @@ // ^[1] ^[1]

} : {
else: <ThisResult>(value: ThisResult| ((data: ADT) => ThisResult)) => Result|ThisResult
else: <ThisResult extends unknown>(value: ThisResult| ((data: ADT) => ThisResult)) => Result|ThisResult
}
)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc