@happyvertical/smrt-cli 0.53.3 → 0.53.5
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/AGENTS.md +3 -0
- package/README.md +64 -0
- package/agents/app-commands.md +118 -0
- package/bin/smrt-web.mjs +19 -0
- package/bin/smrt.js +18 -12
- package/dist/{ApiKey-BZmbOTnL-DchyhIPA.js → ApiKey-BZmbOTnL-BbZupUZ3.js} +2 -2
- package/dist/ApiKeyCollection-Bfb_nw81-DYAZwx0O.js +87 -0
- package/dist/AuditLogCollection-B1YonCAP-Bkj2Ezon.js +193 -0
- package/dist/{NostrIdentity-n70E0vck-CLGPdJ1W.js → NostrIdentity-n70E0vck-Di3_eNCq.js} +4 -4
- package/dist/NostrIdentityCollection-Ca74dkaL-DvjOg9Xy.js +127 -0
- package/dist/{OidcIdentity-Cb1bxreM-DPBTZddF.js → OidcIdentity-Cb1bxreM-LXmC7uAf.js} +2 -2
- package/dist/OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js +86 -0
- package/dist/ProfileAssetCollection-B9hacUJa-CPuaWLk4.js +101 -0
- package/dist/{ProfileCollection-DuJT7Mum-BUYQQ9xZ.js → ProfileCollection-DuJT7Mum-nXbHrPpX.js} +31 -31
- package/dist/ProfileLinkCollection-4uNURz32-CbKZYmYm.js +233 -0
- package/dist/ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js +108 -0
- package/dist/ProfileMetafieldCollection-CoBuM_5G-CPjW3l5r.js +145 -0
- package/dist/ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js +161 -0
- package/dist/ProfileRelationshipTermCollection-DtA9OM23-BoGhQBSQ.js +107 -0
- package/dist/{ProfileRelationshipType-BRiRka6t-xzRfZRFG.js → ProfileRelationshipType-BRiRka6t-Dezjv5jP.js} +1 -1
- package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js +57 -0
- package/dist/app/cli.d.ts +51 -0
- package/dist/app/cli.d.ts.map +1 -0
- package/dist/app/errors.d.ts +55 -0
- package/dist/app/errors.d.ts.map +1 -0
- package/dist/app/identity.d.ts +24 -0
- package/dist/app/identity.d.ts.map +1 -0
- package/dist/app/index.d.ts +20 -0
- package/dist/app/index.d.ts.map +1 -0
- package/dist/app/launchers.d.ts +51 -0
- package/dist/app/launchers.d.ts.map +1 -0
- package/dist/app/operations.d.ts +30 -0
- package/dist/app/operations.d.ts.map +1 -0
- package/dist/app/portability-assets.d.ts +151 -0
- package/dist/app/portability-assets.d.ts.map +1 -0
- package/dist/app/portability.d.ts +117 -0
- package/dist/app/portability.d.ts.map +1 -0
- package/dist/app/process-record.d.ts +54 -0
- package/dist/app/process-record.d.ts.map +1 -0
- package/dist/app/runtime.d.ts +98 -0
- package/dist/app/runtime.d.ts.map +1 -0
- package/dist/app/tokens.d.ts +21 -0
- package/dist/app/tokens.d.ts.map +1 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +4 -0
- package/dist/cli-OZsH5cdL.js +1602 -0
- package/dist/cli-generator.d.ts.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/utilities.d.ts.map +1 -1
- package/dist/{commands-B8N38deG.js → commands-UXK2F_0j.js} +49 -336
- package/dist/database-environment-D_Gk1Brf.js +20 -0
- package/dist/database-environment.d.ts +43 -0
- package/dist/database-environment.d.ts.map +1 -0
- package/dist/dist-BVjJWjT-.js +20 -0
- package/dist/{dist-B62O-xH6.js → dist-C87Ib9Vx.js} +2 -2
- package/dist/{dist-CL9KGm1j.js → dist-DLw_E34G.js} +1654 -1748
- package/dist/{dist-BBQyIRsO.js → dist-GIaWaUho.js} +4 -4
- package/dist/{dist-C8BOgli4.js → dist-RSE5hCY4.js} +3 -3
- package/dist/index.js +19 -9
- package/dist/mcp-apps-packaging-CixRnxz_.js +286 -0
- package/dist/{oidcProvisioningPrimitives-D9OYu5-F-l8afZs4F.js → oidcProvisioningPrimitives-D9OYu5-F-T9KkkDCd.js} +5 -5
- package/dist/portability-CES1YC2m.js +859 -0
- package/dist/resolveIdentity-B-PK6RwU-C9ogf8YG.js +269 -0
- package/package.json +19 -14
- package/dist/ApiKeyCollection-Bfb_nw81-DR5XF_SZ.js +0 -2
- package/dist/AuditLogCollection-B1YonCAP-PbzALncL.js +0 -2
- package/dist/NostrIdentityCollection-Ca74dkaL-C2r-uDlC.js +0 -2
- package/dist/OidcIdentityCollection-TV8VdK69-2fZROnih.js +0 -2
- package/dist/ProfileAssetCollection-B9hacUJa-D33sifgF.js +0 -2
- package/dist/ProfileLinkCollection-4uNURz32-CHDTinax.js +0 -2
- package/dist/ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js +0 -2
- package/dist/ProfileMetafieldCollection-CoBuM_5G-BXtoIP02.js +0 -2
- package/dist/ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js +0 -2
- package/dist/ProfileRelationshipTermCollection-DtA9OM23-DPOMtMr7.js +0 -2
- package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js +0 -2
- package/dist/resolveIdentity-B-PK6RwU-B306Ch1I.js +0 -2
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
|
|
3
|
+
import { SmrtCollection, SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
|
|
4
|
+
//#region ../profiles/dist/chunks/ProfileRelationshipTermCollection-DtA9OM23.js
|
|
5
|
+
var ProfileRelationshipTermCollection_DtA9OM23_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
n: () => ProfileRelationshipTermCollection_exports,
|
|
7
|
+
r: () => ProfileRelationshipTerm,
|
|
8
|
+
t: () => ProfileRelationshipTermCollection
|
|
9
|
+
});
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
13
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
14
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
15
|
+
if (kind && result) __defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
var ProfileRelationshipTerm = class extends SmrtObject {
|
|
19
|
+
relationshipId;
|
|
20
|
+
startedAt = /* @__PURE__ */ new Date();
|
|
21
|
+
endedAt;
|
|
22
|
+
constructor(options = {}) {
|
|
23
|
+
super(options);
|
|
24
|
+
if (options.relationshipId !== void 0) this.relationshipId = options.relationshipId;
|
|
25
|
+
if (options.startedAt) this.startedAt = options.startedAt;
|
|
26
|
+
if (options.endedAt !== void 0) this.endedAt = options.endedAt;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if this term is currently active
|
|
30
|
+
*
|
|
31
|
+
* @returns True if active (no end date or end date in future)
|
|
32
|
+
*/
|
|
33
|
+
isActive() {
|
|
34
|
+
if (!this.endedAt) return true;
|
|
35
|
+
return this.endedAt > /* @__PURE__ */ new Date();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* End this term
|
|
39
|
+
*
|
|
40
|
+
* @param endedAt - End date for the term (defaults to now)
|
|
41
|
+
*/
|
|
42
|
+
async end(endedAt = /* @__PURE__ */ new Date()) {
|
|
43
|
+
this.endedAt = endedAt;
|
|
44
|
+
await this.save();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the duration of this term in days
|
|
48
|
+
*
|
|
49
|
+
* @returns Duration in days
|
|
50
|
+
*/
|
|
51
|
+
getDurationDays() {
|
|
52
|
+
const diffMs = (this.endedAt || /* @__PURE__ */ new Date()).getTime() - this.startedAt.getTime();
|
|
53
|
+
return Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__decorateClass([foreignKey("ProfileRelationship", { required: true })], ProfileRelationshipTerm.prototype, "relationshipId", 2);
|
|
57
|
+
__decorateClass([field({ required: true })], ProfileRelationshipTerm.prototype, "startedAt", 2);
|
|
58
|
+
ProfileRelationshipTerm = __decorateClass([smrt({
|
|
59
|
+
tableStrategy: "sti",
|
|
60
|
+
api: { include: [
|
|
61
|
+
"list",
|
|
62
|
+
"get",
|
|
63
|
+
"create",
|
|
64
|
+
"update",
|
|
65
|
+
"delete"
|
|
66
|
+
] },
|
|
67
|
+
mcp: { include: ["list", "get"] },
|
|
68
|
+
cli: { skipApiCheck: true }
|
|
69
|
+
})], ProfileRelationshipTerm);
|
|
70
|
+
var ProfileRelationshipTermCollection_exports = /* @__PURE__ */ __exportAll$1({ ProfileRelationshipTermCollection: () => ProfileRelationshipTermCollection });
|
|
71
|
+
var ProfileRelationshipTermCollection = class extends SmrtCollection {
|
|
72
|
+
static _itemClass = ProfileRelationshipTerm;
|
|
73
|
+
/**
|
|
74
|
+
* Get all terms for a relationship
|
|
75
|
+
*
|
|
76
|
+
* @param relationshipId - The relationship UUID
|
|
77
|
+
* @returns Array of ProfileRelationshipTerm instances
|
|
78
|
+
*/
|
|
79
|
+
async getByRelationship(relationshipId) {
|
|
80
|
+
return await this.list({
|
|
81
|
+
where: { relationshipId },
|
|
82
|
+
orderBy: ["startedAt DESC"]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the active term for a relationship (no end date or future end date)
|
|
87
|
+
*
|
|
88
|
+
* @param relationshipId - The relationship UUID
|
|
89
|
+
* @returns Active term or null
|
|
90
|
+
*/
|
|
91
|
+
async getActiveTerm(relationshipId) {
|
|
92
|
+
const terms = await this.getByRelationship(relationshipId);
|
|
93
|
+
for (const term of terms) if (term.isActive()) return term;
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get all historical (ended) terms for a relationship
|
|
98
|
+
*
|
|
99
|
+
* @param relationshipId - The relationship UUID
|
|
100
|
+
* @returns Array of ended ProfileRelationshipTerm instances
|
|
101
|
+
*/
|
|
102
|
+
async getHistoricalTerms(relationshipId) {
|
|
103
|
+
return (await this.getByRelationship(relationshipId)).filter((term) => !term.isActive());
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
//#endregion
|
|
107
|
+
export { ProfileRelationshipTermCollection as n, ProfileRelationshipTermCollection_DtA9OM23_exports as r, ProfileRelationshipTerm as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-
|
|
2
|
+
import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
|
|
3
3
|
import { SmrtObject, field, smrt } from "@happyvertical/smrt-core";
|
|
4
4
|
//#region ../profiles/dist/chunks/ProfileRelationshipType-BRiRka6t.js
|
|
5
5
|
var ProfileRelationshipType_BRiRka6t_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
|
|
3
|
+
import { t as ProfileRelationshipType } from "./ProfileRelationshipType-BRiRka6t-Dezjv5jP.js";
|
|
4
|
+
import { SmrtCollection } from "@happyvertical/smrt-core";
|
|
5
|
+
//#region ../profiles/dist/chunks/ProfileRelationshipTypeCollection-BdXwd7Kf.js
|
|
6
|
+
var ProfileRelationshipTypeCollection_BdXwd7Kf_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
n: () => ProfileRelationshipTypeCollection_exports,
|
|
8
|
+
t: () => ProfileRelationshipTypeCollection
|
|
9
|
+
});
|
|
10
|
+
var ProfileRelationshipTypeCollection_exports = /* @__PURE__ */ __exportAll$1({ ProfileRelationshipTypeCollection: () => ProfileRelationshipTypeCollection });
|
|
11
|
+
var ProfileRelationshipTypeCollection = class extends SmrtCollection {
|
|
12
|
+
static _itemClass = ProfileRelationshipType;
|
|
13
|
+
/**
|
|
14
|
+
* Get relationship type by slug
|
|
15
|
+
*
|
|
16
|
+
* @param slug - The slug to search for
|
|
17
|
+
* @returns ProfileRelationshipType instance or null
|
|
18
|
+
*/
|
|
19
|
+
async getBySlug(slug) {
|
|
20
|
+
return await this.get({ slug });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get or create a relationship type by slug
|
|
24
|
+
*
|
|
25
|
+
* @param slug - The slug to search for
|
|
26
|
+
* @param defaults - Default values if creating
|
|
27
|
+
* @returns ProfileRelationshipType instance
|
|
28
|
+
*/
|
|
29
|
+
async getOrCreateBySlug(slug, defaults) {
|
|
30
|
+
const existing = await this.getBySlug(slug);
|
|
31
|
+
if (existing) return existing;
|
|
32
|
+
const relationshipType = await this.create({
|
|
33
|
+
slug,
|
|
34
|
+
...defaults
|
|
35
|
+
});
|
|
36
|
+
await relationshipType.save();
|
|
37
|
+
return relationshipType;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get all reciprocal relationship types
|
|
41
|
+
*
|
|
42
|
+
* @returns Array of reciprocal ProfileRelationshipType instances
|
|
43
|
+
*/
|
|
44
|
+
async getReciprocal() {
|
|
45
|
+
return await this.list({ where: { reciprocal: true } });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get all directional (non-reciprocal) relationship types
|
|
49
|
+
*
|
|
50
|
+
* @returns Array of directional ProfileRelationshipType instances
|
|
51
|
+
*/
|
|
52
|
+
async getDirectional() {
|
|
53
|
+
return await this.list({ where: { reciprocal: false } });
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { ProfileRelationshipTypeCollection_BdXwd7Kf_exports as n, ProfileRelationshipTypeCollection as t };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `smrt app <operation>` dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Every operation writes machine-readable JSON to stdout and, on failure,
|
|
5
|
+
* one secret-free JSON envelope to stderr with exit code 1 — the contract
|
|
6
|
+
* the template's `scripts/smrt-app.mjs` established.
|
|
7
|
+
*/
|
|
8
|
+
import { type AppCommandDependencies, type AppCommandIo } from './runtime.js';
|
|
9
|
+
/** Recovery line carried by every error envelope. */
|
|
10
|
+
export declare const APP_RECOVERY = "Run pnpm app:doctor and follow its recovery instructions.";
|
|
11
|
+
/** Every `smrt app` command with a one-line description (for help output). */
|
|
12
|
+
export declare const APP_COMMANDS: Readonly<Record<string, string>>;
|
|
13
|
+
/** Options for {@link runAppCommand}. */
|
|
14
|
+
export interface RunAppCommandOptions {
|
|
15
|
+
/** Application root. Defaults to `process.cwd()`. */
|
|
16
|
+
cwd?: string;
|
|
17
|
+
/** Output sinks. Defaults to the process streams. */
|
|
18
|
+
io?: Partial<AppCommandIo>;
|
|
19
|
+
/** Collaborator overrides (tests, embedding). */
|
|
20
|
+
dependencies?: Partial<AppCommandDependencies>;
|
|
21
|
+
}
|
|
22
|
+
/** Secret-free failure envelope written to stderr. */
|
|
23
|
+
export interface AppErrorEnvelope {
|
|
24
|
+
schemaVersion: 1;
|
|
25
|
+
status: 'error';
|
|
26
|
+
code: 'operation-failed';
|
|
27
|
+
/** Stable runtime code when the failure carries one (e.g. `migration_failed`). */
|
|
28
|
+
runtimeCode?: string;
|
|
29
|
+
message: string;
|
|
30
|
+
/**
|
|
31
|
+
* `start` only: the redacted, bounded (≤ 8 KiB) tail of the web process's
|
|
32
|
+
* stdout/stderr when it never proved readiness.
|
|
33
|
+
*/
|
|
34
|
+
output?: string;
|
|
35
|
+
/** `start` only: the private (0600) log that `output` was read from. */
|
|
36
|
+
logFile?: string;
|
|
37
|
+
recovery: string;
|
|
38
|
+
secretValuesIncluded: false;
|
|
39
|
+
}
|
|
40
|
+
/** Build the stderr envelope for `error`, redacting secret material. */
|
|
41
|
+
export declare function errorEnvelope(error: unknown): AppErrorEnvelope;
|
|
42
|
+
/** Render `smrt app` usage. */
|
|
43
|
+
export declare function renderAppHelp(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Run `smrt app <argv…>` and resolve to the process exit code.
|
|
46
|
+
*
|
|
47
|
+
* `argv` is everything after `app`. A leading `--` before operation
|
|
48
|
+
* arguments is ignored, matching `pnpm app:import -- <path>`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function runAppCommand(argv: string[], options?: RunAppCommandOptions): Promise<number>;
|
|
51
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/app/cli.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAiBH,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAKlB,MAAM,cAAc,CAAC;AAGtB,qDAAqD;AACrD,eAAO,MAAM,YAAY,8DACoC,CAAC;AAE9D,8EAA8E;AAC9E,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAoBxD,CAAC;AAEH,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,EAAE,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3B,iDAAiD;IACjD,YAAY,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAChD;AAED,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,CAAC,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,kBAAkB,CAAC;IACzB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,KAAK,CAAC;CAC7B;AAED,wEAAwE;AACxE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CA+B9D;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,IAAI,MAAM,CAMtC;AAWD;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,MAAM,CAAC,CAkEjB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared error helpers for the `smrt app` command group.
|
|
3
|
+
*/
|
|
4
|
+
/** Read a Node `code` from an unknown thrown value. */
|
|
5
|
+
export declare function errorCode(error: unknown): string | undefined;
|
|
6
|
+
/** Error carrying a process exit code from a failed child command. */
|
|
7
|
+
export declare class AppCommandError extends Error {
|
|
8
|
+
readonly exitCode: number;
|
|
9
|
+
constructor(message: string, exitCode?: number, options?: {
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A `smrt app start` whose web process never proved readiness. Carries the
|
|
15
|
+
* already-redacted, bounded tail of that process's output and the private
|
|
16
|
+
* log it came from, for the error envelope.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ApplicationStartError extends Error {
|
|
19
|
+
readonly output: string;
|
|
20
|
+
readonly logFile: string;
|
|
21
|
+
constructor(message: string, output: string, logFile: string);
|
|
22
|
+
}
|
|
23
|
+
/** Options for {@link redactSecrets}. */
|
|
24
|
+
export interface RedactSecretsOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Redact every non-empty secret-named environment value and every Bearer
|
|
27
|
+
* token, whatever its length. The default keeps an 8-character floor so a
|
|
28
|
+
* short flag value (`SMRT_AUTH_ENABLED=1`) does not erase every `1` from an
|
|
29
|
+
* operator message; arbitrary child-process output (the `start` tail) has
|
|
30
|
+
* no such guarantee about what it prints, so it is redacted strictly.
|
|
31
|
+
*/
|
|
32
|
+
strict?: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remove secret material from an operator-facing message.
|
|
36
|
+
*
|
|
37
|
+
* Errors raised by drivers, config loaders, and providers routinely echo a
|
|
38
|
+
* connection string, credential, or bootstrap token. Redaction covers:
|
|
39
|
+
* literal values of secret-named environment variables, URL userinfo,
|
|
40
|
+
* `token=`/`password=`/`secret=` query values, and bearer tokens.
|
|
41
|
+
*
|
|
42
|
+
* Every span is located on the raw text and the union is masked at once, so
|
|
43
|
+
* a literal value can never split a structural match (an env value that is
|
|
44
|
+
* a Bearer-token prefix, or a URL's scheme and host, used to leave the rest
|
|
45
|
+
* of the token or the URL password visible). A final structural pass over
|
|
46
|
+
* the masked text keeps everything the earlier sequential order masked.
|
|
47
|
+
*/
|
|
48
|
+
export declare function redactSecrets(message: string, environment?: Record<string, string | undefined>, options?: RedactSecretsOptions): string;
|
|
49
|
+
/**
|
|
50
|
+
* The last `maxBytes` of `text`: a leading partial line (and any split
|
|
51
|
+
* multi-byte character) is dropped when the cut lands mid-text. Redact
|
|
52
|
+
* before cutting; cutting never exposes anything redaction masked.
|
|
53
|
+
*/
|
|
54
|
+
export declare function boundedTail(text: string, maxBytes: number): string;
|
|
55
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/app/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,uDAAuD;AACvD,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAO5D;AAED,sEAAsE;AACtE,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,SAAI,EAAE,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAYzE;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAM7D;AAYD,yCAAyC;AACzC,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAqFD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,EAC7D,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAyBR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CASlE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application identity, private state root, and operator-artifact path
|
|
3
|
+
* custody for the `smrt app` command group.
|
|
4
|
+
*
|
|
5
|
+
* Identity, configuration fingerprint, and the private state root are
|
|
6
|
+
* `@happyvertical/smrt-app-runtime`'s single implementation (re-exported
|
|
7
|
+
* here), so the running web process and these commands can never derive
|
|
8
|
+
* different identities or lock domains. Operator-artifact path custody is
|
|
9
|
+
* CLI-only and stays here.
|
|
10
|
+
*/
|
|
11
|
+
export { type ApplicationStateRootOptions, type FingerprintRuntime, prepareApplicationStateRoot, type ResolveApplicationIdOptions, resolveApplicationId, resolveApplicationStateRoot, runtimeConfigurationFingerprint, type StateCustodyOptions, } from '@happyvertical/smrt-app-runtime';
|
|
12
|
+
/** Inputs for {@link assertExternalArtifactPath}. */
|
|
13
|
+
export interface ExternalArtifactPathOptions {
|
|
14
|
+
sourceRoot: string;
|
|
15
|
+
path: string;
|
|
16
|
+
/** Message label, e.g. `Backup destination`. Defaults to `Artifact`. */
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resolve an operator-selected artifact through its nearest existing ancestor
|
|
21
|
+
* and reject paths that could place application data in or over the checkout.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertExternalArtifactPath(options: ExternalArtifactPathOptions): string;
|
|
24
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/app/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,KAAK,2BAA2B,EAChC,oBAAoB,EACpB,2BAA2B,EAC3B,+BAA+B,EAC/B,KAAK,mBAAmB,GACzB,MAAM,iCAAiC,CAAC;AAWzC,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,2BAA2B,GACnC,MAAM,CAuBR"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@happyvertical/smrt-cli/app` — the application operations behind
|
|
3
|
+
* `smrt app <operation>`, plus the shared lock, lease, identity, process,
|
|
4
|
+
* readiness, and portability primitives they are built from.
|
|
5
|
+
*
|
|
6
|
+
* Importing this entry has no side effects (unlike the package root, which
|
|
7
|
+
* runs the CLI).
|
|
8
|
+
*/
|
|
9
|
+
export { type AcquireWriterLeaseOptions, acquireWriterLease, createProviderReadinessProbe, findInstalledPackage, isStaleOperationLock, lockOwnerPid, type OperationLock, PROVIDER_READINESS_SETTINGS, type ProviderReadinessOptions, processExists, RECLAIM_MUTEX_FILE, type ReadinessComponent, type ReadinessContext, type ReclaimOutcome, readActiveWriterLease, reclaimStaleRecord, resolveReadinessModule, type WriterLease, type WriterLeaseRecord, withOperationLock, } from '@happyvertical/smrt-app-runtime';
|
|
10
|
+
export { APP_COMMANDS, APP_RECOVERY, type AppErrorEnvelope, errorEnvelope, type RunAppCommandOptions, renderAppHelp, runAppCommand, } from './cli.js';
|
|
11
|
+
export { AppCommandError, ApplicationStartError, type RedactSecretsOptions, redactSecrets, } from './errors.js';
|
|
12
|
+
export { type ApplicationStateRootOptions, assertExternalArtifactPath, type ExternalArtifactPathOptions, type FingerprintRuntime, prepareApplicationStateRoot, type ResolveApplicationIdOptions, resolveApplicationId, resolveApplicationStateRoot, runtimeConfigurationFingerprint, type StateCustodyOptions, } from './identity.js';
|
|
13
|
+
export { devServerArguments, launchVite, prepareMigration, resolveViteEntry, runWorker, ViteLauncherError, validateMcpAppsIfPresent, type WorkerKind, } from './launchers.js';
|
|
14
|
+
export { APP_OPERATIONS, type AppOperation, type PortabilityAdapter, runApplicationOperation, START_OUTPUT_TAIL_BYTES, } from './operations.js';
|
|
15
|
+
export { type ExportResult, executeImportPlan, exportApplication, type ImportExecutor, type ImportResult, importApplication, importedRowsMatchBundle, type LogicalExportBundle, type ManifestTable, manifestTables, type PlannedImportTable, type PortabilityContext, type PortabilityRuntime, planImportTables, serializeExportBundle, validateImportBundle, } from './portability.js';
|
|
16
|
+
export { ASSET_MANIFEST_SCHEMA_VERSION, type AssetBundle, type AssetImportJournal, type AssetManifestEntry, type AssetPayload, AssetPortabilityError, assertAssetRoot, bundleContentDigest, collectFilesystemAssets, digestBytes, finishFilesystemAssets, hasCommittedImportJournal, MAX_ASSET_BYTES, MAX_ASSET_COUNT, MAX_BUNDLE_BYTES, MAX_TOTAL_ASSET_BYTES, markFilesystemAssetsCommitted, type PortableRow, type PortableTable, publishFilesystemAssets, readSensitiveBundle, recoverFilesystemAssets, rollbackFilesystemAssets, type StagedAssets, stageFilesystemAssets, type VerifiedAsset, type VerifiedAssets, verifyFilesystemAssets, verifyPublishedFilesystemAssets, } from './portability-assets.js';
|
|
17
|
+
export { type ApplicationProcessRecord, checkOwnedProcess, matchesApplicationProcess, type OwnedProcessState, readOwnedProcess, sendTerminationSignal, verifyOwnedProcess, WEB_LAUNCHER_NAME, writeProcessRecord, } from './process-record.js';
|
|
18
|
+
export { type AppCommandDependencies, type AppCommandIo, type AppContext, type CommandRunner, cliExecutablePath, type RunOptions, type RuntimeEnvironment, runtimeEnvironment, webLauncherPath, } from './runtime.js';
|
|
19
|
+
export { parseTokenLifetime, runTokenOperation, TOKEN_USAGE, } from './tokens.js';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,yBAAyB,EAC9B,kBAAkB,EAClB,4BAA4B,EAC5B,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,KAAK,aAAa,EAClB,2BAA2B,EAC3B,KAAK,wBAAwB,EAC7B,aAAa,EACb,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,gBAAgB,EACrB,aAAa,EACb,KAAK,oBAAoB,EACzB,aAAa,EACb,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,oBAAoB,EACzB,aAAa,GACd,MAAM,aAAa,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tB,+BAA+B,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,kBAAkB,EAClB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,GACZ,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process wrappers: explicit schema preparation (`migrate`), deployed job
|
|
3
|
+
* workers (`worker`), and the Vite launcher (`dev`, `build`, `vite`).
|
|
4
|
+
*
|
|
5
|
+
* Ported from the template's `scripts/smrt-prepare-migration.mjs`,
|
|
6
|
+
* `scripts/smrt-worker.mjs`, `scripts/smrt-vite.mjs`, and
|
|
7
|
+
* `scripts/smrt-mcp-apps.mjs`.
|
|
8
|
+
*/
|
|
9
|
+
import { type AppContext } from './runtime.js';
|
|
10
|
+
/**
|
|
11
|
+
* Prepare the schema explicitly: under the operation lock, refuse while a
|
|
12
|
+
* local writer is live, establish local storage custody without creating
|
|
13
|
+
* schema or bootstrap records, then run `smrt db:migrate`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function prepareMigration(context: AppContext): Promise<number>;
|
|
16
|
+
/** Worker kinds. `task` when omitted; anything else is a usage error. */
|
|
17
|
+
export type WorkerKind = 'task' | 'schedule';
|
|
18
|
+
/** Parse `smrt app worker [kind]`, refusing anything but `task`/`schedule`. */
|
|
19
|
+
export declare function parseWorkerKind(args: readonly string[]): WorkerKind;
|
|
20
|
+
/**
|
|
21
|
+
* Start a deployed job worker. Resolves once the runner is started; the
|
|
22
|
+
* process stays alive until SIGINT/SIGTERM closes the runtime.
|
|
23
|
+
*/
|
|
24
|
+
export declare function runWorker(context: AppContext, args: string[]): Promise<number>;
|
|
25
|
+
/** Failure of the Vite launcher; rendered as `s-m-r-t Vite launcher: …`. */
|
|
26
|
+
export declare class ViteLauncherError extends Error {
|
|
27
|
+
}
|
|
28
|
+
/** Resolve the application's installed Vite CLI entry, refusing unsafe paths. */
|
|
29
|
+
export declare function resolveViteEntry(sourceRoot: string): string;
|
|
30
|
+
/** Loopback host every `smrt app` URL (onboarding, `open`, `start`) names. */
|
|
31
|
+
export declare const LOOPBACK_HOST = "127.0.0.1";
|
|
32
|
+
/**
|
|
33
|
+
* Arguments for `smrt app dev`: the caller's Vite arguments, plus
|
|
34
|
+
* `--host 127.0.0.1` unless they name `--host`, and `--port $PORT` when
|
|
35
|
+
* `PORT` is set and they name no `--port`. Vite's own default host is
|
|
36
|
+
* `localhost`, which Node resolves to `[::1]` first, so the dev server would
|
|
37
|
+
* not answer the `http://127.0.0.1:<PORT>` URL onboarding and `app:open` hand
|
|
38
|
+
* out. An explicit `--host`/`--port` (or `smrt app vite dev …`) wins.
|
|
39
|
+
*/
|
|
40
|
+
export declare function devServerArguments(args: readonly string[], env?: NodeJS.ProcessEnv): string[];
|
|
41
|
+
/**
|
|
42
|
+
* Run the application's Vite CLI in this process with `args` verbatim. The
|
|
43
|
+
* caller has already loaded `.env` without overriding the shell.
|
|
44
|
+
*/
|
|
45
|
+
export declare function launchVite(context: AppContext, args: string[]): Promise<number>;
|
|
46
|
+
/**
|
|
47
|
+
* Validate opt-in portable MCP Apps metadata (`./mcp-apps`) when present.
|
|
48
|
+
* Returns the exit code; findings go to stderr.
|
|
49
|
+
*/
|
|
50
|
+
export declare function validateMcpAppsIfPresent(context: AppContext): Promise<number>;
|
|
51
|
+
//# sourceMappingURL=launchers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launchers.d.ts","sourceRoot":"","sources":["../../src/app/launchers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAcH,OAAO,EAAE,KAAK,UAAU,EAAqB,MAAM,cAAc,CAAC;AAElE;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAyC3E;AAED,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;AAI7C,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAOnE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CA2GjB;AAED,4EAA4E;AAC5E,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAE/C,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAyC3D;AAED,8EAA8E;AAC9E,eAAO,MAAM,aAAa,cAAc,CAAC;AAEzC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,EAAE,CAOV;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAcjB;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,MAAM,CAAC,CAkBjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local/deployed application operations: install, setup, recover, start,
|
|
3
|
+
* stop, doctor, open, backup, export, import.
|
|
4
|
+
*
|
|
5
|
+
* Ported from the template's `scripts/smrt-app.mjs`. Output JSON, exit
|
|
6
|
+
* codes, state files, and environment variables are unchanged so the
|
|
7
|
+
* template's `pnpm app:*` scripts can become `smrt app <operation>`.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResolvedApplicationRuntime } from '@happyvertical/smrt-config';
|
|
10
|
+
import type { ExportResult, ImportResult, PortabilityContext } from './portability.js';
|
|
11
|
+
import { type AppContext } from './runtime.js';
|
|
12
|
+
/** Operations implemented by this module. */
|
|
13
|
+
export declare const APP_OPERATIONS: readonly ["install", "setup", "recover", "start", "stop", "doctor", "open", "backup", "export", "import"];
|
|
14
|
+
/** One of {@link APP_OPERATIONS}. */
|
|
15
|
+
export type AppOperation = (typeof APP_OPERATIONS)[number];
|
|
16
|
+
/** Throw unless the configured profile is `local`. */
|
|
17
|
+
export declare function assertLocalOperation(context: AppContext, operation: string): Promise<ResolvedApplicationRuntime>;
|
|
18
|
+
/** Upper bound on the web-process output a failed `start` reports. */
|
|
19
|
+
export declare const START_OUTPUT_TAIL_BYTES: number;
|
|
20
|
+
/** Portability adapter contract (built-in or an application override). */
|
|
21
|
+
export interface PortabilityAdapter {
|
|
22
|
+
exportApplication(context: PortabilityContext): Promise<ExportResult>;
|
|
23
|
+
importApplication(context: PortabilityContext): Promise<ImportResult>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Run one application operation. Resolves to the process exit code; throws
|
|
27
|
+
* on failure (the caller renders the error envelope).
|
|
28
|
+
*/
|
|
29
|
+
export declare function runApplicationOperation(context: AppContext, operation: AppOperation, args: string[]): Promise<number>;
|
|
30
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/app/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA6BH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAY7E,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EACL,KAAK,UAAU,EAIhB,MAAM,cAAc,CAAC;AAEtB,6CAA6C;AAC7C,eAAO,MAAM,cAAc,2GAWjB,CAAC;AAEX,qCAAqC;AACrC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAuH3D,sDAAsD;AACtD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,0BAA0B,CAAC,CAQrC;AAyPD,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,QAAW,CAAC;AAiZhD,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACtE,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACvE;AAkFD;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,MAAM,EAAE,GACb,OAAO,CAAC,MAAM,CAAC,CAkEjB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem asset portability for logical export/import bundles.
|
|
3
|
+
*
|
|
4
|
+
* Ported unchanged from the template's `scripts/smrt-portability-assets.mjs`:
|
|
5
|
+
* the bundle format, limits, sanitized failure codes, staging journal, and
|
|
6
|
+
* crash-recovery rules are a persisted contract.
|
|
7
|
+
*/
|
|
8
|
+
export declare const ASSET_MANIFEST_SCHEMA_VERSION = 1;
|
|
9
|
+
export declare const MAX_ASSET_COUNT = 1000;
|
|
10
|
+
export declare const MAX_ASSET_BYTES: number;
|
|
11
|
+
export declare const MAX_TOTAL_ASSET_BYTES: number;
|
|
12
|
+
export declare const MAX_BUNDLE_BYTES: number;
|
|
13
|
+
/** Row shape of an exported table. */
|
|
14
|
+
export type PortableRow = Record<string, unknown>;
|
|
15
|
+
/** Exported table as it appears in a bundle. */
|
|
16
|
+
export interface PortableTable {
|
|
17
|
+
name: string;
|
|
18
|
+
columns: string[];
|
|
19
|
+
rows: PortableRow[];
|
|
20
|
+
}
|
|
21
|
+
/** One asset entry of the bundle manifest. */
|
|
22
|
+
export interface AssetManifestEntry {
|
|
23
|
+
key: string;
|
|
24
|
+
byteLength: number;
|
|
25
|
+
contentDigest: string;
|
|
26
|
+
payloadPath: string;
|
|
27
|
+
}
|
|
28
|
+
/** One embedded asset payload. */
|
|
29
|
+
export interface AssetPayload {
|
|
30
|
+
path: string;
|
|
31
|
+
encoding: 'base64';
|
|
32
|
+
data: string;
|
|
33
|
+
}
|
|
34
|
+
/** Asset section of a bundle. */
|
|
35
|
+
export interface AssetBundle {
|
|
36
|
+
schemaVersion: number;
|
|
37
|
+
adapter: 'filesystem';
|
|
38
|
+
entries: AssetManifestEntry[];
|
|
39
|
+
payloads: AssetPayload[];
|
|
40
|
+
}
|
|
41
|
+
/** Verified asset ready to stage. */
|
|
42
|
+
export interface VerifiedAsset {
|
|
43
|
+
key: string;
|
|
44
|
+
bytes: Buffer;
|
|
45
|
+
contentDigest: string;
|
|
46
|
+
relativePath: string;
|
|
47
|
+
}
|
|
48
|
+
/** Result of {@link verifyFilesystemAssets}. */
|
|
49
|
+
export interface VerifiedAssets {
|
|
50
|
+
root: string | null;
|
|
51
|
+
entries: VerifiedAsset[];
|
|
52
|
+
}
|
|
53
|
+
/** Persisted asset-import journal. */
|
|
54
|
+
export interface AssetImportJournal {
|
|
55
|
+
schemaVersion: 1;
|
|
56
|
+
application: string;
|
|
57
|
+
bundleDigest: string;
|
|
58
|
+
assetRoot: string;
|
|
59
|
+
stageRoot: string;
|
|
60
|
+
phase: 'staging' | 'publishing' | 'published';
|
|
61
|
+
rootExisted: boolean;
|
|
62
|
+
entries: Array<{
|
|
63
|
+
relativePath: string;
|
|
64
|
+
contentDigest: string;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Set once the database transaction for this bundle committed (additive;
|
|
68
|
+
* journals written by the template scripts never carry it, and those
|
|
69
|
+
* scripts ignore it). Recovery treats it as proof the rows are this
|
|
70
|
+
* bundle's; without it, recovery verifies row content instead.
|
|
71
|
+
*/
|
|
72
|
+
committedAt?: string;
|
|
73
|
+
}
|
|
74
|
+
/** A staged import: journal path plus its in-memory journal. */
|
|
75
|
+
export interface StagedAssets {
|
|
76
|
+
path: string;
|
|
77
|
+
journal: AssetImportJournal;
|
|
78
|
+
}
|
|
79
|
+
/** Sanitized asset-portability failure with a stable kebab-case `code`. */
|
|
80
|
+
export declare class AssetPortabilityError extends Error {
|
|
81
|
+
readonly code: string;
|
|
82
|
+
constructor(code: string);
|
|
83
|
+
}
|
|
84
|
+
/** `sha256:<hex>` digest of bytes. */
|
|
85
|
+
export declare function digestBytes(value: string | Buffer): string;
|
|
86
|
+
/** Validate an asset root: absolute, outside the source tree, real directory. */
|
|
87
|
+
export declare function assertAssetRoot({ sourceRoot, assetRoot, allowMissing, }: {
|
|
88
|
+
sourceRoot: string;
|
|
89
|
+
assetRoot: unknown;
|
|
90
|
+
allowMissing?: boolean;
|
|
91
|
+
}): string;
|
|
92
|
+
/** Replace provider paths with logical keys while collecting verified payloads. */
|
|
93
|
+
export declare function collectFilesystemAssets({ tables, sourceRoot, assetRoot, onSourceOpened, }: {
|
|
94
|
+
tables: PortableTable[];
|
|
95
|
+
sourceRoot: string;
|
|
96
|
+
assetRoot: string | null | undefined;
|
|
97
|
+
onSourceOpened?: () => void;
|
|
98
|
+
}): AssetBundle;
|
|
99
|
+
/** Validate every manifest/payload relationship and hydrate destination URIs. */
|
|
100
|
+
export declare function verifyFilesystemAssets({ assetBundle, tables, sourceRoot, assetRoot, }: {
|
|
101
|
+
assetBundle: unknown;
|
|
102
|
+
tables: PortableTable[];
|
|
103
|
+
sourceRoot: string;
|
|
104
|
+
assetRoot: string | null | undefined;
|
|
105
|
+
}): VerifiedAssets;
|
|
106
|
+
/** Stage verified bytes without publishing anything into the destination root. */
|
|
107
|
+
export declare function stageFilesystemAssets({ verified, stateRoot, appId, bundleDigest, }: {
|
|
108
|
+
verified: VerifiedAssets;
|
|
109
|
+
stateRoot: string;
|
|
110
|
+
appId: string;
|
|
111
|
+
bundleDigest: string;
|
|
112
|
+
}): StagedAssets | null;
|
|
113
|
+
/** Publish the complete verified tree with one rename that never follows the target. */
|
|
114
|
+
export declare function publishFilesystemAssets(staged: StagedAssets | null, options?: {
|
|
115
|
+
beforeRename?: () => void;
|
|
116
|
+
}): void;
|
|
117
|
+
/** Re-verify the published tree against the staged journal. */
|
|
118
|
+
export declare function verifyPublishedFilesystemAssets(staged: StagedAssets | null): void;
|
|
119
|
+
/** Record in the journal that this bundle's database transaction committed. */
|
|
120
|
+
export declare function markFilesystemAssetsCommitted(staged: StagedAssets | null): void;
|
|
121
|
+
/**
|
|
122
|
+
* True when an import journal for `appId` exists, belongs to `bundleDigest`,
|
|
123
|
+
* and records a committed database transaction.
|
|
124
|
+
*/
|
|
125
|
+
export declare function hasCommittedImportJournal({ stateRoot, appId, bundleDigest, }: {
|
|
126
|
+
stateRoot: string;
|
|
127
|
+
appId: string;
|
|
128
|
+
bundleDigest: string;
|
|
129
|
+
}): boolean;
|
|
130
|
+
/** Verify the published tree and drop the journal. */
|
|
131
|
+
export declare function finishFilesystemAssets(staged: StagedAssets | null): void;
|
|
132
|
+
/** Undo a staged or published import, restoring an empty target. */
|
|
133
|
+
export declare function rollbackFilesystemAssets(staged: StagedAssets | null): void;
|
|
134
|
+
/** Recover a prior crash only when the same bundle and exact target state prove ownership. */
|
|
135
|
+
export declare function recoverFilesystemAssets({ stateRoot, appId, bundleDigest, assetRoot, targetState, }: {
|
|
136
|
+
stateRoot: string;
|
|
137
|
+
appId: string;
|
|
138
|
+
bundleDigest: string;
|
|
139
|
+
assetRoot: string | null;
|
|
140
|
+
targetState: 'empty' | 'complete' | 'dirty';
|
|
141
|
+
}): 'none' | 'complete' | 'retry';
|
|
142
|
+
/**
|
|
143
|
+
* Read an import bundle only when it is a private (mode 0600), regular,
|
|
144
|
+
* non-symlinked file that does not change while it is read.
|
|
145
|
+
*/
|
|
146
|
+
export declare function readSensitiveBundle(path: string, options?: {
|
|
147
|
+
onOpened?: () => void;
|
|
148
|
+
}): string;
|
|
149
|
+
/** Digest identifying one serialized bundle for crash recovery. */
|
|
150
|
+
export declare function bundleContentDigest(serialized: string): string;
|
|
151
|
+
//# sourceMappingURL=portability-assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portability-assets.d.ts","sourceRoot":"","sources":["../../src/app/portability-assets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAC/C,eAAO,MAAM,eAAe,OAAQ,CAAC;AACrC,eAAO,MAAM,eAAe,QAAmB,CAAC;AAChD,eAAO,MAAM,qBAAqB,QAAoB,CAAC;AACvD,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAQlD,sCAAsC;AACtC,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,WAAW,EAAE,CAAC;CACrB;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;C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