primitive-admin 1.2.0-alpha.7 → 1.2.0-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/README.md +8 -2
- package/assets/skill/skills/primitive-platform/SKILL.md +12 -6
- package/dist/src/commands/apps-children.js +2 -0
- package/dist/src/commands/apps-children.js.map +1 -1
- package/dist/src/commands/auth.js +107 -33
- package/dist/src/commands/auth.js.map +1 -1
- package/dist/src/commands/databases.js +13 -1
- package/dist/src/commands/databases.js.map +1 -1
- package/dist/src/commands/documents.js +70 -11
- package/dist/src/commands/documents.js.map +1 -1
- package/dist/src/commands/sync-app-settings.d.ts +12 -2
- package/dist/src/commands/sync-app-settings.js +35 -10
- package/dist/src/commands/sync-app-settings.js.map +1 -1
- package/dist/src/commands/sync.js +44 -10
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/lib/api-client.d.ts +25 -6
- package/dist/src/lib/api-client.js +106 -72
- package/dist/src/lib/api-client.js.map +1 -1
- package/dist/src/lib/app-settings-descriptor.d.ts +38 -0
- package/dist/src/lib/app-settings-descriptor.js +96 -4
- package/dist/src/lib/app-settings-descriptor.js.map +1 -1
- package/dist/src/lib/credentials-home.d.ts +51 -0
- package/dist/src/lib/credentials-home.js +169 -0
- package/dist/src/lib/credentials-home.js.map +1 -0
- package/dist/src/lib/credentials-lock.d.ts +80 -0
- package/dist/src/lib/credentials-lock.js +222 -0
- package/dist/src/lib/credentials-lock.js.map +1 -0
- package/dist/src/lib/credentials-store.d.ts +56 -4
- package/dist/src/lib/credentials-store.js +236 -78
- package/dist/src/lib/credentials-store.js.map +1 -1
- package/dist/src/lib/env-resolver-core.d.ts +1 -1
- package/dist/src/lib/env-resolver-core.js.map +1 -1
- package/dist/src/lib/function-bundle.d.ts +38 -18
- package/dist/src/lib/function-bundle.js +60 -35
- package/dist/src/lib/function-bundle.js.map +1 -1
- package/dist/src/lib/function-document-types.d.ts +5 -3
- package/dist/src/lib/function-document-types.js +10 -14
- package/dist/src/lib/function-document-types.js.map +1 -1
- package/dist/src/lib/function-source-roots.d.ts +67 -0
- package/dist/src/lib/function-source-roots.js +148 -0
- package/dist/src/lib/function-source-roots.js.map +1 -0
- package/dist/src/lib/function-sync.d.ts +27 -0
- package/dist/src/lib/function-sync.js +16 -3
- package/dist/src/lib/function-sync.js.map +1 -1
- package/dist/src/lib/function-typecheck.d.ts +37 -2
- package/dist/src/lib/function-typecheck.js +210 -28
- package/dist/src/lib/function-typecheck.js.map +1 -1
- package/dist/src/lib/generated-config-surfaces.js +21 -10
- package/dist/src/lib/generated-config-surfaces.js.map +1 -1
- package/dist/src/lib/generated-sdk-types.d.ts +1 -1
- package/dist/src/lib/generated-sdk-types.js +1 -1
- package/dist/src/lib/generated-sdk-types.js.map +1 -1
- package/dist/src/lib/login-scope-lines.d.ts +1 -1
- package/dist/src/lib/login-scope-lines.js +1 -1
- package/dist/src/lib/login-scope-lines.js.map +1 -1
- package/dist/src/lib/project-config.d.ts +7 -0
- package/dist/src/lib/project-config.js +22 -1
- package/dist/src/lib/project-config.js.map +1 -1
- package/dist/src/lib/root-import-decision.d.ts +9 -4
- package/dist/src/lib/root-import-decision.js +24 -3
- package/dist/src/lib/root-import-decision.js.map +1 -1
- package/dist/src/lib/scope-request.d.ts +8 -5
- package/dist/src/lib/scope-request.js +17 -8
- package/dist/src/lib/scope-request.js.map +1 -1
- package/package.json +2 -2
|
@@ -8,27 +8,34 @@
|
|
|
8
8
|
* in one envelope. The server verifies the hash and stores the object; it does
|
|
9
9
|
* not compile anything.
|
|
10
10
|
*
|
|
11
|
-
* ──
|
|
11
|
+
* ── Where an imported file may come from ───────────────────────────────
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Every file the build read is classified by its REAL path, never by how it
|
|
14
|
+
* was imported (F-005, widened by #4502):
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* 1. Inside the config tree → a **tree source**: captured as authored bytes
|
|
17
|
+
* and stored with the version, so `config pull` hands it back. An
|
|
18
|
+
* in-tree `node_modules` file still builds and is not captured.
|
|
19
|
+
* 2. Inside a directory the project declares in `functionSources` → a
|
|
20
|
+
* **shared source**: bundled, typechecked, and never captured. The
|
|
21
|
+
* repository is its source of truth, as it is for an npm package, so it is
|
|
22
|
+
* listed in `projectSources` for the typechecker and nowhere else.
|
|
23
|
+
* 3. Under a `node_modules` directory AND reached by a bare specifier (or
|
|
24
|
+
* from a file one reached) → a **dependency**: inlined, never captured.
|
|
25
|
+
* 4. Anything else → an **escape**, refused. A push can never read a file
|
|
26
|
+
* off a developer's disk that neither the tree nor a declaration admits.
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* Rule 3 keeps two conditions on purpose. The provenance half: a resolver
|
|
29
|
+
* plugin records the files a BARE specifier reached, so `import
|
|
30
|
+
* "../../node_modules/private/index.js"` — a relative import that merely lands
|
|
31
|
+
* in a `node_modules` directory — is still an escape. Deciding by path alone
|
|
32
|
+
* would let that one specifier read any file on the disk and upload it. The
|
|
33
|
+
* path half: a bare specifier is not a free pass either. esbuild honours each
|
|
34
|
+
* file's nearest tsconfig `paths`, so a shared file's `@/util/h` resolves into
|
|
35
|
+
* the web app's own source, and a workspace package is a symlink to a
|
|
36
|
+
* directory the repository owns. Both are bare specifiers landing on ordinary
|
|
37
|
+
* files outside `node_modules`, so both are escapes unless their directory is
|
|
38
|
+
* declared — after which they are shared sources, bundled AND typechecked.
|
|
32
39
|
*
|
|
33
40
|
* `primitive-functions` is the one bare specifier left EXTERNAL: the loader
|
|
34
41
|
* (#3180) supplies it at invoke time, so baking a copy into every bundle would
|
|
@@ -104,6 +111,13 @@ export interface BuiltFunctionBundle {
|
|
|
104
111
|
contentHash: string;
|
|
105
112
|
/** Every authored file the build read, sorted by path. */
|
|
106
113
|
sources: FunctionSourceFile[];
|
|
114
|
+
/**
|
|
115
|
+
* The shared sources the bundle inlined from declared `functionSources`
|
|
116
|
+
* directories: POSIX paths relative to the real tree root
|
|
117
|
+
* (`../../web/src/engine/x.ts`), sorted. Never stored or sent — the push
|
|
118
|
+
* hands them to the typechecker.
|
|
119
|
+
*/
|
|
120
|
+
projectSources: string[];
|
|
107
121
|
}
|
|
108
122
|
export interface EnvelopeShape {
|
|
109
123
|
schemaVersion: number;
|
|
@@ -144,4 +158,10 @@ export declare function buildFunctionBundle(options: {
|
|
|
144
158
|
entry: string;
|
|
145
159
|
/** Only for the message; the key is not part of the build. */
|
|
146
160
|
functionKey: string;
|
|
161
|
+
/**
|
|
162
|
+
* The declared `functionSources` directories, as absolute paths. Defaults
|
|
163
|
+
* to what the selected project config declares; the push loop resolves them
|
|
164
|
+
* once and passes them, so their warnings are printed once.
|
|
165
|
+
*/
|
|
166
|
+
sourceRoots?: readonly string[];
|
|
147
167
|
}): Promise<BuiltFunctionBundle>;
|
|
@@ -8,27 +8,34 @@
|
|
|
8
8
|
* in one envelope. The server verifies the hash and stores the object; it does
|
|
9
9
|
* not compile anything.
|
|
10
10
|
*
|
|
11
|
-
* ──
|
|
11
|
+
* ── Where an imported file may come from ───────────────────────────────
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Every file the build read is classified by its REAL path, never by how it
|
|
14
|
+
* was imported (F-005, widened by #4502):
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* 1. Inside the config tree → a **tree source**: captured as authored bytes
|
|
17
|
+
* and stored with the version, so `config pull` hands it back. An
|
|
18
|
+
* in-tree `node_modules` file still builds and is not captured.
|
|
19
|
+
* 2. Inside a directory the project declares in `functionSources` → a
|
|
20
|
+
* **shared source**: bundled, typechecked, and never captured. The
|
|
21
|
+
* repository is its source of truth, as it is for an npm package, so it is
|
|
22
|
+
* listed in `projectSources` for the typechecker and nowhere else.
|
|
23
|
+
* 3. Under a `node_modules` directory AND reached by a bare specifier (or
|
|
24
|
+
* from a file one reached) → a **dependency**: inlined, never captured.
|
|
25
|
+
* 4. Anything else → an **escape**, refused. A push can never read a file
|
|
26
|
+
* off a developer's disk that neither the tree nor a declaration admits.
|
|
25
27
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* Rule 3 keeps two conditions on purpose. The provenance half: a resolver
|
|
29
|
+
* plugin records the files a BARE specifier reached, so `import
|
|
30
|
+
* "../../node_modules/private/index.js"` — a relative import that merely lands
|
|
31
|
+
* in a `node_modules` directory — is still an escape. Deciding by path alone
|
|
32
|
+
* would let that one specifier read any file on the disk and upload it. The
|
|
33
|
+
* path half: a bare specifier is not a free pass either. esbuild honours each
|
|
34
|
+
* file's nearest tsconfig `paths`, so a shared file's `@/util/h` resolves into
|
|
35
|
+
* the web app's own source, and a workspace package is a symlink to a
|
|
36
|
+
* directory the repository owns. Both are bare specifiers landing on ordinary
|
|
37
|
+
* files outside `node_modules`, so both are escapes unless their directory is
|
|
38
|
+
* declared — after which they are shared sources, bundled AND typechecked.
|
|
32
39
|
*
|
|
33
40
|
* `primitive-functions` is the one bare specifier left EXTERNAL: the loader
|
|
34
41
|
* (#3180) supplies it at invoke time, so baking a copy into every bundle would
|
|
@@ -73,6 +80,7 @@ import * as esbuild from "esbuild";
|
|
|
73
80
|
import { createHash } from "crypto";
|
|
74
81
|
import { existsSync, readFileSync, realpathSync } from "fs";
|
|
75
82
|
import { isAbsolute, relative, resolve, sep } from "path";
|
|
83
|
+
import { FUNCTION_SOURCES_KEY, isInsideDirectory, resolveFunctionSourceRoots, } from "./function-source-roots.js";
|
|
76
84
|
/** The module the loader supplies; never bundled. */
|
|
77
85
|
export const PRIMITIVE_FUNCTIONS_MODULE = "primitive-functions";
|
|
78
86
|
/** What that module was called before #3209. Refused at push, by name. */
|
|
@@ -170,7 +178,17 @@ function outsideRoot(root, candidate) {
|
|
|
170
178
|
function escapeRefusal(what, path) {
|
|
171
179
|
return new FunctionBuildError(`${what} '${path}' resolves outside the config tree root. ` +
|
|
172
180
|
"Filesystem imports must stay inside the config tree; npm packages are " +
|
|
173
|
-
"imported by name and inlined into the bundle."
|
|
181
|
+
"imported by name and inlined into the bundle. To share code from " +
|
|
182
|
+
`another directory, declare it in "${FUNCTION_SOURCES_KEY}" in primitive/config.json.`);
|
|
183
|
+
}
|
|
184
|
+
/** The real path, or the spelling itself when it cannot be resolved. */
|
|
185
|
+
function realOrSelf(path) {
|
|
186
|
+
try {
|
|
187
|
+
return realpathSync(path);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return path;
|
|
191
|
+
}
|
|
174
192
|
}
|
|
175
193
|
/**
|
|
176
194
|
* Build one function's bundle and collect its authored sources.
|
|
@@ -181,6 +199,8 @@ function escapeRefusal(what, path) {
|
|
|
181
199
|
export async function buildFunctionBundle(options) {
|
|
182
200
|
const { configDir, entry, functionKey } = options;
|
|
183
201
|
const treeRoot = realpathSync(resolve(configDir));
|
|
202
|
+
const sourceRoots = (options.sourceRoots ??
|
|
203
|
+
resolveFunctionSourceRoots(configDir).roots.map((root) => root.absolute)).map((root) => realOrSelf(resolve(root)));
|
|
184
204
|
// 1. The entry, lexically. An escaping entry is refused as an escape even
|
|
185
205
|
// when the file it names does not exist — "no such file" would be a
|
|
186
206
|
// misleading answer to `entry = "../../etc/passwd"`.
|
|
@@ -299,26 +319,30 @@ export async function buildFunctionBundle(options) {
|
|
|
299
319
|
}
|
|
300
320
|
const bundle = Buffer.from(output.contents);
|
|
301
321
|
// 3. Every file the build actually read, from the metafile — the honest list,
|
|
302
|
-
// rather than a re-parse of the imports
|
|
303
|
-
//
|
|
304
|
-
// import, and one outside the tree is an escape esbuild followed that the
|
|
305
|
-
// push refuses.
|
|
322
|
+
// rather than a re-parse of the imports — classified by its real path in
|
|
323
|
+
// the order the module note gives.
|
|
306
324
|
const sources = [];
|
|
325
|
+
const projectSources = new Set();
|
|
307
326
|
for (const input of Object.keys(result.metafile?.inputs ?? {})) {
|
|
308
|
-
const path = toPosix(input);
|
|
309
327
|
const absolute = resolve(treeRoot, input);
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
328
|
+
const real = realOrSelf(absolute);
|
|
329
|
+
const inNodeModules = real.split(sep).includes("node_modules");
|
|
330
|
+
if (!isInsideDirectory(treeRoot, real)) {
|
|
331
|
+
// A dependency a bare specifier reached is inlined even when it sits
|
|
332
|
+
// under a declared directory: it is a package, not shared source.
|
|
333
|
+
if (inNodeModules && isDependencyFile(absolute))
|
|
334
|
+
continue;
|
|
335
|
+
if (sourceRoots.some((root) => isInsideDirectory(root, real))) {
|
|
336
|
+
projectSources.add(toPosix(relative(treeRoot, real)));
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
throw escapeRefusal("import", toPosix(relative(treeRoot, real)));
|
|
317
340
|
}
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
341
|
+
const path = toPosix(relative(treeRoot, real));
|
|
342
|
+
// In-tree `node_modules`, reached by a bare specifier or a filesystem
|
|
343
|
+
// import: inside the boundary, so it builds — but `config pull` refuses to
|
|
344
|
+
// write a stored `node_modules` path, so capturing it would promise a round
|
|
345
|
+
// trip that cannot be kept.
|
|
322
346
|
if (isDependencyPath(path))
|
|
323
347
|
continue;
|
|
324
348
|
const content = readFileSync(absolute);
|
|
@@ -336,6 +360,7 @@ export async function buildFunctionBundle(options) {
|
|
|
336
360
|
bundle,
|
|
337
361
|
contentHash: createHash("sha256").update(bundle).digest("hex"),
|
|
338
362
|
sources,
|
|
363
|
+
projectSources: [...projectSources].sort(),
|
|
339
364
|
};
|
|
340
365
|
}
|
|
341
366
|
//# sourceMappingURL=function-bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-bundle.js","sourceRoot":"","sources":["../../../src/lib/function-bundle.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"function-bundle.js","sourceRoot":"","sources":["../../../src/lib/function-bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC1D,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,4BAA4B,CAAC;AAEpC,qDAAqD;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;AAEhE,0EAA0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,0EAA0E;AAC1E,MAAM,oBAAoB,GAAG,GAAW,EAAE,CACxC,QAAQ,kBAAkB,oCAAoC;IAC9D,IAAI,0BAA0B,WAAW,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAa;IACrC,6EAA6E;IAC7E,0DAA0D;IAC1D,IAAI,MAAM,CACR,kEAAkE,kBAAkB,KAAK,EACzF,GAAG,CACJ;IACD,qDAAqD;IACrD,IAAI,MAAM,CACR,sCAAsC,kBAAkB,KA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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,OAAO;QACL,KAAK,EAAE,aAAa;QACpB,MAAM;QACN,WAAW,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9D,OAAO;QACP,cAAc,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,IAAI,EAAE;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -75,9 +75,11 @@ export interface DocumentSchemaSource {
|
|
|
75
75
|
content: string;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* The project root a config tree belongs to: the
|
|
79
|
-
*
|
|
80
|
-
*
|
|
78
|
+
* The project root a config tree belongs to: the root of the project config
|
|
79
|
+
* the resolver contract selects — `PRIMITIVE_PROJECT_CONFIG` when it is set,
|
|
80
|
+
* else `primitive/config.json` walking up from the tree (#4502). Null when no
|
|
81
|
+
* config is selected (`--dir` at a scratch path). The stale-layout refusal
|
|
82
|
+
* propagates, as it does from every other reader.
|
|
81
83
|
*/
|
|
82
84
|
export declare function projectRootFor(configDir: string): string | null;
|
|
83
85
|
/**
|
|
@@ -19,12 +19,13 @@
|
|
|
19
19
|
* don't work".
|
|
20
20
|
*/
|
|
21
21
|
import { existsSync, readFileSync } from "fs";
|
|
22
|
-
import {
|
|
22
|
+
import { join, resolve, sep } from "path";
|
|
23
23
|
import { loadSchemaFromTomlString } from "js-bao";
|
|
24
24
|
import { parseConfigToml, stringifyConfigToml } from "./config-toml.js";
|
|
25
25
|
import { tsTypeForDbFieldType } from "./db-codegen/dbTsTypes.js";
|
|
26
26
|
import { objectPropertyKey } from "./db-codegen/dbNaming.js";
|
|
27
|
-
import {
|
|
27
|
+
import { projectRootForConfigPath } from "./env-resolver-core.js";
|
|
28
|
+
import { findProjectConfigPath } from "./project-config.js";
|
|
28
29
|
/** The regenerated declaration beside `primitive-db-types.d.ts`. */
|
|
29
30
|
export const DOCUMENT_TYPES_DECLARATION_FILE = "primitive-document-types.d.ts";
|
|
30
31
|
/** The canonical document schema, relative to the project root. */
|
|
@@ -105,20 +106,15 @@ function fieldType(type, enumValues) {
|
|
|
105
106
|
return tsTypeForDbFieldType(type);
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
|
-
* The project root a config tree belongs to: the
|
|
109
|
-
*
|
|
110
|
-
*
|
|
109
|
+
* The project root a config tree belongs to: the root of the project config
|
|
110
|
+
* the resolver contract selects — `PRIMITIVE_PROJECT_CONFIG` when it is set,
|
|
111
|
+
* else `primitive/config.json` walking up from the tree (#4502). Null when no
|
|
112
|
+
* config is selected (`--dir` at a scratch path). The stale-layout refusal
|
|
113
|
+
* propagates, as it does from every other reader.
|
|
111
114
|
*/
|
|
112
115
|
export function projectRootFor(configDir) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (existsSync(join(dir, PROJECT_TREE_DIR, PROJECT_CONFIG_FILENAME)))
|
|
116
|
-
return dir;
|
|
117
|
-
const parent = dirname(dir);
|
|
118
|
-
if (parent === dir)
|
|
119
|
-
return null;
|
|
120
|
-
dir = parent;
|
|
121
|
-
}
|
|
116
|
+
const configPath = findProjectConfigPath(resolve(configDir));
|
|
117
|
+
return configPath ? projectRootForConfigPath(configPath) : null;
|
|
122
118
|
}
|
|
123
119
|
/**
|
|
124
120
|
* The document schema a tree's functions are typed against, or null when the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-document-types.js","sourceRoot":"","sources":["../../../src/lib/function-document-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"function-document-types.js","sourceRoot":"","sources":["../../../src/lib/function-document-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE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,EAAE,IAAI,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CACvG,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAC;IAC9E,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directories outside the config tree that function code may import from
|
|
3
|
+
* — `functionSources` in `primitive/config.json` (#4502).
|
|
4
|
+
*
|
|
5
|
+
* An app whose server functions reuse TypeScript its web client already runs
|
|
6
|
+
* declares the directories that code lives in. A file under one is a SHARED
|
|
7
|
+
* source: `config push` bundles it and typechecks it like the tree's own
|
|
8
|
+
* files, and never stores it in the envelope — the repository is its source of
|
|
9
|
+
* truth, the way it is for an npm package.
|
|
10
|
+
*
|
|
11
|
+
* The declaration is checked twice, at the two moments each half can be
|
|
12
|
+
* answered:
|
|
13
|
+
*
|
|
14
|
+
* - its SHAPE when the file loads (`validateFunctionSourcesShape`, called by
|
|
15
|
+
* `validateProjectConfig`), so every command that reads the config names a
|
|
16
|
+
* malformed entry: relative, non-empty, no `node_modules` segment. `..` is
|
|
17
|
+
* allowed, for the monorepo whose `primitive/` sits in a sub-package beside
|
|
18
|
+
* the shared code;
|
|
19
|
+
* - its CONTAINMENT at push (`resolveFunctionSourceRoots`), because it is a
|
|
20
|
+
* fact about the disk: each entry is realpath-resolved and must land inside
|
|
21
|
+
* the git repository root around the project, or inside the project root
|
|
22
|
+
* when there is no repository. An entry that does not exist or escapes is
|
|
23
|
+
* dropped for that push with one warning naming it, and an import into it
|
|
24
|
+
* is then refused like any other escape.
|
|
25
|
+
*
|
|
26
|
+
* The config read is the one the resolver contract selects
|
|
27
|
+
* (`findProjectConfigPath`), so `PRIMITIVE_PROJECT_CONFIG` decides here exactly
|
|
28
|
+
* as it does for every other reader.
|
|
29
|
+
*/
|
|
30
|
+
/** The `primitive/config.json` key that declares the directories. */
|
|
31
|
+
export declare const FUNCTION_SOURCES_KEY = "functionSources";
|
|
32
|
+
/** A declared directory that survived containment, for one push. */
|
|
33
|
+
export interface FunctionSourceRoot {
|
|
34
|
+
/** The entry as declared (backslashes normalized). */
|
|
35
|
+
declared: string;
|
|
36
|
+
/** Its real path — what a bundled input's real path is compared against. */
|
|
37
|
+
absolute: string;
|
|
38
|
+
}
|
|
39
|
+
/** The roots a push admits, and what it should say once about the rest. */
|
|
40
|
+
export interface FunctionSourceRoots {
|
|
41
|
+
roots: FunctionSourceRoot[];
|
|
42
|
+
warnings: string[];
|
|
43
|
+
}
|
|
44
|
+
/** A shape problem with the declaration, worded to name the entry. */
|
|
45
|
+
export declare class FunctionSourcesShapeError extends Error {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The declared entries, normalized, or a `FunctionSourcesShapeError` naming
|
|
50
|
+
* the first one that cannot be a directory relative to the project root.
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateFunctionSourcesShape(raw: unknown): string[];
|
|
53
|
+
/**
|
|
54
|
+
* The real path of the git work tree around `dir`, or null when `dir` is not
|
|
55
|
+
* in one or git cannot be run. git reports the toplevel with symlinks
|
|
56
|
+
* resolved, so it is compared against real paths only.
|
|
57
|
+
*/
|
|
58
|
+
export declare function gitTopLevel(dir: string): string | null;
|
|
59
|
+
/** Whether `candidate` is `root` or inside it. Both are real paths. */
|
|
60
|
+
export declare function isInsideDirectory(root: string, candidate: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The declared directories a push of `configDir` admits, as real paths, and
|
|
63
|
+
* one warning for each entry it drops. No project config selected, or none
|
|
64
|
+
* declared, is no roots and nothing to say; a selected config that does not
|
|
65
|
+
* load is no roots and one warning naming the error.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveFunctionSourceRoots(configDir: string): FunctionSourceRoots;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The directories outside the config tree that function code may import from
|
|
3
|
+
* — `functionSources` in `primitive/config.json` (#4502).
|
|
4
|
+
*
|
|
5
|
+
* An app whose server functions reuse TypeScript its web client already runs
|
|
6
|
+
* declares the directories that code lives in. A file under one is a SHARED
|
|
7
|
+
* source: `config push` bundles it and typechecks it like the tree's own
|
|
8
|
+
* files, and never stores it in the envelope — the repository is its source of
|
|
9
|
+
* truth, the way it is for an npm package.
|
|
10
|
+
*
|
|
11
|
+
* The declaration is checked twice, at the two moments each half can be
|
|
12
|
+
* answered:
|
|
13
|
+
*
|
|
14
|
+
* - its SHAPE when the file loads (`validateFunctionSourcesShape`, called by
|
|
15
|
+
* `validateProjectConfig`), so every command that reads the config names a
|
|
16
|
+
* malformed entry: relative, non-empty, no `node_modules` segment. `..` is
|
|
17
|
+
* allowed, for the monorepo whose `primitive/` sits in a sub-package beside
|
|
18
|
+
* the shared code;
|
|
19
|
+
* - its CONTAINMENT at push (`resolveFunctionSourceRoots`), because it is a
|
|
20
|
+
* fact about the disk: each entry is realpath-resolved and must land inside
|
|
21
|
+
* the git repository root around the project, or inside the project root
|
|
22
|
+
* when there is no repository. An entry that does not exist or escapes is
|
|
23
|
+
* dropped for that push with one warning naming it, and an import into it
|
|
24
|
+
* is then refused like any other escape.
|
|
25
|
+
*
|
|
26
|
+
* The config read is the one the resolver contract selects
|
|
27
|
+
* (`findProjectConfigPath`), so `PRIMITIVE_PROJECT_CONFIG` decides here exactly
|
|
28
|
+
* as it does for every other reader.
|
|
29
|
+
*/
|
|
30
|
+
import { execFileSync } from "child_process";
|
|
31
|
+
import { realpathSync, statSync } from "fs";
|
|
32
|
+
import { isAbsolute, relative, resolve } from "path";
|
|
33
|
+
import { projectRootForConfigPath } from "./env-resolver-core.js";
|
|
34
|
+
import { findProjectConfigPath, loadProjectConfigFromPath, ProjectConfigError, } from "./project-config.js";
|
|
35
|
+
/** The `primitive/config.json` key that declares the directories. */
|
|
36
|
+
export const FUNCTION_SOURCES_KEY = "functionSources";
|
|
37
|
+
/** A shape problem with the declaration, worded to name the entry. */
|
|
38
|
+
export class FunctionSourcesShapeError extends Error {
|
|
39
|
+
constructor(message) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "FunctionSourcesShapeError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The declared entries, normalized, or a `FunctionSourcesShapeError` naming
|
|
46
|
+
* the first one that cannot be a directory relative to the project root.
|
|
47
|
+
*/
|
|
48
|
+
export function validateFunctionSourcesShape(raw) {
|
|
49
|
+
if (!Array.isArray(raw)) {
|
|
50
|
+
throw new FunctionSourcesShapeError(`"${FUNCTION_SOURCES_KEY}" must be an array of directory paths relative to the project root.`);
|
|
51
|
+
}
|
|
52
|
+
return raw.map((value) => {
|
|
53
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
54
|
+
throw new FunctionSourcesShapeError(`"${FUNCTION_SOURCES_KEY}" entry ${JSON.stringify(value)} must be a non-empty directory path.`);
|
|
55
|
+
}
|
|
56
|
+
const entry = value.replace(/\\/g, "/");
|
|
57
|
+
if (entry.startsWith("/") || /^[A-Za-z]:/.test(entry)) {
|
|
58
|
+
throw new FunctionSourcesShapeError(`"${FUNCTION_SOURCES_KEY}" entry "${entry}" must be relative to the project root, not absolute.`);
|
|
59
|
+
}
|
|
60
|
+
if (entry.split("/").includes("node_modules")) {
|
|
61
|
+
throw new FunctionSourcesShapeError(`"${FUNCTION_SOURCES_KEY}" entry "${entry}" names a node_modules directory; ` +
|
|
62
|
+
"packages are imported by name and inlined without being declared.");
|
|
63
|
+
}
|
|
64
|
+
return entry;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The real path of the git work tree around `dir`, or null when `dir` is not
|
|
69
|
+
* in one or git cannot be run. git reports the toplevel with symlinks
|
|
70
|
+
* resolved, so it is compared against real paths only.
|
|
71
|
+
*/
|
|
72
|
+
export function gitTopLevel(dir) {
|
|
73
|
+
try {
|
|
74
|
+
const topLevel = execFileSync("git", ["rev-parse", "--show-toplevel"], {
|
|
75
|
+
cwd: dir,
|
|
76
|
+
encoding: "utf-8",
|
|
77
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
78
|
+
}).trim();
|
|
79
|
+
return topLevel ? realpathSync(topLevel) : null;
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Whether `candidate` is `root` or inside it. Both are real paths. */
|
|
86
|
+
export function isInsideDirectory(root, candidate) {
|
|
87
|
+
const rel = relative(root, candidate);
|
|
88
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The declared directories a push of `configDir` admits, as real paths, and
|
|
92
|
+
* one warning for each entry it drops. No project config selected, or none
|
|
93
|
+
* declared, is no roots and nothing to say; a selected config that does not
|
|
94
|
+
* load is no roots and one warning naming the error.
|
|
95
|
+
*/
|
|
96
|
+
export function resolveFunctionSourceRoots(configDir) {
|
|
97
|
+
const configPath = findProjectConfigPath(resolve(configDir));
|
|
98
|
+
if (!configPath)
|
|
99
|
+
return { roots: [], warnings: [] };
|
|
100
|
+
let declared;
|
|
101
|
+
try {
|
|
102
|
+
declared = loadProjectConfigFromPath(configPath).functionSources ?? [];
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
if (!(err instanceof ProjectConfigError))
|
|
106
|
+
throw err;
|
|
107
|
+
return {
|
|
108
|
+
roots: [],
|
|
109
|
+
warnings: [
|
|
110
|
+
`"${FUNCTION_SOURCES_KEY}" not read: ${err.message} (${configPath})`,
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (declared.length === 0)
|
|
115
|
+
return { roots: [], warnings: [] };
|
|
116
|
+
const projectRoot = projectRootForConfigPath(configPath);
|
|
117
|
+
const realProjectRoot = realpathSync(projectRoot);
|
|
118
|
+
const repositoryRoot = gitTopLevel(realProjectRoot);
|
|
119
|
+
const container = repositoryRoot ?? realProjectRoot;
|
|
120
|
+
const containerLabel = repositoryRoot
|
|
121
|
+
? `the git repository root (${container})`
|
|
122
|
+
: `the project root (${container})`;
|
|
123
|
+
const roots = [];
|
|
124
|
+
const warnings = [];
|
|
125
|
+
for (const entry of declared) {
|
|
126
|
+
let absolute;
|
|
127
|
+
try {
|
|
128
|
+
absolute = realpathSync(resolve(projectRoot, entry));
|
|
129
|
+
if (!statSync(absolute).isDirectory())
|
|
130
|
+
throw new Error("not a directory");
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
warnings.push(`"${FUNCTION_SOURCES_KEY}" entry "${entry}" is not a directory under ${projectRoot}; ` +
|
|
134
|
+
"it is ignored for this push.");
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!isInsideDirectory(container, absolute)) {
|
|
138
|
+
warnings.push(`"${FUNCTION_SOURCES_KEY}" entry "${entry}" resolves to ${absolute}, outside ${containerLabel}; ` +
|
|
139
|
+
"it is ignored for this push.");
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (roots.some((root) => root.absolute === absolute))
|
|
143
|
+
continue;
|
|
144
|
+
roots.push({ declared: entry, absolute });
|
|
145
|
+
}
|
|
146
|
+
return { roots, warnings };
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=function-source-roots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-source-roots.js","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