@hypequery/protocol 0.4.0 → 0.6.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/README.md CHANGED
@@ -80,8 +80,14 @@ with the deployment-v1 domain-separated SHA-256 digest.
80
80
  The proposed deployment-bundle surface validates the portable manifest that
81
81
  binds a deployment identity to exact deployment and runtime artifact files. It
82
82
  provides canonical encoding and a separate bundle-v1 identity. Filesystem-safe
83
- writing and byte verification remain in the CLI because this package performs
84
- no I/O.
83
+ writing remains in the CLI, while reusable filesystem verification and
84
+ receiving-side intake live in `@hypequery/deployment`; this package performs no
85
+ I/O.
86
+
87
+ The proposed deployment-release surface binds one verified bundle identity to
88
+ an explicit project and environment. Its deterministic identity serves as the
89
+ idempotency key for authenticated deployment submission without putting
90
+ credentials, timestamps, release state, or provider behavior into the envelope.
85
91
 
86
92
  ## Runtime compatibility
87
93
 
package/dist/index.d.ts CHANGED
@@ -8,6 +8,8 @@ export type { ProtocolAggregation, ProtocolBinaryOperator, ProtocolComparisonOpe
8
8
  export type { ProtocolIdentifier, ProtocolIdentifierErrorCode, ProtocolQualifiedIdentifier, } from './identifiers/index.js';
9
9
  export { DEFAULT_PROTOCOL_QUERY_IMPLEMENTATION_LIMITS, ProtocolQueryImplementationError, validateProtocolQueryImplementation, validateProtocolSqlExpression, } from './query-implementations/index.js';
10
10
  export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
11
+ export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
12
+ export type { PreparedProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseErrorCode, ProtocolDeploymentReleaseLimits, ProtocolDeploymentReleaseOptions, ProtocolDeploymentReleaseTarget, } from './releases/index.js';
11
13
  export type { PreparedProtocolDeploymentBundleManifest, ProtocolDeploymentBundleArtifact, ProtocolDeploymentBundleDeployment, ProtocolDeploymentBundleErrorCode, ProtocolDeploymentBundleFile, ProtocolDeploymentBundleLimits, ProtocolDeploymentBundleManifest, ProtocolDeploymentBundleOptions, } from './bundles/index.js';
12
14
  export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
13
15
  export type { PreparedProtocolDeploymentContract, ProtocolAccessPolicy, ProtocolDatasetContract, ProtocolDatasetDimension, ProtocolDatasetFieldSource, ProtocolDatasetFieldType, ProtocolDatasetFilter, ProtocolDatasetLimits, ProtocolDatasetMeasure, ProtocolDatasetMetric, ProtocolDatasetRelationship, ProtocolDatasetTenantPolicy, ProtocolDeploymentContract, ProtocolDeploymentErrorCode, ProtocolDeploymentLimits, ProtocolDeploymentOptions, ProtocolEndpointPolicy, ProtocolEndpointTenantPolicy, ProtocolNamedQueryContract, ProtocolRuntimeArtifact, } from './deployments/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EAC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tC,8CAA8C,EAC9C,oCAAoC,EACpC,uCAAuC,EACvC,wCAAwC,GACzC,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,wCAAwC,EACxC,gCAAgC,EAChC,kCAAkC,EAClC,iCAAiC,EACjC,4BAA4B,EAC5B,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB,EACvB,gCAAgC,EAChC,wCAAwC,EACxC,8BAA8B,EAC9B,iCAAiC,EACjC,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,kCAAkC,EAClC,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,E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C,wCAAwC,EACxC,yCAAyC,EACzC,uCAAuC,GACxC,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,yCAAyC,EACzC,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EACV,wCAAwC,EACxC,gCAAgC,EAChC,kCAAkC,EAClC,iCAAiC,EACjC,4BAA4B,EAC5B,8BAA8B,EAC9B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,kCAAkC,EAClC,mCAAmC,EACnC,uBAAuB,EACvB,gCAAgC,EAChC,wCAAwC,EACxC,8BAA8B,EAC9B,iCAAiC,EACjC,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,kCAAkC,EAClC,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,YAAY,EACV,2BAA2B,EAC3B,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,EAClC,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -4,4 +4,5 @@ export { DEFAULT_PROTOCOL_EXPRESSION_LIMITS, ProtocolExpressionError, validatePr
4
4
  export { DEFAULT_PROTOCOL_SCHEMA_LIMITS, ProtocolSchemaError, validateProtocolSchema, } from './schemas/index.js';
5
5
  export { DEFAULT_PROTOCOL_QUERY_IMPLEMENTATION_LIMITS, ProtocolQueryImplementationError, validateProtocolQueryImplementation, validateProtocolSqlExpression, } from './query-implementations/index.js';
6
6
  export { DEFAULT_PROTOCOL_DEPLOYMENT_BUNDLE_LIMITS, PROTOCOL_DEPLOYMENT_BUNDLE_IDENTITY_DOMAIN, ProtocolDeploymentBundleError, encodeProtocolDeploymentBundleManifest, encodeProtocolDeploymentBundleManifestToString, hashProtocolDeploymentBundleManifest, prepareProtocolDeploymentBundleManifest, validateProtocolDeploymentBundleManifest, } from './bundles/index.js';
7
+ export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS, PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, ProtocolDeploymentReleaseError, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './releases/index.js';
7
8
  export { DEFAULT_PROTOCOL_DEPLOYMENT_LIMITS, PROTOCOL_DEPLOYMENT_IDENTITY_DOMAIN, ProtocolDeploymentError, encodeProtocolDeploymentContract, encodeProtocolDeploymentContractToString, hashProtocolDeploymentContract, prepareProtocolDeploymentContract, validateProtocolDatasetContract, validateProtocolDeploymentContract, } from './deployments/index.js';
@@ -0,0 +1,13 @@
1
+ import type { ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseOptions } from './types.js';
2
+ export declare const PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN = "hypequery:deployment-release:v1\0";
3
+ export interface PreparedProtocolDeploymentReleaseEnvelope {
4
+ readonly release: ProtocolDeploymentReleaseEnvelope;
5
+ readonly canonical: string;
6
+ readonly bytes: Uint8Array;
7
+ readonly identity: string;
8
+ }
9
+ export declare function prepareProtocolDeploymentReleaseEnvelope(input: unknown, options?: ProtocolDeploymentReleaseOptions): PreparedProtocolDeploymentReleaseEnvelope;
10
+ export declare function encodeProtocolDeploymentReleaseEnvelope(input: unknown, options?: ProtocolDeploymentReleaseOptions): Uint8Array;
11
+ export declare function encodeProtocolDeploymentReleaseEnvelopeToString(input: unknown, options?: ProtocolDeploymentReleaseOptions): string;
12
+ export declare function hashProtocolDeploymentReleaseEnvelope(input: unknown, options?: ProtocolDeploymentReleaseOptions): string;
13
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/releases/codec.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,iCAAiC,EACjC,gCAAgC,EACjC,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,2CAA2C,sCAAsC,CAAC;AAE/F,MAAM,WAAW,yCAAyC;IACxD,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,yCAAyC,CAS3C;AAED,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,UAAU,CAEZ;AAED,wBAAgB,+CAA+C,CAC7D,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,MAAM,CAER;AAED,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,MAAM,CAER"}
@@ -0,0 +1,25 @@
1
+ import { sha256 } from '@noble/hashes/sha2';
2
+ import { bytesToHex } from '@noble/hashes/utils';
3
+ import { serializeJcs } from '../values/jcs.js';
4
+ import { validateProtocolDeploymentReleaseEnvelope } from './validate.js';
5
+ const textEncoder = new TextEncoder();
6
+ export const PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN = 'hypequery:deployment-release:v1\0';
7
+ export function prepareProtocolDeploymentReleaseEnvelope(input, options = {}) {
8
+ const release = validateProtocolDeploymentReleaseEnvelope(input, options);
9
+ const canonical = serializeJcs(release);
10
+ const bytes = textEncoder.encode(canonical);
11
+ const identity = bytesToHex(sha256.create()
12
+ .update(textEncoder.encode(PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN))
13
+ .update(bytes)
14
+ .digest());
15
+ return Object.freeze({ release, canonical, bytes, identity });
16
+ }
17
+ export function encodeProtocolDeploymentReleaseEnvelope(input, options = {}) {
18
+ return prepareProtocolDeploymentReleaseEnvelope(input, options).bytes;
19
+ }
20
+ export function encodeProtocolDeploymentReleaseEnvelopeToString(input, options = {}) {
21
+ return prepareProtocolDeploymentReleaseEnvelope(input, options).canonical;
22
+ }
23
+ export function hashProtocolDeploymentReleaseEnvelope(input, options = {}) {
24
+ return prepareProtocolDeploymentReleaseEnvelope(input, options).identity;
25
+ }
@@ -0,0 +1,8 @@
1
+ import type { ProtocolDeploymentReleaseErrorCode } from './types.js';
2
+ export declare class ProtocolDeploymentReleaseError extends TypeError {
3
+ readonly code: ProtocolDeploymentReleaseErrorCode;
4
+ readonly path: string;
5
+ constructor(code: ProtocolDeploymentReleaseErrorCode, path?: string);
6
+ }
7
+ export declare function releaseError(code: ProtocolDeploymentReleaseErrorCode, path?: string): never;
8
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/releases/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,YAAY,CAAC;AAErE,qBAAa,8BAA+B,SAAQ,SAAS;IAC3D,QAAQ,CAAC,IAAI,EAAE,kCAAkC,CAAC;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,kCAAkC,EAAE,IAAI,SAAM;CAMjE;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,kCAAkC,EACxC,IAAI,SAAM,GACT,KAAK,CAEP"}
@@ -0,0 +1,13 @@
1
+ export class ProtocolDeploymentReleaseError extends TypeError {
2
+ code;
3
+ path;
4
+ constructor(code, path = '$') {
5
+ super(`${code} at ${path}`);
6
+ this.name = 'ProtocolDeploymentReleaseError';
7
+ this.code = code;
8
+ this.path = path;
9
+ }
10
+ }
11
+ export function releaseError(code, path = '$') {
12
+ throw new ProtocolDeploymentReleaseError(code, path);
13
+ }
@@ -0,0 +1,7 @@
1
+ export { ProtocolDeploymentReleaseError } from './errors.js';
2
+ export { PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, } from './codec.js';
3
+ export type { PreparedProtocolDeploymentReleaseEnvelope } from './codec.js';
4
+ export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS } from './limits.js';
5
+ export { validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './validate.js';
6
+ export type { ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseErrorCode, ProtocolDeploymentReleaseLimits, ProtocolDeploymentReleaseOptions, ProtocolDeploymentReleaseTarget, } from './types.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/releases/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EACL,2CAA2C,EAC3C,uCAAuC,EACvC,+CAA+C,EAC/C,qCAAqC,EACrC,wCAAwC,GACzC,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,yCAAyC,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,0CAA0C,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EACL,yCAAyC,EACzC,uCAAuC,GACxC,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,iCAAiC,EACjC,kCAAkC,EAClC,+BAA+B,EAC/B,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,YAAY,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ProtocolDeploymentReleaseError } from './errors.js';
2
+ export { PROTOCOL_DEPLOYMENT_RELEASE_IDENTITY_DOMAIN, encodeProtocolDeploymentReleaseEnvelope, encodeProtocolDeploymentReleaseEnvelopeToString, hashProtocolDeploymentReleaseEnvelope, prepareProtocolDeploymentReleaseEnvelope, } from './codec.js';
3
+ export { DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS } from './limits.js';
4
+ export { validateProtocolDeploymentReleaseEnvelope, validateProtocolDeploymentReleaseTarget, } from './validate.js';
@@ -0,0 +1,4 @@
1
+ import type { ProtocolDeploymentReleaseLimits, ProtocolDeploymentReleaseOptions } from './types.js';
2
+ export declare const DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS: Readonly<ProtocolDeploymentReleaseLimits>;
3
+ export declare function resolveDeploymentReleaseLimits(options?: ProtocolDeploymentReleaseOptions): Readonly<ProtocolDeploymentReleaseLimits>;
4
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/releases/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,+BAA+B,EAC/B,gCAAgC,EACjC,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,0CAA0C,EACvD,QAAQ,CAAC,+BAA+B,CAEtC,CAAC;AAEH,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,gCAAqC,GAC7C,QAAQ,CAAC,+BAA+B,CAAC,CAe3C"}
@@ -0,0 +1,18 @@
1
+ export const DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS = Object.freeze({
2
+ maxTargetBytes: 128,
3
+ });
4
+ export function resolveDeploymentReleaseLimits(options = {}) {
5
+ const result = { ...DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS };
6
+ for (const key of Object.keys(result)) {
7
+ const value = options.limits?.[key];
8
+ if (value === undefined)
9
+ continue;
10
+ const maximum = DEFAULT_PROTOCOL_DEPLOYMENT_RELEASE_LIMITS[key];
11
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
12
+ throw new RangeError(`${key} must be a positive safe integer no greater than ${maximum} `
13
+ + '(the deployment release v1 maximum)');
14
+ }
15
+ result[key] = value;
16
+ }
17
+ return Object.freeze(result);
18
+ }
@@ -0,0 +1,19 @@
1
+ export interface ProtocolDeploymentReleaseTarget {
2
+ readonly project: string;
3
+ readonly environment: string;
4
+ }
5
+ export interface ProtocolDeploymentReleaseEnvelope {
6
+ readonly kind: 'hypequery-deployment-release';
7
+ readonly version: 1;
8
+ readonly bundleIdentity: string;
9
+ readonly target: ProtocolDeploymentReleaseTarget;
10
+ }
11
+ export interface ProtocolDeploymentReleaseLimits {
12
+ readonly maxTargetBytes: number;
13
+ }
14
+ /** Parser budgets that may tighten, but not raise, release-envelope v1 limits. */
15
+ export interface ProtocolDeploymentReleaseOptions {
16
+ readonly limits?: Partial<ProtocolDeploymentReleaseLimits>;
17
+ }
18
+ export type ProtocolDeploymentReleaseErrorCode = 'HQ_RELEASE_TYPE' | 'HQ_RELEASE_UNKNOWN_FIELD' | 'HQ_RELEASE_INVALID_VERSION' | 'HQ_RELEASE_INVALID_VALUE' | 'HQ_RELEASE_TOO_LARGE' | 'HQ_RELEASE_UNSAFE_OBJECT';
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/releases/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,+BAA+B,CAAC;CAClD;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,kFAAkF;AAClF,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,+BAA+B,CAAC,CAAC;CAC5D;AAED,MAAM,MAAM,kCAAkC,GAC1C,iBAAiB,GACjB,0BAA0B,GAC1B,4BAA4B,GAC5B,0BAA0B,GAC1B,sBAAsB,GACtB,0BAA0B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseOptions, ProtocolDeploymentReleaseTarget } from './types.js';
2
+ export declare function validateProtocolDeploymentReleaseTarget(input: unknown, options?: ProtocolDeploymentReleaseOptions): ProtocolDeploymentReleaseTarget;
3
+ export declare function validateProtocolDeploymentReleaseEnvelope(input: unknown, options?: ProtocolDeploymentReleaseOptions): ProtocolDeploymentReleaseEnvelope;
4
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/releases/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iCAAiC,EACjC,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,YAAY,CAAC;AA6DpB,wBAAgB,uCAAuC,CACrD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,+BAA+B,CAKjC;AAED,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,iCAAiC,CAwBnC"}
@@ -0,0 +1,85 @@
1
+ import { releaseError } from './errors.js';
2
+ import { resolveDeploymentReleaseLimits } from './limits.js';
3
+ const SHA256_PATTERN = /^[0-9a-f]{64}$/;
4
+ const TARGET_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
5
+ const textEncoder = new TextEncoder();
6
+ function requireRecord(input, path) {
7
+ if (typeof input !== 'object' || input === null || Array.isArray(input)) {
8
+ releaseError('HQ_RELEASE_TYPE', path);
9
+ }
10
+ const prototype = Object.getPrototypeOf(input);
11
+ if (prototype !== Object.prototype && prototype !== null) {
12
+ releaseError('HQ_RELEASE_UNSAFE_OBJECT', path);
13
+ }
14
+ if (Object.getOwnPropertySymbols(input).length > 0) {
15
+ releaseError('HQ_RELEASE_UNSAFE_OBJECT', path);
16
+ }
17
+ for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(input))) {
18
+ if (!descriptor.enumerable || !('value' in descriptor)) {
19
+ releaseError('HQ_RELEASE_UNSAFE_OBJECT', path);
20
+ }
21
+ }
22
+ return input;
23
+ }
24
+ function exactFields(value, required, path) {
25
+ const allowed = new Set(required);
26
+ for (const key of Object.keys(value)) {
27
+ if (!allowed.has(key))
28
+ releaseError('HQ_RELEASE_UNKNOWN_FIELD', `${path}.${key}`);
29
+ }
30
+ for (const key of required) {
31
+ if (!Object.hasOwn(value, key))
32
+ releaseError('HQ_RELEASE_TYPE', `${path}.${key}`);
33
+ }
34
+ }
35
+ function freezeRecord(entries) {
36
+ return Object.freeze(Object.assign(Object.create(null), entries));
37
+ }
38
+ function targetToken(value, path, maximum) {
39
+ if (typeof value !== 'string')
40
+ releaseError('HQ_RELEASE_TYPE', path);
41
+ if (value.length > maximum || textEncoder.encode(value).byteLength > maximum) {
42
+ releaseError('HQ_RELEASE_TOO_LARGE', path);
43
+ }
44
+ if (!TARGET_PATTERN.test(value))
45
+ releaseError('HQ_RELEASE_INVALID_VALUE', path);
46
+ return value;
47
+ }
48
+ function validateTargetWithMaximum(input, maximum) {
49
+ const value = requireRecord(input, '$.target');
50
+ exactFields(value, ['project', 'environment'], '$.target');
51
+ return freezeRecord({
52
+ project: targetToken(value.project, '$.target.project', maximum),
53
+ environment: targetToken(value.environment, '$.target.environment', maximum),
54
+ });
55
+ }
56
+ export function validateProtocolDeploymentReleaseTarget(input, options = {}) {
57
+ return validateTargetWithMaximum(input, resolveDeploymentReleaseLimits(options).maxTargetBytes);
58
+ }
59
+ export function validateProtocolDeploymentReleaseEnvelope(input, options = {}) {
60
+ const limits = resolveDeploymentReleaseLimits(options);
61
+ const value = requireRecord(input, '$');
62
+ exactFields(value, ['kind', 'version', 'bundleIdentity', 'target'], '$');
63
+ if (value.kind !== 'hypequery-deployment-release') {
64
+ if (typeof value.kind !== 'string')
65
+ releaseError('HQ_RELEASE_TYPE', '$.kind');
66
+ releaseError('HQ_RELEASE_INVALID_VALUE', '$.kind');
67
+ }
68
+ if (value.version !== 1) {
69
+ if (typeof value.version !== 'number')
70
+ releaseError('HQ_RELEASE_TYPE', '$.version');
71
+ releaseError('HQ_RELEASE_INVALID_VERSION', '$.version');
72
+ }
73
+ if (typeof value.bundleIdentity !== 'string') {
74
+ releaseError('HQ_RELEASE_TYPE', '$.bundleIdentity');
75
+ }
76
+ if (!SHA256_PATTERN.test(value.bundleIdentity)) {
77
+ releaseError('HQ_RELEASE_INVALID_VALUE', '$.bundleIdentity');
78
+ }
79
+ return freezeRecord({
80
+ kind: 'hypequery-deployment-release',
81
+ version: 1,
82
+ bundleIdentity: value.bundleIdentity,
83
+ target: validateTargetWithMaximum(value.target, limits.maxTargetBytes),
84
+ });
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/protocol",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Public contracts and TypeScript reference implementation for portable Hypequery artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",