@flytedesk/app-kit 11.3.0 → 11.5.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/README.md +128 -0
- package/dist/auth/guards.d.ts +4 -0
- package/dist/auth/guards.js +22 -0
- package/dist/auth/guards.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/prisma/index.d.ts +1 -0
- package/dist/auth/prisma/index.js +2 -0
- package/dist/auth/prisma/index.js.map +1 -0
- package/dist/auth/prisma/prismaAuthStore.d.ts +181 -0
- package/dist/auth/prisma/prismaAuthStore.js +273 -0
- package/dist/auth/prisma/prismaAuthStore.js.map +1 -0
- package/dist/chat/tools/index.d.ts +38 -0
- package/dist/chat/tools/index.js +60 -0
- package/dist/chat/tools/index.js.map +1 -0
- package/dist/cli/auth-sync.d.ts +2 -0
- package/dist/cli/auth-sync.js +23 -0
- package/dist/cli/auth-sync.js.map +1 -0
- package/dist/flytebot/client.d.ts +66 -0
- package/dist/flytebot/client.js +377 -0
- package/dist/flytebot/client.js.map +1 -0
- package/dist/flytebot/env.d.ts +11 -0
- package/dist/flytebot/env.js +25 -0
- package/dist/flytebot/env.js.map +1 -0
- package/dist/flytebot/error.d.ts +36 -0
- package/dist/flytebot/error.js +60 -0
- package/dist/flytebot/error.js.map +1 -0
- package/dist/flytebot/index.d.ts +32 -0
- package/dist/flytebot/index.js +28 -0
- package/dist/flytebot/index.js.map +1 -0
- package/dist/flytebot/sse.d.ts +11 -0
- package/dist/flytebot/sse.js +55 -0
- package/dist/flytebot/sse.js.map +1 -0
- package/dist/flytebot/testing/fake.d.ts +77 -0
- package/dist/flytebot/testing/fake.js +399 -0
- package/dist/flytebot/testing/fake.js.map +1 -0
- package/dist/flytebot/testing/index.d.ts +18 -0
- package/dist/flytebot/testing/index.js +18 -0
- package/dist/flytebot/testing/index.js.map +1 -0
- package/dist/flytebot/webhook.d.ts +24 -0
- package/dist/flytebot/webhook.js +63 -0
- package/dist/flytebot/webhook.js.map +1 -0
- package/dist/repo-check/checkNarration.d.ts +13 -0
- package/dist/repo-check/checkNarration.js +346 -0
- package/dist/repo-check/checkNarration.js.map +1 -0
- package/dist/repo-check/checkNoNul.d.ts +3 -0
- package/dist/repo-check/checkNoNul.js +35 -0
- package/dist/repo-check/checkNoNul.js.map +1 -0
- package/dist/repo-check/cli.d.ts +9 -0
- package/dist/repo-check/cli.js +103 -0
- package/dist/repo-check/cli.js.map +1 -0
- package/dist/repo-check/config.d.ts +13 -0
- package/dist/repo-check/config.js +39 -0
- package/dist/repo-check/config.js.map +1 -0
- package/dist/repo-check/repoFiles.d.ts +8 -0
- package/dist/repo-check/repoFiles.js +44 -0
- package/dist/repo-check/repoFiles.js.map +1 -0
- package/dist/repo-check/repoHygiene.d.ts +5 -0
- package/dist/repo-check/repoHygiene.js +12 -0
- package/dist/repo-check/repoHygiene.js.map +1 -0
- package/dist/repo-check/scriptComments.d.ts +28 -0
- package/dist/repo-check/scriptComments.js +243 -0
- package/dist/repo-check/scriptComments.js.map +1 -0
- package/dist/spa-server/index.d.ts +25 -0
- package/dist/spa-server/index.js +35 -2
- package/dist/spa-server/index.js.map +1 -1
- package/package.json +26 -3
- package/prisma/fragments/auth.meta.json +4 -0
- package/prisma/fragments/auth.prisma +75 -0
- package/prisma/migrations/0004_app_kit_auth_init/migration.sql +47 -0
- package/prisma/migrations/manifest.json +7 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { DEFAULT_EXCLUDED_DIRS } from "./repoFiles.js";
|
|
3
|
+
const KEYS = [
|
|
4
|
+
"excludedDirs",
|
|
5
|
+
"narrationAllowlist",
|
|
6
|
+
"narrationExcludedBasenames",
|
|
7
|
+
];
|
|
8
|
+
/** Parses a repo's config file: a JSON object whose keys are all optional string arrays.
|
|
9
|
+
* An unknown key or a wrong type throws, so a typo cannot silently disable a check. */
|
|
10
|
+
export function parseRepoCheckConfig(json, source) {
|
|
11
|
+
const raw = JSON.parse(json);
|
|
12
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
13
|
+
throw new Error(`${source}: config must be a JSON object`);
|
|
14
|
+
}
|
|
15
|
+
const record = raw;
|
|
16
|
+
for (const key of Object.keys(record)) {
|
|
17
|
+
if (!KEYS.includes(key)) {
|
|
18
|
+
throw new Error(`${source}: unknown config key "${key}" (allowed: ${KEYS.join(", ")})`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const list = (key) => {
|
|
22
|
+
const value = record[key];
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return [];
|
|
25
|
+
if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) {
|
|
26
|
+
throw new Error(`${source}: "${key}" must be an array of strings`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
excludedDirs: [...DEFAULT_EXCLUDED_DIRS, ...list("excludedDirs")],
|
|
32
|
+
narrationAllowlist: list("narrationAllowlist"),
|
|
33
|
+
narrationExcludedBasenames: list("narrationExcludedBasenames"),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function loadRepoCheckConfig(path) {
|
|
37
|
+
return parseRepoCheckConfig(readFileSync(path, "utf8"), path);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/repo-check/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAYvD,MAAM,IAAI,GAAG;IACX,cAAc;IACd,oBAAoB;IACpB,4BAA4B;CACpB,CAAC;AAEX;wFACwF;AACxF,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,MAAc;IA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,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,oBAAoB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Directories no check reads: dependency/build output no one hand-writes into, VCS internals,
|
|
2
|
+
* and a checked-out worktree (a full separate copy of the same repo — scanning it would just
|
|
3
|
+
* double-report, or scan another in-flight change's uncommitted work). A repo's config adds
|
|
4
|
+
* its own to these. */
|
|
5
|
+
export declare const DEFAULT_EXCLUDED_DIRS: readonly string[];
|
|
6
|
+
export declare function extensionOf(fileName: string): string;
|
|
7
|
+
/** The absolute paths of the files under `rootDir` with one of `extensions`, outside `excludedDirs`. */
|
|
8
|
+
export declare function listRepoFiles(rootDir: string, extensions: ReadonlySet<string>, excludedDirs: readonly string[]): string[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one walk over the repo's files that the whole-repo hygiene checks share: every
|
|
3
|
+
* file under a root whose extension is in a given set, skipping the directories named in a given
|
|
4
|
+
* set. A check names what it reads and what it skips; it never walks the tree itself.
|
|
5
|
+
*/
|
|
6
|
+
import { readdirSync, statSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
/** Directories no check reads: dependency/build output no one hand-writes into, VCS internals,
|
|
9
|
+
* and a checked-out worktree (a full separate copy of the same repo — scanning it would just
|
|
10
|
+
* double-report, or scan another in-flight change's uncommitted work). A repo's config adds
|
|
11
|
+
* its own to these. */
|
|
12
|
+
export const DEFAULT_EXCLUDED_DIRS = [
|
|
13
|
+
"node_modules",
|
|
14
|
+
".git",
|
|
15
|
+
"dist",
|
|
16
|
+
"build",
|
|
17
|
+
"coverage",
|
|
18
|
+
".turbo",
|
|
19
|
+
".claude",
|
|
20
|
+
"playwright-report",
|
|
21
|
+
"test-results",
|
|
22
|
+
];
|
|
23
|
+
export function extensionOf(fileName) {
|
|
24
|
+
const dot = fileName.lastIndexOf(".");
|
|
25
|
+
return dot === -1 ? "" : fileName.slice(dot);
|
|
26
|
+
}
|
|
27
|
+
/** The absolute paths of the files under `rootDir` with one of `extensions`, outside `excludedDirs`. */
|
|
28
|
+
export function listRepoFiles(rootDir, extensions, excludedDirs) {
|
|
29
|
+
const out = [];
|
|
30
|
+
const walk = (dir) => {
|
|
31
|
+
for (const entry of readdirSync(dir)) {
|
|
32
|
+
if (excludedDirs.includes(entry))
|
|
33
|
+
continue;
|
|
34
|
+
const full = join(dir, entry);
|
|
35
|
+
if (statSync(full).isDirectory())
|
|
36
|
+
walk(full);
|
|
37
|
+
else if (extensions.has(extensionOf(entry)))
|
|
38
|
+
out.push(full);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
walk(rootDir);
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=repoFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoFiles.js","sourceRoot":"","sources":["../../src/repo-check/repoFiles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;wBAGwB;AACxB,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,cAAc;IACd,MAAM;IACN,MAAM;IACN,OAAO;IACP,UAAU;IACV,QAAQ;IACR,SAAS;IACT,mBAAmB;IACnB,cAAc;CACf,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,wGAAwG;AACxG,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,UAA+B,EAC/B,YAA+B;IAE/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,CAAC,GAAW,EAAQ,EAAE;QACjC,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,IAAI,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,SAAS;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,IAAI,CAAC,CAAC;iBACxC,IAAI,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,OAAO,CAAC,CAAC;IACd,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RepoCheckConfig } from "./config.js";
|
|
2
|
+
/** One line per finding of either whole-repo hygiene check under `rootDir`; empty when the tree
|
|
3
|
+
* is clean. A NUL byte makes grep and git treat a file as binary, and review narration rots
|
|
4
|
+
* once the review is over, so both are checked across the whole tree by every repo's gate. */
|
|
5
|
+
export declare function repoHygieneFindings(rootDir: string, config: RepoCheckConfig): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { scanForNarration } from "./checkNarration.js";
|
|
2
|
+
import { findFilesWithNul } from "./checkNoNul.js";
|
|
3
|
+
/** One line per finding of either whole-repo hygiene check under `rootDir`; empty when the tree
|
|
4
|
+
* is clean. A NUL byte makes grep and git treat a file as binary, and review narration rots
|
|
5
|
+
* once the review is over, so both are checked across the whole tree by every repo's gate. */
|
|
6
|
+
export function repoHygieneFindings(rootDir, config) {
|
|
7
|
+
return [
|
|
8
|
+
...findFilesWithNul(rootDir, config).map((file) => `${file}: holds a NUL byte`),
|
|
9
|
+
...scanForNarration(rootDir, config).map((hit) => `${hit.file.replaceAll("\\", "/")}:${hit.line}: review narration "${hit.match}"`),
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=repoHygiene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoHygiene.js","sourceRoot":"","sources":["../../src/repo-check/repoHygiene.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD;;+FAE+F;AAC/F,MAAM,UAAU,mBAAmB,CACjC,OAAe,EACf,MAAuB;IAEvB,OAAO;QACL,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,CACtC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,oBAAoB,CACtC;QACD,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,CACtC,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,uBAAuB,GAAG,CAAC,KAAK,GAAG,CACnF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comment extraction for the two non-JavaScript languages this repo's
|
|
3
|
+
* infrastructure is written in: shell (`.sh`) and Terraform's HCL (`.tf`).
|
|
4
|
+
*
|
|
5
|
+
* Like the JavaScript extractor in `checkNarration.ts`, this is a lightweight
|
|
6
|
+
* tokenizer, not a parser. It only has to answer one question well: which
|
|
7
|
+
* characters are comment text and which are code or string content. A `#`
|
|
8
|
+
* inside a quoted string, inside `$#`, `${#name}` or `${name#prefix}`, or in a
|
|
9
|
+
* URL fragment is never a comment; a `#` that begins a word in shell, or any
|
|
10
|
+
* `#` outside a string in HCL, is one.
|
|
11
|
+
*
|
|
12
|
+
* Handled: single-quoted and double-quoted strings, `$(...)` command
|
|
13
|
+
* substitution (nested quotes included) inside shell double quotes, `${...}`
|
|
14
|
+
* template interpolation (nested strings included) inside HCL strings, and
|
|
15
|
+
* here-document / heredoc bodies, whose contents are neither comments nor code.
|
|
16
|
+
* Known limits (no script in this repo uses them today): a shell `${param}` expansion
|
|
17
|
+
* whose own text contains an unpaired quote character is not tracked separately
|
|
18
|
+
* (paired quotes inside one tokenize correctly); a comment inside a `$(...)` in double
|
|
19
|
+
* quotes is skipped, not reported; and `<< word` used as a shift is read as a heredoc.
|
|
20
|
+
*/
|
|
21
|
+
export interface CommentFragment {
|
|
22
|
+
/** 1-based line the comment text starts on. */
|
|
23
|
+
line: number;
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
export type ScriptDialect = "shell" | "hcl";
|
|
27
|
+
/** Every comment in `source`, with the line it starts on. */
|
|
28
|
+
export declare function extractScriptComments(source: string, dialect: ScriptDialect): CommentFragment[];
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comment extraction for the two non-JavaScript languages this repo's
|
|
3
|
+
* infrastructure is written in: shell (`.sh`) and Terraform's HCL (`.tf`).
|
|
4
|
+
*
|
|
5
|
+
* Like the JavaScript extractor in `checkNarration.ts`, this is a lightweight
|
|
6
|
+
* tokenizer, not a parser. It only has to answer one question well: which
|
|
7
|
+
* characters are comment text and which are code or string content. A `#`
|
|
8
|
+
* inside a quoted string, inside `$#`, `${#name}` or `${name#prefix}`, or in a
|
|
9
|
+
* URL fragment is never a comment; a `#` that begins a word in shell, or any
|
|
10
|
+
* `#` outside a string in HCL, is one.
|
|
11
|
+
*
|
|
12
|
+
* Handled: single-quoted and double-quoted strings, `$(...)` command
|
|
13
|
+
* substitution (nested quotes included) inside shell double quotes, `${...}`
|
|
14
|
+
* template interpolation (nested strings included) inside HCL strings, and
|
|
15
|
+
* here-document / heredoc bodies, whose contents are neither comments nor code.
|
|
16
|
+
* Known limits (no script in this repo uses them today): a shell `${param}` expansion
|
|
17
|
+
* whose own text contains an unpaired quote character is not tracked separately
|
|
18
|
+
* (paired quotes inside one tokenize correctly); a comment inside a `$(...)` in double
|
|
19
|
+
* quotes is skipped, not reported; and `<< word` used as a shift is read as a heredoc.
|
|
20
|
+
*/
|
|
21
|
+
const RULES = {
|
|
22
|
+
shell: { hashNeedsWordStart: true, slashComments: false },
|
|
23
|
+
hcl: { hashNeedsWordStart: false, slashComments: true },
|
|
24
|
+
};
|
|
25
|
+
function skipShellSingleQuoted(src, i) {
|
|
26
|
+
const end = src.indexOf("'", i + 1);
|
|
27
|
+
return end === -1 ? src.length : end + 1;
|
|
28
|
+
}
|
|
29
|
+
function skipBacktickSubstitution(src, i) {
|
|
30
|
+
let j = i + 1;
|
|
31
|
+
while (j < src.length) {
|
|
32
|
+
if (src[j] === "\\")
|
|
33
|
+
j += 2;
|
|
34
|
+
else if (src[j] === "`")
|
|
35
|
+
return j + 1;
|
|
36
|
+
else
|
|
37
|
+
j++;
|
|
38
|
+
}
|
|
39
|
+
return src.length;
|
|
40
|
+
}
|
|
41
|
+
/** `start` is the index right after `$(`; returns the index right after the
|
|
42
|
+
* matching `)`. Strings inside are consumed whole so a paren in one never
|
|
43
|
+
* counts. */
|
|
44
|
+
function skipShellCommandSubstitution(src, start) {
|
|
45
|
+
let depth = 1;
|
|
46
|
+
let j = start;
|
|
47
|
+
while (j < src.length && depth > 0) {
|
|
48
|
+
const ch = src[j];
|
|
49
|
+
if (ch === "\\") {
|
|
50
|
+
j += 2;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (ch === "'") {
|
|
54
|
+
j = skipShellSingleQuoted(src, j);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (ch === '"') {
|
|
58
|
+
j = skipShellDoubleQuoted(src, j);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (ch === "#" && (j === start || /[\s;&|(]/.test(src[j - 1]))) {
|
|
62
|
+
// A comment inside the substitution runs to the end of its line, quotes and all.
|
|
63
|
+
const newline = src.indexOf("\n", j);
|
|
64
|
+
if (newline === -1)
|
|
65
|
+
return src.length;
|
|
66
|
+
j = newline;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (ch === "(")
|
|
70
|
+
depth++;
|
|
71
|
+
else if (ch === ")")
|
|
72
|
+
depth--;
|
|
73
|
+
j++;
|
|
74
|
+
}
|
|
75
|
+
return j;
|
|
76
|
+
}
|
|
77
|
+
function skipShellDoubleQuoted(src, i) {
|
|
78
|
+
let j = i + 1;
|
|
79
|
+
while (j < src.length) {
|
|
80
|
+
const ch = src[j];
|
|
81
|
+
if (ch === "\\") {
|
|
82
|
+
j += 2;
|
|
83
|
+
}
|
|
84
|
+
else if (ch === '"') {
|
|
85
|
+
return j + 1;
|
|
86
|
+
}
|
|
87
|
+
else if (ch === "$" && src[j + 1] === "(") {
|
|
88
|
+
j = skipShellCommandSubstitution(src, j + 2);
|
|
89
|
+
}
|
|
90
|
+
else if (ch === "`") {
|
|
91
|
+
j = skipBacktickSubstitution(src, j);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
j++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return src.length;
|
|
98
|
+
}
|
|
99
|
+
/** `start` is the index right after `${`; returns the index right after the
|
|
100
|
+
* matching `}`. */
|
|
101
|
+
function skipHclInterpolation(src, start) {
|
|
102
|
+
let depth = 1;
|
|
103
|
+
let j = start;
|
|
104
|
+
while (j < src.length && depth > 0) {
|
|
105
|
+
const ch = src[j];
|
|
106
|
+
if (ch === '"') {
|
|
107
|
+
j = skipHclString(src, j);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (ch === "{")
|
|
111
|
+
depth++;
|
|
112
|
+
else if (ch === "}")
|
|
113
|
+
depth--;
|
|
114
|
+
j++;
|
|
115
|
+
}
|
|
116
|
+
return j;
|
|
117
|
+
}
|
|
118
|
+
function skipHclString(src, i) {
|
|
119
|
+
let j = i + 1;
|
|
120
|
+
while (j < src.length) {
|
|
121
|
+
const ch = src[j];
|
|
122
|
+
if (ch === "\\") {
|
|
123
|
+
j += 2;
|
|
124
|
+
}
|
|
125
|
+
else if (ch === '"') {
|
|
126
|
+
return j + 1;
|
|
127
|
+
}
|
|
128
|
+
else if (src.startsWith("$${", j) || src.startsWith("%%{", j)) {
|
|
129
|
+
j += 3;
|
|
130
|
+
}
|
|
131
|
+
else if ((ch === "$" || ch === "%") && src[j + 1] === "{") {
|
|
132
|
+
j = skipHclInterpolation(src, j + 2);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
j++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return src.length;
|
|
139
|
+
}
|
|
140
|
+
const HEREDOC_START = /^<<-?[ \t]*(?:'([A-Za-z_]\w*)'|"([A-Za-z_]\w*)"|([A-Za-z_]\w*))/;
|
|
141
|
+
/** Index right after the terminator line of a heredoc whose body starts at
|
|
142
|
+
* `bodyStart` (the first character of the line after the opener). */
|
|
143
|
+
function skipHeredocBody(src, bodyStart, terminator) {
|
|
144
|
+
let lineStart = bodyStart;
|
|
145
|
+
while (lineStart < src.length) {
|
|
146
|
+
const newline = src.indexOf("\n", lineStart);
|
|
147
|
+
const lineEnd = newline === -1 ? src.length : newline;
|
|
148
|
+
if (src.slice(lineStart, lineEnd).trim() === terminator)
|
|
149
|
+
return lineEnd;
|
|
150
|
+
lineStart = lineEnd + 1;
|
|
151
|
+
}
|
|
152
|
+
return src.length;
|
|
153
|
+
}
|
|
154
|
+
function lineLocator(src) {
|
|
155
|
+
const lineStarts = [0];
|
|
156
|
+
for (let i = 0; i < src.length; i++) {
|
|
157
|
+
if (src[i] === "\n")
|
|
158
|
+
lineStarts.push(i + 1);
|
|
159
|
+
}
|
|
160
|
+
return (pos) => {
|
|
161
|
+
let lo = 0;
|
|
162
|
+
let hi = lineStarts.length - 1;
|
|
163
|
+
while (lo < hi) {
|
|
164
|
+
const mid = (lo + hi + 1) >> 1;
|
|
165
|
+
if (lineStarts[mid] <= pos)
|
|
166
|
+
lo = mid;
|
|
167
|
+
else
|
|
168
|
+
hi = mid - 1;
|
|
169
|
+
}
|
|
170
|
+
return lo + 1;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
/** Every comment in `source`, with the line it starts on. */
|
|
174
|
+
export function extractScriptComments(source, dialect) {
|
|
175
|
+
const rules = RULES[dialect];
|
|
176
|
+
const lineOf = lineLocator(source);
|
|
177
|
+
const fragments = [];
|
|
178
|
+
const n = source.length;
|
|
179
|
+
let pendingHeredoc = null;
|
|
180
|
+
// Index right after a backslash-escaped character: a `#` there belongs to the same word.
|
|
181
|
+
let afterEscape = -1;
|
|
182
|
+
let i = 0;
|
|
183
|
+
while (i < n) {
|
|
184
|
+
const ch = source[i];
|
|
185
|
+
if (ch === "\n") {
|
|
186
|
+
if (pendingHeredoc !== null) {
|
|
187
|
+
i = skipHeredocBody(source, i + 1, pendingHeredoc);
|
|
188
|
+
pendingHeredoc = null;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
i++;
|
|
192
|
+
}
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const startsComment = ch === "#" &&
|
|
196
|
+
i !== afterEscape &&
|
|
197
|
+
(!rules.hashNeedsWordStart || i === 0 || /[\s;&|(]/.test(source[i - 1]));
|
|
198
|
+
if (startsComment || (rules.slashComments && source.startsWith("//", i))) {
|
|
199
|
+
const newline = source.indexOf("\n", i);
|
|
200
|
+
const stop = newline === -1 ? n : newline;
|
|
201
|
+
fragments.push({ line: lineOf(i), text: source.slice(i, stop) });
|
|
202
|
+
i = stop;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (rules.slashComments && source.startsWith("/*", i)) {
|
|
206
|
+
const close = source.indexOf("*/", i + 2);
|
|
207
|
+
const stop = close === -1 ? n : close + 2;
|
|
208
|
+
fragments.push({ line: lineOf(i), text: source.slice(i, stop) });
|
|
209
|
+
i = stop;
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
// `<<<word` is a here-string, not a heredoc.
|
|
213
|
+
if (ch === "<" &&
|
|
214
|
+
source.startsWith("<<", i) &&
|
|
215
|
+
source[i - 1] !== "<" &&
|
|
216
|
+
source[i + 2] !== "<") {
|
|
217
|
+
const opener = HEREDOC_START.exec(source.slice(i, i + 80));
|
|
218
|
+
if (opener) {
|
|
219
|
+
pendingHeredoc = opener[1] ?? opener[2] ?? opener[3] ?? null;
|
|
220
|
+
i += opener[0].length;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (dialect === "shell" && ch === "\\") {
|
|
225
|
+
afterEscape = i + 2;
|
|
226
|
+
i += 2;
|
|
227
|
+
}
|
|
228
|
+
else if (dialect === "shell" && ch === "'") {
|
|
229
|
+
i = skipShellSingleQuoted(source, i);
|
|
230
|
+
}
|
|
231
|
+
else if (dialect === "shell" && ch === '"') {
|
|
232
|
+
i = skipShellDoubleQuoted(source, i);
|
|
233
|
+
}
|
|
234
|
+
else if (dialect === "hcl" && ch === '"') {
|
|
235
|
+
i = skipHclString(source, i);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
i++;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return fragments;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=scriptComments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptComments.js","sourceRoot":"","sources":["../../src/repo-check/scriptComments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH,MAAM,KAAK,GAAwC;IACjD,KAAK,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;IAC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YACN,CAAC,EAAE,CAAC;QACN,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -14,6 +14,31 @@
|
|
|
14
14
|
* value for the whole tree.
|
|
15
15
|
*/
|
|
16
16
|
import { type Server } from "node:http";
|
|
17
|
+
/** Vite's own default output directory for content-hashed files. */
|
|
18
|
+
export declare const DEFAULT_ASSET_PREFIX = "/assets/";
|
|
19
|
+
/**
|
|
20
|
+
* THE Cache-Control policy of a served SPA (AK-18, AK-59) — the one place it is written.
|
|
21
|
+
* `createSpaServer`, the `spa-server` bin and `spaCachePolicy` (the Fastify plugin) all
|
|
22
|
+
* answer through it: a path under `assetPrefix` (content-hashed, so a new build never
|
|
23
|
+
* overwrites it) is immutable for a year; everything else — `index.html` and every
|
|
24
|
+
* SPA-fallback route — is `no-cache`, so a deploy is never hidden behind a stale shell.
|
|
25
|
+
*/
|
|
26
|
+
export declare function spaCacheControl(pathname: string, assetPrefix?: string): string;
|
|
27
|
+
export interface SpaCachePolicyOptions {
|
|
28
|
+
/** See `SpaServerOptions.assetPrefix`. Default "/assets/". */
|
|
29
|
+
assetPrefix?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The same policy for a Fastify app that serves its SPA itself (e.g. with
|
|
33
|
+
* `@fastify/static`): `app.register(spaCachePolicy, { assetPrefix })` stamps
|
|
34
|
+
* `spaCacheControl` on every successful (status < 400) response of the routes in the
|
|
35
|
+
* scope it is registered in, unless the route set its own Cache-Control. The hook covers the
|
|
36
|
+
* scope the plugin is registered in and its children, never the parent: register it
|
|
37
|
+
* inside a scope that holds only the SPA routes (`app.register(async (spa) => {
|
|
38
|
+
* await spa.register(spaCachePolicy); ...static routes... })`) so the app's API routes
|
|
39
|
+
* keep their own headers.
|
|
40
|
+
*/
|
|
41
|
+
export declare const spaCachePolicy: import("fastify").FastifyPluginCallback<SpaCachePolicyOptions, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
17
42
|
export interface SpaServerOptions {
|
|
18
43
|
/** Directory containing the built SPA (e.g. Vite's "dist"). */
|
|
19
44
|
dir: string;
|
package/dist/spa-server/index.js
CHANGED
|
@@ -14,18 +14,51 @@
|
|
|
14
14
|
* value for the whole tree.
|
|
15
15
|
*/
|
|
16
16
|
import { createServer } from "node:http";
|
|
17
|
+
import fp from "fastify-plugin";
|
|
17
18
|
import sirv from "sirv";
|
|
19
|
+
/** Vite's own default output directory for content-hashed files. */
|
|
20
|
+
export const DEFAULT_ASSET_PREFIX = "/assets/";
|
|
21
|
+
/**
|
|
22
|
+
* THE Cache-Control policy of a served SPA (AK-18, AK-59) — the one place it is written.
|
|
23
|
+
* `createSpaServer`, the `spa-server` bin and `spaCachePolicy` (the Fastify plugin) all
|
|
24
|
+
* answer through it: a path under `assetPrefix` (content-hashed, so a new build never
|
|
25
|
+
* overwrites it) is immutable for a year; everything else — `index.html` and every
|
|
26
|
+
* SPA-fallback route — is `no-cache`, so a deploy is never hidden behind a stale shell.
|
|
27
|
+
*/
|
|
28
|
+
export function spaCacheControl(pathname, assetPrefix = DEFAULT_ASSET_PREFIX) {
|
|
29
|
+
return pathname.startsWith(assetPrefix)
|
|
30
|
+
? "public, max-age=31536000, immutable"
|
|
31
|
+
: "no-cache";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The same policy for a Fastify app that serves its SPA itself (e.g. with
|
|
35
|
+
* `@fastify/static`): `app.register(spaCachePolicy, { assetPrefix })` stamps
|
|
36
|
+
* `spaCacheControl` on every successful (status < 400) response of the routes in the
|
|
37
|
+
* scope it is registered in, unless the route set its own Cache-Control. The hook covers the
|
|
38
|
+
* scope the plugin is registered in and its children, never the parent: register it
|
|
39
|
+
* inside a scope that holds only the SPA routes (`app.register(async (spa) => {
|
|
40
|
+
* await spa.register(spaCachePolicy); ...static routes... })`) so the app's API routes
|
|
41
|
+
* keep their own headers.
|
|
42
|
+
*/
|
|
43
|
+
export const spaCachePolicy = fp(async (app, options) => {
|
|
44
|
+
app.addHook("onSend", async (request, reply, payload) => {
|
|
45
|
+
if (reply.statusCode < 400 && !reply.hasHeader("cache-control")) {
|
|
46
|
+
const pathname = request.url.split("?")[0] ?? request.url;
|
|
47
|
+
reply.header("cache-control", spaCacheControl(pathname, options.assetPrefix));
|
|
48
|
+
}
|
|
49
|
+
return payload;
|
|
50
|
+
});
|
|
51
|
+
}, { name: "@flytedesk/app-kit/spa-cache-policy", fastify: "4.x || 5.x" });
|
|
18
52
|
/** Builds the request handler — everything BUT actually binding a port, so a consumer
|
|
19
53
|
* that already owns an HTTP server (or wants to compose this behind its own routing)
|
|
20
54
|
* can still get the same Cache-Control behaviour. `serveSpa` (below) is the one-call
|
|
21
55
|
* version for a consumer that just wants a running server. */
|
|
22
56
|
export function createSpaServer(options) {
|
|
23
|
-
const assetPrefix = options.assetPrefix ?? "/assets/";
|
|
24
57
|
const serve = sirv(options.dir, {
|
|
25
58
|
single: true,
|
|
26
59
|
etag: true,
|
|
27
60
|
setHeaders(res, pathname) {
|
|
28
|
-
res.setHeader("Cache-Control", pathname.
|
|
61
|
+
res.setHeader("Cache-Control", spaCacheControl(pathname, options.assetPrefix));
|
|
29
62
|
},
|
|
30
63
|
});
|
|
31
64
|
return createServer((req, res) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spa-server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/spa-server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAC;AAEjG,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,oEAAoE;AACpE,MAAM,C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AC;KACF,CAAC,CAAC;IACH,OAAO,YAAY,CAAC,CAAC,GAAoB,EAAE,GAAmB,EAAE,EAAE;QAChE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;YACnB,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC;YACrB,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAgBD;;;oBAGoB;AACpB,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;IACvC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flytedesk/app-kit",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0",
|
|
4
4
|
"description": "Shared platform kit for flytedesk apps: flytedesk-id auth (BFF/OIDC client) and a Postgres-native trace/audit layer.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,13 +32,19 @@
|
|
|
32
32
|
"profile-sync": "./dist/cli/profile-sync.js",
|
|
33
33
|
"flags-sync": "./dist/cli/flags-sync.js",
|
|
34
34
|
"spa-server": "./dist/spa-server/cli.js",
|
|
35
|
-
"app-kit-chat-mcp": "./dist/chat/mcp/entry.js"
|
|
35
|
+
"app-kit-chat-mcp": "./dist/chat/mcp/entry.js",
|
|
36
|
+
"app-kit-repo-check": "./dist/repo-check/cli.js",
|
|
37
|
+
"auth-sync": "./dist/cli/auth-sync.js"
|
|
36
38
|
},
|
|
37
39
|
"exports": {
|
|
38
40
|
"./auth": {
|
|
39
41
|
"types": "./dist/auth/index.d.ts",
|
|
40
42
|
"import": "./dist/auth/index.js"
|
|
41
43
|
},
|
|
44
|
+
"./auth/prisma": {
|
|
45
|
+
"types": "./dist/auth/prisma/index.d.ts",
|
|
46
|
+
"import": "./dist/auth/prisma/index.js"
|
|
47
|
+
},
|
|
42
48
|
"./auth/plugin": {
|
|
43
49
|
"types": "./dist/auth/plugin.d.ts",
|
|
44
50
|
"import": "./dist/auth/plugin.js"
|
|
@@ -87,6 +93,18 @@
|
|
|
87
93
|
"types": "./dist/chat/index.d.ts",
|
|
88
94
|
"import": "./dist/chat/index.js"
|
|
89
95
|
},
|
|
96
|
+
"./chat/tools": {
|
|
97
|
+
"types": "./dist/chat/tools/index.d.ts",
|
|
98
|
+
"import": "./dist/chat/tools/index.js"
|
|
99
|
+
},
|
|
100
|
+
"./flytebot": {
|
|
101
|
+
"types": "./dist/flytebot/index.d.ts",
|
|
102
|
+
"import": "./dist/flytebot/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./flytebot/testing": {
|
|
105
|
+
"types": "./dist/flytebot/testing/index.d.ts",
|
|
106
|
+
"import": "./dist/flytebot/testing/index.js"
|
|
107
|
+
},
|
|
90
108
|
"./spa-server": {
|
|
91
109
|
"types": "./dist/spa-server/index.d.ts",
|
|
92
110
|
"import": "./dist/spa-server/index.js"
|
|
@@ -140,6 +158,7 @@
|
|
|
140
158
|
"@changesets/cli": "^3.0.1",
|
|
141
159
|
"@google-cloud/bigquery": "^9.1.0",
|
|
142
160
|
"@playwright/test": "^1.63.0",
|
|
161
|
+
"@prisma/adapter-pg": "^7.10.1",
|
|
143
162
|
"@prisma/client": "^7.10.0",
|
|
144
163
|
"@testcontainers/mysql": "^12.2.1",
|
|
145
164
|
"@testcontainers/postgresql": "^12.1.0",
|
|
@@ -161,6 +180,7 @@
|
|
|
161
180
|
"mysql2": "^3.24.6",
|
|
162
181
|
"pg": "^8.23.0",
|
|
163
182
|
"prettier": "^3.9.6",
|
|
183
|
+
"prisma": "^7.10.1",
|
|
164
184
|
"publint": "^0.3.24",
|
|
165
185
|
"react": "^19.3.0",
|
|
166
186
|
"react-dom": "^19.3.0",
|
|
@@ -172,11 +192,14 @@
|
|
|
172
192
|
},
|
|
173
193
|
"dependencies": {
|
|
174
194
|
"@fastify/cookie": "^11.0.1",
|
|
195
|
+
"@flytedesk/flytebot-contracts": "^0.2.0",
|
|
175
196
|
"cross-spawn": "^7.0.6",
|
|
176
197
|
"fastify-plugin": "^6.0.0",
|
|
198
|
+
"google-auth-library": "^11.3.1",
|
|
177
199
|
"jose": "^6.2.10",
|
|
178
200
|
"node-sql-parser": "^5.4.0",
|
|
179
201
|
"pgsql-ast-parser": "^12.0.2",
|
|
180
|
-
"sirv": "^3.0.2"
|
|
202
|
+
"sirv": "^3.0.2",
|
|
203
|
+
"zod": "^4.6.7"
|
|
181
204
|
}
|
|
182
205
|
}
|