@mionjs/core 0.8.0-alpha.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.
Files changed (136) hide show
  1. package/.dist/cjs/index.cjs +245 -0
  2. package/.dist/cjs/index.cjs.map +1 -0
  3. package/.dist/cjs/index.d.ts +21 -0
  4. package/.dist/cjs/package.json +1 -0
  5. package/.dist/cjs/src/binary/bodyDeserializer.cjs +54 -0
  6. package/.dist/cjs/src/binary/bodyDeserializer.cjs.map +1 -0
  7. package/.dist/cjs/src/binary/bodyDeserializer.d.ts +5 -0
  8. package/.dist/cjs/src/binary/bodySerializer.cjs +49 -0
  9. package/.dist/cjs/src/binary/bodySerializer.cjs.map +1 -0
  10. package/.dist/cjs/src/binary/bodySerializer.d.ts +6 -0
  11. package/.dist/cjs/src/binary/dataView.cjs +212 -0
  12. package/.dist/cjs/src/binary/dataView.cjs.map +1 -0
  13. package/.dist/cjs/src/binary/dataView.d.ts +16 -0
  14. package/.dist/cjs/src/constants.cjs +84 -0
  15. package/.dist/cjs/src/constants.cjs.map +1 -0
  16. package/.dist/cjs/src/constants.d.ts +50 -0
  17. package/.dist/cjs/src/errors.cjs +170 -0
  18. package/.dist/cjs/src/errors.cjs.map +1 -0
  19. package/.dist/cjs/src/errors.d.ts +24 -0
  20. package/.dist/cjs/src/friendlyErrors.cjs +235 -0
  21. package/.dist/cjs/src/friendlyErrors.cjs.map +1 -0
  22. package/.dist/cjs/src/friendlyErrors.d.ts +4 -0
  23. package/.dist/cjs/src/headers.cjs +11 -0
  24. package/.dist/cjs/src/headers.cjs.map +1 -0
  25. package/.dist/cjs/src/headers.d.ts +12 -0
  26. package/.dist/cjs/src/jit/jitUtils.cjs +173 -0
  27. package/.dist/cjs/src/jit/jitUtils.cjs.map +1 -0
  28. package/.dist/cjs/src/jit/jitUtils.d.ts +30 -0
  29. package/.dist/cjs/src/pureFns/pureFn.cjs +80 -0
  30. package/.dist/cjs/src/pureFns/pureFn.cjs.map +1 -0
  31. package/.dist/cjs/src/pureFns/pureFn.d.ts +2 -0
  32. package/.dist/cjs/src/pureFns/pureServerFn.cjs +20 -0
  33. package/.dist/cjs/src/pureFns/pureServerFn.cjs.map +1 -0
  34. package/.dist/cjs/src/pureFns/pureServerFn.d.ts +4 -0
  35. package/.dist/cjs/src/pureFns/quickHash.cjs +62 -0
  36. package/.dist/cjs/src/pureFns/quickHash.cjs.map +1 -0
  37. package/.dist/cjs/src/pureFns/quickHash.d.ts +7 -0
  38. package/.dist/cjs/src/pureFns/restoreJitFns.cjs +88 -0
  39. package/.dist/cjs/src/pureFns/restoreJitFns.cjs.map +1 -0
  40. package/.dist/cjs/src/pureFns/restoreJitFns.d.ts +3 -0
  41. package/.dist/cjs/src/routerUtils.cjs +209 -0
  42. package/.dist/cjs/src/routerUtils.cjs.map +1 -0
  43. package/.dist/cjs/src/routerUtils.d.ts +24 -0
  44. package/.dist/cjs/src/types/formats/formatBrands.types.cjs +45 -0
  45. package/.dist/cjs/src/types/formats/formatBrands.types.cjs.map +1 -0
  46. package/.dist/cjs/src/types/formats/formatBrands.types.d.ts +45 -0
  47. package/.dist/cjs/src/types/formats/formats.types.cjs +27 -0
  48. package/.dist/cjs/src/types/formats/formats.types.cjs.map +1 -0
  49. package/.dist/cjs/src/types/formats/formats.types.d.ts +37 -0
  50. package/.dist/cjs/src/types/formats/formatsParams.types.cjs +60 -0
  51. package/.dist/cjs/src/types/formats/formatsParams.types.cjs.map +1 -0
  52. package/.dist/cjs/src/types/formats/formatsParams.types.d.ts +234 -0
  53. package/.dist/cjs/src/types/formats/friendlyErrors.types.cjs +53 -0
  54. package/.dist/cjs/src/types/formats/friendlyErrors.types.cjs.map +1 -0
  55. package/.dist/cjs/src/types/formats/friendlyErrors.types.d.ts +71 -0
  56. package/.dist/cjs/src/types/general.types.cjs +145 -0
  57. package/.dist/cjs/src/types/general.types.cjs.map +1 -0
  58. package/.dist/cjs/src/types/general.types.d.ts +246 -0
  59. package/.dist/cjs/src/types/method.types.cjs +26 -0
  60. package/.dist/cjs/src/types/method.types.cjs.map +1 -0
  61. package/.dist/cjs/src/types/method.types.d.ts +60 -0
  62. package/.dist/cjs/src/types/pureFunctions.types.cjs +39 -0
  63. package/.dist/cjs/src/types/pureFunctions.types.cjs.map +1 -0
  64. package/.dist/cjs/src/types/pureFunctions.types.d.ts +75 -0
  65. package/.dist/cjs/src/utils.cjs +47 -0
  66. package/.dist/cjs/src/utils.cjs.map +1 -0
  67. package/.dist/cjs/src/utils.d.ts +9 -0
  68. package/.dist/esm/index.d.ts +21 -0
  69. package/.dist/esm/index.js +245 -0
  70. package/.dist/esm/index.js.map +1 -0
  71. package/.dist/esm/src/binary/bodyDeserializer.d.ts +5 -0
  72. package/.dist/esm/src/binary/bodyDeserializer.js +54 -0
  73. package/.dist/esm/src/binary/bodyDeserializer.js.map +1 -0
  74. package/.dist/esm/src/binary/bodySerializer.d.ts +6 -0
  75. package/.dist/esm/src/binary/bodySerializer.js +49 -0
  76. package/.dist/esm/src/binary/bodySerializer.js.map +1 -0
  77. package/.dist/esm/src/binary/dataView.d.ts +16 -0
  78. package/.dist/esm/src/binary/dataView.js +212 -0
  79. package/.dist/esm/src/binary/dataView.js.map +1 -0
  80. package/.dist/esm/src/constants.d.ts +50 -0
  81. package/.dist/esm/src/constants.js +84 -0
  82. package/.dist/esm/src/constants.js.map +1 -0
  83. package/.dist/esm/src/errors.d.ts +24 -0
  84. package/.dist/esm/src/errors.js +170 -0
  85. package/.dist/esm/src/errors.js.map +1 -0
  86. package/.dist/esm/src/friendlyErrors.d.ts +4 -0
  87. package/.dist/esm/src/friendlyErrors.js +235 -0
  88. package/.dist/esm/src/friendlyErrors.js.map +1 -0
  89. package/.dist/esm/src/headers.d.ts +12 -0
  90. package/.dist/esm/src/headers.js +11 -0
  91. package/.dist/esm/src/headers.js.map +1 -0
  92. package/.dist/esm/src/jit/jitUtils.d.ts +30 -0
  93. package/.dist/esm/src/jit/jitUtils.js +173 -0
  94. package/.dist/esm/src/jit/jitUtils.js.map +1 -0
  95. package/.dist/esm/src/pureFns/pureFn.d.ts +2 -0
  96. package/.dist/esm/src/pureFns/pureFn.js +80 -0
  97. package/.dist/esm/src/pureFns/pureFn.js.map +1 -0
  98. package/.dist/esm/src/pureFns/pureServerFn.d.ts +4 -0
  99. package/.dist/esm/src/pureFns/pureServerFn.js +20 -0
  100. package/.dist/esm/src/pureFns/pureServerFn.js.map +1 -0
  101. package/.dist/esm/src/pureFns/quickHash.d.ts +7 -0
  102. package/.dist/esm/src/pureFns/quickHash.js +62 -0
  103. package/.dist/esm/src/pureFns/quickHash.js.map +1 -0
  104. package/.dist/esm/src/pureFns/restoreJitFns.d.ts +3 -0
  105. package/.dist/esm/src/pureFns/restoreJitFns.js +88 -0
  106. package/.dist/esm/src/pureFns/restoreJitFns.js.map +1 -0
  107. package/.dist/esm/src/routerUtils.d.ts +24 -0
  108. package/.dist/esm/src/routerUtils.js +209 -0
  109. package/.dist/esm/src/routerUtils.js.map +1 -0
  110. package/.dist/esm/src/types/formats/formatBrands.types.d.ts +45 -0
  111. package/.dist/esm/src/types/formats/formatBrands.types.js +45 -0
  112. package/.dist/esm/src/types/formats/formatBrands.types.js.map +1 -0
  113. package/.dist/esm/src/types/formats/formats.types.d.ts +37 -0
  114. package/.dist/esm/src/types/formats/formats.types.js +27 -0
  115. package/.dist/esm/src/types/formats/formats.types.js.map +1 -0
  116. package/.dist/esm/src/types/formats/formatsParams.types.d.ts +234 -0
  117. package/.dist/esm/src/types/formats/formatsParams.types.js +60 -0
  118. package/.dist/esm/src/types/formats/formatsParams.types.js.map +1 -0
  119. package/.dist/esm/src/types/formats/friendlyErrors.types.d.ts +71 -0
  120. package/.dist/esm/src/types/formats/friendlyErrors.types.js +53 -0
  121. package/.dist/esm/src/types/formats/friendlyErrors.types.js.map +1 -0
  122. package/.dist/esm/src/types/general.types.d.ts +246 -0
  123. package/.dist/esm/src/types/general.types.js +145 -0
  124. package/.dist/esm/src/types/general.types.js.map +1 -0
  125. package/.dist/esm/src/types/method.types.d.ts +60 -0
  126. package/.dist/esm/src/types/method.types.js +26 -0
  127. package/.dist/esm/src/types/method.types.js.map +1 -0
  128. package/.dist/esm/src/types/pureFunctions.types.d.ts +75 -0
  129. package/.dist/esm/src/types/pureFunctions.types.js +39 -0
  130. package/.dist/esm/src/types/pureFunctions.types.js.map +1 -0
  131. package/.dist/esm/src/utils.d.ts +9 -0
  132. package/.dist/esm/src/utils.js +47 -0
  133. package/.dist/esm/src/utils.js.map +1 -0
  134. package/LICENSE +21 -0
  135. package/README.md +32 -0
  136. package/package.json +58 -0
@@ -0,0 +1,60 @@
1
+ import { FnsDataCache, PureFnsDataCache, JitCompiledFunctions, SerializerMode } from './general.types.ts';
2
+ export interface MethodMetadata {
3
+ type: number;
4
+ id: string;
5
+ isAsync: boolean;
6
+ hasReturnData: boolean;
7
+ paramNames?: string[];
8
+ paramsJitHash: string;
9
+ returnJitHash: string;
10
+ headersParam?: HeadersMetaData;
11
+ headersReturn?: HeadersMetaData;
12
+ middleFnIds?: string[];
13
+ pointer: string[];
14
+ nestLevel: number;
15
+ }
16
+ export interface RemoteMethodOpts {
17
+ runOnError?: boolean;
18
+ validateParams?: boolean;
19
+ validateReturn?: boolean;
20
+ description?: string;
21
+ serializer?: SerializerMode;
22
+ isMutation?: boolean | undefined;
23
+ }
24
+ export interface RouteOnlyOptions extends RemoteMethodOpts {
25
+ runOnError: false;
26
+ serializer: SerializerMode;
27
+ }
28
+ export interface MethodWithOptions extends MethodMetadata {
29
+ options: RemoteMethodOpts;
30
+ }
31
+ export type MethodsCache = Record<string, MethodWithOptions>;
32
+ export interface HeadersMetaData {
33
+ headerNames: string[];
34
+ jitHash: string;
35
+ }
36
+ export interface SerializableMethodsData {
37
+ methods: MethodsCache;
38
+ deps: FnsDataCache;
39
+ purFnDeps: PureFnsDataCache;
40
+ }
41
+ export interface HeadersMethodWithJitFns extends HeadersMetaData {
42
+ jitFns: Pick<JitCompiledFunctions, 'isType' | 'typeErrors'>;
43
+ }
44
+ export interface MethodWithJitFns extends MethodMetadata {
45
+ paramsJitFns: JitCompiledFunctions;
46
+ returnJitFns: JitCompiledFunctions;
47
+ headersParam?: HeadersMethodWithJitFns;
48
+ headersReturn?: HeadersMethodWithJitFns;
49
+ }
50
+ export type MethodWithOptsAndJitFns = MethodWithOptions & MethodWithJitFns;
51
+ export declare type __ΩMethodMetadata = any[];
52
+ export declare type __ΩRemoteMethodOpts = any[];
53
+ export declare type __ΩRouteOnlyOptions = any[];
54
+ export declare type __ΩMethodWithOptions = any[];
55
+ export declare type __ΩMethodsCache = any[];
56
+ export declare type __ΩHeadersMetaData = any[];
57
+ export declare type __ΩSerializableMethodsData = any[];
58
+ export declare type __ΩHeadersMethodWithJitFns = any[];
59
+ export declare type __ΩMethodWithJitFns = any[];
60
+ export declare type __ΩMethodWithOptsAndJitFns = any[];
@@ -0,0 +1,26 @@
1
+ import { __ΩJitCompiledFunctions as ___JitCompiledFunctions, __ΩSerializerMode as ___SerializerMode, __ΩFnsDataCache as ___FnsDataCache, __ΩPureFnsDataCache as ___PureFnsDataCache } from "./general.types.js";
2
+ const __ΩRecord = ["K", "T", "Record", `l'e#"Rb!b"Pde"!N#!w#y`];
3
+ const __ΩPick = ["T", "K", "Pick", 'l+e#!e"!fRb!b"Pde""N#!w#y'];
4
+ const __ΩMethodMetadata = ["type", "id", "isAsync", "hasReturnData", "paramNames", "paramsJitHash", "returnJitHash", () => __ΩHeadersMetaData, "headersParam", () => __ΩHeadersMetaData, "headersReturn", "middleFnIds", "pointer", "nestLevel", "MethodMetadata", `P'4!&4")4#)4$&F4%8&4&&4'n(4)8n*4+8&F4,8&F4-'4.Mw/y`];
5
+ const __ΩRemoteMethodOpts = ["runOnError", "validateParams", "validateReturn", "description", () => ___SerializerMode, "serializer", "isMutation", "RemoteMethodOpts", `P)4!8)4"8)4#8&4$8n%4&8P)-J4'8Mw(y`];
6
+ const __ΩRouteOnlyOptions = [() => __ΩRemoteMethodOpts, false, "runOnError", () => ___SerializerMode, "serializer", "RouteOnlyOptions", 'Pn!."4#n$4%Mw&y'];
7
+ const __ΩMethodWithOptions = [() => __ΩMethodMetadata, () => __ΩRemoteMethodOpts, "options", "MethodWithOptions", 'Pn!n"4#Mw$y'];
8
+ const __ΩMethodsCache = [() => __ΩRecord, () => __ΩMethodWithOptions, "MethodsCache", '&n"o!#w#y'];
9
+ const __ΩHeadersMetaData = ["headerNames", "jitHash", "HeadersMetaData", 'P&F4!&4"Mw#y'];
10
+ const __ΩSerializableMethodsData = [() => __ΩMethodsCache, "methods", () => ___FnsDataCache, "deps", () => ___PureFnsDataCache, "purFnDeps", "SerializableMethodsData", `Pn!4"n#4$n%4&Mw'y`];
11
+ const __ΩHeadersMethodWithJitFns = [() => __ΩHeadersMetaData, () => __ΩPick, () => ___JitCompiledFunctions, "isType", "typeErrors", "jitFns", "HeadersMethodWithJitFns", `Pn!n#P.$.%Jo"#4&Mw'y`];
12
+ const __ΩMethodWithJitFns = [() => __ΩMethodMetadata, () => ___JitCompiledFunctions, "paramsJitFns", () => ___JitCompiledFunctions, "returnJitFns", () => __ΩHeadersMethodWithJitFns, "headersParam", () => __ΩHeadersMethodWithJitFns, "headersReturn", "MethodWithJitFns", `Pn!n"4#n$4%n&4'8n(4)8Mw*y`];
13
+ const __ΩMethodWithOptsAndJitFns = [() => __ΩMethodWithOptions, () => __ΩMethodWithJitFns, "MethodWithOptsAndJitFns", 'Pn!n"Kw#y'];
14
+ export {
15
+ __ΩHeadersMetaData,
16
+ __ΩHeadersMethodWithJitFns,
17
+ __ΩMethodMetadata,
18
+ __ΩMethodWithJitFns,
19
+ __ΩMethodWithOptions,
20
+ __ΩMethodWithOptsAndJitFns,
21
+ __ΩMethodsCache,
22
+ __ΩRemoteMethodOpts,
23
+ __ΩRouteOnlyOptions,
24
+ __ΩSerializableMethodsData
25
+ };
26
+ //# sourceMappingURL=method.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method.types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,75 @@
1
+ import { TypeFormatValue } from './formats/formats.types.ts';
2
+ import { RunTypeError } from './general.types.ts';
3
+ import { JITUtils } from '../jit/jitUtils.ts';
4
+ type StrNumber = string | number;
5
+ export type PureFunctionDeps = Record<string, PureFunction>;
6
+ export type GenericPureFunction<P extends TypeFormatValue> = (val: any, formatParams: P, deps: PureFunctionDeps) => any;
7
+ export type ErrorsPureFunction<P extends TypeFormatValue> = (val: any, pλth: StrNumber[], εrr: RunTypeError[], expected: string, formatName: string, formatParams: P, formatPath: StrNumber[], deps: PureFunctionDeps, accessPath?: StrNumber[], fmtAccessPath?: StrNumber[]) => RunTypeError[];
8
+ export type PureFunction = (...args: any[]) => any;
9
+ export type PureFunctionFactory = (jitUtils: JITUtils) => PureFunction;
10
+ export interface PureFunctionData {
11
+ readonly namespace: string;
12
+ readonly paramNames: string[];
13
+ readonly code: string;
14
+ readonly fnName: string;
15
+ readonly bodyHash: string;
16
+ readonly pureFnDependencies: Array<string>;
17
+ }
18
+ export interface CompiledPureFunction extends PureFunctionData {
19
+ createPureFn: PureFunctionFactory;
20
+ fn?: PureFunction;
21
+ }
22
+ export interface PersistedPureFunction extends CompiledPureFunction {
23
+ fn: undefined;
24
+ }
25
+ export interface PureFnDef<F extends (...args: any[]) => any = (...args: any[]) => any> {
26
+ readonly namespace?: string;
27
+ readonly fnName?: string;
28
+ isFactory?: boolean;
29
+ readonly pureFn: F;
30
+ }
31
+ export interface ParsedFactoryFn {
32
+ readonly bodyHash: string;
33
+ readonly paramNames: string[];
34
+ readonly code: string;
35
+ }
36
+ export interface PureServerFnRef<F extends (...args: any[]) => any = (...args: any[]) => any> extends Required<PureFnDef<F>> {
37
+ readonly namespace: string;
38
+ readonly fnName: string;
39
+ readonly bodyHash: string;
40
+ pureFnDependencies?: Array<string>;
41
+ }
42
+ export interface MapFromServerFnRef<F extends (...args: any[]) => any = (...args: any[]) => any> extends PureServerFnRef<F> {
43
+ fromRequestId: string;
44
+ toRequestId: string;
45
+ paramIndex: number;
46
+ mapFromSymbol: symbol;
47
+ type(): ReturnType<F>;
48
+ }
49
+ export type MapFromRef = Pick<MapFromServerFnRef<any>, 'fromRequestId' | 'toRequestId' | 'fnName' | 'namespace' | 'paramIndex'>;
50
+ export interface RoutesFlowQuery {
51
+ routes: string[];
52
+ mappings?: RoutesFlowMapping[];
53
+ }
54
+ export interface RoutesFlowMapping {
55
+ fromId: string;
56
+ toId: string;
57
+ bodyHash: string;
58
+ paramIndex: number;
59
+ }
60
+ export {};
61
+ export declare type __ΩPureFunctionDeps = any[];
62
+ export declare type __ΩGenericPureFunction = any[];
63
+ export declare type __ΩErrorsPureFunction = any[];
64
+ export declare type __ΩPureFunction = any[];
65
+ export declare type __ΩPureFunctionFactory = any[];
66
+ export declare type __ΩPureFunctionData = any[];
67
+ export declare type __ΩCompiledPureFunction = any[];
68
+ export declare type __ΩPersistedPureFunction = any[];
69
+ export declare type __ΩPureFnDef = any[];
70
+ export declare type __ΩParsedFactoryFn = any[];
71
+ export declare type __ΩPureServerFnRef = any[];
72
+ export declare type __ΩMapFromServerFnRef = any[];
73
+ export declare type __ΩMapFromRef = any[];
74
+ export declare type __ΩRoutesFlowQuery = any[];
75
+ export declare type __ΩRoutesFlowMapping = any[];
@@ -0,0 +1,39 @@
1
+ import { __ΩRunTypeError as ___RunTypeError } from "./general.types.js";
2
+ const __ΩRecord = ["K", "T", "Record", `l'e#"Rb!b"Pde"!N#!w#y`];
3
+ const __ΩRequired = ["T", "Required", 'l+e#!e"!fRb!Pde"!gN##w"y'];
4
+ const __ΩReturnType = ["T", "args", "", "ReturnType", `l>e"!R"RPde#!P"@2"h"!/#qk#'QRb!Pde"!p)w$y`];
5
+ const __ΩPick = ["T", "K", "Pick", 'l+e#!e"!fRb!b"Pde""N#!w#y'];
6
+ const __ΩStrNumber = ["StrNumber", "P&'Jw!y"];
7
+ const __ΩPureFunctionDeps = [() => __ΩRecord, () => __ΩPureFunction, "PureFunctionDeps", '&n"o!#w#y'];
8
+ const __ΩGenericPureFunction = ["P", "val", "formatParams", () => __ΩPureFunctionDeps, "deps", "", "GenericPureFunction", `b!P"2"e"!2#n$2%"/&w'y`];
9
+ const __ΩErrorsPureFunction = ["P", "val", () => __ΩStrNumber, "pλth", () => ___RunTypeError, "εrr", "expected", "formatName", "formatParams", () => __ΩStrNumber, "formatPath", () => __ΩPureFunctionDeps, "deps", () => __ΩStrNumber, "accessPath", () => __ΩStrNumber, "fmtAccessPath", () => ___RunTypeError, "", "ErrorsPureFunction", `b!P"2"n#F2$n%F2&&2'&2(e"!2)n*F2+n,2-n.F2/8n0F218n2F/3w4y`];
10
+ const __ΩPureFunction = ["args", "", "PureFunction", 'P"@2!"/"w#y'];
11
+ const __ΩPureFunctionFactory = ["JITUtils", "jitUtils", () => __ΩPureFunction, "", "PureFunctionFactory", 'P"w!2"n#/$w%y'];
12
+ const __ΩPureFunctionData = ["namespace", "paramNames", "code", "fnName", "bodyHash", "pureFnDependencies", "PureFunctionData", `P&4!9&F4"9&4#9&4$9&4%9&F4&9Mw'y`];
13
+ const __ΩCompiledPureFunction = [() => __ΩPureFunctionData, () => __ΩPureFunctionFactory, "createPureFn", () => __ΩPureFunction, "fn", "CompiledPureFunction", 'Pn!n"4#n$4%8Mw&y'];
14
+ const __ΩPersistedPureFunction = [() => __ΩCompiledPureFunction, "fn", "PersistedPureFunction", 'Pn!-4"Mw#y'];
15
+ const __ΩPureFnDef = ["args", "", "F", "namespace", "fnName", "isFactory", "pureFn", "PureFnDef", `P"@2!"/"c#P&4$89&4%89)4&8e"!4'9Mw(y`];
16
+ const __ΩParsedFactoryFn = ["bodyHash", "paramNames", "code", "ParsedFactoryFn", 'P&4!9&F4"9&4#9Mw$y'];
17
+ const __ΩPureServerFnRef = ["args", "", "F", () => __ΩRequired, () => __ΩPureFnDef, "namespace", "fnName", "bodyHash", "pureFnDependencies", "PureServerFnRef", `P"@2!"/"c#Pe"!o%"o$"&4&9&4'9&4(9&F4)8Mw*y`];
18
+ const __ΩMapFromServerFnRef = ["args", "", "F", () => __ΩPureServerFnRef, "fromRequestId", "toRequestId", "paramIndex", "mapFromSymbol", () => __ΩReturnType, "type", "MapFromServerFnRef", `P"@2!"/"c#Pe"!o$"&4%&4&'4'+4(Pe#!o)"1*Mw+y`];
19
+ const __ΩMapFromRef = [() => __ΩPick, () => __ΩMapFromServerFnRef, "fromRequestId", "toRequestId", "fnName", "namespace", "paramIndex", "MapFromRef", `"o""P.#.$.%.&.'Jo!#w(y`];
20
+ const __ΩRoutesFlowQuery = ["routes", () => __ΩRoutesFlowMapping, "mappings", "RoutesFlowQuery", 'P&F4!n"F4#8Mw$y'];
21
+ const __ΩRoutesFlowMapping = ["fromId", "toId", "bodyHash", "paramIndex", "RoutesFlowMapping", `P&4!&4"&4#'4$Mw%y`];
22
+ export {
23
+ __ΩCompiledPureFunction,
24
+ __ΩErrorsPureFunction,
25
+ __ΩGenericPureFunction,
26
+ __ΩMapFromRef,
27
+ __ΩMapFromServerFnRef,
28
+ __ΩParsedFactoryFn,
29
+ __ΩPersistedPureFunction,
30
+ __ΩPureFnDef,
31
+ __ΩPureFunction,
32
+ __ΩPureFunctionData,
33
+ __ΩPureFunctionDeps,
34
+ __ΩPureFunctionFactory,
35
+ __ΩPureServerFnRef,
36
+ __ΩRoutesFlowMapping,
37
+ __ΩRoutesFlowQuery
38
+ };
39
+ //# sourceMappingURL=pureFunctions.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pureFunctions.types.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ import { CompiledPureFunction } from './types/pureFunctions.types.ts';
2
+ export declare function randomUUID_V7(): string;
3
+ export declare function getENV(key: string): string | undefined;
4
+ export declare function toBase64Url(str: string): string;
5
+ export declare function fromBase64Url(encoded: string): string;
6
+ export declare function isMionCompileMode(): boolean;
7
+ export declare function isMionAOTEmitMode(): boolean;
8
+ export declare function isTestEnv(): boolean;
9
+ export declare function initPureFunction(compiled: CompiledPureFunction): asserts compiled is Required<CompiledPureFunction>;
@@ -0,0 +1,47 @@
1
+ import { getJitUtils } from "./jit/jitUtils.js";
2
+ function randomUUID_V7() {
3
+ const uuid = crypto.randomUUID();
4
+ const tHex = Date.now().toString(16).padStart(12, "0");
5
+ return `${tHex.substring(0, 8)}-${tHex.substring(8)}-7${uuid.substring(15)}`;
6
+ }
7
+ function getENV(key) {
8
+ if (typeof process !== "undefined" && process.env) {
9
+ return process.env[key];
10
+ }
11
+ return void 0;
12
+ }
13
+ function toBase64Url(str) {
14
+ return btoa(str).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
15
+ }
16
+ function fromBase64Url(encoded) {
17
+ return atob(encoded.replace(/-/g, "+").replace(/_/g, "/"));
18
+ }
19
+ let isTest = void 0;
20
+ function isMionCompileMode() {
21
+ const val = getENV("MION_COMPILE");
22
+ return val === "onlyAOT" || val === "viteSSR";
23
+ }
24
+ function isMionAOTEmitMode() {
25
+ const val = getENV("MION_COMPILE");
26
+ return val === "onlyAOT" || val === "viteSSR" || val === "serve";
27
+ }
28
+ function isTestEnv() {
29
+ if (isTest !== void 0) return isTest;
30
+ isTest = getENV("VITEST") !== void 0 || getENV("NODE_ENV") === "test";
31
+ return isTest;
32
+ }
33
+ function initPureFunction(compiled) {
34
+ if (compiled.fn) return;
35
+ compiled.fn = compiled.createPureFn(getJitUtils());
36
+ }
37
+ export {
38
+ fromBase64Url,
39
+ getENV,
40
+ initPureFunction,
41
+ isMionAOTEmitMode,
42
+ isMionCompileMode,
43
+ isTestEnv,
44
+ randomUUID_V7,
45
+ toBase64Url
46
+ };
47
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/utils.ts"],"sourcesContent":["/* ###############\n * 2025 mion\n * Author: Ma-jerez\n * License: MIT\n * The software is provided \"as is\", without warranty of any kind.\n * ############### */\n\nimport {getJitUtils} from './jit/jitUtils.ts';\nimport type {CompiledPureFunction} from './types/pureFunctions.types.ts';\n\n/** Generates a random UUID V7 (RFC 9562),\n * uses crypto.randomUUID() (v4) as random source as it's a native C++ binding that batches entropy,\n * might be faster than allocating typed arrays via crypto.getRandomValues */\nexport function randomUUID_V7(): string {\n const uuid = crypto.randomUUID();\n const tHex = Date.now().toString(16).padStart(12, '0');\n return `${tHex.substring(0, 8)}-${tHex.substring(8)}-7${uuid.substring(15)}`;\n}\n\n/**\n * Browser-safe function to access environment variables.\n * Returns undefined when running in browser environments where process is not available.\n * @param key - The environment variable key to retrieve\n * @returns The environment variable value or undefined if not available/in browser\n */\nexport function getENV(key: string): string | undefined {\n if (typeof process !== 'undefined' && process.env) {\n return process.env[key];\n }\n return undefined;\n}\n\n// ############# Base64 URL #############\n\n/** Encodes a string to URL-safe base64 (RFC 4648 §5) without padding */\nexport function toBase64Url(str: string): string {\n return btoa(str).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\n/** Decodes a URL-safe base64 string (RFC 4648 §5) back to a string */\nexport function fromBase64Url(encoded: string): string {\n return atob(encoded.replace(/-/g, '+').replace(/_/g, '/'));\n}\n\nlet isTest: boolean | undefined = undefined;\n/** Whether the process is in mion compile mode (onlyAOT or viteSSR).\n * In these modes platform adapters skip server.listen() — the server does NOT start. */\nexport function isMionCompileMode(): boolean {\n const val = getENV('MION_COMPILE');\n return val === 'onlyAOT' || val === 'viteSSR';\n}\n\n/** Whether AOT caches should be generated and emitted (onlyAOT, viteSSR, or serve).\n * Unlike isMionCompileMode(), this also includes 'serve' mode where the server DOES start\n * and keeps running after emitting AOT caches via IPC. */\nexport function isMionAOTEmitMode(): boolean {\n const val = getENV('MION_COMPILE');\n return val === 'onlyAOT' || val === 'viteSSR' || val === 'serve';\n}\n\nexport function isTestEnv() {\n if (isTest !== undefined) return isTest;\n isTest = getENV('VITEST') !== undefined || getENV('NODE_ENV') === 'test';\n return isTest;\n}\n\n/**\n * Restores the full state of a compiled pure function,\n * The pure function itself can't be compiled to code as it contains references to context code and jitUtils.\n * So we need to restore it manually by invoking the closure function.\n * */\nexport function initPureFunction(compiled: CompiledPureFunction): asserts compiled is Required<CompiledPureFunction> {\n if (compiled.fn) return;\n compiled.fn = compiled.createPureFn(getJitUtils());\n}\n"],"names":[],"mappings":";AAaO,SAAS,gBAAwB;AACpC,QAAM,OAAO,OAAO,WAAA;AACpB,QAAM,OAAO,KAAK,MAAM,SAAS,EAAE,EAAE,SAAS,IAAI,GAAG;AACrD,SAAO,GAAG,KAAK,UAAU,GAAG,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;AAC9E;AAQO,SAAS,OAAO,KAAiC;AACpD,MAAI,OAAO,YAAY,eAAe,QAAQ,KAAK;AAC/C,WAAO,QAAQ,IAAI,GAAG;AAAA,EAC1B;AACA,SAAO;AACX;AAKO,SAAS,YAAY,KAAqB;AAC7C,SAAO,KAAK,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AAC9E;AAGO,SAAS,cAAc,SAAyB;AACnD,SAAO,KAAK,QAAQ,QAAQ,MAAM,GAAG,EAAE,QAAQ,MAAM,GAAG,CAAC;AAC7D;AAEA,IAAI,SAA8B;AAG3B,SAAS,oBAA6B;AACzC,QAAM,MAAM,OAAO,cAAc;AACjC,SAAO,QAAQ,aAAa,QAAQ;AACxC;AAKO,SAAS,oBAA6B;AACzC,QAAM,MAAM,OAAO,cAAc;AACjC,SAAO,QAAQ,aAAa,QAAQ,aAAa,QAAQ;AAC7D;AAEO,SAAS,YAAY;AACxB,MAAI,WAAW,OAAW,QAAO;AACjC,WAAS,OAAO,QAAQ,MAAM,UAAa,OAAO,UAAU,MAAM;AAClE,SAAO;AACX;AAOO,SAAS,iBAAiB,UAAoF;AACjH,MAAI,SAAS,GAAI;AACjB,WAAS,KAAK,SAAS,aAAa,YAAA,CAAa;AACrD;"}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mion
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/MionKit/mion/master/assets/public/bannerx90-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/MionKit/mion/master/assets/public/bannerx90.png">
5
+ <img alt='mion, a mikro kit for Typescript Serverless APIs' src='https://raw.githubusercontent.com/MionKit/mion/master/assets/public/bannerx90.png'>
6
+ </picture>
7
+ </p>
8
+ <p align="center">
9
+ <strong>mion core functionality.
10
+ </strong>
11
+ </p>
12
+ <p align=center>
13
+ <img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square&maxAge=99999999" alt="npm" style="max-width:100%;">
14
+ <img src="https://img.shields.io/badge/license-MIT-97ca00.svg?style=flat-square&maxAge=99999999" alt="npm" style="max-width:100%;">
15
+ </p>
16
+
17
+ # `@mionjs/core`
18
+
19
+ This library contains core functionality shared between other mion packages.
20
+
21
+ - errors
22
+ - configuration
23
+
24
+ All items in this library should be isomorphic, this mean should used both in the browser or node server.
25
+
26
+ ## Check Out The [Website And Documentation](http://mion.io) 📚
27
+
28
+ [![mion-website-banner](https://raw.githubusercontent.com/MionKit/mion/master/assets/public/mion-website-banner.png)](http://mion.io)
29
+
30
+ ---
31
+
32
+ [MIT LICENSE](../../LICENSE)
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@mionjs/core",
3
+ "version": "0.8.0-alpha.0",
4
+ "type": "module",
5
+ "description": "Core functionality required across multiple mion packages",
6
+ "keywords": [
7
+ "typescript",
8
+ "API",
9
+ "RPC",
10
+ "json",
11
+ "schema",
12
+ "generate",
13
+ "server",
14
+ "serverless",
15
+ "framework",
16
+ "node",
17
+ "runtime types"
18
+ ],
19
+ "author": "ma jerez",
20
+ "homepage": "https://mion.io/",
21
+ "license": "MIT",
22
+ "browser": {},
23
+ "exports": {
24
+ ".": {
25
+ "source": "./index.ts",
26
+ "types": "./.dist/esm/index.d.ts",
27
+ "require": "./.dist/cjs/index.cjs",
28
+ "default": "./.dist/esm/index.js"
29
+ }
30
+ },
31
+ "directories": {
32
+ "lib": ".dist"
33
+ },
34
+ "files": [
35
+ ".dist"
36
+ ],
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/MionKit/mion.git"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "scripts": {
45
+ "test": "vitest run",
46
+ "dev": "vite build --watch",
47
+ "dev:test": "vitest watch",
48
+ "lint": "npx eslint src",
49
+ "format": "prettier --write src/**/*.ts",
50
+ "build": "vite build",
51
+ "clean": "rimraf .dist & rimraf .coverage",
52
+ "fresh-start": "npm run clean && rimraf node_modules"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/MionKit/mion/issues"
56
+ },
57
+ "gitHead": "5d2ec524ba39d040338ce8946d8edf78aa7291a3"
58
+ }