@voidhash/mimic 0.0.1-alpha.7 → 0.0.1-alpha.8
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/.turbo/turbo-build.log +43 -15
- package/dist/Document-ChuFrTk1.cjs +571 -0
- package/dist/Document-CwiAFTIq.mjs +438 -0
- package/dist/Document-CwiAFTIq.mjs.map +1 -0
- package/dist/Presence-DKKP4v5X.d.cts +91 -0
- package/dist/Presence-DKKP4v5X.d.cts.map +1 -0
- package/dist/Presence-DdMVKcOv.mjs +110 -0
- package/dist/Presence-DdMVKcOv.mjs.map +1 -0
- package/dist/Presence-N8u7Eppr.d.mts +91 -0
- package/dist/Presence-N8u7Eppr.d.mts.map +1 -0
- package/dist/Presence-gWrmGBeu.cjs +126 -0
- package/dist/Primitive-BK7kfHJZ.d.cts +1165 -0
- package/dist/Primitive-BK7kfHJZ.d.cts.map +1 -0
- package/dist/Primitive-D1kdB6za.d.mts +1165 -0
- package/dist/Primitive-D1kdB6za.d.mts.map +1 -0
- package/dist/client/index.cjs +1456 -0
- package/dist/client/index.d.cts +692 -0
- package/dist/client/index.d.cts.map +1 -0
- package/dist/client/index.d.mts +692 -0
- package/dist/client/index.d.mts.map +1 -0
- package/dist/client/index.mjs +1413 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.cjs +224 -765
- package/dist/index.d.cts +5 -1152
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +5 -1152
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +69 -569
- package/dist/index.mjs.map +1 -1
- package/dist/server/index.cjs +191 -0
- package/dist/server/index.d.cts +148 -0
- package/dist/server/index.d.cts.map +1 -0
- package/dist/server/index.d.mts +148 -0
- package/dist/server/index.d.mts.map +1 -0
- package/dist/server/index.mjs +182 -0
- package/dist/server/index.mjs.map +1 -0
- package/package.json +16 -4
- package/src/primitives/Array.ts +25 -14
- package/src/primitives/Boolean.ts +29 -17
- package/src/primitives/Either.ts +30 -17
- package/src/primitives/Lazy.ts +16 -2
- package/src/primitives/Literal.ts +29 -18
- package/src/primitives/Number.ts +35 -24
- package/src/primitives/String.ts +36 -23
- package/src/primitives/Struct.ts +74 -26
- package/src/primitives/Tree.ts +30 -14
- package/src/primitives/Union.ts +21 -21
- package/src/primitives/shared.ts +27 -34
- package/tests/primitives/Array.test.ts +108 -0
- package/tests/primitives/Struct.test.ts +2 -2
- package/tests/primitives/Tree.test.ts +128 -0
- package/tsdown.config.ts +1 -1
- /package/dist/{chunk-C6wwvPpM.mjs → chunk-CLMFDpHK.mjs} +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { t as __export } from "./chunk-CLMFDpHK.mjs";
|
|
2
|
+
import { m as _defineProperty } from "./Document-CwiAFTIq.mjs";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
|
|
5
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
|
|
6
|
+
function ownKeys(e, r) {
|
|
7
|
+
var t = Object.keys(e);
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
10
|
+
r && (o = o.filter(function(r$1) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
12
|
+
})), t.push.apply(t, o);
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
function _objectSpread2(e) {
|
|
17
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
18
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
19
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
20
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
21
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
22
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/Presence.ts
|
|
30
|
+
/**
|
|
31
|
+
* @since 0.0.1
|
|
32
|
+
* Presence module for ephemeral per-connection state.
|
|
33
|
+
* Used by both client and server for schema validation.
|
|
34
|
+
*/
|
|
35
|
+
var Presence_exports = /* @__PURE__ */ __export({
|
|
36
|
+
isValid: () => isValid,
|
|
37
|
+
make: () => make,
|
|
38
|
+
validate: () => validate,
|
|
39
|
+
validateSafe: () => validateSafe
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new Presence schema wrapper.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { Presence } from "@voidhash/mimic";
|
|
47
|
+
* import { Schema } from "effect";
|
|
48
|
+
*
|
|
49
|
+
* const CursorPresence = Presence.make({
|
|
50
|
+
* schema: Schema.Struct({
|
|
51
|
+
* name: Schema.String,
|
|
52
|
+
* cursor: Schema.Struct({
|
|
53
|
+
* x: Schema.Number,
|
|
54
|
+
* y: Schema.Number,
|
|
55
|
+
* }),
|
|
56
|
+
* }),
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const make = (options) => ({
|
|
61
|
+
_tag: "Presence",
|
|
62
|
+
schema: options.schema,
|
|
63
|
+
_Data: void 0
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Validates unknown data against a Presence schema.
|
|
67
|
+
* Throws a ParseError if validation fails.
|
|
68
|
+
*
|
|
69
|
+
* @param presence - The Presence instance with the schema
|
|
70
|
+
* @param data - Unknown data to validate
|
|
71
|
+
* @returns The validated and typed data
|
|
72
|
+
* @throws ParseError if validation fails
|
|
73
|
+
*/
|
|
74
|
+
const validate = (presence, data) => {
|
|
75
|
+
return Schema.decodeUnknownSync(presence.schema)(data);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Safely validates unknown data against a Presence schema.
|
|
79
|
+
* Returns undefined if validation fails instead of throwing.
|
|
80
|
+
*
|
|
81
|
+
* @param presence - The Presence instance with the schema
|
|
82
|
+
* @param data - Unknown data to validate
|
|
83
|
+
* @returns The validated data or undefined if invalid
|
|
84
|
+
*/
|
|
85
|
+
const validateSafe = (presence, data) => {
|
|
86
|
+
try {
|
|
87
|
+
return Schema.decodeUnknownSync(presence.schema)(data);
|
|
88
|
+
} catch (_unused) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Checks if unknown data is valid according to a Presence schema.
|
|
94
|
+
*
|
|
95
|
+
* @param presence - The Presence instance with the schema
|
|
96
|
+
* @param data - Unknown data to check
|
|
97
|
+
* @returns true if valid, false otherwise
|
|
98
|
+
*/
|
|
99
|
+
const isValid = (presence, data) => {
|
|
100
|
+
try {
|
|
101
|
+
Schema.decodeUnknownSync(presence.schema)(data);
|
|
102
|
+
return true;
|
|
103
|
+
} catch (_unused2) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { validate as n, _objectSpread2 as r, Presence_exports as t };
|
|
110
|
+
//# sourceMappingURL=Presence-DdMVKcOv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Presence-DdMVKcOv.mjs","names":[],"sources":["../src/Presence.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Presence module for ephemeral per-connection state.\n * Used by both client and server for schema validation.\n */\nimport * as Schema from \"effect/Schema\";\n\n// =============================================================================\n// Presence Types\n// =============================================================================\n\n/**\n * A Presence schema wrapper that holds an Effect Schema for validation.\n * This is used by both client and server to validate presence data.\n */\nexport interface Presence<TData> {\n readonly _tag: \"Presence\";\n /** The Effect Schema used for validation */\n readonly schema: Schema.Schema<TData>;\n /** Branded type marker for inference */\n readonly _Data: TData;\n}\n\n/**\n * Options for creating a Presence instance.\n */\nexport interface PresenceOptions<TData> {\n /** The Effect Schema defining the presence data structure */\n readonly schema: Schema.Schema<TData>;\n}\n\n/**\n * Infer the data type from a Presence instance.\n */\nexport type Infer<P extends Presence<any>> = P[\"_Data\"];\n\n/**\n * Any Presence type (for generic constraints).\n */\nexport type AnyPresence = Presence<any>;\n\n// =============================================================================\n// Presence Entry (for storage/transport)\n// =============================================================================\n\n/**\n * A presence entry as stored/transmitted.\n */\nexport interface PresenceEntry<TData = unknown> {\n /** The presence data */\n readonly data: TData;\n /** Optional user ID from authentication */\n readonly userId?: string;\n}\n\n// =============================================================================\n// Factory Function\n// =============================================================================\n\n/**\n * Creates a new Presence schema wrapper.\n *\n * @example\n * ```typescript\n * import { Presence } from \"@voidhash/mimic\";\n * import { Schema } from \"effect\";\n *\n * const CursorPresence = Presence.make({\n * schema: Schema.Struct({\n * name: Schema.String,\n * cursor: Schema.Struct({\n * x: Schema.Number,\n * y: Schema.Number,\n * }),\n * }),\n * });\n * ```\n */\nexport const make = <TData,>(options: PresenceOptions<TData>): Presence<TData> => ({\n _tag: \"Presence\",\n schema: options.schema,\n _Data: undefined as unknown as TData,\n});\n\n// =============================================================================\n// Validation Functions\n// =============================================================================\n\n/**\n * Validates unknown data against a Presence schema.\n * Throws a ParseError if validation fails.\n *\n * @param presence - The Presence instance with the schema\n * @param data - Unknown data to validate\n * @returns The validated and typed data\n * @throws ParseError if validation fails\n */\nexport const validate = <TData,>(\n presence: Presence<TData>,\n data: unknown\n): TData => {\n return Schema.decodeUnknownSync(presence.schema)(data);\n};\n\n/**\n * Safely validates unknown data against a Presence schema.\n * Returns undefined if validation fails instead of throwing.\n *\n * @param presence - The Presence instance with the schema\n * @param data - Unknown data to validate\n * @returns The validated data or undefined if invalid\n */\nexport const validateSafe = <TData,>(\n presence: Presence<TData>,\n data: unknown\n): TData | undefined => {\n try {\n return Schema.decodeUnknownSync(presence.schema)(data);\n } catch {\n return undefined;\n }\n};\n\n/**\n * Checks if unknown data is valid according to a Presence schema.\n *\n * @param presence - The Presence instance with the schema\n * @param data - Unknown data to check\n * @returns true if valid, false otherwise\n */\nexport const isValid = <TData,>(\n presence: Presence<TData>,\n data: unknown\n): data is TData => {\n try {\n Schema.decodeUnknownSync(presence.schema)(data);\n return true;\n } catch {\n return false;\n }\n};\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,MAAa,QAAgB,aAAsD;CACjF,MAAM;CACN,QAAQ,QAAQ;CAChB,OAAO;CACR;;;;;;;;;;AAeD,MAAa,YACX,UACA,SACU;AACV,QAAO,OAAO,kBAAkB,SAAS,OAAO,CAAC,KAAK;;;;;;;;;;AAWxD,MAAa,gBACX,UACA,SACsB;AACtB,KAAI;AACF,SAAO,OAAO,kBAAkB,SAAS,OAAO,CAAC,KAAK;mBAChD;AACN;;;;;;;;;;AAWJ,MAAa,WACX,UACA,SACkB;AAClB,KAAI;AACF,SAAO,kBAAkB,SAAS,OAAO,CAAC,KAAK;AAC/C,SAAO;oBACD;AACN,SAAO"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
|
|
3
|
+
//#region src/Presence.d.ts
|
|
4
|
+
declare namespace Presence_d_exports {
|
|
5
|
+
export { AnyPresence, Infer, Presence, PresenceEntry, PresenceOptions, isValid, make, validate, validateSafe };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A Presence schema wrapper that holds an Effect Schema for validation.
|
|
9
|
+
* This is used by both client and server to validate presence data.
|
|
10
|
+
*/
|
|
11
|
+
interface Presence<TData> {
|
|
12
|
+
readonly _tag: "Presence";
|
|
13
|
+
/** The Effect Schema used for validation */
|
|
14
|
+
readonly schema: Schema.Schema<TData>;
|
|
15
|
+
/** Branded type marker for inference */
|
|
16
|
+
readonly _Data: TData;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for creating a Presence instance.
|
|
20
|
+
*/
|
|
21
|
+
interface PresenceOptions<TData> {
|
|
22
|
+
/** The Effect Schema defining the presence data structure */
|
|
23
|
+
readonly schema: Schema.Schema<TData>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Infer the data type from a Presence instance.
|
|
27
|
+
*/
|
|
28
|
+
type Infer<P extends Presence<any>> = P["_Data"];
|
|
29
|
+
/**
|
|
30
|
+
* Any Presence type (for generic constraints).
|
|
31
|
+
*/
|
|
32
|
+
type AnyPresence = Presence<any>;
|
|
33
|
+
/**
|
|
34
|
+
* A presence entry as stored/transmitted.
|
|
35
|
+
*/
|
|
36
|
+
interface PresenceEntry<TData = unknown> {
|
|
37
|
+
/** The presence data */
|
|
38
|
+
readonly data: TData;
|
|
39
|
+
/** Optional user ID from authentication */
|
|
40
|
+
readonly userId?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new Presence schema wrapper.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* import { Presence } from "@voidhash/mimic";
|
|
48
|
+
* import { Schema } from "effect";
|
|
49
|
+
*
|
|
50
|
+
* const CursorPresence = Presence.make({
|
|
51
|
+
* schema: Schema.Struct({
|
|
52
|
+
* name: Schema.String,
|
|
53
|
+
* cursor: Schema.Struct({
|
|
54
|
+
* x: Schema.Number,
|
|
55
|
+
* y: Schema.Number,
|
|
56
|
+
* }),
|
|
57
|
+
* }),
|
|
58
|
+
* });
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const make: <TData>(options: PresenceOptions<TData>) => Presence<TData>;
|
|
62
|
+
/**
|
|
63
|
+
* Validates unknown data against a Presence schema.
|
|
64
|
+
* Throws a ParseError if validation fails.
|
|
65
|
+
*
|
|
66
|
+
* @param presence - The Presence instance with the schema
|
|
67
|
+
* @param data - Unknown data to validate
|
|
68
|
+
* @returns The validated and typed data
|
|
69
|
+
* @throws ParseError if validation fails
|
|
70
|
+
*/
|
|
71
|
+
declare const validate: <TData>(presence: Presence<TData>, data: unknown) => TData;
|
|
72
|
+
/**
|
|
73
|
+
* Safely validates unknown data against a Presence schema.
|
|
74
|
+
* Returns undefined if validation fails instead of throwing.
|
|
75
|
+
*
|
|
76
|
+
* @param presence - The Presence instance with the schema
|
|
77
|
+
* @param data - Unknown data to validate
|
|
78
|
+
* @returns The validated data or undefined if invalid
|
|
79
|
+
*/
|
|
80
|
+
declare const validateSafe: <TData>(presence: Presence<TData>, data: unknown) => TData | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if unknown data is valid according to a Presence schema.
|
|
83
|
+
*
|
|
84
|
+
* @param presence - The Presence instance with the schema
|
|
85
|
+
* @param data - Unknown data to check
|
|
86
|
+
* @returns true if valid, false otherwise
|
|
87
|
+
*/
|
|
88
|
+
declare const isValid: <TData>(presence: Presence<TData>, data: unknown) => data is TData;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { Presence_d_exports as i, Infer as n, PresenceEntry as r, AnyPresence as t };
|
|
91
|
+
//# sourceMappingURL=Presence-N8u7Eppr.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Presence-N8u7Eppr.d.mts","names":[],"sources":["../src/Presence.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAeiB;;;mBAGE,MAAA,CAAO,OAAO;;EAHhB,SAAA,KAAQ,EAKP,KALO;;;;;AAWR,UAAA,eAAe,CAAA,KAAA,CAEC,CAAA;EAMrB;EAKA,SAAA,MAAW,EAXJ,MAAA,CAAO,MAWA,CAXO,KAWC,CAAA;AASlC;AA8BA;;;AAAwE,KA5C5D,KA4C4D,CAAA,UA5C5C,QA4C4C,CAAA,GAAA,CAAA,CAAA,GA5C3B,CA4C2B,CAAA,OAAA,CAAA;;;AAmBxE;AACqB,KA3DT,WAAA,GAAc,QA2DL,CAAA,GAAA,CAAA;;;;AAcR,UAhEI,aAyEhB,CAAA,QAAA,OAAA,CAAA,CAAA;EARoB;EAAT,SAAA,IAAA,EA/DK,KA+DL;EAET;EAAK,SAAA,MAAA,CAAA,EAAA,MAAA;AAeR;;;;;;;;;;;;;;;;;;;;cApDa,uBAAyB,gBAAgB,WAAS,SAAS;;;;;;;;;;cAmB3D,4BACD,SAAS,0BAElB;;;;;;;;;cAYU,gCACD,SAAS,0BAElB;;;;;;;;cAeU,2BACD,SAAS,kCAEV"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const require_Document = require('./Document-ChuFrTk1.cjs');
|
|
2
|
+
let effect_Schema = require("effect/Schema");
|
|
3
|
+
effect_Schema = require_Document.__toESM(effect_Schema);
|
|
4
|
+
|
|
5
|
+
//#region \0@oxc-project+runtime@0.103.0/helpers/objectSpread2.js
|
|
6
|
+
function ownKeys(e, r) {
|
|
7
|
+
var t = Object.keys(e);
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
10
|
+
r && (o = o.filter(function(r$1) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
12
|
+
})), t.push.apply(t, o);
|
|
13
|
+
}
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
function _objectSpread2(e) {
|
|
17
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
18
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
19
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
20
|
+
require_Document._defineProperty(e, r$1, t[r$1]);
|
|
21
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
22
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/Presence.ts
|
|
30
|
+
/**
|
|
31
|
+
* @since 0.0.1
|
|
32
|
+
* Presence module for ephemeral per-connection state.
|
|
33
|
+
* Used by both client and server for schema validation.
|
|
34
|
+
*/
|
|
35
|
+
var Presence_exports = /* @__PURE__ */ require_Document.__export({
|
|
36
|
+
isValid: () => isValid,
|
|
37
|
+
make: () => make,
|
|
38
|
+
validate: () => validate,
|
|
39
|
+
validateSafe: () => validateSafe
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new Presence schema wrapper.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* import { Presence } from "@voidhash/mimic";
|
|
47
|
+
* import { Schema } from "effect";
|
|
48
|
+
*
|
|
49
|
+
* const CursorPresence = Presence.make({
|
|
50
|
+
* schema: Schema.Struct({
|
|
51
|
+
* name: Schema.String,
|
|
52
|
+
* cursor: Schema.Struct({
|
|
53
|
+
* x: Schema.Number,
|
|
54
|
+
* y: Schema.Number,
|
|
55
|
+
* }),
|
|
56
|
+
* }),
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const make = (options) => ({
|
|
61
|
+
_tag: "Presence",
|
|
62
|
+
schema: options.schema,
|
|
63
|
+
_Data: void 0
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Validates unknown data against a Presence schema.
|
|
67
|
+
* Throws a ParseError if validation fails.
|
|
68
|
+
*
|
|
69
|
+
* @param presence - The Presence instance with the schema
|
|
70
|
+
* @param data - Unknown data to validate
|
|
71
|
+
* @returns The validated and typed data
|
|
72
|
+
* @throws ParseError if validation fails
|
|
73
|
+
*/
|
|
74
|
+
const validate = (presence, data) => {
|
|
75
|
+
return effect_Schema.decodeUnknownSync(presence.schema)(data);
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Safely validates unknown data against a Presence schema.
|
|
79
|
+
* Returns undefined if validation fails instead of throwing.
|
|
80
|
+
*
|
|
81
|
+
* @param presence - The Presence instance with the schema
|
|
82
|
+
* @param data - Unknown data to validate
|
|
83
|
+
* @returns The validated data or undefined if invalid
|
|
84
|
+
*/
|
|
85
|
+
const validateSafe = (presence, data) => {
|
|
86
|
+
try {
|
|
87
|
+
return effect_Schema.decodeUnknownSync(presence.schema)(data);
|
|
88
|
+
} catch (_unused) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Checks if unknown data is valid according to a Presence schema.
|
|
94
|
+
*
|
|
95
|
+
* @param presence - The Presence instance with the schema
|
|
96
|
+
* @param data - Unknown data to check
|
|
97
|
+
* @returns true if valid, false otherwise
|
|
98
|
+
*/
|
|
99
|
+
const isValid = (presence, data) => {
|
|
100
|
+
try {
|
|
101
|
+
effect_Schema.decodeUnknownSync(presence.schema)(data);
|
|
102
|
+
return true;
|
|
103
|
+
} catch (_unused2) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
Object.defineProperty(exports, 'Presence_exports', {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return Presence_exports;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, '_objectSpread2', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return _objectSpread2;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, 'validate', {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () {
|
|
124
|
+
return validate;
|
|
125
|
+
}
|
|
126
|
+
});
|