@pyxmate/memory 1.23.2 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-6EEEOV6B.mjs +0 -0
- package/dist/{chunk-7YHCNO3N.mjs → chunk-L2RHO7DP.mjs} +1 -1
- package/dist/{chunk-SGL73IY5.mjs → chunk-LF22PCY6.mjs} +1 -1
- package/dist/{chunk-C46EE5BH.mjs → chunk-VXXRCAKS.mjs} +416 -3
- package/dist/cli/pyx-mem.mjs +751 -139
- package/dist/dashboard.mjs +3 -3
- package/dist/{data-plane-contract-C5VqxrpF.d.ts → data-plane-contract-CGU0qjv4.d.ts} +121 -1
- package/dist/data-plane-contract.d.ts +1 -1
- package/dist/data-plane-contract.mjs +26 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/react.mjs +3 -3
- package/package.json +1 -1
|
File without changes
|
|
@@ -164,6 +164,38 @@ var DATA_PLANE_COMPILER_LIMITS = {
|
|
|
164
164
|
graphEntities: 1e3,
|
|
165
165
|
graphRelationships: 2e3
|
|
166
166
|
};
|
|
167
|
+
var HOSTED_FILE_INGEST_PROTOCOL = {
|
|
168
|
+
version: 1,
|
|
169
|
+
capability: "hosted-file-ingest-v1",
|
|
170
|
+
capabilityHeader: "X-Pyx-Gateway-Capabilities",
|
|
171
|
+
uploadTokenHeader: "X-Pyx-Upload-Token",
|
|
172
|
+
metaKey: "pyx.dev/hosted-file-ingest",
|
|
173
|
+
routeBase: "/api/memory/file-ingests",
|
|
174
|
+
preparationVersion: "pyx-file-prepare-v1"
|
|
175
|
+
};
|
|
176
|
+
var HOSTED_FILE_INGEST_LIMITS = {
|
|
177
|
+
maxFileBytes: 50 * 1024 * 1024,
|
|
178
|
+
maxFilenameBytes: 255,
|
|
179
|
+
maxExtractedUtf8Bytes: 4 * 1024 * 1024,
|
|
180
|
+
maxChunks: 4096,
|
|
181
|
+
maxChunkUtf8Bytes: 16 * 1024,
|
|
182
|
+
maxPageEntries: 50,
|
|
183
|
+
maxPageEmbeddingUtf8Bytes: 256 * 1024,
|
|
184
|
+
maxPageCanonicalBytes: 512 * 1024,
|
|
185
|
+
maxManifestCanonicalBytes: 256 * 1024,
|
|
186
|
+
uploadTokenTtlMs: 10 * 60 * 1e3,
|
|
187
|
+
prepareTimeoutMs: 60 * 1e3,
|
|
188
|
+
jobTtlMs: 24 * 60 * 60 * 1e3
|
|
189
|
+
};
|
|
190
|
+
var HOSTED_FILE_INGEST_JOB_STATES = [
|
|
191
|
+
"awaiting_upload",
|
|
192
|
+
"uploaded",
|
|
193
|
+
"prepared",
|
|
194
|
+
"published",
|
|
195
|
+
"failed",
|
|
196
|
+
"cancelled",
|
|
197
|
+
"expired"
|
|
198
|
+
];
|
|
167
199
|
var MEMORY_TYPES = ["short-term", "long-term", "working", "episodic", "summary"];
|
|
168
200
|
var ENTRY_STATUSES = ["active", "superseded", "archived"];
|
|
169
201
|
var SENSITIVITY_LEVELS = ["public", "internal", "secret"];
|
|
@@ -199,6 +231,10 @@ var DATA_PLANE_OPERATION_COVERAGE = {
|
|
|
199
231
|
"rest:batch_store": {
|
|
200
232
|
support: "journal_multi_step"
|
|
201
233
|
},
|
|
234
|
+
"rest:file_ingest_begin": { support: "journal_multi_step" },
|
|
235
|
+
"rest:file_ingest_prepare": { support: "journal_multi_step" },
|
|
236
|
+
"rest:file_ingest_commit": { support: "journal_multi_step" },
|
|
237
|
+
"rest:file_ingest_publish": { support: "journal_multi_step" },
|
|
202
238
|
"rest:get": { support: "sqlite_atomic_one_step" },
|
|
203
239
|
"rest:expand": { support: "sqlite_atomic_one_step" },
|
|
204
240
|
"rest:delete": {
|
|
@@ -911,6 +947,128 @@ function normalizeBatchStore(input, context) {
|
|
|
911
947
|
}
|
|
912
948
|
return { entries };
|
|
913
949
|
}
|
|
950
|
+
var HOSTED_FILE_INGEST_JOB_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
951
|
+
var SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
952
|
+
function requireHostedFileIngestJobId(value, field) {
|
|
953
|
+
const text = requireString(value, field, { maxBytes: 36 });
|
|
954
|
+
if (!HOSTED_FILE_INGEST_JOB_ID_RE.test(text)) {
|
|
955
|
+
throw new Error(`${field} must be a lowercase UUIDv4`);
|
|
956
|
+
}
|
|
957
|
+
return text;
|
|
958
|
+
}
|
|
959
|
+
function requireSha256Hex(value, field) {
|
|
960
|
+
const text = requireString(value, field, { maxBytes: 64 });
|
|
961
|
+
if (!SHA256_HEX_RE.test(text)) throw new Error(`${field} must be a lowercase SHA-256 hex digest`);
|
|
962
|
+
return text;
|
|
963
|
+
}
|
|
964
|
+
function requireHostedFileIngestFilename(value, field) {
|
|
965
|
+
const name = requireString(value, field, {
|
|
966
|
+
maxBytes: HOSTED_FILE_INGEST_LIMITS.maxFilenameBytes
|
|
967
|
+
});
|
|
968
|
+
if (name.includes("/") || name.includes("\\") || name.startsWith(".") || // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what this rejects
|
|
969
|
+
/[\u0000-\u001f\u007f]/.test(name)) {
|
|
970
|
+
throw new Error(`${field} must be a plain filename`);
|
|
971
|
+
}
|
|
972
|
+
return name;
|
|
973
|
+
}
|
|
974
|
+
function normalizeFileIngestBegin(input) {
|
|
975
|
+
const value = requireObject(input, "input");
|
|
976
|
+
requireExactKeys(value, ["jobId", "filename", "byteLength", "sha256", "description"], "input");
|
|
977
|
+
const normalized = {
|
|
978
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "input.jobId"),
|
|
979
|
+
filename: requireHostedFileIngestFilename(value.filename, "input.filename"),
|
|
980
|
+
byteLength: requireInteger(
|
|
981
|
+
value.byteLength,
|
|
982
|
+
"input.byteLength",
|
|
983
|
+
1,
|
|
984
|
+
HOSTED_FILE_INGEST_LIMITS.maxFileBytes
|
|
985
|
+
),
|
|
986
|
+
sha256: requireSha256Hex(value.sha256, "input.sha256")
|
|
987
|
+
};
|
|
988
|
+
withOptional(normalized, "description", optionalString(value.description, "input.description"));
|
|
989
|
+
return normalized;
|
|
990
|
+
}
|
|
991
|
+
function normalizeFileIngestJob(input) {
|
|
992
|
+
const value = requireObject(input, "input");
|
|
993
|
+
requireExactKeys(value, ["jobId"], "input");
|
|
994
|
+
return { jobId: requireHostedFileIngestJobId(value.jobId, "input.jobId") };
|
|
995
|
+
}
|
|
996
|
+
function normalizeHostedFileIngestPageDescriptor(input, field) {
|
|
997
|
+
const value = requireObject(input, field);
|
|
998
|
+
const keys = [
|
|
999
|
+
"pageIndex",
|
|
1000
|
+
"firstChunkIndex",
|
|
1001
|
+
"chunkCount",
|
|
1002
|
+
"pageSha256",
|
|
1003
|
+
"embeddingInputSha256",
|
|
1004
|
+
"embeddingUnicodeScalars",
|
|
1005
|
+
"embeddingUtf8Bytes"
|
|
1006
|
+
];
|
|
1007
|
+
requireExactKeys(value, keys, field);
|
|
1008
|
+
const limits = HOSTED_FILE_INGEST_LIMITS;
|
|
1009
|
+
const firstChunkIndex = requireInteger(
|
|
1010
|
+
value.firstChunkIndex,
|
|
1011
|
+
`${field}.firstChunkIndex`,
|
|
1012
|
+
0,
|
|
1013
|
+
limits.maxChunks - 1
|
|
1014
|
+
);
|
|
1015
|
+
const chunkCount = requireInteger(
|
|
1016
|
+
value.chunkCount,
|
|
1017
|
+
`${field}.chunkCount`,
|
|
1018
|
+
1,
|
|
1019
|
+
limits.maxPageEntries
|
|
1020
|
+
);
|
|
1021
|
+
if (firstChunkIndex + chunkCount > limits.maxChunks) {
|
|
1022
|
+
throw new Error(`${field} exceeds ${limits.maxChunks} chunks`);
|
|
1023
|
+
}
|
|
1024
|
+
const embeddingUtf8Bytes = requireInteger(
|
|
1025
|
+
value.embeddingUtf8Bytes,
|
|
1026
|
+
`${field}.embeddingUtf8Bytes`,
|
|
1027
|
+
1,
|
|
1028
|
+
limits.maxPageEmbeddingUtf8Bytes
|
|
1029
|
+
);
|
|
1030
|
+
return {
|
|
1031
|
+
pageIndex: requireInteger(value.pageIndex, `${field}.pageIndex`, 0, limits.maxChunks - 1),
|
|
1032
|
+
firstChunkIndex,
|
|
1033
|
+
chunkCount,
|
|
1034
|
+
pageSha256: requireSha256Hex(value.pageSha256, `${field}.pageSha256`),
|
|
1035
|
+
embeddingInputSha256: requireSha256Hex(
|
|
1036
|
+
value.embeddingInputSha256,
|
|
1037
|
+
`${field}.embeddingInputSha256`
|
|
1038
|
+
),
|
|
1039
|
+
// Every Unicode scalar occupies at least one UTF-8 byte.
|
|
1040
|
+
embeddingUnicodeScalars: requireInteger(
|
|
1041
|
+
value.embeddingUnicodeScalars,
|
|
1042
|
+
`${field}.embeddingUnicodeScalars`,
|
|
1043
|
+
1,
|
|
1044
|
+
embeddingUtf8Bytes
|
|
1045
|
+
),
|
|
1046
|
+
embeddingUtf8Bytes
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
function normalizeFileIngestCommit(input) {
|
|
1050
|
+
const value = requireObject(input, "input");
|
|
1051
|
+
requireExactKeys(value, ["jobId", "manifestSha256", "page"], "input");
|
|
1052
|
+
return {
|
|
1053
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "input.jobId"),
|
|
1054
|
+
manifestSha256: requireSha256Hex(value.manifestSha256, "input.manifestSha256"),
|
|
1055
|
+
page: { ...normalizeHostedFileIngestPageDescriptor(value.page, "input.page") }
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
function normalizeFileIngestPublish(input) {
|
|
1059
|
+
const value = requireObject(input, "input");
|
|
1060
|
+
requireExactKeys(value, ["jobId", "manifestSha256", "entryCount"], "input");
|
|
1061
|
+
return {
|
|
1062
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "input.jobId"),
|
|
1063
|
+
manifestSha256: requireSha256Hex(value.manifestSha256, "input.manifestSha256"),
|
|
1064
|
+
entryCount: requireInteger(
|
|
1065
|
+
value.entryCount,
|
|
1066
|
+
"input.entryCount",
|
|
1067
|
+
1,
|
|
1068
|
+
HOSTED_FILE_INGEST_LIMITS.maxChunks
|
|
1069
|
+
)
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
914
1072
|
function normalizeSearch(input, mcp) {
|
|
915
1073
|
const value = requireObject(input, "input");
|
|
916
1074
|
const keys = [
|
|
@@ -1092,6 +1250,14 @@ function normalizeSupportedInput(operation, input, context) {
|
|
|
1092
1250
|
return normalizeStore(input, context, true);
|
|
1093
1251
|
case "rest:batch_store":
|
|
1094
1252
|
return normalizeBatchStore(input, context);
|
|
1253
|
+
case "rest:file_ingest_begin":
|
|
1254
|
+
return normalizeFileIngestBegin(input);
|
|
1255
|
+
case "rest:file_ingest_prepare":
|
|
1256
|
+
return normalizeFileIngestJob(input);
|
|
1257
|
+
case "rest:file_ingest_commit":
|
|
1258
|
+
return normalizeFileIngestCommit(input);
|
|
1259
|
+
case "rest:file_ingest_publish":
|
|
1260
|
+
return normalizeFileIngestPublish(input);
|
|
1095
1261
|
case "rest:search":
|
|
1096
1262
|
return normalizeSearch(input, false);
|
|
1097
1263
|
case "mcp:search_memories":
|
|
@@ -1177,6 +1343,9 @@ function requireExecutionScope(operation, context) {
|
|
|
1177
1343
|
if (context.runtimeAttestation.tenantMode === "multi" && namespaceRequiredInMulti.has(operation) && context.scope.namespaceId === void 0) {
|
|
1178
1344
|
throw new Error(`${operation} requires trusted context.scope.namespaceId in multi-tenant mode`);
|
|
1179
1345
|
}
|
|
1346
|
+
if (operation.startsWith("rest:file_ingest_") && (context.scope.userId !== void 0 || context.scope.teamId !== void 0)) {
|
|
1347
|
+
throw new Error(`${operation} does not accept user or team scope`);
|
|
1348
|
+
}
|
|
1180
1349
|
if (operation === "mcp:get_user_profile" || operation === "mcp:upsert_user_profile") {
|
|
1181
1350
|
if (context.scope.namespaceId === void 0) {
|
|
1182
1351
|
throw new Error(`${operation} requires trusted context.scope.namespaceId`);
|
|
@@ -1454,6 +1623,10 @@ function compileDataPlaneRequest(request) {
|
|
|
1454
1623
|
case "rest:reinforce":
|
|
1455
1624
|
case "mcp:reinforce":
|
|
1456
1625
|
return ["vector", "sqlite"];
|
|
1626
|
+
case "rest:file_ingest_commit":
|
|
1627
|
+
return ["embedding", "sqlite"];
|
|
1628
|
+
case "rest:file_ingest_publish":
|
|
1629
|
+
return ["vector", "sqlite"];
|
|
1457
1630
|
default:
|
|
1458
1631
|
return ["sqlite"];
|
|
1459
1632
|
}
|
|
@@ -1470,7 +1643,8 @@ function compileDataPlaneRequest(request) {
|
|
|
1470
1643
|
}))
|
|
1471
1644
|
};
|
|
1472
1645
|
const manifest = hashDataPlaneManifestV1(executionPlan);
|
|
1473
|
-
const
|
|
1646
|
+
const filePage = supportedOperation === "rest:file_ingest_commit" ? normalizedInput.page : void 0;
|
|
1647
|
+
const embeddingUnicodeScalars = filePage !== void 0 ? filePage.embeddingUnicodeScalars : supportedOperation === "rest:store" || supportedOperation === "mcp:store_memory" ? storeHasTarget("vector") ? Array.from(normalizedInput.content).length : 0 : supportedOperation === "rest:batch_store" ? storeEntries.reduce(
|
|
1474
1648
|
(total, entry2) => total + (entry2.targets.includes("vector") ? Array.from(entry2.content).length : 0),
|
|
1475
1649
|
0
|
|
1476
1650
|
) : supportedOperation === "rest:search" || supportedOperation === "mcp:search_memories" ? Array.from(normalizedInput.query).length : 0;
|
|
@@ -1487,12 +1661,240 @@ function compileDataPlaneRequest(request) {
|
|
|
1487
1661
|
manifestCanonicalJson: manifest.canonicalJson,
|
|
1488
1662
|
manifestSha256: manifest.sha256,
|
|
1489
1663
|
quoteDimensions: {
|
|
1490
|
-
databaseOperations: supportedOperation === "rest:batch_store" ? normalizedInput.entries.length : 1,
|
|
1664
|
+
databaseOperations: supportedOperation === "rest:batch_store" ? normalizedInput.entries.length : filePage !== void 0 ? filePage.chunkCount : 1,
|
|
1491
1665
|
embeddingUnicodeScalars,
|
|
1492
1666
|
embeddingEvents: embeddingUnicodeScalars > 0 ? 1 : 0
|
|
1493
1667
|
}
|
|
1494
1668
|
};
|
|
1495
1669
|
}
|
|
1670
|
+
function normalizeHostedFileIngestManifest(input, field) {
|
|
1671
|
+
const value = requireObject(input, field);
|
|
1672
|
+
requireExactKeys(
|
|
1673
|
+
value,
|
|
1674
|
+
[
|
|
1675
|
+
"manifestSha256",
|
|
1676
|
+
"preparationVersion",
|
|
1677
|
+
"entryCount",
|
|
1678
|
+
"pageCount",
|
|
1679
|
+
"extractedUtf8Bytes",
|
|
1680
|
+
"embeddingUnicodeScalars",
|
|
1681
|
+
"pages"
|
|
1682
|
+
],
|
|
1683
|
+
field
|
|
1684
|
+
);
|
|
1685
|
+
const limits = HOSTED_FILE_INGEST_LIMITS;
|
|
1686
|
+
if (!Array.isArray(value.pages) || value.pages.length < 1) {
|
|
1687
|
+
throw new Error(`${field}.pages must be a non-empty array`);
|
|
1688
|
+
}
|
|
1689
|
+
const pages = value.pages.map(
|
|
1690
|
+
(page, index) => normalizeHostedFileIngestPageDescriptor(page, `${field}.pages[${index}]`)
|
|
1691
|
+
);
|
|
1692
|
+
let nextChunk = 0;
|
|
1693
|
+
let scalars = 0;
|
|
1694
|
+
for (const [index, page] of pages.entries()) {
|
|
1695
|
+
if (page.pageIndex !== index || page.firstChunkIndex !== nextChunk) {
|
|
1696
|
+
throw new Error(`${field}.pages[${index}] is out of sequence`);
|
|
1697
|
+
}
|
|
1698
|
+
nextChunk += page.chunkCount;
|
|
1699
|
+
scalars += page.embeddingUnicodeScalars;
|
|
1700
|
+
}
|
|
1701
|
+
const manifest = {
|
|
1702
|
+
manifestSha256: requireSha256Hex(value.manifestSha256, `${field}.manifestSha256`),
|
|
1703
|
+
preparationVersion: requireString(value.preparationVersion, `${field}.preparationVersion`, {
|
|
1704
|
+
maxBytes: 64
|
|
1705
|
+
}),
|
|
1706
|
+
entryCount: requireInteger(value.entryCount, `${field}.entryCount`, 1, limits.maxChunks),
|
|
1707
|
+
pageCount: requireInteger(value.pageCount, `${field}.pageCount`, 1, limits.maxChunks),
|
|
1708
|
+
extractedUtf8Bytes: requireInteger(
|
|
1709
|
+
value.extractedUtf8Bytes,
|
|
1710
|
+
`${field}.extractedUtf8Bytes`,
|
|
1711
|
+
1,
|
|
1712
|
+
limits.maxExtractedUtf8Bytes
|
|
1713
|
+
),
|
|
1714
|
+
embeddingUnicodeScalars: requireInteger(
|
|
1715
|
+
value.embeddingUnicodeScalars,
|
|
1716
|
+
`${field}.embeddingUnicodeScalars`,
|
|
1717
|
+
1,
|
|
1718
|
+
Number.MAX_SAFE_INTEGER
|
|
1719
|
+
),
|
|
1720
|
+
pages
|
|
1721
|
+
};
|
|
1722
|
+
if (manifest.pageCount !== pages.length || manifest.entryCount !== nextChunk || manifest.embeddingUnicodeScalars !== scalars) {
|
|
1723
|
+
throw new Error(`${field} totals do not match its pages`);
|
|
1724
|
+
}
|
|
1725
|
+
return manifest;
|
|
1726
|
+
}
|
|
1727
|
+
function requireIsoField(value, field) {
|
|
1728
|
+
return requireCanonicalIso(value, field);
|
|
1729
|
+
}
|
|
1730
|
+
function normalizeHostedFileIngestPublication(input, field) {
|
|
1731
|
+
const value = requireObject(input, field);
|
|
1732
|
+
requireExactKeys(value, ["entryCount", "retiredCount", "fileId"], field);
|
|
1733
|
+
return {
|
|
1734
|
+
entryCount: requireInteger(
|
|
1735
|
+
value.entryCount,
|
|
1736
|
+
`${field}.entryCount`,
|
|
1737
|
+
1,
|
|
1738
|
+
HOSTED_FILE_INGEST_LIMITS.maxChunks
|
|
1739
|
+
),
|
|
1740
|
+
retiredCount: requireInteger(
|
|
1741
|
+
value.retiredCount,
|
|
1742
|
+
`${field}.retiredCount`,
|
|
1743
|
+
0,
|
|
1744
|
+
Number.MAX_SAFE_INTEGER
|
|
1745
|
+
),
|
|
1746
|
+
fileId: requireString(value.fileId, `${field}.fileId`, { maxBytes: 64 })
|
|
1747
|
+
};
|
|
1748
|
+
}
|
|
1749
|
+
function parseHostedFileIngestJobView(input) {
|
|
1750
|
+
const value = requireObject(input, "job");
|
|
1751
|
+
requireExactKeys(
|
|
1752
|
+
value,
|
|
1753
|
+
[
|
|
1754
|
+
"jobId",
|
|
1755
|
+
"state",
|
|
1756
|
+
"filename",
|
|
1757
|
+
"byteLength",
|
|
1758
|
+
"sha256",
|
|
1759
|
+
"expiresAt",
|
|
1760
|
+
"upload",
|
|
1761
|
+
"manifest",
|
|
1762
|
+
"committedPages",
|
|
1763
|
+
"publication",
|
|
1764
|
+
"error"
|
|
1765
|
+
],
|
|
1766
|
+
"job"
|
|
1767
|
+
);
|
|
1768
|
+
const view = {
|
|
1769
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "job.jobId"),
|
|
1770
|
+
state: requireEnum(value.state, HOSTED_FILE_INGEST_JOB_STATES, "job.state"),
|
|
1771
|
+
filename: requireHostedFileIngestFilename(value.filename, "job.filename"),
|
|
1772
|
+
byteLength: requireInteger(
|
|
1773
|
+
value.byteLength,
|
|
1774
|
+
"job.byteLength",
|
|
1775
|
+
1,
|
|
1776
|
+
HOSTED_FILE_INGEST_LIMITS.maxFileBytes
|
|
1777
|
+
),
|
|
1778
|
+
sha256: requireSha256Hex(value.sha256, "job.sha256"),
|
|
1779
|
+
expiresAt: requireIsoField(value.expiresAt, "job.expiresAt")
|
|
1780
|
+
};
|
|
1781
|
+
if (value.upload !== void 0) {
|
|
1782
|
+
const upload = requireObject(value.upload, "job.upload");
|
|
1783
|
+
requireExactKeys(upload, ["token", "expiresAt"], "job.upload");
|
|
1784
|
+
view.upload = {
|
|
1785
|
+
token: requireString(upload.token, "job.upload.token", { maxBytes: 128 }),
|
|
1786
|
+
expiresAt: requireIsoField(upload.expiresAt, "job.upload.expiresAt")
|
|
1787
|
+
};
|
|
1788
|
+
}
|
|
1789
|
+
if (value.manifest !== void 0) {
|
|
1790
|
+
view.manifest = normalizeHostedFileIngestManifest(value.manifest, "job.manifest");
|
|
1791
|
+
}
|
|
1792
|
+
if (value.committedPages !== void 0) {
|
|
1793
|
+
if (!Array.isArray(value.committedPages)) {
|
|
1794
|
+
throw new Error("job.committedPages must be an array");
|
|
1795
|
+
}
|
|
1796
|
+
view.committedPages = value.committedPages.map(
|
|
1797
|
+
(page, index) => requireInteger(page, `job.committedPages[${index}]`, 0, HOSTED_FILE_INGEST_LIMITS.maxChunks)
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
if (value.publication !== void 0) {
|
|
1801
|
+
view.publication = normalizeHostedFileIngestPublication(value.publication, "job.publication");
|
|
1802
|
+
}
|
|
1803
|
+
if (value.error !== void 0) {
|
|
1804
|
+
const error = requireObject(value.error, "job.error");
|
|
1805
|
+
requireExactKeys(error, ["code", "message"], "job.error");
|
|
1806
|
+
view.error = {
|
|
1807
|
+
code: requireString(error.code, "job.error.code", { maxBytes: 64 }),
|
|
1808
|
+
message: requireString(error.message, "job.error.message", { maxBytes: 4096 })
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
return view;
|
|
1812
|
+
}
|
|
1813
|
+
function parseHostedFileIngestCommitResult(input) {
|
|
1814
|
+
const value = requireObject(input, "commit");
|
|
1815
|
+
requireExactKeys(value, ["jobId", "pageIndex", "state", "alreadyCommitted"], "commit");
|
|
1816
|
+
return {
|
|
1817
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "commit.jobId"),
|
|
1818
|
+
pageIndex: requireInteger(
|
|
1819
|
+
value.pageIndex,
|
|
1820
|
+
"commit.pageIndex",
|
|
1821
|
+
0,
|
|
1822
|
+
HOSTED_FILE_INGEST_LIMITS.maxChunks - 1
|
|
1823
|
+
),
|
|
1824
|
+
state: requireEnum(value.state, ["committed"], "commit.state"),
|
|
1825
|
+
alreadyCommitted: requireBoolean(value.alreadyCommitted, "commit.alreadyCommitted")
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
function parseHostedFileIngestPublishResult(input) {
|
|
1829
|
+
const value = requireObject(input, "publish");
|
|
1830
|
+
requireExactKeys(value, ["jobId", "state", "entryCount", "retiredCount", "fileId"], "publish");
|
|
1831
|
+
return {
|
|
1832
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "publish.jobId"),
|
|
1833
|
+
state: requireEnum(value.state, ["published"], "publish.state"),
|
|
1834
|
+
...normalizeHostedFileIngestPublication(
|
|
1835
|
+
{ entryCount: value.entryCount, retiredCount: value.retiredCount, fileId: value.fileId },
|
|
1836
|
+
"publish"
|
|
1837
|
+
)
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
var HOSTED_FILE_INGEST_GATEWAY_STATES = [
|
|
1841
|
+
"active",
|
|
1842
|
+
"limit_exceeded",
|
|
1843
|
+
"quota_paused",
|
|
1844
|
+
"published",
|
|
1845
|
+
"failed",
|
|
1846
|
+
"cancel_requested",
|
|
1847
|
+
"cancelled",
|
|
1848
|
+
"expired"
|
|
1849
|
+
];
|
|
1850
|
+
var HOSTED_FILE_INGEST_RETRYABLE_CODES = [
|
|
1851
|
+
"prepare_in_progress",
|
|
1852
|
+
"page_commit_in_progress",
|
|
1853
|
+
"publish_in_progress"
|
|
1854
|
+
];
|
|
1855
|
+
function requireMicrocents(value, field) {
|
|
1856
|
+
const text = requireString(value, field, { maxBytes: 20 });
|
|
1857
|
+
if (!/^(0|[1-9][0-9]*)$/.test(text) || BigInt(text) > 9223372036854775807n) {
|
|
1858
|
+
throw new Error(`${field} must be a non-negative BIGINT decimal string`);
|
|
1859
|
+
}
|
|
1860
|
+
return text;
|
|
1861
|
+
}
|
|
1862
|
+
function parseHostedFileIngestAuthorization(input) {
|
|
1863
|
+
const value = requireObject(input, "authorization");
|
|
1864
|
+
requireExactKeys(
|
|
1865
|
+
value,
|
|
1866
|
+
[
|
|
1867
|
+
"jobId",
|
|
1868
|
+
"state",
|
|
1869
|
+
"allocated",
|
|
1870
|
+
"revision",
|
|
1871
|
+
"ceilingMicrocents",
|
|
1872
|
+
"estimateMicrocents",
|
|
1873
|
+
"settledMicrocents",
|
|
1874
|
+
"outstandingMicrocents",
|
|
1875
|
+
"authorized"
|
|
1876
|
+
],
|
|
1877
|
+
"authorization"
|
|
1878
|
+
);
|
|
1879
|
+
const nullableMicrocents = (field) => value[field] === null ? null : requireMicrocents(value[field], `authorization.${field}`);
|
|
1880
|
+
return {
|
|
1881
|
+
jobId: requireHostedFileIngestJobId(value.jobId, "authorization.jobId"),
|
|
1882
|
+
state: requireEnum(value.state, HOSTED_FILE_INGEST_GATEWAY_STATES, "authorization.state"),
|
|
1883
|
+
allocated: requireBoolean(value.allocated, "authorization.allocated"),
|
|
1884
|
+
revision: requireInteger(value.revision, "authorization.revision", 0, Number.MAX_SAFE_INTEGER),
|
|
1885
|
+
ceilingMicrocents: nullableMicrocents("ceilingMicrocents"),
|
|
1886
|
+
estimateMicrocents: nullableMicrocents("estimateMicrocents"),
|
|
1887
|
+
settledMicrocents: requireMicrocents(
|
|
1888
|
+
value.settledMicrocents,
|
|
1889
|
+
"authorization.settledMicrocents"
|
|
1890
|
+
),
|
|
1891
|
+
outstandingMicrocents: requireMicrocents(
|
|
1892
|
+
value.outstandingMicrocents,
|
|
1893
|
+
"authorization.outstandingMicrocents"
|
|
1894
|
+
),
|
|
1895
|
+
authorized: requireBoolean(value.authorized, "authorization.authorized")
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1496
1898
|
|
|
1497
1899
|
export {
|
|
1498
1900
|
normalizeGraphLabel,
|
|
@@ -1516,12 +1918,23 @@ export {
|
|
|
1516
1918
|
DATA_PLANE_MANIFEST_FRAME,
|
|
1517
1919
|
DATA_PLANE_HTTP_RESPONSE_FRAME,
|
|
1518
1920
|
DATA_PLANE_COMPILER_LIMITS,
|
|
1921
|
+
HOSTED_FILE_INGEST_PROTOCOL,
|
|
1922
|
+
HOSTED_FILE_INGEST_LIMITS,
|
|
1923
|
+
HOSTED_FILE_INGEST_JOB_STATES,
|
|
1519
1924
|
DATA_PLANE_OPERATION_COVERAGE,
|
|
1520
1925
|
encodeListCursorToken,
|
|
1521
1926
|
parseListCursorToken,
|
|
1927
|
+
requireHostedFileIngestFilename,
|
|
1928
|
+
normalizeHostedFileIngestPageDescriptor,
|
|
1522
1929
|
canonicalDataPlaneJson,
|
|
1523
1930
|
hashDataPlaneStepInputV1,
|
|
1524
1931
|
hashDataPlaneManifestV1,
|
|
1525
1932
|
hashDataPlaneHttpResponseV1,
|
|
1526
|
-
compileDataPlaneRequest
|
|
1933
|
+
compileDataPlaneRequest,
|
|
1934
|
+
parseHostedFileIngestJobView,
|
|
1935
|
+
parseHostedFileIngestCommitResult,
|
|
1936
|
+
parseHostedFileIngestPublishResult,
|
|
1937
|
+
HOSTED_FILE_INGEST_GATEWAY_STATES,
|
|
1938
|
+
HOSTED_FILE_INGEST_RETRYABLE_CODES,
|
|
1939
|
+
parseHostedFileIngestAuthorization
|
|
1527
1940
|
};
|