primitive-admin 1.1.0-alpha.82 → 1.1.0-alpha.83

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 (86) hide show
  1. package/dist/src/commands/documents.js +333 -42
  2. package/dist/src/commands/documents.js.map +1 -1
  3. package/dist/src/commands/functions.js +302 -120
  4. package/dist/src/commands/functions.js.map +1 -1
  5. package/dist/src/commands/locks.js +15 -1
  6. package/dist/src/commands/locks.js.map +1 -1
  7. package/dist/src/commands/sync.d.ts +50 -0
  8. package/dist/src/commands/sync.js +560 -312
  9. package/dist/src/commands/sync.js.map +1 -1
  10. package/dist/src/lib/api-client.d.ts +75 -2
  11. package/dist/src/lib/api-client.js +122 -7
  12. package/dist/src/lib/api-client.js.map +1 -1
  13. package/dist/src/lib/config-object-descriptor.js +5 -5
  14. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  15. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  16. package/dist/src/lib/document-ingest-artifact.js +505 -0
  17. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  18. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  19. package/dist/src/lib/document-ingest-input.js +132 -0
  20. package/dist/src/lib/document-ingest-input.js.map +1 -0
  21. package/dist/src/lib/document-ingest.d.ts +78 -0
  22. package/dist/src/lib/document-ingest.js +231 -0
  23. package/dist/src/lib/document-ingest.js.map +1 -0
  24. package/dist/src/lib/function-bundle.d.ts +6 -0
  25. package/dist/src/lib/function-bundle.js +8 -0
  26. package/dist/src/lib/function-bundle.js.map +1 -1
  27. package/dist/src/lib/function-collect.d.ts +1 -1
  28. package/dist/src/lib/function-collect.js +16 -0
  29. package/dist/src/lib/function-collect.js.map +1 -1
  30. package/dist/src/lib/function-db-types.d.ts +4 -0
  31. package/dist/src/lib/function-db-types.js +31 -2
  32. package/dist/src/lib/function-db-types.js.map +1 -1
  33. package/dist/src/lib/function-document-types.d.ts +83 -0
  34. package/dist/src/lib/function-document-types.js +133 -0
  35. package/dist/src/lib/function-document-types.js.map +1 -1
  36. package/dist/src/lib/function-grants-preflight.js +5 -0
  37. package/dist/src/lib/function-grants-preflight.js.map +1 -1
  38. package/dist/src/lib/function-log-lines.d.ts +76 -0
  39. package/dist/src/lib/function-log-lines.js +160 -0
  40. package/dist/src/lib/function-log-lines.js.map +1 -0
  41. package/dist/src/lib/function-log-row.d.ts +29 -0
  42. package/dist/src/lib/function-log-row.js +73 -0
  43. package/dist/src/lib/function-log-row.js.map +1 -0
  44. package/dist/src/lib/function-run.d.ts +53 -35
  45. package/dist/src/lib/function-run.js +55 -44
  46. package/dist/src/lib/function-run.js.map +1 -1
  47. package/dist/src/lib/function-schema-codegen.d.ts +6 -9
  48. package/dist/src/lib/function-schema-codegen.js +22 -35
  49. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  50. package/dist/src/lib/function-sync.d.ts +226 -35
  51. package/dist/src/lib/function-sync.js +731 -99
  52. package/dist/src/lib/function-sync.js.map +1 -1
  53. package/dist/src/lib/function-versions.d.ts +122 -0
  54. package/dist/src/lib/function-versions.js +182 -0
  55. package/dist/src/lib/function-versions.js.map +1 -0
  56. package/dist/src/lib/generated-config-surfaces.d.ts +390 -146
  57. package/dist/src/lib/generated-config-surfaces.js +1207 -401
  58. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  59. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  60. package/dist/src/lib/generated-sdk-types.js +1 -1
  61. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  62. package/dist/src/lib/log-inspection.d.ts +2 -0
  63. package/dist/src/lib/log-inspection.js +4 -0
  64. package/dist/src/lib/log-inspection.js.map +1 -1
  65. package/dist/src/lib/output.d.ts +15 -0
  66. package/dist/src/lib/output.js +28 -0
  67. package/dist/src/lib/output.js.map +1 -1
  68. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  69. package/dist/src/lib/snapshot-audit-source.js +58 -0
  70. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  71. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  72. package/dist/src/lib/snapshot-audit-store.js +196 -0
  73. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  74. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  75. package/dist/src/lib/snapshot-audit.js +431 -0
  76. package/dist/src/lib/snapshot-audit.js.map +1 -0
  77. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  78. package/dist/src/lib/snapshot-build-rows.js +87 -0
  79. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  80. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +23 -16
  81. package/dist/src/lib/swift-codegen/functionGenerator.js +34 -33
  82. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  83. package/dist/src/lib/sync-selectors.d.ts +45 -2
  84. package/dist/src/lib/sync-selectors.js +66 -5
  85. package/dist/src/lib/sync-selectors.js.map +1 -1
  86. package/package.json +2 -2
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Which files `primitive documents ingest` reads, and in which order.
3
+ *
4
+ * Two layouts, and the directory itself says which one it is:
5
+ *
6
+ * - **plain** — `<dir>/<model>.ndjson` or `<model>.ndjson.gz`, one record per
7
+ * line. Nothing on disk promises the lines ascend, so they are sorted.
8
+ * - **export** — what `primitive documents export` wrote: a
9
+ * `snapshot/manifest.json` and its chunks, at the directory itself or under
10
+ * `documents/<document-id>/`. A snapshot's chunks ascend and are disjoint
11
+ * per model in manifest order, so an export needs no sort — it is read in
12
+ * that order and streamed straight through.
13
+ *
14
+ * A directory that is neither, or that is both, is refused naming what it
15
+ * held. Every refusal here happens before a session exists: an ingest replaces
16
+ * a live document's tables, and half of one is not something to discover from
17
+ * the server's side.
18
+ */
19
+ /** A directory that is not an ingest input, said as what was found. */
20
+ export declare class IngestInputError extends Error {
21
+ constructor(message: string);
22
+ }
23
+ /** One file of lines, and the model they belong to. */
24
+ export interface IngestSource {
25
+ model: string;
26
+ /** Absolute path on disk. */
27
+ file: string;
28
+ gzip: boolean;
29
+ /** What a `file:line` message calls it: relative to the input root. */
30
+ label: string;
31
+ }
32
+ /** What the input directory holds. */
33
+ export interface DiscoveredIngestInput {
34
+ layout: "plain" | "export";
35
+ /** The directory the sources are relative to. */
36
+ root: string;
37
+ /** In read order: manifest order for an export, model order for plain. */
38
+ sources: IngestSource[];
39
+ /** Parts of an export an ingest has no use for, named once on stderr. */
40
+ ignored: string[];
41
+ /** True when the read order is already ascending per model. */
42
+ presorted: boolean;
43
+ }
44
+ /**
45
+ * Decide what `dir` is and list the files to read, in order.
46
+ *
47
+ * `documentId` matters only for the export layout: an export directory may
48
+ * hold several documents, and re-ingesting one document's rows into another
49
+ * is not a thing to guess at.
50
+ */
51
+ export declare function discoverIngestInput(dir: string, documentId: string): DiscoveredIngestInput;
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Which files `primitive documents ingest` reads, and in which order.
3
+ *
4
+ * Two layouts, and the directory itself says which one it is:
5
+ *
6
+ * - **plain** — `<dir>/<model>.ndjson` or `<model>.ndjson.gz`, one record per
7
+ * line. Nothing on disk promises the lines ascend, so they are sorted.
8
+ * - **export** — what `primitive documents export` wrote: a
9
+ * `snapshot/manifest.json` and its chunks, at the directory itself or under
10
+ * `documents/<document-id>/`. A snapshot's chunks ascend and are disjoint
11
+ * per model in manifest order, so an export needs no sort — it is read in
12
+ * that order and streamed straight through.
13
+ *
14
+ * A directory that is neither, or that is both, is refused naming what it
15
+ * held. Every refusal here happens before a session exists: an ingest replaces
16
+ * a live document's tables, and half of one is not something to discover from
17
+ * the server's side.
18
+ */
19
+ import fs from "fs";
20
+ import path from "path";
21
+ import { chunkAddressOf } from "./snapshot-manifest-layout.js";
22
+ /** A directory that is not an ingest input, said as what was found. */
23
+ export class IngestInputError extends Error {
24
+ constructor(message) {
25
+ super(message);
26
+ this.name = "IngestInputError";
27
+ }
28
+ }
29
+ /** Files and directories an export carries that a bulk load does not read. */
30
+ const EXPORT_IGNORED = [
31
+ "epochs",
32
+ "current.yjs",
33
+ "chain.json",
34
+ "document.yjs",
35
+ "blobs",
36
+ ];
37
+ const LINE_FILE = /^(.+)\.ndjson(\.gz)?$/;
38
+ /**
39
+ * Decide what `dir` is and list the files to read, in order.
40
+ *
41
+ * `documentId` matters only for the export layout: an export directory may
42
+ * hold several documents, and re-ingesting one document's rows into another
43
+ * is not a thing to guess at.
44
+ */
45
+ export function discoverIngestInput(dir, documentId) {
46
+ if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) {
47
+ throw new IngestInputError(`Not a directory: ${dir}`);
48
+ }
49
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
50
+ const lineFiles = entries.filter((entry) => entry.isFile() && LINE_FILE.test(entry.name));
51
+ const hasOwnSnapshot = fs.existsSync(path.join(dir, "snapshot", "manifest.json"));
52
+ const documentsDir = path.join(dir, "documents");
53
+ const hasDocuments = fs.existsSync(documentsDir) && fs.statSync(documentsDir).isDirectory();
54
+ if (hasOwnSnapshot && lineFiles.length > 0) {
55
+ throw new IngestInputError(`${dir} holds both layouts: a snapshot/manifest.json and ` +
56
+ `${lineFiles.map((entry) => entry.name).join(", ")}. ` +
57
+ "An ingest reads one directory as one layout; split them.");
58
+ }
59
+ if (hasOwnSnapshot)
60
+ return exportInput(dir, dir);
61
+ if (hasDocuments && lineFiles.length === 0) {
62
+ const mine = path.join(documentsDir, documentId);
63
+ if (fs.existsSync(path.join(mine, "snapshot", "manifest.json"))) {
64
+ return exportInput(dir, mine);
65
+ }
66
+ const others = fs
67
+ .readdirSync(documentsDir, { withFileTypes: true })
68
+ .filter((entry) => entry.isDirectory())
69
+ .map((entry) => entry.name);
70
+ throw new IngestInputError(`This export holds ${others.length === 0 ? "no documents" : others.join(", ")}` +
71
+ ` and nothing for ${documentId}. Point --input at the export of the ` +
72
+ "document being ingested, or at its documents/<document-id> directory.");
73
+ }
74
+ if (lineFiles.length === 0) {
75
+ const found = entries.map((entry) => entry.name);
76
+ if (found.length === 0) {
77
+ throw new IngestInputError(`${dir} is empty. An ingest reads <model>.ndjson[.gz] files, or an ` +
78
+ "export's snapshot/manifest.json.");
79
+ }
80
+ throw new IngestInputError(`${dir} holds nothing an ingest can read: ${found.join(", ")}. ` +
81
+ "Expected <model>.ndjson[.gz] files, or an export's snapshot/manifest.json.");
82
+ }
83
+ // A plain directory with a stray file in it is still ambiguous: the stray
84
+ // may be the model file somebody meant to name, so it is named rather than
85
+ // quietly skipped.
86
+ const strays = entries
87
+ .filter((entry) => !(entry.isFile() && LINE_FILE.test(entry.name)))
88
+ .map((entry) => entry.name);
89
+ if (strays.length > 0) {
90
+ throw new IngestInputError(`${dir} holds files an ingest cannot read: ${strays.join(", ")}. ` +
91
+ "A plain input directory holds <model>.ndjson[.gz] files and nothing else.");
92
+ }
93
+ const sources = lineFiles
94
+ .map((entry) => {
95
+ const match = LINE_FILE.exec(entry.name);
96
+ return {
97
+ model: match[1],
98
+ file: path.join(dir, entry.name),
99
+ gzip: Boolean(match[2]),
100
+ label: entry.name,
101
+ };
102
+ })
103
+ .sort((left, right) => left.model.localeCompare(right.model));
104
+ return { layout: "plain", root: dir, sources, ignored: [], presorted: false };
105
+ }
106
+ /** The sources of an export rooted at `root`, in manifest order. */
107
+ function exportInput(dir, root) {
108
+ const manifestPath = path.join(root, "snapshot", "manifest.json");
109
+ let manifest;
110
+ try {
111
+ manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
112
+ }
113
+ catch (error) {
114
+ throw new IngestInputError(`${path.relative(dir, manifestPath) || manifestPath} is not readable JSON: ${error.message}`);
115
+ }
116
+ const chunks = Array.isArray(manifest?.chunks) ? manifest.chunks : null;
117
+ if (!chunks) {
118
+ throw new IngestInputError(`${path.relative(dir, manifestPath) || manifestPath} names no chunks.`);
119
+ }
120
+ const sources = chunks.map((chunk) => {
121
+ const address = chunkAddressOf(chunk);
122
+ const label = `snapshot/${address.model}/${address.index}.ndjson.gz`;
123
+ const file = path.join(root, "snapshot", address.model, `${address.index}.ndjson.gz`);
124
+ if (!fs.existsSync(file)) {
125
+ throw new IngestInputError(`The export's manifest names ${label}, which is not on disk.`);
126
+ }
127
+ return { model: address.model, file, gzip: true, label };
128
+ });
129
+ const ignored = EXPORT_IGNORED.filter((name) => fs.existsSync(path.join(root, name)));
130
+ return { layout: "export", root, sources, ignored, presorted: true };
131
+ }
132
+ //# sourceMappingURL=document-ingest-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-ingest-input.js","sourceRoot":"","sources":["../../../src/lib/document-ingest-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,uEAAuE;AACvE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAyBD,8EAA8E;AAC9E,MAAM,cAAc,GAAG;IACrB,QAAQ;IACR,aAAa;IACb,YAAY;IACZ,cAAc;IACd,OAAO;CACR,CAAC;AAEF,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,GAAW,EACX,UAAkB;IAElB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;QAC3D,MAAM,IAAI,gBAAgB,CAAC,oBAAoB,GAAG,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,SAAS,GAAG,OAAO,CAAC,MA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AAI,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Driving one bulk-load session: create, upload, commit, poll.
3
+ *
4
+ * The artifact is already built and checked by the time anything here runs
5
+ * (`document-ingest-artifact`), so every refusal this module reports comes
6
+ * from the server. What it decides is what to do about one:
7
+ *
8
+ * - a create the server refuses uploads nothing;
9
+ * - an upload that fails ABORTS the session rather than retrying a slot whose
10
+ * reservation this side cannot see — the artifact is deterministic and a
11
+ * re-run is cheap;
12
+ * - Ctrl-C during the uploads aborts too, because the session it was filling
13
+ * is not going to be committed; Ctrl-C while POLLING leaves the session
14
+ * alone, because by then the document is already being changed and giving up
15
+ * on watching is not giving up on the load.
16
+ *
17
+ * Exit codes follow `functions runs wait`/`invoke`, as `docs/cli-design.md`
18
+ * records them: 0 completed, 1 failed or refused, 124 a wait that gave up,
19
+ * 130 Ctrl-C.
20
+ */
21
+ import type { IngestArtifactPlan, IngestChunkDescriptor } from "./document-ingest-artifact.js";
22
+ /** A plan the operator did not confirm, or cannot be asked about. */
23
+ export declare class IngestRefusedError extends Error {
24
+ constructor(message: string);
25
+ }
26
+ /** The six calls driving a session; `ApiClient` supplies them in the verb. */
27
+ export interface IngestDriverClient {
28
+ createIngest(documentId: string): Promise<any>;
29
+ uploadIngestChunk(documentId: string, sessionId: string, chunk: IngestChunkDescriptor & {
30
+ body: Buffer;
31
+ }): Promise<any>;
32
+ commitIngest(documentId: string, sessionId: string): Promise<any>;
33
+ abortIngest(documentId: string, sessionId: string): Promise<any>;
34
+ getIngest(documentId: string, sessionId: string): Promise<any>;
35
+ }
36
+ export interface DriveIngestOptions {
37
+ client: IngestDriverClient;
38
+ documentId: string;
39
+ plan: IngestArtifactPlan;
40
+ /** Uploads in flight at once. */
41
+ concurrency?: number;
42
+ /** Poll until the session settles; `--no-wait` sets this false. */
43
+ wait?: boolean;
44
+ /** `--timeout`, in milliseconds; null waits indefinitely. */
45
+ timeoutMs?: number | null;
46
+ /** Ctrl-C. */
47
+ signal?: AbortSignal;
48
+ /** State changes and progress; stderr in the verb. */
49
+ onProgress?: (line: string) => void;
50
+ /** Where a chunk's bytes come from; the plan's own files by default. */
51
+ readChunk?: (chunk: IngestChunkDescriptor) => Promise<Buffer>;
52
+ now?: () => number;
53
+ sleep?: (ms: number) => Promise<void>;
54
+ }
55
+ /** What the run settled on. */
56
+ export interface IngestOutcome {
57
+ /** 0 complete, 1 failed or refused, 124 timed out, 130 interrupted. */
58
+ exitCode: number;
59
+ sessionId: string | null;
60
+ /** The terminal session view, when one was read. */
61
+ session: any | null;
62
+ /** The reason, for stderr. */
63
+ message?: string;
64
+ }
65
+ /** The plan summary an operator confirms, one line per row. */
66
+ export declare function summariseIngestPlan(plan: IngestArtifactPlan): string[];
67
+ /**
68
+ * Refuse a run that cannot ask, before it asks the server anything.
69
+ *
70
+ * A bulk load deletes and overwrites a live document's records with no undo,
71
+ * which is what the CLI design's destructive default is for. A pipeline that
72
+ * meant to run one says so with `-y`.
73
+ */
74
+ export declare function assertIngestConfirmable(options: {
75
+ yes: boolean;
76
+ isTTY: boolean;
77
+ }): void;
78
+ export declare function driveDocumentIngest(options: DriveIngestOptions): Promise<IngestOutcome>;
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Driving one bulk-load session: create, upload, commit, poll.
3
+ *
4
+ * The artifact is already built and checked by the time anything here runs
5
+ * (`document-ingest-artifact`), so every refusal this module reports comes
6
+ * from the server. What it decides is what to do about one:
7
+ *
8
+ * - a create the server refuses uploads nothing;
9
+ * - an upload that fails ABORTS the session rather than retrying a slot whose
10
+ * reservation this side cannot see — the artifact is deterministic and a
11
+ * re-run is cheap;
12
+ * - Ctrl-C during the uploads aborts too, because the session it was filling
13
+ * is not going to be committed; Ctrl-C while POLLING leaves the session
14
+ * alone, because by then the document is already being changed and giving up
15
+ * on watching is not giving up on the load.
16
+ *
17
+ * Exit codes follow `functions runs wait`/`invoke`, as `docs/cli-design.md`
18
+ * records them: 0 completed, 1 failed or refused, 124 a wait that gave up,
19
+ * 130 Ctrl-C.
20
+ */
21
+ import fs from "fs";
22
+ /** A plan the operator did not confirm, or cannot be asked about. */
23
+ export class IngestRefusedError extends Error {
24
+ constructor(message) {
25
+ super(message);
26
+ this.name = "IngestRefusedError";
27
+ }
28
+ }
29
+ const POLL_FAST_MS = 2_000;
30
+ const POLL_SLOW_MS = 5_000;
31
+ const POLL_SLOWS_AFTER_MS = 60_000;
32
+ /** The plan summary an operator confirms, one line per row. */
33
+ export function summariseIngestPlan(plan) {
34
+ const lines = plan.models.map((model) => ` ${model.model}: ${model.rows} rows, ${model.chunks} chunks, ` +
35
+ `${model.bytes} bytes` +
36
+ (model.deletes > 0 ? `, ${model.deletes} deletes` : ""));
37
+ return [
38
+ `${plan.rows} rows across ${plan.models.length} model(s), ` +
39
+ `${plan.chunks.length} chunks, ${plan.bytes} bytes` +
40
+ (plan.deletes > 0 ? `, ${plan.deletes} deletes` : ""),
41
+ ...lines,
42
+ ];
43
+ }
44
+ /**
45
+ * Refuse a run that cannot ask, before it asks the server anything.
46
+ *
47
+ * A bulk load deletes and overwrites a live document's records with no undo,
48
+ * which is what the CLI design's destructive default is for. A pipeline that
49
+ * meant to run one says so with `-y`.
50
+ */
51
+ export function assertIngestConfirmable(options) {
52
+ if (options.yes || options.isTTY)
53
+ return;
54
+ throw new IngestRefusedError("A bulk load replaces records in a live document and cannot be undone. " +
55
+ "Re-run with -y to confirm it without a prompt.");
56
+ }
57
+ export async function driveDocumentIngest(options) {
58
+ const { client, documentId, plan, concurrency = 4, wait = true, timeoutMs = null, signal, onProgress = () => { }, readChunk = async (chunk) => fs.readFileSync(chunk.file), now = () => Date.now(), sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), } = options;
59
+ // ── create ──
60
+ let session;
61
+ try {
62
+ session = await client.createIngest(documentId);
63
+ }
64
+ catch (error) {
65
+ if (error?.code === "DOCUMENT_INGEST_ACTIVE") {
66
+ const active = (error.details && error.details.sessionId) ?? "the active session";
67
+ return {
68
+ exitCode: 1,
69
+ sessionId: null,
70
+ session: null,
71
+ message: `${error.message}\nThis document already has bulk load ${active}. ` +
72
+ `Watch it with \`primitive documents ingests get ${documentId} ${active}\`, ` +
73
+ `or give it up with \`primitive documents ingests abort\`.`,
74
+ };
75
+ }
76
+ return {
77
+ exitCode: 1,
78
+ sessionId: null,
79
+ session: null,
80
+ message: String(error?.message ?? error),
81
+ };
82
+ }
83
+ const sessionId = String(session.sessionId);
84
+ onProgress(`Session ${sessionId} opened.`);
85
+ const giveUp = async (message, exitCode) => {
86
+ try {
87
+ await client.abortIngest(documentId, sessionId);
88
+ onProgress(`Session ${sessionId} aborted; nothing was applied.`);
89
+ }
90
+ catch (error) {
91
+ onProgress(`Session ${sessionId} could not be aborted: ${error?.message ?? error}`);
92
+ }
93
+ return { exitCode, sessionId, session: null, message };
94
+ };
95
+ // ── upload ──
96
+ const queue = [...plan.chunks];
97
+ let uploaded = 0;
98
+ let failure = null;
99
+ const worker = async () => {
100
+ for (;;) {
101
+ if (failure !== null || signal?.aborted)
102
+ return;
103
+ const chunk = queue.shift();
104
+ if (!chunk)
105
+ return;
106
+ try {
107
+ const body = await readChunk(chunk);
108
+ await client.uploadIngestChunk(documentId, sessionId, { ...chunk, body });
109
+ uploaded += 1;
110
+ onProgress(`Uploaded ${uploaded}/${plan.chunks.length} chunks ` +
111
+ `(${chunk.model} ${chunk.index}).`);
112
+ }
113
+ catch (error) {
114
+ // The first failure wins: the others are the same session going away.
115
+ if (failure === null)
116
+ failure = String(error?.message ?? error);
117
+ return;
118
+ }
119
+ }
120
+ };
121
+ await Promise.all(Array.from({ length: Math.max(1, Math.min(concurrency, queue.length || 1)) }, worker));
122
+ if (failure !== null)
123
+ return giveUp(failure, 1);
124
+ if (signal?.aborted) {
125
+ return giveUp("Interrupted while uploading; the session was aborted and nothing was applied.", 130);
126
+ }
127
+ // ── commit ──
128
+ try {
129
+ session = await client.commitIngest(documentId, sessionId);
130
+ }
131
+ catch (error) {
132
+ return giveUp(String(error?.message ?? error), 1);
133
+ }
134
+ onProgress(`Session ${sessionId} committed.`);
135
+ if (!wait) {
136
+ return { exitCode: 0, sessionId, session, message: undefined };
137
+ }
138
+ // ── poll ──
139
+ //
140
+ // Past this point the session is the server's business: the copy has begun
141
+ // and the document's tables will be swapped whatever this process does. So
142
+ // neither a timeout nor a Ctrl-C aborts it — both say so and leave.
143
+ const started = now();
144
+ let reported = null;
145
+ let reportedProgress = "";
146
+ for (;;) {
147
+ let view;
148
+ try {
149
+ view = await client.getIngest(documentId, sessionId);
150
+ }
151
+ catch (error) {
152
+ return {
153
+ exitCode: 1,
154
+ sessionId,
155
+ session: null,
156
+ message: String(error?.message ?? error),
157
+ };
158
+ }
159
+ if (view?.state !== reported) {
160
+ reported = view?.state ?? null;
161
+ onProgress(`Session ${sessionId} is ${reported}.`);
162
+ }
163
+ const progress = describeProgress(view?.progress);
164
+ if (progress && progress !== reportedProgress) {
165
+ reportedProgress = progress;
166
+ onProgress(` ${progress}`);
167
+ }
168
+ if (view?.state === "complete") {
169
+ return { exitCode: 0, sessionId, session: view };
170
+ }
171
+ if (view?.state === "failed" || view?.state === "aborted") {
172
+ return {
173
+ exitCode: 1,
174
+ sessionId,
175
+ session: view,
176
+ message: describeFailure(view),
177
+ };
178
+ }
179
+ const elapsed = now() - started;
180
+ if (timeoutMs !== null && elapsed >= timeoutMs) {
181
+ return {
182
+ exitCode: 124,
183
+ sessionId,
184
+ session: view,
185
+ message: `Gave up waiting after ${Math.round(elapsed / 1000)}s. The session ` +
186
+ `keeps running; watch it with \`primitive documents ingests get ` +
187
+ `${documentId} ${sessionId}\`.`,
188
+ };
189
+ }
190
+ await sleep(elapsed >= POLL_SLOWS_AFTER_MS ? POLL_SLOW_MS : POLL_FAST_MS);
191
+ if (signal?.aborted) {
192
+ return {
193
+ exitCode: 130,
194
+ sessionId,
195
+ session: view,
196
+ message: `Interrupted. The session keeps running; watch it with ` +
197
+ `\`primitive documents ingests get ${documentId} ${sessionId}\`.`,
198
+ };
199
+ }
200
+ }
201
+ }
202
+ /** The session's own words for why it stopped. */
203
+ function describeFailure(view) {
204
+ if (view?.state === "aborted")
205
+ return "The session was aborted.";
206
+ const failure = view?.failure;
207
+ if (!failure)
208
+ return "The session failed.";
209
+ // A failure's rows are `{ model, id }` on the wire, and a bounded sample of
210
+ // them; a string is accepted too so a stub or an older server still reads.
211
+ const rows = Array.isArray(failure.rows) && failure.rows.length > 0
212
+ ? `\n ${failure.rows
213
+ .map((row) => typeof row === "string" ? row : `${row?.model} ${row?.id}`)
214
+ .join("\n ")}`
215
+ : "";
216
+ return `${failure.code}: ${failure.reason}${rows}`;
217
+ }
218
+ /** One line of counters, or nothing while they are all still zero. */
219
+ function describeProgress(progress) {
220
+ if (!progress)
221
+ return "";
222
+ const copied = progress.rowsCopied ?? 0;
223
+ const chunks = progress.chunksApplied ?? 0;
224
+ const rows = progress.rowsApplied ?? 0;
225
+ const reconciled = progress.recordsReconciled ?? 0;
226
+ if (copied + chunks + rows + reconciled === 0)
227
+ return "";
228
+ return (`copied ${copied} rows, applied ${chunks} chunks / ${rows} rows, ` +
229
+ `reconciled ${reconciled} records`);
230
+ }
231
+ //# sourceMappingURL=document-ingest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-ingest.js","sourceRoot":"","sources":["../../../src/lib/document-ingest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAMpB,qEAAqE;AACrE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AA8CD,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAEnC,+DAA+D;AAC/D,MAAM,UAAU,mB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AAM,MAAM,GAAG,QAAQ,CAAC,UAAU,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,IAAI,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,IAAI,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,QAAQ,CAAC,iBAAiB,IAAI,CAAC,CAAC;IACnD,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,UAAU,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACzD,OAAO,CACL,UAAU,MAAM,kBAAkB,MAAM,aAAa,IAAI,SAAS;QAClE,cAAc,UAAU,UAAU,CACnC,CAAC;AACJ,CAAC"}
@@ -116,6 +116,12 @@ export interface EnvelopeShape {
116
116
  bundle: string;
117
117
  /** base64 of the collected manifest JSON, or null when there is none. */
118
118
  manifest?: string | null;
119
+ /**
120
+ * base64 of the project's authored `models/models.toml` bytes, or absent
121
+ * when the project declares no document schema (#3455). Must stay identical
122
+ * to the server's `FunctionEnvelope.documentSchema`.
123
+ */
124
+ documentSchema?: string | null;
119
125
  }
120
126
  /**
121
127
  * The canonical encoding both sides hash. Fixed key order, sources sorted by
@@ -135,6 +135,14 @@ export function canonicalFunctionEnvelopeBytes(envelope) {
135
135
  // `null` rather than absent when there is none, so the encoding of a
136
136
  // manifest-less push is stable rather than depending on a missing key.
137
137
  manifest: envelope.manifest ?? null,
138
+ // #3455 — the twin of the server's rule: the key is emitted ONLY when
139
+ // there is a schema, so a tree with no `models/models.toml` builds the
140
+ // same bytes it built before this change and its no-op detection is
141
+ // intact. `undefined` would be dropped by `JSON.stringify` anyway; the
142
+ // spread says the rule rather than relying on that.
143
+ ...(typeof envelope.documentSchema === "string" && envelope.documentSchema
144
+ ? { documentSchema: envelope.documentSchema }
145
+ : {}),
138
146
  };
139
147
  return new TextEncoder().encode(JSON.stringify(canonical));
140
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"function-bundle.js","sourceRoot":"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AC,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;KACR,CAAC;AACJ,CAAC"}
@@ -99,7 +99,7 @@ export declare function scanBundleForManifest(bundle: string): {
99
99
  * every other export are inert, so a module that calls one at import time
100
100
  * neither fails nor has an effect.
101
101
  */
102
- export declare const COLLECT_STUB_SOURCE = "\nconst registry = (globalThis.__PRIMITIVE_COLLECT_REGISTRY__ ||= []);\n\n// The default-coercion rule the SDK applies at registration (#3281,\n// D3281-SO-005), spelled here too so a default the declared type cannot\n// coerce is refused at PUSH \u2014 this stub is what push runs \u2014 rather than at\n// the first invocation. The vendored grammar (`coerceParamDefault` in\n// generated-config-surfaces.ts) is the same rule and re-checks the manifest.\nconst SCALAR_TYPES = [\"string\", \"number\", \"boolean\", \"any\"];\nfunction coerceScalar(type, value) {\n if (type === \"number\") {\n const n = typeof value === \"number\" ? value : Number(value);\n if (typeof value === \"boolean\" || value === null || value === \"\" || !Number.isFinite(n)) {\n return { ok: false, reason: \"must be a number\" };\n }\n return { ok: true, value: n };\n }\n if (type === \"boolean\") {\n if (typeof value === \"boolean\") return { ok: true, value };\n if (value === \"true\") return { ok: true, value: true };\n if (value === \"false\") return { ok: true, value: false };\n return { ok: false, reason: \"must be a boolean\" };\n }\n if (type === \"string\") {\n if (typeof value !== \"string\") return { ok: false, reason: \"must be a string\" };\n return { ok: true, value };\n }\n return { ok: true, value };\n}\nfunction coerceDefault(spec, value) {\n if (spec.type === \"array\") {\n if (!Array.isArray(value)) return { ok: false, reason: \"must be an array\" };\n const itemType = spec.items && spec.items.type ? String(spec.items.type) : \"any\";\n const out = [];\n for (const element of value) {\n const coerced = coerceScalar(itemType, element);\n if (!coerced.ok) return { ok: false, reason: \"every element \" + coerced.reason };\n out.push(coerced.value);\n }\n return { ok: true, value: out };\n }\n return coerceScalar(spec.type === undefined ? \"any\" : String(spec.type), value);\n}\n\nfunction record(kind, name, config) {\n const c = config || {};\n const params = {};\n for (const [key, value] of Object.entries(c.params || {})) {\n const spec = value && typeof value === \"object\" ? value : { type: String(value) };\n const entry = {};\n const fail = (message) => {\n throw new Error(\"'\" + name + \"': parameter '\" + key + \"' \" + message);\n };\n if (spec.type !== undefined) entry.type = String(spec.type);\n if (entry.type === \"array\") {\n if (spec.items !== undefined && spec.items !== null) {\n const itemType =\n spec.items && typeof spec.items === \"object\" ? String(spec.items.type ?? \"\") : \"\";\n if (!SCALAR_TYPES.includes(itemType)) {\n fail(\"declares an `items` type outside \" + SCALAR_TYPES.join(\", \") + \".\");\n }\n entry.items = { type: itemType };\n }\n if (spec.caller === true) fail(\"is an array bound to $caller; `caller` is a scalar binding.\");\n }\n if (spec.default !== undefined) {\n const coerced = coerceDefault(entry, spec.default);\n if (!coerced.ok) fail(\"has a default that \" + coerced.reason + \".\");\n entry.default = coerced.value;\n }\n if (spec.caller === true || spec === \"$caller\" || spec.type === \"$caller\") {\n entry.caller = true;\n }\n params[String(key)] = entry;\n }\n const declaredCaller = Object.values(params).some((p) => p.caller === true);\n registry.push({\n kind,\n name: String(name),\n models: Array.isArray(c.models) ? c.models.map(String) : [],\n params,\n cache:\n c.cache && typeof c.cache === \"object\" && Number(c.cache.ttlMs) > 0\n ? { ttlMs: Number(c.cache.ttlMs) }\n : null,\n callerScoped: declaredCaller,\n });\n return async () => {\n throw new Error(\n \"'\" + name + \"' was called during manifest collection; a registration's \" +\n \"`run` only executes inside a real invocation.\"\n );\n };\n}\n\n// The PUBLIC surface, all of it. An ESM import of a name a module does not\n// export is a build error, so a stub missing one export refuses a tree the\n// sandbox would have run \u2014 collection is mandatory, so that is a valid\n// function that cannot be pushed at all (CR3187-007). The constants carry the\n// runtime's own values so a registration computed from one collects the same\n// way it will run.\nexport const SDK_STUB_VERSION = \"collect\";\nexport const MAX_QUERY_CACHE_TTL_MS = 60000;\nexport const PMAP_DEFAULT_CONCURRENCY = 8;\nexport function defineQuery(name, config) { return record(\"query\", name, config); }\nexport function defineMutation(name, config) { return record(\"mutation\", name, config); }\nexport function defineFunction(keyOrHandler, maybeHandler) {\n // The KEYED form (#3281) returns a wrapper CARRYING its key, exactly as the\n // baked SDK's does. That is what push reads: the child resolves the callable\n // the bootstrap would select and compares THAT key to the file's\n // (D3281-SO-006). The registry entry is the child's report of what the\n // module scope did; it is not what the check consults, because a keyed\n // handler an entry merely imports for composition registers here too.\n if (typeof keyOrHandler === \"string\" || maybeHandler !== undefined) {\n registry.push({ kind: \"function\", name: String(keyOrHandler) });\n const wrapped = function (...args) {\n return maybeHandler(...args);\n };\n wrapped.functionKey = String(keyOrHandler);\n return wrapped;\n }\n return keyOrHandler;\n}\nexport function pMap(items, mapper) { return Promise.all((items || []).map(mapper)); }\nexport function ulid() { return \"00000000000000000000000000\"; }\nexport const stepPolicy = new Proxy({}, { get: () => ({}) });\nexport default {\n SDK_STUB_VERSION,\n defineFunction,\n defineQuery,\n defineMutation,\n pMap,\n ulid,\n};\n";
102
+ export declare const COLLECT_STUB_SOURCE = "\nconst registry = (globalThis.__PRIMITIVE_COLLECT_REGISTRY__ ||= []);\n\n// The default-coercion rule the SDK applies at registration (#3281,\n// D3281-SO-005), spelled here too so a default the declared type cannot\n// coerce is refused at PUSH \u2014 this stub is what push runs \u2014 rather than at\n// the first invocation. The vendored grammar (`coerceParamDefault` in\n// generated-config-surfaces.ts) is the same rule and re-checks the manifest.\nconst SCALAR_TYPES = [\"string\", \"number\", \"boolean\", \"any\"];\nfunction coerceScalar(type, value) {\n if (type === \"number\") {\n const n = typeof value === \"number\" ? value : Number(value);\n if (typeof value === \"boolean\" || value === null || value === \"\" || !Number.isFinite(n)) {\n return { ok: false, reason: \"must be a number\" };\n }\n return { ok: true, value: n };\n }\n if (type === \"boolean\") {\n if (typeof value === \"boolean\") return { ok: true, value };\n if (value === \"true\") return { ok: true, value: true };\n if (value === \"false\") return { ok: true, value: false };\n return { ok: false, reason: \"must be a boolean\" };\n }\n if (type === \"string\") {\n if (typeof value !== \"string\") return { ok: false, reason: \"must be a string\" };\n return { ok: true, value };\n }\n return { ok: true, value };\n}\nfunction coerceDefault(spec, value) {\n if (spec.type === \"array\") {\n if (!Array.isArray(value)) return { ok: false, reason: \"must be an array\" };\n const itemType = spec.items && spec.items.type ? String(spec.items.type) : \"any\";\n const out = [];\n for (const element of value) {\n const coerced = coerceScalar(itemType, element);\n if (!coerced.ok) return { ok: false, reason: \"every element \" + coerced.reason };\n out.push(coerced.value);\n }\n return { ok: true, value: out };\n }\n return coerceScalar(spec.type === undefined ? \"any\" : String(spec.type), value);\n}\n\nfunction record(kind, name, config) {\n const c = config || {};\n const params = {};\n for (const [key, value] of Object.entries(c.params || {})) {\n const spec = value && typeof value === \"object\" ? value : { type: String(value) };\n const entry = {};\n const fail = (message) => {\n throw new Error(\"'\" + name + \"': parameter '\" + key + \"' \" + message);\n };\n if (spec.type !== undefined) entry.type = String(spec.type);\n if (entry.type === \"array\") {\n if (spec.items !== undefined && spec.items !== null) {\n const itemType =\n spec.items && typeof spec.items === \"object\" ? String(spec.items.type ?? \"\") : \"\";\n if (!SCALAR_TYPES.includes(itemType)) {\n fail(\"declares an `items` type outside \" + SCALAR_TYPES.join(\", \") + \".\");\n }\n entry.items = { type: itemType };\n }\n if (spec.caller === true) fail(\"is an array bound to $caller; `caller` is a scalar binding.\");\n }\n if (spec.default !== undefined) {\n const coerced = coerceDefault(entry, spec.default);\n if (!coerced.ok) fail(\"has a default that \" + coerced.reason + \".\");\n entry.default = coerced.value;\n }\n if (spec.caller === true || spec === \"$caller\" || spec.type === \"$caller\") {\n entry.caller = true;\n }\n params[String(key)] = entry;\n }\n const declaredCaller = Object.values(params).some((p) => p.caller === true);\n registry.push({\n kind,\n name: String(name),\n models: Array.isArray(c.models) ? c.models.map(String) : [],\n params,\n cache:\n c.cache && typeof c.cache === \"object\" && Number(c.cache.ttlMs) > 0\n ? { ttlMs: Number(c.cache.ttlMs) }\n : null,\n callerScoped: declaredCaller,\n });\n return async () => {\n throw new Error(\n \"'\" + name + \"' was called during manifest collection; a registration's \" +\n \"`run` only executes inside a real invocation.\"\n );\n };\n}\n\n// The PUBLIC surface, all of it. An ESM import of a name a module does not\n// export is a build error, so a stub missing one export refuses a tree the\n// sandbox would have run \u2014 collection is mandatory, so that is a valid\n// function that cannot be pushed at all (CR3187-007). The constants carry the\n// runtime's own values so a registration computed from one collects the same\n// way it will run.\nexport const SDK_STUB_VERSION = \"collect\";\nexport const MAX_QUERY_CACHE_TTL_MS = 60000;\nexport const PMAP_DEFAULT_CONCURRENCY = 8;\nexport function defineQuery(name, config) { return record(\"query\", name, config); }\nexport function defineMutation(name, config) { return record(\"mutation\", name, config); }\nexport function defineFunction(keyOrHandler, maybeHandler) {\n // The KEYED form (#3281) returns a wrapper CARRYING its key, exactly as the\n // baked SDK's does. That is what push reads: the child resolves the callable\n // the bootstrap would select and compares THAT key to the file's\n // (D3281-SO-006). The registry entry is the child's report of what the\n // module scope did; it is not what the check consults, because a keyed\n // handler an entry merely imports for composition registers here too.\n if (typeof keyOrHandler === \"string\" || maybeHandler !== undefined) {\n registry.push({ kind: \"function\", name: String(keyOrHandler) });\n const wrapped = function (...args) {\n return maybeHandler(...args);\n };\n wrapped.functionKey = String(keyOrHandler);\n return wrapped;\n }\n return keyOrHandler;\n}\nexport function pMap(items, mapper) { return Promise.all((items || []).map(mapper)); }\nexport function ulid() { return \"00000000000000000000000000\"; }\nexport const stepPolicy = new Proxy({}, { get: () => ({}) });\n// #3482 \u2014 the runtime surface, and `assertRuntime` is INERT here on purpose.\n// Collection has no runtime: this child process exists to learn what a tree\n// registers, and there is nothing for an assertion to be about. A stub that\n// threw would refuse exactly the functions the assertion exists for \u2014 and the\n// placement the guide teaches is module scope, which collection runs.\nexport function assertRuntime() {}\nexport class FunctionRuntimeError extends Error {\n constructor(message, runtime, required) {\n super(message);\n this.name = \"FUNCTION_RUNTIME_REFUSED\";\n this.runtime = runtime;\n this.required = required;\n }\n}\nexport default {\n SDK_STUB_VERSION,\n defineFunction,\n defineQuery,\n defineMutation,\n pMap,\n ulid,\n assertRuntime,\n FunctionRuntimeError,\n};\n";
103
103
  /**
104
104
  * Collect one function's manifest.
105
105
  *