@void/platform 0.20.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/dist/index.d.mts +264 -0
  4. package/dist/index.mjs +895 -0
  5. package/dist/installer.d.mts +49 -0
  6. package/dist/installer.mjs +176 -0
  7. package/dist/runtime/api/README.md +1 -0
  8. package/dist/runtime/api/index.js +70824 -0
  9. package/dist/runtime/api/index.js.map +8 -0
  10. package/dist/runtime/dispatch/README.md +1 -0
  11. package/dist/runtime/dispatch/index.js +3289 -0
  12. package/dist/runtime/dispatch/index.js.map +8 -0
  13. package/dist/runtime/drizzle/0000_confused_starjammers.sql +66 -0
  14. package/dist/runtime/drizzle/0001_famous_magus.sql +15 -0
  15. package/dist/runtime/drizzle/0002_glorious_morgan_stark.sql +17 -0
  16. package/dist/runtime/drizzle/0003_awesome_ares.sql +3 -0
  17. package/dist/runtime/drizzle/0004_talented_mimic.sql +1 -0
  18. package/dist/runtime/drizzle/0005_legal_red_ghost.sql +15 -0
  19. package/dist/runtime/drizzle/0006_wonderful_madame_masque.sql +17 -0
  20. package/dist/runtime/drizzle/0007_normal_skin.sql +4 -0
  21. package/dist/runtime/drizzle/0008_auth_codes.sql +5 -0
  22. package/dist/runtime/drizzle/0009_chubby_masked_marvel.sql +1 -0
  23. package/dist/runtime/drizzle/0010_wild_aqueduct.sql +10 -0
  24. package/dist/runtime/drizzle/0011_curly_stryfe.sql +2 -0
  25. package/dist/runtime/drizzle/0012_eminent_mystique.sql +1 -0
  26. package/dist/runtime/drizzle/0013_quick_selene.sql +3 -0
  27. package/dist/runtime/drizzle/0014_mysterious_medusa.sql +1 -0
  28. package/dist/runtime/drizzle/0015_backfill_accepted_invitations.sql +14 -0
  29. package/dist/runtime/drizzle/0016_verified_phoenix.sql +1 -0
  30. package/dist/runtime/drizzle/0017_gorgeous_johnny_blaze.sql +3 -0
  31. package/dist/runtime/drizzle/0018_project_migrations.sql +21 -0
  32. package/dist/runtime/drizzle/0019_project_database_credentials.sql +10 -0
  33. package/dist/runtime/drizzle/0027_github_deploy.sql +82 -0
  34. package/dist/runtime/drizzle/0028_check_runs.sql +1 -0
  35. package/dist/runtime/drizzle/0029_fluffy_justin_hammer.sql +1 -0
  36. package/dist/runtime/drizzle/0030_smooth_marvel_boy.sql +13 -0
  37. package/dist/runtime/drizzle/0031_thankful_madame_masque.sql +9 -0
  38. package/dist/runtime/drizzle/0032_remarkable_skullbuster.sql +10 -0
  39. package/dist/runtime/drizzle/0033_operator_sessions_and_events.sql +21 -0
  40. package/dist/runtime/drizzle/0034_email_destinations.sql +21 -0
  41. package/dist/runtime/drizzle/0035_invitation_actor_history.sql +5 -0
  42. package/dist/runtime/drizzle/0036_flowery_master_chief.sql +2 -0
  43. package/dist/runtime/drizzle/0037_unusual_bloodaxe.sql +14 -0
  44. package/dist/runtime/drizzle/0038_deployment_admission_protocol.sql +25 -0
  45. package/dist/runtime/drizzle/compatibility.json +26 -0
  46. package/dist/runtime/drizzle/meta/_journal.json +230 -0
  47. package/dist/runtime/manifest.json +254 -0
  48. package/dist/runtime/proxy/README.md +1 -0
  49. package/dist/runtime/proxy/index.js +5416 -0
  50. package/dist/runtime/proxy/index.js.map +8 -0
  51. package/dist/runtime/tail/README.md +1 -0
  52. package/dist/runtime/tail/index.js +61 -0
  53. package/dist/runtime/tail/index.js.map +8 -0
  54. package/package.json +40 -0
@@ -0,0 +1,49 @@
1
+ //#region src/installer.d.ts
2
+ export type PlatformRuntimeArtifact = Readonly<{
3
+ path: string;
4
+ sha256: string;
5
+ size: number;
6
+ }>;
7
+ export type PlatformRuntimeMigration = Readonly<{
8
+ index: number;
9
+ sha256: string;
10
+ tag: string;
11
+ timestampMillis: number;
12
+ }>;
13
+ export type PlatformRuntimeDatabaseCompatibility = Readonly<{
14
+ platformVersion: string;
15
+ schemaDigest: string;
16
+ }>;
17
+ export type PlatformRuntimeDatabaseManifest = Readonly<{
18
+ journalSha256: string;
19
+ lineage: string;
20
+ migrations: ReadonlyArray<PlatformRuntimeMigration>;
21
+ protocolVersion: 1;
22
+ rollbackSafeFrom: ReadonlyArray<PlatformRuntimeDatabaseCompatibility>;
23
+ schemaDigest: string;
24
+ }>;
25
+ export type PlatformRuntimeManifest = Readonly<{
26
+ applicationRoutingVersion?: 1;
27
+ artifacts: Readonly<Record<"api" | "dispatch" | "proxy" | "tail", PlatformRuntimeArtifact>>;
28
+ database: PlatformRuntimeDatabaseManifest;
29
+ platformVersion: string;
30
+ safetyProtocols: Readonly<{
31
+ sandboxDrain: 0 | 1 | 2;
32
+ }>;
33
+ schemaVersion: 2;
34
+ sourceRevision: string | null;
35
+ /** Queue payload contract shared by the API consumer and trusted producers. */
36
+ usageProtocolVersion: 0 | 1;
37
+ }>;
38
+ export type PlatformRuntime = Readonly<{
39
+ directory: string;
40
+ manifest: PlatformRuntimeManifest;
41
+ manifestSha256: string;
42
+ source: "custom" | "package";
43
+ }>;
44
+ export declare function platformDatabaseSchemaDigest(lineage: string, migrations: ReadonlyArray<PlatformRuntimeMigration>): string;
45
+ export declare function parsePlatformRuntimeManifest(value: unknown): PlatformRuntimeManifest;
46
+ export declare function getPlatformRuntimeDirectory(): string;
47
+ export declare function readPlatformRuntimeManifest(runtimeDirectory?: string): PlatformRuntimeManifest;
48
+ export declare function resolvePlatformRuntime(customRuntimeDirectory?: string, baseDirectory?: string): PlatformRuntime;
49
+ //#endregion
@@ -0,0 +1,176 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync, realpathSync, statSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
4
+ import { dirname, isAbsolute, join, resolve } from "pathslash";
5
+ //#region src/installer.ts
6
+ const SHA256_PATTERN = /^[0-9a-f]{64}$/;
7
+ const TAG_PATTERN = /^[0-9]{4}_[a-z0-9_]+$/;
8
+ function platformDatabaseSchemaDigest(lineage, migrations) {
9
+ return createHash("sha256").update(JSON.stringify({
10
+ lineage,
11
+ migrations: migrations.map(({ index, sha256, tag, timestampMillis }) => ({
12
+ index,
13
+ sha256,
14
+ tag,
15
+ timestampMillis
16
+ }))
17
+ })).digest("hex");
18
+ }
19
+ function parsePlatformRuntimeManifest(value) {
20
+ const root = record(value, "runtime manifest");
21
+ if (root.schemaVersion !== 2) throw new Error("runtime manifest schemaVersion must be 2");
22
+ const artifactsValue = record(root.artifacts, "runtime manifest artifacts");
23
+ const artifacts = Object.fromEntries([
24
+ "api",
25
+ "dispatch",
26
+ "proxy",
27
+ "tail"
28
+ ].map((name) => [name, parseArtifact(artifactsValue[name], name)]));
29
+ const databaseValue = record(root.database, "runtime manifest database");
30
+ if (databaseValue.protocolVersion !== 1) throw new Error("runtime manifest database protocolVersion must be 1");
31
+ const lineage = nonemptyString(databaseValue.lineage, "database lineage");
32
+ const migrations = array(databaseValue.migrations, "database migrations").map((migration, position) => parseMigration(migration, position));
33
+ const seenIndexes = /* @__PURE__ */ new Set();
34
+ const seenTags = /* @__PURE__ */ new Set();
35
+ const seenTimestamps = /* @__PURE__ */ new Set();
36
+ let previousIndex = -1;
37
+ let previousTimestamp = -1;
38
+ for (const migration of migrations) {
39
+ if (seenIndexes.has(migration.index) || seenTags.has(migration.tag) || seenTimestamps.has(migration.timestampMillis)) throw new Error("runtime manifest database migrations must be unique");
40
+ if (migration.index <= previousIndex || migration.timestampMillis <= previousTimestamp) throw new Error("runtime manifest database migrations must be strictly ordered");
41
+ seenIndexes.add(migration.index);
42
+ seenTags.add(migration.tag);
43
+ seenTimestamps.add(migration.timestampMillis);
44
+ previousIndex = migration.index;
45
+ previousTimestamp = migration.timestampMillis;
46
+ }
47
+ const schemaDigest = sha256(databaseValue.schemaDigest, "database schema digest");
48
+ if (schemaDigest !== platformDatabaseSchemaDigest(lineage, migrations)) throw new Error("runtime manifest database schema digest does not match its migrations");
49
+ const rollbackSafeFrom = array(databaseValue.rollbackSafeFrom, "database rollback compatibility entries").map((entry, position) => {
50
+ const compatibility = record(entry, `database rollback compatibility entry ${position}`);
51
+ return {
52
+ platformVersion: nonemptyString(compatibility.platformVersion, `database rollback compatibility entry ${position} platformVersion`),
53
+ schemaDigest: sha256(compatibility.schemaDigest, `database rollback compatibility entry ${position} schemaDigest`)
54
+ };
55
+ });
56
+ const compatibilityKeys = rollbackSafeFrom.map(({ platformVersion, schemaDigest: digest }) => `${platformVersion}\0${digest}`);
57
+ if (new Set(compatibilityKeys).size !== compatibilityKeys.length) throw new Error("runtime manifest database rollback compatibility entries must be unique");
58
+ const prefixDigests = new Set(Array.from({ length: migrations.length + 1 }, (_, length) => platformDatabaseSchemaDigest(lineage, migrations.slice(0, length))));
59
+ if (rollbackSafeFrom.some((entry) => !prefixDigests.has(entry.schemaDigest))) throw new Error("runtime manifest database rollback compatibility must reference this migration lineage");
60
+ return {
61
+ artifacts,
62
+ ...root.applicationRoutingVersion === 1 ? { applicationRoutingVersion: 1 } : {},
63
+ database: {
64
+ journalSha256: sha256(databaseValue.journalSha256, "database journal digest"),
65
+ lineage,
66
+ migrations,
67
+ protocolVersion: 1,
68
+ rollbackSafeFrom,
69
+ schemaDigest
70
+ },
71
+ platformVersion: nonemptyString(root.platformVersion, "runtime manifest platformVersion"),
72
+ safetyProtocols: parseSafetyProtocols(root.safetyProtocols),
73
+ schemaVersion: 2,
74
+ sourceRevision: root.sourceRevision === void 0 || root.sourceRevision === null ? null : sourceRevision(root.sourceRevision),
75
+ usageProtocolVersion: usageProtocolVersion(root.usageProtocolVersion)
76
+ };
77
+ }
78
+ function parseSafetyProtocols(value) {
79
+ if (value === void 0) return { sandboxDrain: 0 };
80
+ const protocols = record(value, "runtime manifest safetyProtocols");
81
+ if (protocols.sandboxDrain !== 0 && protocols.sandboxDrain !== 1 && protocols.sandboxDrain !== 2) throw new Error("runtime manifest safetyProtocols.sandboxDrain must be 0, 1, or 2");
82
+ return { sandboxDrain: protocols.sandboxDrain };
83
+ }
84
+ function usageProtocolVersion(value) {
85
+ if (value === void 0 || value === 0) return 0;
86
+ if (value === 1) return 1;
87
+ throw new Error("runtime manifest usageProtocolVersion must be 0 or 1");
88
+ }
89
+ function getPlatformRuntimeDirectory() {
90
+ return join(dirname(fileURLToPath(import.meta.url)), "runtime");
91
+ }
92
+ function readPlatformRuntimeManifest(runtimeDirectory = getPlatformRuntimeDirectory()) {
93
+ const path = join(runtimeDirectory, "manifest.json");
94
+ try {
95
+ return parsePlatformRuntimeManifest(JSON.parse(readFileSync(path, "utf8")));
96
+ } catch (error) {
97
+ throw new Error(`Void Platform deployment artifacts are missing or invalid at ${path}: ${error instanceof Error ? error.message : String(error)}`);
98
+ }
99
+ }
100
+ function resolvePlatformRuntime(customRuntimeDirectory, baseDirectory = process.cwd()) {
101
+ const source = customRuntimeDirectory ? "custom" : "package";
102
+ const requestedDirectory = customRuntimeDirectory ? isAbsolute(customRuntimeDirectory) ? customRuntimeDirectory : resolve(baseDirectory, customRuntimeDirectory) : getPlatformRuntimeDirectory();
103
+ let directory;
104
+ try {
105
+ directory = realpathSync(requestedDirectory);
106
+ if (!statSync(directory).isDirectory()) throw new Error("not a directory");
107
+ } catch (error) {
108
+ throw new Error(`Void Platform runtime directory is unavailable at ${requestedDirectory}: ${error instanceof Error ? error.message : String(error)}`);
109
+ }
110
+ const manifestPath = join(directory, "manifest.json");
111
+ let manifestContents;
112
+ try {
113
+ manifestContents = readFileSync(manifestPath);
114
+ } catch (error) {
115
+ throw new Error(`Void Platform deployment artifacts are missing or invalid at ${manifestPath}: ${error instanceof Error ? error.message : String(error)}`);
116
+ }
117
+ return {
118
+ directory,
119
+ manifest: readPlatformRuntimeManifest(directory),
120
+ manifestSha256: createHash("sha256").update(manifestContents).digest("hex"),
121
+ source
122
+ };
123
+ }
124
+ function parseArtifact(value, name) {
125
+ const artifact = record(value, `runtime manifest artifact ${name}`);
126
+ const path = nonemptyString(artifact.path, `runtime manifest artifact ${name} path`);
127
+ if (path.startsWith("/") || path.split(/[\\/]/u).includes("..")) throw new Error(`runtime manifest artifact ${name} path must stay inside the package`);
128
+ const size = safeInteger(artifact.size, `runtime manifest artifact ${name} size`);
129
+ if (size < 0) throw new Error(`runtime manifest artifact ${name} size must not be negative`);
130
+ return {
131
+ path,
132
+ sha256: sha256(artifact.sha256, `runtime manifest artifact ${name} digest`),
133
+ size
134
+ };
135
+ }
136
+ function parseMigration(value, position) {
137
+ const migration = record(value, `database migration ${position}`);
138
+ const tag = nonemptyString(migration.tag, `database migration ${position} tag`);
139
+ if (!TAG_PATTERN.test(tag)) throw new Error(`database migration ${position} tag is invalid`);
140
+ const index = safeInteger(migration.index, `database migration ${position} index`);
141
+ const timestampMillis = safeInteger(migration.timestampMillis, `database migration ${position} timestampMillis`);
142
+ if (index < 0 || timestampMillis < 0) throw new Error(`database migration ${position} index and timestampMillis must be positive`);
143
+ return {
144
+ index,
145
+ sha256: sha256(migration.sha256, `database migration ${position} digest`),
146
+ tag,
147
+ timestampMillis
148
+ };
149
+ }
150
+ function record(value, name) {
151
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${name} must be an object`);
152
+ return value;
153
+ }
154
+ function array(value, name) {
155
+ if (!Array.isArray(value)) throw new Error(`${name} must be an array`);
156
+ return value;
157
+ }
158
+ function nonemptyString(value, name) {
159
+ if (typeof value !== "string" || value.trim() === "") throw new Error(`${name} must be a non-empty string`);
160
+ return value;
161
+ }
162
+ function sourceRevision(value) {
163
+ const revision = nonemptyString(value, "runtime manifest sourceRevision");
164
+ if (revision.length > 200 || !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(revision)) throw new Error("runtime manifest sourceRevision is invalid");
165
+ return revision;
166
+ }
167
+ function safeInteger(value, name) {
168
+ if (typeof value !== "number" || !Number.isSafeInteger(value)) throw new Error(`${name} must be a safe integer`);
169
+ return value;
170
+ }
171
+ function sha256(value, name) {
172
+ if (typeof value !== "string" || !SHA256_PATTERN.test(value)) throw new Error(`${name} must be a lowercase SHA-256 digest`);
173
+ return value;
174
+ }
175
+ //#endregion
176
+ export { getPlatformRuntimeDirectory, parsePlatformRuntimeManifest, platformDatabaseSchemaDigest, readPlatformRuntimeManifest, resolvePlatformRuntime };
@@ -0,0 +1 @@
1
+ This folder contains the built output assets for the worker "void-runtime-build-api" generated at 2026-09-17T22:53:24.336Z.