@hypequery/protocol 0.4.0 → 0.5.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
@@ -83,6 +83,11 @@ provides canonical encoding and a separate bundle-v1 identity. Filesystem-safe
83
83
  writing and byte verification remain in the CLI because this package performs
84
84
  no I/O.
85
85
 
86
+ The proposed deployment-release surface binds one verified bundle identity to
87
+ an explicit project and environment. Its deterministic identity can serve as an
88
+ idempotency key for a future authenticated upload API without putting
89
+ credentials, timestamps, release state, or provider behavior into the envelope.
90
+
86
91
  ## Runtime compatibility
87
92
 
88
93
  This package is ESM-only. Consumers must load it with `import`; CommonJS
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, } 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,EACpB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,qBAAqB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A4B,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,EACnB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,gBAAgB,EAChB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,0BAA0B,EAC1B,u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M,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, } 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 } 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,EAAE,yCAAyC,EAAE,MAAM,eAAe,CAAC;AAC1E,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 } 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,3 @@
1
+ import type { ProtocolDeploymentReleaseEnvelope, ProtocolDeploymentReleaseOptions } from './types.js';
2
+ export declare function validateProtocolDeploymentReleaseEnvelope(input: unknown, options?: ProtocolDeploymentReleaseOptions): ProtocolDeploymentReleaseEnvelope;
3
+ //# 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,EAEjC,MAAM,YAAY,CAAC;AA6DpB,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,gCAAqC,GAC7C,iCAAiC,CAwBnC"}
@@ -0,0 +1,82 @@
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 validateTarget(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 validateProtocolDeploymentReleaseEnvelope(input, options = {}) {
57
+ const limits = resolveDeploymentReleaseLimits(options);
58
+ const value = requireRecord(input, '$');
59
+ exactFields(value, ['kind', 'version', 'bundleIdentity', 'target'], '$');
60
+ if (value.kind !== 'hypequery-deployment-release') {
61
+ if (typeof value.kind !== 'string')
62
+ releaseError('HQ_RELEASE_TYPE', '$.kind');
63
+ releaseError('HQ_RELEASE_INVALID_VALUE', '$.kind');
64
+ }
65
+ if (value.version !== 1) {
66
+ if (typeof value.version !== 'number')
67
+ releaseError('HQ_RELEASE_TYPE', '$.version');
68
+ releaseError('HQ_RELEASE_INVALID_VERSION', '$.version');
69
+ }
70
+ if (typeof value.bundleIdentity !== 'string') {
71
+ releaseError('HQ_RELEASE_TYPE', '$.bundleIdentity');
72
+ }
73
+ if (!SHA256_PATTERN.test(value.bundleIdentity)) {
74
+ releaseError('HQ_RELEASE_INVALID_VALUE', '$.bundleIdentity');
75
+ }
76
+ return freezeRecord({
77
+ kind: 'hypequery-deployment-release',
78
+ version: 1,
79
+ bundleIdentity: value.bundleIdentity,
80
+ target: validateTarget(value.target, limits.maxTargetBytes),
81
+ });
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/protocol",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Public contracts and TypeScript reference implementation for portable Hypequery artifacts",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",