@holo-js/core 0.1.9 → 0.2.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.
- package/dist/{chunk-OAA4RKVE.mjs → chunk-F423SU6D.mjs} +54 -38
- package/dist/errors.d.ts +11 -0
- package/dist/errors.mjs +106 -0
- package/dist/index.mjs +1 -1
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.mjs +1 -1
- package/package.json +32 -27
|
@@ -98,6 +98,7 @@ function createGeneratedBroadcastManifest(registry) {
|
|
|
98
98
|
channels: Object.freeze(registry.channels.map((entry) => Object.freeze({
|
|
99
99
|
name: entry.pattern,
|
|
100
100
|
pattern: entry.pattern,
|
|
101
|
+
...typeof entry.guard === "undefined" ? {} : { guard: entry.guard },
|
|
101
102
|
type: entry.type,
|
|
102
103
|
params: Object.freeze([...entry.params]),
|
|
103
104
|
whispers: Object.freeze([...entry.whispers])
|
|
@@ -519,6 +520,10 @@ function closeSessionRedisAdapter(adapter) {
|
|
|
519
520
|
return adapter.disconnect?.() || adapter.close?.();
|
|
520
521
|
}
|
|
521
522
|
var CORE_BROADCAST_PUBLISHER_MARKER = /* @__PURE__ */ Symbol.for("holo-js.core.broadcast.publisher");
|
|
523
|
+
var frameworkBuildEnvKey = "HOLO_INTERNAL_FRAMEWORK_BUILD";
|
|
524
|
+
function shouldBootRuntimeServices(processEnv = process.env) {
|
|
525
|
+
return processEnv[frameworkBuildEnvKey] !== "1";
|
|
526
|
+
}
|
|
522
527
|
function getRuntimeState() {
|
|
523
528
|
const runtime = globalThis;
|
|
524
529
|
runtime.__holoRuntime__ ??= {};
|
|
@@ -654,6 +659,11 @@ function createRequestAwareAuthContext(context, accessors) {
|
|
|
654
659
|
requestAccessorStorage.enterWith({
|
|
655
660
|
accessors: nextAccessors
|
|
656
661
|
});
|
|
662
|
+
},
|
|
663
|
+
async runWithRequestAccessors(nextAccessors, callback) {
|
|
664
|
+
return await requestAccessorStorage.run({
|
|
665
|
+
accessors: nextAccessors
|
|
666
|
+
}, callback);
|
|
657
667
|
}
|
|
658
668
|
});
|
|
659
669
|
}
|
|
@@ -2607,6 +2617,10 @@ async function createHolo(projectRoot, options = {}) {
|
|
|
2607
2617
|
setAuthRequestAccessors(authRequest) {
|
|
2608
2618
|
activeAuthContext?.setRequestAccessors?.(authRequest);
|
|
2609
2619
|
},
|
|
2620
|
+
async runWithAuthRequestAccessors(authRequest, callback) {
|
|
2621
|
+
const runner = activeAuthContext?.runWithRequestAccessors;
|
|
2622
|
+
return runner ? await runner(authRequest, callback) : await callback();
|
|
2623
|
+
},
|
|
2610
2624
|
async initialize() {
|
|
2611
2625
|
if (runtime.initialized) {
|
|
2612
2626
|
throw new Error("Holo runtime is already initialized.");
|
|
@@ -2625,49 +2639,51 @@ async function createHolo(projectRoot, options = {}) {
|
|
|
2625
2639
|
});
|
|
2626
2640
|
}
|
|
2627
2641
|
try {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2642
|
+
if (shouldBootRuntimeServices(options.processEnv)) {
|
|
2643
|
+
await manager.initializeAll();
|
|
2644
|
+
const optionalSubsystems = await reconfigureOptionalHoloSubsystems(projectRoot, loadedConfig, {
|
|
2645
|
+
renderView: options.renderView,
|
|
2646
|
+
authRequest: options.authRequest,
|
|
2647
|
+
authorizationError: options.authorizationError
|
|
2648
|
+
});
|
|
2649
|
+
activeQueueModule = optionalSubsystems.queueModule;
|
|
2650
|
+
activeSessionRuntime = optionalSubsystems.session;
|
|
2651
|
+
activeAuthRuntime = optionalSubsystems.auth;
|
|
2652
|
+
activeAuthContext = optionalSubsystems.authContext;
|
|
2653
|
+
const optionalEventsModule = activeQueueModule ? await loadEventsModule() : void 0;
|
|
2654
|
+
if (activeQueueModule && optionalEventsModule) {
|
|
2655
|
+
await optionalEventsModule.ensureEventsQueueJobRegisteredAsync?.();
|
|
2656
|
+
}
|
|
2657
|
+
if (registryHasEvents(registry)) {
|
|
2658
|
+
const eventsModule = await loadEventsModule(true);
|
|
2659
|
+
if (!eventsModule) {
|
|
2660
|
+
throw new Error("[@holo-js/core] Events support requires @holo-js/events to be installed.");
|
|
2661
|
+
}
|
|
2662
|
+
activeEventsModule = eventsModule;
|
|
2663
|
+
const eventRegistration = await registerProjectEventsAndListeners(
|
|
2664
|
+
projectRoot,
|
|
2665
|
+
registry,
|
|
2666
|
+
eventsModule,
|
|
2667
|
+
activeQueueModule
|
|
2668
|
+
);
|
|
2669
|
+
runtimeOwnedEventNames.splice(0, runtimeOwnedEventNames.length, ...eventRegistration.eventNames);
|
|
2670
|
+
runtimeOwnedListenerIds.splice(0, runtimeOwnedListenerIds.length, ...eventRegistration.listenerIds);
|
|
2646
2671
|
}
|
|
2647
|
-
|
|
2648
|
-
const
|
|
2672
|
+
activeAuthorizationModule = await loadAuthorizationModule();
|
|
2673
|
+
const authorizationRegistration = await registerProjectAuthorizationDefinitions(
|
|
2649
2674
|
projectRoot,
|
|
2650
2675
|
registry,
|
|
2651
|
-
|
|
2652
|
-
activeQueueModule
|
|
2676
|
+
activeAuthorizationModule
|
|
2653
2677
|
);
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
);
|
|
2663
|
-
runtimeOwnedAuthorizationPolicyNames.splice(0, runtimeOwnedAuthorizationPolicyNames.length, ...authorizationRegistration.policyNames);
|
|
2664
|
-
runtimeOwnedAuthorizationAbilityNames.splice(0, runtimeOwnedAuthorizationAbilityNames.length, ...authorizationRegistration.abilityNames);
|
|
2665
|
-
if (options.registerProjectQueueJobs === true && registryHasJobs(registry)) {
|
|
2666
|
-
if (!activeQueueModule) {
|
|
2667
|
-
throw new Error("[@holo-js/core] Project jobs require @holo-js/queue to be installed.");
|
|
2678
|
+
runtimeOwnedAuthorizationPolicyNames.splice(0, runtimeOwnedAuthorizationPolicyNames.length, ...authorizationRegistration.policyNames);
|
|
2679
|
+
runtimeOwnedAuthorizationAbilityNames.splice(0, runtimeOwnedAuthorizationAbilityNames.length, ...authorizationRegistration.abilityNames);
|
|
2680
|
+
if (options.registerProjectQueueJobs === true && registryHasJobs(registry)) {
|
|
2681
|
+
if (!activeQueueModule) {
|
|
2682
|
+
throw new Error("[@holo-js/core] Project jobs require @holo-js/queue to be installed.");
|
|
2683
|
+
}
|
|
2684
|
+
runtimeOwnedQueueJobNames.splice(0, runtimeOwnedQueueJobNames.length);
|
|
2685
|
+
runtimeOwnedQueueJobNames.push(...await registerProjectQueueJobs(projectRoot, registry, activeQueueModule));
|
|
2668
2686
|
}
|
|
2669
|
-
runtimeOwnedQueueJobNames.splice(0, runtimeOwnedQueueJobNames.length);
|
|
2670
|
-
runtimeOwnedQueueJobNames.push(...await registerProjectQueueJobs(projectRoot, registry, activeQueueModule));
|
|
2671
2687
|
}
|
|
2672
2688
|
runtime.initialized = true;
|
|
2673
2689
|
getRuntimeState().current = runtime;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type HoloHttpErrorStatus = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
2
|
+
type NormalizedHoloHttpError = {
|
|
3
|
+
readonly status: HoloHttpErrorStatus;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly code?: string;
|
|
6
|
+
readonly cause: unknown;
|
|
7
|
+
};
|
|
8
|
+
declare function isHoloHttpErrorStatus(status: number): status is HoloHttpErrorStatus;
|
|
9
|
+
declare function normalizeHoloHttpError(error: unknown): NormalizedHoloHttpError | undefined;
|
|
10
|
+
|
|
11
|
+
export { type HoloHttpErrorStatus, type NormalizedHoloHttpError, isHoloHttpErrorStatus, normalizeHoloHttpError };
|
package/dist/errors.mjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var httpStatuses = /* @__PURE__ */ new Set([
|
|
3
|
+
400,
|
|
4
|
+
401,
|
|
5
|
+
402,
|
|
6
|
+
403,
|
|
7
|
+
404,
|
|
8
|
+
405,
|
|
9
|
+
406,
|
|
10
|
+
407,
|
|
11
|
+
408,
|
|
12
|
+
409,
|
|
13
|
+
410,
|
|
14
|
+
411,
|
|
15
|
+
412,
|
|
16
|
+
413,
|
|
17
|
+
414,
|
|
18
|
+
415,
|
|
19
|
+
416,
|
|
20
|
+
417,
|
|
21
|
+
418,
|
|
22
|
+
421,
|
|
23
|
+
422,
|
|
24
|
+
423,
|
|
25
|
+
424,
|
|
26
|
+
425,
|
|
27
|
+
426,
|
|
28
|
+
428,
|
|
29
|
+
429,
|
|
30
|
+
431,
|
|
31
|
+
451,
|
|
32
|
+
500,
|
|
33
|
+
501,
|
|
34
|
+
502,
|
|
35
|
+
503,
|
|
36
|
+
504,
|
|
37
|
+
505,
|
|
38
|
+
506,
|
|
39
|
+
507,
|
|
40
|
+
508,
|
|
41
|
+
510,
|
|
42
|
+
511
|
|
43
|
+
]);
|
|
44
|
+
function isObject(value) {
|
|
45
|
+
return !!value && typeof value === "object";
|
|
46
|
+
}
|
|
47
|
+
function readNumber(value) {
|
|
48
|
+
return typeof value === "number" && Number.isInteger(value) ? value : void 0;
|
|
49
|
+
}
|
|
50
|
+
function readString(value) {
|
|
51
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
52
|
+
}
|
|
53
|
+
function readStatus(error) {
|
|
54
|
+
if (!isObject(error)) {
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
const directStatus = readNumber(error.status);
|
|
58
|
+
if (directStatus) {
|
|
59
|
+
return directStatus;
|
|
60
|
+
}
|
|
61
|
+
const statusCode = readNumber(error.statusCode);
|
|
62
|
+
if (statusCode) {
|
|
63
|
+
return statusCode;
|
|
64
|
+
}
|
|
65
|
+
const digest = readString(error.digest);
|
|
66
|
+
const nextHttpStatus = digest?.match(/^NEXT_HTTP_ERROR_FALLBACK;(\d{3})$/)?.[1];
|
|
67
|
+
return nextHttpStatus ? Number(nextHttpStatus) : void 0;
|
|
68
|
+
}
|
|
69
|
+
function readMessage(error) {
|
|
70
|
+
if (error instanceof Error && error.message.length > 0) {
|
|
71
|
+
return error.message;
|
|
72
|
+
}
|
|
73
|
+
if (isObject(error)) {
|
|
74
|
+
const message = readString(error.message);
|
|
75
|
+
if (message) {
|
|
76
|
+
return message;
|
|
77
|
+
}
|
|
78
|
+
const statusText = readString(error.statusText);
|
|
79
|
+
if (statusText) {
|
|
80
|
+
return statusText;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return "An unexpected error occurred.";
|
|
84
|
+
}
|
|
85
|
+
function readCode(error) {
|
|
86
|
+
return isObject(error) ? readString(error.code) : void 0;
|
|
87
|
+
}
|
|
88
|
+
function isHoloHttpErrorStatus(status) {
|
|
89
|
+
return httpStatuses.has(status);
|
|
90
|
+
}
|
|
91
|
+
function normalizeHoloHttpError(error) {
|
|
92
|
+
const status = readStatus(error);
|
|
93
|
+
if (!status || !isHoloHttpErrorStatus(status)) {
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
status,
|
|
98
|
+
message: readMessage(error),
|
|
99
|
+
code: readCode(error),
|
|
100
|
+
cause: error
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
isHoloHttpErrorStatus,
|
|
105
|
+
normalizeHoloHttpError
|
|
106
|
+
};
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
resolveGeneratedProjectRegistryPath,
|
|
18
18
|
resolveRuntimeConnectionManagerOptions,
|
|
19
19
|
resolveStorageKeyPath
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-F423SU6D.mjs";
|
|
21
21
|
|
|
22
22
|
// src/adapter.ts
|
|
23
23
|
import { readdir, stat } from "node:fs/promises";
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ interface GeneratedChannelRegistryEntry {
|
|
|
55
55
|
readonly sourcePath: string;
|
|
56
56
|
readonly pattern: string;
|
|
57
57
|
readonly exportName?: string;
|
|
58
|
+
readonly guard?: string;
|
|
58
59
|
readonly type: 'private' | 'presence';
|
|
59
60
|
readonly params: readonly string[];
|
|
60
61
|
readonly whispers: readonly string[];
|
|
@@ -111,6 +112,7 @@ interface GeneratedBroadcastManifestEvent {
|
|
|
111
112
|
interface GeneratedBroadcastManifestChannel {
|
|
112
113
|
readonly name: string;
|
|
113
114
|
readonly pattern: string;
|
|
115
|
+
readonly guard?: string;
|
|
114
116
|
readonly type: 'private' | 'presence';
|
|
115
117
|
readonly params: readonly string[];
|
|
116
118
|
readonly whispers: readonly string[];
|
|
@@ -745,6 +747,7 @@ interface HoloRuntime<TCustom extends HoloConfigMap = HoloConfigMap> {
|
|
|
745
747
|
readonly initialized: boolean;
|
|
746
748
|
initialize(): Promise<void>;
|
|
747
749
|
shutdown(): Promise<void>;
|
|
750
|
+
runWithAuthRequestAccessors<TValue>(accessors: NonNullable<CreateHoloOptions['authRequest']>, callback: () => Promise<TValue>): Promise<TValue>;
|
|
748
751
|
useConfig<TKey extends Extract<keyof RuntimeConfigRegistry<TCustom>, string>>(key: TKey): RuntimeConfigRegistry<TCustom>[TKey];
|
|
749
752
|
useConfig<TPath extends DotPath<RuntimeConfigRegistry<TCustom>>>(path: TPath): ValueAtPath<RuntimeConfigRegistry<TCustom>, TPath>;
|
|
750
753
|
config<TPath extends DotPath<RuntimeConfigRegistry<TCustom>>>(path: TPath): ValueAtPath<RuntimeConfigRegistry<TCustom>, TPath>;
|
|
@@ -955,6 +958,7 @@ declare function reconfigureOptionalHoloSubsystems<TCustom extends HoloConfigMap
|
|
|
955
958
|
readonly authContext?: {
|
|
956
959
|
activate(): void;
|
|
957
960
|
setRequestAccessors?(accessors?: CreateHoloOptions['authRequest']): void;
|
|
961
|
+
runWithRequestAccessors?<TValue>(accessors: NonNullable<CreateHoloOptions['authRequest']>, callback: () => Promise<TValue>): Promise<TValue>;
|
|
958
962
|
};
|
|
959
963
|
}>;
|
|
960
964
|
declare function resetOptionalHoloSubsystems(): Promise<void>;
|
package/dist/runtime/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Holo-JS Framework - Portable runtime core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
"import": "./dist/index.mjs",
|
|
11
11
|
"default": "./dist/index.mjs"
|
|
12
12
|
},
|
|
13
|
+
"./errors": {
|
|
14
|
+
"types": "./dist/errors.d.ts",
|
|
15
|
+
"import": "./dist/errors.mjs",
|
|
16
|
+
"default": "./dist/errors.mjs"
|
|
17
|
+
},
|
|
13
18
|
"./runtime": {
|
|
14
19
|
"types": "./dist/runtime/index.d.ts",
|
|
15
20
|
"import": "./dist/runtime/index.mjs",
|
|
@@ -28,26 +33,26 @@
|
|
|
28
33
|
"test": "vitest --run"
|
|
29
34
|
},
|
|
30
35
|
"dependencies": {
|
|
31
|
-
"@holo-js/config": "^0.
|
|
32
|
-
"@holo-js/db": "^0.
|
|
36
|
+
"@holo-js/config": "^0.2.0",
|
|
37
|
+
"@holo-js/db": "^0.2.0",
|
|
33
38
|
"esbuild": "^0.27.4"
|
|
34
39
|
},
|
|
35
40
|
"peerDependencies": {
|
|
36
|
-
"@holo-js/auth": "^0.
|
|
37
|
-
"@holo-js/auth-clerk": "^0.
|
|
38
|
-
"@holo-js/auth-social": "^0.
|
|
39
|
-
"@holo-js/auth-workos": "^0.
|
|
40
|
-
"@holo-js/authorization": "^0.
|
|
41
|
-
"@holo-js/broadcast": "^0.
|
|
42
|
-
"@holo-js/cache": "^0.
|
|
43
|
-
"@holo-js/events": "^0.
|
|
44
|
-
"@holo-js/mail": "^0.
|
|
45
|
-
"@holo-js/notifications": "^0.
|
|
46
|
-
"@holo-js/queue": "^0.
|
|
47
|
-
"@holo-js/queue-db": "^0.
|
|
48
|
-
"@holo-js/security": "^0.
|
|
49
|
-
"@holo-js/session": "^0.
|
|
50
|
-
"@holo-js/storage": "^0.
|
|
41
|
+
"@holo-js/auth": "^0.2.0",
|
|
42
|
+
"@holo-js/auth-clerk": "^0.2.0",
|
|
43
|
+
"@holo-js/auth-social": "^0.2.0",
|
|
44
|
+
"@holo-js/auth-workos": "^0.2.0",
|
|
45
|
+
"@holo-js/authorization": "^0.2.0",
|
|
46
|
+
"@holo-js/broadcast": "^0.2.0",
|
|
47
|
+
"@holo-js/cache": "^0.2.0",
|
|
48
|
+
"@holo-js/events": "^0.2.0",
|
|
49
|
+
"@holo-js/mail": "^0.2.0",
|
|
50
|
+
"@holo-js/notifications": "^0.2.0",
|
|
51
|
+
"@holo-js/queue": "^0.2.0",
|
|
52
|
+
"@holo-js/queue-db": "^0.2.0",
|
|
53
|
+
"@holo-js/security": "^0.2.0",
|
|
54
|
+
"@holo-js/session": "^0.2.0",
|
|
55
|
+
"@holo-js/storage": "^0.2.0"
|
|
51
56
|
},
|
|
52
57
|
"peerDependenciesMeta": {
|
|
53
58
|
"@holo-js/auth": {
|
|
@@ -97,15 +102,15 @@
|
|
|
97
102
|
}
|
|
98
103
|
},
|
|
99
104
|
"devDependencies": {
|
|
100
|
-
"@holo-js/auth": "^0.
|
|
101
|
-
"@holo-js/auth-social-google": "^0.
|
|
102
|
-
"@holo-js/authorization": "^0.
|
|
103
|
-
"@holo-js/events": "^0.
|
|
104
|
-
"@holo-js/mail": "^0.
|
|
105
|
-
"@holo-js/notifications": "^0.
|
|
106
|
-
"@holo-js/queue-db": "^0.
|
|
107
|
-
"@holo-js/session": "^0.
|
|
108
|
-
"@holo-js/storage": "^0.
|
|
105
|
+
"@holo-js/auth": "^0.2.0",
|
|
106
|
+
"@holo-js/auth-social-google": "^0.2.0",
|
|
107
|
+
"@holo-js/authorization": "^0.2.0",
|
|
108
|
+
"@holo-js/events": "^0.2.0",
|
|
109
|
+
"@holo-js/mail": "^0.2.0",
|
|
110
|
+
"@holo-js/notifications": "^0.2.0",
|
|
111
|
+
"@holo-js/queue-db": "^0.2.0",
|
|
112
|
+
"@holo-js/session": "^0.2.0",
|
|
113
|
+
"@holo-js/storage": "^0.2.0",
|
|
109
114
|
"@types/node": "^22.10.2",
|
|
110
115
|
"tsup": "^8.3.5",
|
|
111
116
|
"typescript": "^5.7.2",
|