@hypequery/deployment 0.12.0 → 0.13.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/bundle.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- import { type ProtocolDeploymentBundleManifest, type ProtocolDeploymentContract } from '@hypequery/protocol';
1
+ import { type ProtocolBusinessContext, type ProtocolDeploymentBundleManifest, type ProtocolDeploymentContract } from '@hypequery/protocol';
2
2
  export declare const DEPLOYMENT_BUNDLE_MANIFEST = "bundle.json";
3
3
  export declare const DEPLOYMENT_BUNDLE_CONTRACT = "deployment.json";
4
+ export declare const DEPLOYMENT_BUNDLE_BUSINESS_CONTEXT = "business-context.json";
4
5
  export interface VerifiedDeploymentBundle {
5
6
  readonly directory: string;
6
7
  readonly manifest: ProtocolDeploymentBundleManifest;
7
8
  readonly identity: string;
8
9
  readonly contract: ProtocolDeploymentContract;
10
+ /** Reviewed business context; present only for version 2 bundles. */
11
+ readonly businessContext?: ProtocolBusinessContext;
9
12
  }
10
13
  export declare function verifyDeploymentBundle(bundleDirectory: string): Promise<VerifiedDeploymentBundle>;
11
14
  //# sourceMappingURL=bundle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAC;AAG7B,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AACxD,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;CAC/C;AAkID,wBAAsB,sBAAsB,CAC1C,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,wBAAwB,CAAC,CAqEnC"}
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAQA,OAAO,EAKL,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACrC,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AACxD,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAC5D,eAAO,MAAM,kCAAkC,0BAA0B,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC9C,qEAAqE;IACrE,QAAQ,CAAC,eAAe,CAAC,EAAE,uBAAuB,CAAC;CACpD;AAgID,wBAAsB,sBAAsB,CAC1C,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,wBAAwB,CAAC,CAwEnC"}
package/dist/bundle.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { constants, lstat, open, readdir, } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, prepareProtocolDeploymentBundleManifest, prepareProtocolDeploymentContract, } from '@hypequery/protocol';
4
+ import { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, prepareProtocolBusinessContext, prepareProtocolDeploymentBundleManifest, prepareProtocolDeploymentContract, } from '@hypequery/protocol';
5
+ import { deploymentBundleFiles } from './utils/bundle-files.js';
5
6
  import { readBoundedFile } from './utils/read-bounded-file.js';
6
7
  export const DEPLOYMENT_BUNDLE_MANIFEST = 'bundle.json';
7
8
  export const DEPLOYMENT_BUNDLE_CONTRACT = 'deployment.json';
9
+ export const DEPLOYMENT_BUNDLE_BUSINESS_CONTEXT = 'business-context.json';
8
10
  const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
9
11
  const utf8Encoder = new TextEncoder();
10
12
  function errorCode(error) {
@@ -59,11 +61,9 @@ function expectedDirectories(files) {
59
61
  return result;
60
62
  }
61
63
  async function verifyExactEntries(root, manifest) {
62
- const source = manifest.source;
63
64
  const expectedFiles = new Set([
64
65
  DEPLOYMENT_BUNDLE_MANIFEST,
65
- manifest.deployment.path,
66
- ...(source?.files.map(file => `${source.root}/${file.path}`) ?? []),
66
+ ...deploymentBundleFiles(manifest).map(file => file.path),
67
67
  ]);
68
68
  const expectedDirectoryPaths = expectedDirectories([...expectedFiles]);
69
69
  const seenFiles = new Set();
@@ -159,6 +159,7 @@ export async function verifyDeploymentBundle(bundleDirectory) {
159
159
  if (preparedContract.identity !== deployment.identity) {
160
160
  throw new Error('Deployment identity does not match the bundle manifest.');
161
161
  }
162
+ const businessContext = await verifyBusinessContext(root, preparedManifest.manifest);
162
163
  const source = preparedManifest.manifest.source;
163
164
  if (source) {
164
165
  for (const file of source.files) {
@@ -172,5 +173,29 @@ export async function verifyDeploymentBundle(bundleDirectory) {
172
173
  manifest: preparedManifest.manifest,
173
174
  identity: preparedManifest.identity,
174
175
  contract: preparedContract.contract,
176
+ ...(businessContext ? { businessContext } : {}),
175
177
  });
176
178
  }
179
+ async function verifyBusinessContext(root, manifest) {
180
+ const entry = manifest.businessContext;
181
+ if (!entry)
182
+ return undefined;
183
+ const bytes = await readBoundedRegularFile(root, entry.path, DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS.maxBusinessContextBytes);
184
+ verifyFile(bytes, entry);
185
+ let input;
186
+ try {
187
+ input = JSON.parse(utf8Decoder.decode(bytes));
188
+ }
189
+ catch (error) {
190
+ throw new Error(`Invalid business context JSON in bundle: ${entry.path}\n\n`
191
+ + (error instanceof Error ? error.message : String(error)));
192
+ }
193
+ const prepared = prepareProtocolBusinessContext(input);
194
+ if (!Buffer.from(bytes).equals(Buffer.from(`${prepared.canonical}\n`))) {
195
+ throw new Error('Business context JSON must contain canonical JSON followed by one newline.');
196
+ }
197
+ if (prepared.identity !== entry.identity) {
198
+ throw new Error('Business context identity does not match the bundle manifest.');
199
+ }
200
+ return prepared.context;
201
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"filesystem-store.d.ts","sourceRoot":"","sources":["../src/filesystem-store.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,iCAAiC,EACvC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,yBAAyB,EAE1B,MAAM,YAAY,CAAC;AAUpB,MAAM,MAAM,kCAAkC,GAC1C,mCAAmC,GACnC,wCAAwC,GACxC,mCAAmC,GACnC,wBAAwB,CAAC;AAE7B,qBAAa,8BAA+B,SAAQ,KAAK;IACvD,QAAQ,CAAC,IAAI,EAAE,kCAAkC,CAAC;gBAGhD,IAAI,EAAE,kCAAkC,EACxC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAM7C;AAED,MAAM,WAAW,0CAA0C;IACzD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;CAC3C;AAED,MAAM,WAAW,mCAAmC,CAAC,SAAS,CAC5D,SAAQ,yBAAyB,CAAC,SAAS,CAAC;IAC5C,IAAI,C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,GAAG,SAAS,CAAC,CAAC;CAChF;AA6ZD,wBAAgB,yCAAyC,CAAC,SAAS,GAAG,OAAO,EAC3E,OAAO,EAAE,0CAA0C,GAClD,mCAAmC,CAAC,SAAS,CAAC,CAkHhD"}
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import { prepareProtocolDeploymentReleaseEnvelope, } from '@hypequery/protocol';
5
5
  import { DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
6
6
  import { readBoundedFile } from './utils/read-bounded-file.js';
7
+ import { deploymentBundleFiles } from './utils/bundle-files.js';
7
8
  const RELEASE_FILE = 'release.json';
8
9
  const MAX_MANIFEST_BYTES = 1024 * 1024;
9
10
  const MAX_RELEASE_BYTES = 16 * 1024;
@@ -149,17 +150,12 @@ async function copyRegularFile(sourcePath, destinationPath, maximumBytes, expect
149
150
  }
150
151
  }
151
152
  function bundleFilePaths(bundle) {
152
- const source = bundle.manifest.source;
153
153
  return Object.freeze([
154
154
  { path: DEPLOYMENT_BUNDLE_MANIFEST },
155
- {
156
- path: bundle.manifest.deployment.path,
157
- byteLength: bundle.manifest.deployment.byteLength,
158
- },
159
- ...(source?.files.map(file => ({
160
- path: `${source.root}/${file.path}`,
155
+ ...deploymentBundleFiles(bundle.manifest).map(file => ({
156
+ path: file.path,
161
157
  byteLength: file.byteLength,
162
- })) ?? []),
158
+ })),
163
159
  ]);
164
160
  }
165
161
  async function syncBundleDirectories(bundleRoot, files) {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { createFileSystemDeploymentActivationRegistry, DeploymentActivationError, validateDeploymentActivationRecord, } from './activation.js';
2
2
  export type { DeploymentActivationErrorCode, DeploymentActivationHistoryPage, DeploymentActivationHistoryQuery, DeploymentActivationRegistry, DeploymentActivationRelease, DeploymentActivationRecord, DeploymentActivationRequest, DeploymentActivationResult, DeploymentReleaseReader, FileSystemDeploymentActivationRegistryOptions, } from './activation.js';
3
- export { DEPLOYMENT_BUNDLE_CONTRACT, DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
3
+ export { DEPLOYMENT_BUNDLE_BUSINESS_CONTEXT, DEPLOYMENT_BUNDLE_CONTRACT, DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
4
+ export { deploymentBundleFiles } from './utils/bundle-files.js';
5
+ export type { DeploymentBundleFileEntry, DeploymentBundleFileRole, } from './utils/bundle-files.js';
4
6
  export type { VerifiedDeploymentBundle } from './bundle.js';
5
7
  export { DeploymentIntakeError, } from './errors.js';
6
8
  export type { DeploymentIntakeErrorCode } from './errors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4CAA4C,EAC5C,yBAAyB,EACzB,kCAAkC,GACnC,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,6BAA6B,EAC7B,+BAA+B,EAC/B,gCAAgC,EAChC,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,6CAA6C,GAC9C,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,yCAAyC,EACzC,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EACV,kCAAkC,EAClC,mCAAmC,EACnC,0CAA0C,EAC1C,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,wCAAwC,EACxC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ationError, validateDeploymentActivationRecord, } from './activation.js';
2
- export { DEPLOYMENT_BUNDLE_CONTRACT, DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
2
+ export { DEPLOYMENT_BUNDLE_BUSINESS_CONTEXT, DEPLOYMENT_BUNDLE_CONTRACT, DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
3
+ export { deploymentBundleFiles } from './utils/bundle-files.js';
3
4
  export { DeploymentIntakeError, } from './errors.js';
4
5
  export { createFileSystemDeploymentSubmissionStore, FileSystemDeploymentStoreError, } from './filesystem-store.js';
5
6
  export { createDeploymentIntake, } from './intake.js';
@@ -1 +1 @@
1
- {"version":3,"file":"intake.d.ts","sourceRoot":"","sources":["../src/intake.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EAIxB,MAAM,YAAY,CAAC;AAwSpB,wBAAgB,sBAAsB,CAAC,SAAS,EAC9C,OAAO,EAAE,uBAAuB,CAAC,SAAS,CAAC,GAC1C,gBAAgB,CAiIlB"}
1
+ {"version":3,"file":"intake.d.ts","sourceRoot":"","sources":["../src/intake.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EACV,gBAAgB,EAChB,uBAAuB,EAIxB,MAAM,YAAY,CAAC;AAoSpB,wBAAgB,sBAAsB,CAAC,SAAS,EAC9C,OAAO,EAAE,uBAAuB,CAAC,SAAS,CAAC,GAC1C,gBAAgB,CA2HlB"}
package/dist/intake.js CHANGED
@@ -6,6 +6,7 @@ import { prepareProtocolDeploymentBundleManifest, prepareProtocolDeploymentRelea
6
6
  import { DEPLOYMENT_BUNDLE_MANIFEST, verifyDeploymentBundle, } from './bundle.js';
7
7
  import { badRequest, DeploymentIntakeError, tooLarge, } from './errors.js';
8
8
  import { resolveDeploymentIntakeLimits } from './limits.js';
9
+ import { deploymentBundleFiles } from './utils/bundle-files.js';
9
10
  import { BoundedMultipartReader, } from './multipart.js';
10
11
  const BOUNDARY_PATTERN = /^[A-Za-z0-9-]{1,70}$/;
11
12
  const DIGEST_PATTERN = /^[0-9a-f]{64}$/;
@@ -85,11 +86,7 @@ function decodeJson(bytes, description) {
85
86
  }
86
87
  }
87
88
  function requireReconstructablePaths(manifest) {
88
- const source = manifest.manifest.source;
89
- const files = [
90
- manifest.manifest.deployment.path,
91
- ...(source?.files.map(file => `${source.root}/${file.path}`) ?? []),
92
- ];
89
+ const files = deploymentBundleFiles(manifest.manifest).map(file => file.path);
93
90
  const fileSet = new Set(files);
94
91
  if (fileSet.has(DEPLOYMENT_BUNDLE_MANIFEST)) {
95
92
  throw badRequest('The bundle manifest path is reserved.');
@@ -285,16 +282,10 @@ export function createDeploymentIntake(options) {
285
282
  const bundleRoot = path.join(temporaryRoot, 'bundle');
286
283
  await mkdir(bundleRoot);
287
284
  await writeFile(path.join(bundleRoot, DEPLOYMENT_BUNDLE_MANIFEST), manifest.bytes, { flag: 'wx' });
288
- const source = manifest.prepared.manifest.source;
289
- const files = [
290
- manifest.prepared.manifest.deployment,
291
- ...(source?.files.map(file => ({
292
- ...file,
293
- path: `${source.root}/${file.path}`,
294
- })) ?? []),
295
- ];
285
+ const files = deploymentBundleFiles(manifest.prepared.manifest);
296
286
  for (let index = 0; index < files.length; index += 1) {
297
- await receiveBundleFile(reader, bundleRoot, files[index], index === 0 ? 'application/json' : 'application/octet-stream', index === files.length - 1);
287
+ const file = files[index];
288
+ await receiveBundleFile(reader, bundleRoot, file, file.contentType, index === files.length - 1);
298
289
  }
299
290
  await reader.finish();
300
291
  throwIfAborted(request.signal);
@@ -0,0 +1,14 @@
1
+ import type { ProtocolDeploymentBundleFile, ProtocolDeploymentBundleManifest } from '@hypequery/protocol';
2
+ export type DeploymentBundleFileRole = 'deployment' | 'business-context' | 'source';
3
+ export interface DeploymentBundleFileEntry extends ProtocolDeploymentBundleFile {
4
+ readonly role: DeploymentBundleFileRole;
5
+ /** Media type used when the file travels in a multipart submission. */
6
+ readonly contentType: 'application/json' | 'application/octet-stream';
7
+ }
8
+ /**
9
+ * Every declared file in a bundle (excluding `bundle.json`), with bundle-relative
10
+ * paths, in the fixed order used for upload, intake, storage and verification:
11
+ * deployment contract, business context, then source files.
12
+ */
13
+ export declare function deploymentBundleFiles(manifest: ProtocolDeploymentBundleManifest): readonly DeploymentBundleFileEntry[];
14
+ //# sourceMappingURL=bundle-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-files.d.ts","sourceRoot":"","sources":["../../src/utils/bundle-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAE7B,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,kBAAkB,GAAG,QAAQ,CAAC;AAEpF,MAAM,WAAW,yBAA0B,SAAQ,4BAA4B;IAC7E,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAC;IACxC,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,kBAAkB,GAAG,0BAA0B,CAAC;CACvE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gCAAgC,GACzC,SAAS,yBAAyB,EAAE,CAyBtC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Every declared file in a bundle (excluding `bundle.json`), with bundle-relative
3
+ * paths, in the fixed order used for upload, intake, storage and verification:
4
+ * deployment contract, business context, then source files.
5
+ */
6
+ export function deploymentBundleFiles(manifest) {
7
+ const { deployment, businessContext, source } = manifest;
8
+ return Object.freeze([
9
+ {
10
+ role: 'deployment',
11
+ contentType: 'application/json',
12
+ path: deployment.path,
13
+ sha256: deployment.sha256,
14
+ byteLength: deployment.byteLength,
15
+ },
16
+ ...(businessContext ? [{
17
+ role: 'business-context',
18
+ contentType: 'application/json',
19
+ path: businessContext.path,
20
+ sha256: businessContext.sha256,
21
+ byteLength: businessContext.byteLength,
22
+ }] : []),
23
+ ...(source?.files.map(file => ({
24
+ role: 'source',
25
+ contentType: 'application/octet-stream',
26
+ path: `${source.root}/${file.path}`,
27
+ sha256: file.sha256,
28
+ byteLength: file.byteLength,
29
+ })) ?? []),
30
+ ]);
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/deployment",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Verified deployment intake, activation, and semantic invocation for Hypequery analytics",
5
5
  "keywords": [
6
6
  "hypequery",
@@ -26,13 +26,13 @@
26
26
  "README.md"
27
27
  ],
28
28
  "dependencies": {
29
- "@hypequery/protocol": "0.25.0"
29
+ "@hypequery/protocol": "0.27.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^26.6.6",
33
33
  "typescript": "^6.0.3",
34
34
  "vitest": "^5.1.0",
35
- "@hypequery/datasets": "0.30.0"
35
+ "@hypequery/datasets": "0.32.0"
36
36
  },
37
37
  "engines": {
38
38
  "node": ">=20"