@objectstack/types 17.0.0-rc.1 → 17.0.0-rc.3
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/CHANGELOG.md +164 -0
- package/dist/node.d.mts +28 -0
- package/dist/node.d.ts +28 -0
- package/dist/node.js +52 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +26 -0
- package/dist/node.mjs.map +1 -0
- package/package.json +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,169 @@
|
|
|
1
1
|
# @objectstack/types
|
|
2
2
|
|
|
3
|
+
## 17.0.0-rc.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [2e284b2]
|
|
8
|
+
- @objectstack/spec@17.0.0-rc.3
|
|
9
|
+
|
|
10
|
+
## 17.0.0-rc.2
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- b25a116: fix(verify): resolve the enterprise organizations package from the HOST APP (#4700)
|
|
15
|
+
|
|
16
|
+
`bootStack(app, { multiTenant: true })` — and therefore `objectstack verify
|
|
17
|
+
--multi-tenant` — could never load `@objectstack/organizations`. Node ESM
|
|
18
|
+
resolves a bare `import()` against the **importer's own realpath**, which for
|
|
19
|
+
`packages/verify` is inside the framework workspace, while the enterprise
|
|
20
|
+
package is cloud-private and only ever lives in the verified app's
|
|
21
|
+
`node_modules`. Every real host app fell into the catch and was told to
|
|
22
|
+
"Install/link it in this workspace" — about a package it had already installed.
|
|
23
|
+
Same defect class as cloud#1013, which fixed `objectstack serve`; #4699 fixed
|
|
24
|
+
that one call site and this issue tracked the two the sweep left behind.
|
|
25
|
+
|
|
26
|
+
**New: `@objectstack/types/node`.** The host-app resolver (`createHostRequire` /
|
|
27
|
+
`createHostImporter`) moved out of `packages/cli/src/utils/import-from-host.ts`
|
|
28
|
+
— where `@objectstack/verify` and the dogfood suite could not import it without
|
|
29
|
+
inverting the dependency direction — into a **node-only subpath export** of
|
|
30
|
+
`@objectstack/types`. One behaviour, one source; the CLI now consumes it and its
|
|
31
|
+
private copy is deleted.
|
|
32
|
+
|
|
33
|
+
It is a subpath and **not** the root export because `@objectstack/types` is a
|
|
34
|
+
dependency of `@objectstack/hono` ("edge-compatible REST API server for
|
|
35
|
+
Cloudflare Workers, Deno, Bun, and Node") and of the plugin layer a `LiteKernel`
|
|
36
|
+
boots on Workers. The root entry reaches zero `node:` builtins, and a Workers
|
|
37
|
+
bundle breaks on `node:module` even when nothing calls it. `tsup` emits the two
|
|
38
|
+
entries as separate self-contained bundles (`splitting: false`), and a test
|
|
39
|
+
walks the root's import graph and fails on the first reachable `node:`
|
|
40
|
+
specifier, so the isolation is enforced rather than merely intended. Same
|
|
41
|
+
arrangement `@objectstack/metadata` already ships for its `./node` subpath.
|
|
42
|
+
|
|
43
|
+
**New: `BootOptions.hostRoot`** (optional, defaults to `process.cwd()`) names
|
|
44
|
+
the app whose `node_modules` supplies those optional packages — for a harness
|
|
45
|
+
booting an app that is not the working directory.
|
|
46
|
+
|
|
47
|
+
**The dogfood multi-org gates had never run.** Two suites probed availability
|
|
48
|
+
with the same bare `import()` and so were **constant-false** — not "false
|
|
49
|
+
because absent" but false by construction, in every environment including the
|
|
50
|
+
cloud CI whose comment claimed it ran them. The #1994 cross-tenant RLS proof and
|
|
51
|
+
the attachments cross-tenant isolation block had therefore never executed while
|
|
52
|
+
the suite reported green (Prime Directive #10, test-suite edition). They now
|
|
53
|
+
resolve like the runtime does, and `OS_TEST_MULTI_ORG_ENABLED=1` declares that a
|
|
54
|
+
run is expected to ship the package — turning a silent skip into a loud failure,
|
|
55
|
+
so a run can no longer pass by quietly not running the gates it exists for.
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [430dcc2]
|
|
60
|
+
- Updated dependencies [e6ac4bd]
|
|
61
|
+
- Updated dependencies [80334c7]
|
|
62
|
+
- Updated dependencies [ce5242c]
|
|
63
|
+
- Updated dependencies [a7163ea]
|
|
64
|
+
- Updated dependencies [e6e9379]
|
|
65
|
+
- Updated dependencies [98877c9]
|
|
66
|
+
- Updated dependencies [98877c9]
|
|
67
|
+
- Updated dependencies [e6b1b69]
|
|
68
|
+
- Updated dependencies [ad047d2]
|
|
69
|
+
- Updated dependencies [2826d1e]
|
|
70
|
+
- Updated dependencies [5a84d41]
|
|
71
|
+
- Updated dependencies [20b1a9e]
|
|
72
|
+
- Updated dependencies [203a449]
|
|
73
|
+
- Updated dependencies [ac37fc6]
|
|
74
|
+
- Updated dependencies [4820f55]
|
|
75
|
+
- Updated dependencies [462d9c4]
|
|
76
|
+
- Updated dependencies [7d21581]
|
|
77
|
+
- Updated dependencies [f2445c9]
|
|
78
|
+
- Updated dependencies [23338c3]
|
|
79
|
+
- Updated dependencies [5b843fb]
|
|
80
|
+
- Updated dependencies [b4487aa]
|
|
81
|
+
- Updated dependencies [65ca83a]
|
|
82
|
+
- Updated dependencies [67bf2e2]
|
|
83
|
+
- Updated dependencies [c6d1cb4]
|
|
84
|
+
- Updated dependencies [36030ff]
|
|
85
|
+
- Updated dependencies [6117f7b]
|
|
86
|
+
- Updated dependencies [e533b0b]
|
|
87
|
+
- Updated dependencies [cdf4d9a]
|
|
88
|
+
- Updated dependencies [aee1806]
|
|
89
|
+
- Updated dependencies [c13350b]
|
|
90
|
+
- Updated dependencies [c13350b]
|
|
91
|
+
- Updated dependencies [9ca2d85]
|
|
92
|
+
- Updated dependencies [c13350b]
|
|
93
|
+
- Updated dependencies [891d345]
|
|
94
|
+
- Updated dependencies [a52e2ef]
|
|
95
|
+
- Updated dependencies [5293114]
|
|
96
|
+
- Updated dependencies [20bc357]
|
|
97
|
+
- Updated dependencies [5966c2a]
|
|
98
|
+
- Updated dependencies [2382580]
|
|
99
|
+
- Updated dependencies [d9fa683]
|
|
100
|
+
- Updated dependencies [3c7bcc0]
|
|
101
|
+
- Updated dependencies [4b6cac7]
|
|
102
|
+
- Updated dependencies [7631964]
|
|
103
|
+
- Updated dependencies [ac471a0]
|
|
104
|
+
- Updated dependencies [60ae58e]
|
|
105
|
+
- Updated dependencies [ce92674]
|
|
106
|
+
- Updated dependencies [9f601e8]
|
|
107
|
+
- Updated dependencies [51c5227]
|
|
108
|
+
- Updated dependencies [a4a85c8]
|
|
109
|
+
- Updated dependencies [07a4e26]
|
|
110
|
+
- Updated dependencies [ec975f1]
|
|
111
|
+
- Updated dependencies [eb4204b]
|
|
112
|
+
- Updated dependencies [4f13be2]
|
|
113
|
+
- Updated dependencies [61cc079]
|
|
114
|
+
- Updated dependencies [0e96e46]
|
|
115
|
+
- Updated dependencies [d52d4fe]
|
|
116
|
+
- Updated dependencies [742cebb]
|
|
117
|
+
- Updated dependencies [ce92674]
|
|
118
|
+
- Updated dependencies [cf2c9b7]
|
|
119
|
+
- Updated dependencies [0f9faa2]
|
|
120
|
+
- Updated dependencies [7cf42fe]
|
|
121
|
+
- Updated dependencies [5966c2a]
|
|
122
|
+
- Updated dependencies [f78dd83]
|
|
123
|
+
- Updated dependencies [a2cd18a]
|
|
124
|
+
- Updated dependencies [4638aaa]
|
|
125
|
+
- Updated dependencies [0222d3c]
|
|
126
|
+
- Updated dependencies [0a936ea]
|
|
127
|
+
- Updated dependencies [023c00b]
|
|
128
|
+
- Updated dependencies [155507e]
|
|
129
|
+
- Updated dependencies [7bba90b]
|
|
130
|
+
- Updated dependencies [7e05d8e]
|
|
131
|
+
- Updated dependencies [061406d]
|
|
132
|
+
- Updated dependencies [c1f344b]
|
|
133
|
+
- Updated dependencies [9c93465]
|
|
134
|
+
- Updated dependencies [ebb209c]
|
|
135
|
+
- Updated dependencies [63b33e6]
|
|
136
|
+
- Updated dependencies [2a44c1d]
|
|
137
|
+
- Updated dependencies [695cfbd]
|
|
138
|
+
- Updated dependencies [7445149]
|
|
139
|
+
- Updated dependencies [071d0dc]
|
|
140
|
+
- Updated dependencies [0848bea]
|
|
141
|
+
- Updated dependencies [d51bed2]
|
|
142
|
+
- Updated dependencies [b8b3c64]
|
|
143
|
+
- Updated dependencies [0c0fbd9]
|
|
144
|
+
- Updated dependencies [f3141d8]
|
|
145
|
+
- Updated dependencies [5a84d41]
|
|
146
|
+
- Updated dependencies [fd3013a]
|
|
147
|
+
- Updated dependencies [21676eb]
|
|
148
|
+
- Updated dependencies [e336549]
|
|
149
|
+
- Updated dependencies [d40f43a]
|
|
150
|
+
- Updated dependencies [e5e7ee0]
|
|
151
|
+
- Updated dependencies [a2ebea2]
|
|
152
|
+
- Updated dependencies [800bdb0]
|
|
153
|
+
- Updated dependencies [04f1182]
|
|
154
|
+
- Updated dependencies [5647006]
|
|
155
|
+
- Updated dependencies [38f7e4f]
|
|
156
|
+
- Updated dependencies [c57f3cf]
|
|
157
|
+
- Updated dependencies [97faca3]
|
|
158
|
+
- Updated dependencies [ad5fe25]
|
|
159
|
+
- Updated dependencies [ea90179]
|
|
160
|
+
- Updated dependencies [ce92674]
|
|
161
|
+
- Updated dependencies [5ef0b5b]
|
|
162
|
+
- Updated dependencies [48fbacb]
|
|
163
|
+
- Updated dependencies [355e951]
|
|
164
|
+
- Updated dependencies [dadb43f]
|
|
165
|
+
- @objectstack/spec@17.0.0-rc.2
|
|
166
|
+
|
|
3
167
|
## 17.0.0-rc.1
|
|
4
168
|
|
|
5
169
|
### Minor Changes
|
package/dist/node.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports a package as the host app would see it.
|
|
3
|
+
*
|
|
4
|
+
* `any` is the module namespace of a package this repo does not compile against
|
|
5
|
+
* (it is not a dependency of the importing package at all) — every call site
|
|
6
|
+
* reads an export off it dynamically, exactly as the bare `import()` it replaces
|
|
7
|
+
* did.
|
|
8
|
+
*/
|
|
9
|
+
type HostImporter = (pkg: string) => Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* A `require` anchored at the **host app's** `package.json` — i.e. the project
|
|
12
|
+
* `objectstack serve` was invoked in, or the app `bootStack` is verifying, whose
|
|
13
|
+
* `node_modules` carries the packages it declares.
|
|
14
|
+
*
|
|
15
|
+
* @param hostRoot Directory holding the host app's `package.json` (default: the
|
|
16
|
+
* process CWD, which is where the CLI reads `objectstack.config.ts` from too).
|
|
17
|
+
*/
|
|
18
|
+
declare function createHostRequire(hostRoot?: string): NodeRequire;
|
|
19
|
+
/**
|
|
20
|
+
* Build an importer that resolves from the host app first, then falls back to
|
|
21
|
+
* the importing package's own resolution.
|
|
22
|
+
*
|
|
23
|
+
* @param hostRequire Reuse an existing host `require` (callers usually also need
|
|
24
|
+
* it to read the host `package.json`); defaults to one anchored at the CWD.
|
|
25
|
+
*/
|
|
26
|
+
declare function createHostImporter(hostRequire?: NodeRequire): HostImporter;
|
|
27
|
+
|
|
28
|
+
export { type HostImporter, createHostImporter, createHostRequire };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports a package as the host app would see it.
|
|
3
|
+
*
|
|
4
|
+
* `any` is the module namespace of a package this repo does not compile against
|
|
5
|
+
* (it is not a dependency of the importing package at all) — every call site
|
|
6
|
+
* reads an export off it dynamically, exactly as the bare `import()` it replaces
|
|
7
|
+
* did.
|
|
8
|
+
*/
|
|
9
|
+
type HostImporter = (pkg: string) => Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* A `require` anchored at the **host app's** `package.json` — i.e. the project
|
|
12
|
+
* `objectstack serve` was invoked in, or the app `bootStack` is verifying, whose
|
|
13
|
+
* `node_modules` carries the packages it declares.
|
|
14
|
+
*
|
|
15
|
+
* @param hostRoot Directory holding the host app's `package.json` (default: the
|
|
16
|
+
* process CWD, which is where the CLI reads `objectstack.config.ts` from too).
|
|
17
|
+
*/
|
|
18
|
+
declare function createHostRequire(hostRoot?: string): NodeRequire;
|
|
19
|
+
/**
|
|
20
|
+
* Build an importer that resolves from the host app first, then falls back to
|
|
21
|
+
* the importing package's own resolution.
|
|
22
|
+
*
|
|
23
|
+
* @param hostRequire Reuse an existing host `require` (callers usually also need
|
|
24
|
+
* it to read the host `package.json`); defaults to one anchored at the CWD.
|
|
25
|
+
*/
|
|
26
|
+
declare function createHostImporter(hostRequire?: NodeRequire): HostImporter;
|
|
27
|
+
|
|
28
|
+
export { type HostImporter, createHostImporter, createHostRequire };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/node.ts
|
|
21
|
+
var node_exports = {};
|
|
22
|
+
__export(node_exports, {
|
|
23
|
+
createHostImporter: () => createHostImporter,
|
|
24
|
+
createHostRequire: () => createHostRequire
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(node_exports);
|
|
27
|
+
var import_node_module = require("module");
|
|
28
|
+
var import_node_path = require("path");
|
|
29
|
+
var import_node_url = require("url");
|
|
30
|
+
function createHostRequire(hostRoot = process.cwd()) {
|
|
31
|
+
return (0, import_node_module.createRequire)((0, import_node_path.join)(hostRoot, "package.json"));
|
|
32
|
+
}
|
|
33
|
+
function createHostImporter(hostRequire = createHostRequire()) {
|
|
34
|
+
return async (pkg) => {
|
|
35
|
+
let resolved;
|
|
36
|
+
try {
|
|
37
|
+
resolved = hostRequire.resolve(pkg);
|
|
38
|
+
} catch {
|
|
39
|
+
return import(
|
|
40
|
+
/* webpackIgnore: true */
|
|
41
|
+
pkg
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return import((0, import_node_url.pathToFileURL)(resolved).href);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
48
|
+
0 && (module.exports = {
|
|
49
|
+
createHostImporter,
|
|
50
|
+
createHostRequire
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"sourcesContent":["// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * `@objectstack/types/node` — the **node-only** slice of the shared utilities.\n *\n * WHY A SUBPATH AND NOT THE ROOT EXPORT. `@objectstack/types` is a dependency of\n * `@objectstack/hono`, whose whole reason to exist is \"edge-compatible REST API\n * server for Cloudflare Workers, Deno, Bun, and Node\" — and of the plugin/service\n * layer a `LiteKernel` boots on Workers. The root entry (`src/index.ts`) reaches\n * **zero** `node:` builtins today, and that is a property those consumers depend\n * on: a Workers bundle that pulls in `node:module` fails to build (or dies at\n * first call) even when nothing ever invokes it. Everything here needs\n * `node:module` / `node:url` by definition — it exists to drive Node's own\n * resolver — so it lives behind its own entry point instead.\n *\n * The isolation is structural, not conventional: `tsup` builds `src/index.ts` and\n * `src/node.ts` as separate entries with `splitting: false`, so the root bundle\n * contains no reference to this file, and `node-isolation.test.ts` fails the\n * build if anything reachable from the root ever imports a `node:` builtin. Same\n * arrangement `@objectstack/metadata` already ships for `./node`.\n *\n * ── What lives here ──────────────────────────────────────────────────────────\n *\n * Resolving optional packages from the **host app**, not from the framework\n * package doing the importing.\n *\n * Node ESM resolves a bare `import('pkg')` against the **importer's own\n * realpath**. Framework packages (the CLI, `@objectstack/verify`,\n * `@objectstack/dogfood`) are reached through `link:`/workspace dependencies, so\n * their realpath is inside the *framework* workspace — a bare import from any of\n * them can only ever see packages installed in the framework's own\n * `node_modules`. Every package that lives OUTSIDE that workspace and is supplied\n * by the app being served, verified or tested — a cloud-private package such as\n * `@objectstack/organizations` or `@objectstack/service-ai-studio`, or anything a\n * customer installs into their own project — is therefore invisible to a bare\n * import, no matter what the host app declares in its `package.json`\n * (cloud#1013: `objectstack serve` could never load the enterprise multi-org\n * runtime, so every self-hosted walled-posture deployment hit the ADR-0093 D5\n * fail-fast and exited 1; framework#4700: `bootStack({ multiTenant: true })` told\n * apps to install a package they had already installed, and the dogfood\n * multi-org probes were constant-false).\n *\n * The fix is to resolve from the host app's root and import the resolved\n * absolute path. The importing package's own resolution stays as the fallback,\n * for the framework-owned packages it depends on and the host does not declare.\n *\n * Resolution failure is the ONLY thing that falls back. A package the host\n * resolves but that throws while it evaluates is a genuine crash and propagates\n * unchanged: re-importing it bare would replace the real cause with a\n * `MODULE_NOT_FOUND`, which every caller here classifies as \"not installed\" —\n * turning a broken package into a silent skip (or, on the organizations path,\n * into a fatal message telling the operator to install what is already there).\n */\n\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\n/**\n * Imports a package as the host app would see it.\n *\n * `any` is the module namespace of a package this repo does not compile against\n * (it is not a dependency of the importing package at all) — every call site\n * reads an export off it dynamically, exactly as the bare `import()` it replaces\n * did.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HostImporter = (pkg: string) => Promise<any>;\n\n/**\n * A `require` anchored at the **host app's** `package.json` — i.e. the project\n * `objectstack serve` was invoked in, or the app `bootStack` is verifying, whose\n * `node_modules` carries the packages it declares.\n *\n * @param hostRoot Directory holding the host app's `package.json` (default: the\n * process CWD, which is where the CLI reads `objectstack.config.ts` from too).\n */\nexport function createHostRequire(hostRoot: string = process.cwd()): NodeRequire {\n return createRequire(join(hostRoot, 'package.json'));\n}\n\n/**\n * Build an importer that resolves from the host app first, then falls back to\n * the importing package's own resolution.\n *\n * @param hostRequire Reuse an existing host `require` (callers usually also need\n * it to read the host `package.json`); defaults to one anchored at the CWD.\n */\nexport function createHostImporter(\n hostRequire: NodeRequire = createHostRequire(),\n): HostImporter {\n return async (pkg: string): Promise<any> => {\n let resolved: string;\n try {\n resolved = hostRequire.resolve(pkg);\n } catch {\n // Invisible to the host app — try the importing package's own\n // dependencies. A package neither can see throws MODULE_NOT_FOUND from\n // here, which is what the callers' \"missing vs crashed\" classification\n // expects.\n return import(/* webpackIgnore: true */ pkg);\n }\n return import(pathToFileURL(resolved).href);\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDA,yBAA8B;AAC9B,uBAAqB;AACrB,sBAA8B;AAqBvB,SAAS,kBAAkB,WAAmB,QAAQ,IAAI,GAAgB;AAC/E,aAAO,sCAAc,uBAAK,UAAU,cAAc,CAAC;AACrD;AASO,SAAS,mBACd,cAA2B,kBAAkB,GAC/B;AACd,SAAO,OAAO,QAA8B;AAC1C,QAAI;AACJ,QAAI;AACF,iBAAW,YAAY,QAAQ,GAAG;AAAA,IACpC,QAAQ;AAKN,aAAO;AAAA;AAAA,QAAiC;AAAA;AAAA,IAC1C;AACA,WAAO,WAAO,+BAAc,QAAQ,EAAE;AAAA,EACxC;AACF;","names":[]}
|
package/dist/node.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/node.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
function createHostRequire(hostRoot = process.cwd()) {
|
|
6
|
+
return createRequire(join(hostRoot, "package.json"));
|
|
7
|
+
}
|
|
8
|
+
function createHostImporter(hostRequire = createHostRequire()) {
|
|
9
|
+
return async (pkg) => {
|
|
10
|
+
let resolved;
|
|
11
|
+
try {
|
|
12
|
+
resolved = hostRequire.resolve(pkg);
|
|
13
|
+
} catch {
|
|
14
|
+
return import(
|
|
15
|
+
/* webpackIgnore: true */
|
|
16
|
+
pkg
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return import(pathToFileURL(resolved).href);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
createHostImporter,
|
|
24
|
+
createHostRequire
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=node.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"sourcesContent":["// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * `@objectstack/types/node` — the **node-only** slice of the shared utilities.\n *\n * WHY A SUBPATH AND NOT THE ROOT EXPORT. `@objectstack/types` is a dependency of\n * `@objectstack/hono`, whose whole reason to exist is \"edge-compatible REST API\n * server for Cloudflare Workers, Deno, Bun, and Node\" — and of the plugin/service\n * layer a `LiteKernel` boots on Workers. The root entry (`src/index.ts`) reaches\n * **zero** `node:` builtins today, and that is a property those consumers depend\n * on: a Workers bundle that pulls in `node:module` fails to build (or dies at\n * first call) even when nothing ever invokes it. Everything here needs\n * `node:module` / `node:url` by definition — it exists to drive Node's own\n * resolver — so it lives behind its own entry point instead.\n *\n * The isolation is structural, not conventional: `tsup` builds `src/index.ts` and\n * `src/node.ts` as separate entries with `splitting: false`, so the root bundle\n * contains no reference to this file, and `node-isolation.test.ts` fails the\n * build if anything reachable from the root ever imports a `node:` builtin. Same\n * arrangement `@objectstack/metadata` already ships for `./node`.\n *\n * ── What lives here ──────────────────────────────────────────────────────────\n *\n * Resolving optional packages from the **host app**, not from the framework\n * package doing the importing.\n *\n * Node ESM resolves a bare `import('pkg')` against the **importer's own\n * realpath**. Framework packages (the CLI, `@objectstack/verify`,\n * `@objectstack/dogfood`) are reached through `link:`/workspace dependencies, so\n * their realpath is inside the *framework* workspace — a bare import from any of\n * them can only ever see packages installed in the framework's own\n * `node_modules`. Every package that lives OUTSIDE that workspace and is supplied\n * by the app being served, verified or tested — a cloud-private package such as\n * `@objectstack/organizations` or `@objectstack/service-ai-studio`, or anything a\n * customer installs into their own project — is therefore invisible to a bare\n * import, no matter what the host app declares in its `package.json`\n * (cloud#1013: `objectstack serve` could never load the enterprise multi-org\n * runtime, so every self-hosted walled-posture deployment hit the ADR-0093 D5\n * fail-fast and exited 1; framework#4700: `bootStack({ multiTenant: true })` told\n * apps to install a package they had already installed, and the dogfood\n * multi-org probes were constant-false).\n *\n * The fix is to resolve from the host app's root and import the resolved\n * absolute path. The importing package's own resolution stays as the fallback,\n * for the framework-owned packages it depends on and the host does not declare.\n *\n * Resolution failure is the ONLY thing that falls back. A package the host\n * resolves but that throws while it evaluates is a genuine crash and propagates\n * unchanged: re-importing it bare would replace the real cause with a\n * `MODULE_NOT_FOUND`, which every caller here classifies as \"not installed\" —\n * turning a broken package into a silent skip (or, on the organizations path,\n * into a fatal message telling the operator to install what is already there).\n */\n\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\n/**\n * Imports a package as the host app would see it.\n *\n * `any` is the module namespace of a package this repo does not compile against\n * (it is not a dependency of the importing package at all) — every call site\n * reads an export off it dynamically, exactly as the bare `import()` it replaces\n * did.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type HostImporter = (pkg: string) => Promise<any>;\n\n/**\n * A `require` anchored at the **host app's** `package.json` — i.e. the project\n * `objectstack serve` was invoked in, or the app `bootStack` is verifying, whose\n * `node_modules` carries the packages it declares.\n *\n * @param hostRoot Directory holding the host app's `package.json` (default: the\n * process CWD, which is where the CLI reads `objectstack.config.ts` from too).\n */\nexport function createHostRequire(hostRoot: string = process.cwd()): NodeRequire {\n return createRequire(join(hostRoot, 'package.json'));\n}\n\n/**\n * Build an importer that resolves from the host app first, then falls back to\n * the importing package's own resolution.\n *\n * @param hostRequire Reuse an existing host `require` (callers usually also need\n * it to read the host `package.json`); defaults to one anchored at the CWD.\n */\nexport function createHostImporter(\n hostRequire: NodeRequire = createHostRequire(),\n): HostImporter {\n return async (pkg: string): Promise<any> => {\n let resolved: string;\n try {\n resolved = hostRequire.resolve(pkg);\n } catch {\n // Invisible to the host app — try the importing package's own\n // dependencies. A package neither can see throws MODULE_NOT_FOUND from\n // here, which is what the callers' \"missing vs crashed\" classification\n // expects.\n return import(/* webpackIgnore: true */ pkg);\n }\n return import(pathToFileURL(resolved).href);\n };\n}\n"],"mappings":";AAsDA,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAqBvB,SAAS,kBAAkB,WAAmB,QAAQ,IAAI,GAAgB;AAC/E,SAAO,cAAc,KAAK,UAAU,cAAc,CAAC;AACrD;AASO,SAAS,mBACd,cAA2B,kBAAkB,GAC/B;AACd,SAAO,OAAO,QAA8B;AAC1C,QAAI;AACJ,QAAI;AACF,iBAAW,YAAY,QAAQ,GAAG;AAAA,IACpC,QAAQ;AAKN,aAAO;AAAA;AAAA,QAAiC;AAAA;AAAA,IAC1C;AACA,WAAO,OAAO,cAAc,QAAQ,EAAE;AAAA,EACxC;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/types",
|
|
3
|
-
"version": "17.0.0-rc.
|
|
3
|
+
"version": "17.0.0-rc.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Shared interfaces describing the ObjectStack Runtime environment",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,10 +10,15 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.mjs",
|
|
12
12
|
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./node": {
|
|
15
|
+
"types": "./dist/node.d.ts",
|
|
16
|
+
"import": "./dist/node.mjs",
|
|
17
|
+
"require": "./dist/node.js"
|
|
13
18
|
}
|
|
14
19
|
},
|
|
15
20
|
"dependencies": {
|
|
16
|
-
"@objectstack/spec": "17.0.0-rc.
|
|
21
|
+
"@objectstack/spec": "17.0.0-rc.3"
|
|
17
22
|
},
|
|
18
23
|
"devDependencies": {
|
|
19
24
|
"typescript": "^6.0.3",
|
|
@@ -45,7 +50,7 @@
|
|
|
45
50
|
"node": ">=22.0.0"
|
|
46
51
|
},
|
|
47
52
|
"scripts": {
|
|
48
|
-
"build": "tsup
|
|
53
|
+
"build": "tsup",
|
|
49
54
|
"typecheck": "tsc --noEmit",
|
|
50
55
|
"test": "vitest run"
|
|
51
56
|
}
|