@hypequery/datasets 0.31.0 → 0.34.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/agent-catalog.d.ts +3 -3
- package/dist/agent-catalog.d.ts.map +1 -1
- package/dist/cache/protocol-cache-keys.d.ts.map +1 -1
- package/dist/cache/protocol-cache-keys.js +25 -1
- package/dist/cache/query-signature.d.ts.map +1 -1
- package/dist/cache/query-signature.js +16 -5
- package/dist/catalog.d.ts +5 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +9 -0
- package/dist/client-contract/build-from-deployment.d.ts +2 -2
- package/dist/client-contract/build-from-deployment.d.ts.map +1 -1
- package/dist/client-contract/build-from-deployment.js +7 -0
- package/dist/cloud-publication.d.ts +37 -0
- package/dist/cloud-publication.d.ts.map +1 -0
- package/dist/cloud-publication.js +46 -0
- package/dist/cloud-publishing.d.ts +2 -2
- package/dist/cloud-publishing.d.ts.map +1 -1
- package/dist/codegen/dataset-source.d.ts.map +1 -1
- package/dist/codegen/dataset-source.js +4 -1
- package/dist/contract-3-authoring.fixture.d.ts +103 -0
- package/dist/contract-3-authoring.fixture.d.ts.map +1 -0
- package/dist/contract-3-authoring.fixture.js +40 -0
- package/dist/contract.d.ts +5 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +9 -0
- package/dist/dataset-compilation.d.ts +3 -0
- package/dist/dataset-compilation.d.ts.map +1 -1
- package/dist/dataset-query.d.ts +5 -0
- package/dist/dataset-query.d.ts.map +1 -1
- package/dist/dataset.d.ts.map +1 -1
- package/dist/dataset.js +12 -2
- package/dist/event-operations.d.ts +43 -0
- package/dist/event-operations.d.ts.map +1 -0
- package/dist/event-operations.js +137 -0
- package/dist/execution-capabilities.d.ts +2 -1
- package/dist/execution-capabilities.d.ts.map +1 -1
- package/dist/execution-capabilities.js +1 -1
- package/dist/execution-capabilities.json +6 -6
- package/dist/executor.d.ts +13 -0
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js +42 -8
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/portable-execution-errors.d.ts +11 -0
- package/dist/portable-execution-errors.d.ts.map +1 -1
- package/dist/portable-execution-errors.js +14 -0
- package/dist/portable-executor.d.ts +22 -5
- package/dist/portable-executor.d.ts.map +1 -1
- package/dist/portable-executor.js +64 -5
- package/dist/protocol-adapter.d.ts +12 -0
- package/dist/protocol-adapter.d.ts.map +1 -1
- package/dist/protocol-adapter.js +30 -8
- package/dist/protocol-deployment-adapter.d.ts +10 -3
- package/dist/protocol-deployment-adapter.d.ts.map +1 -1
- package/dist/protocol-deployment-adapter.js +60 -26
- package/dist/protocol-rehydrate.d.ts +3 -16
- package/dist/protocol-rehydrate.d.ts.map +1 -1
- package/dist/protocol-rehydrate.js +71 -11
- package/dist/query-builder-protocol.d.ts +10 -0
- package/dist/query-builder-protocol.d.ts.map +1 -1
- package/dist/query-planner.d.ts.map +1 -1
- package/dist/query-planner.js +3 -1
- package/dist/relationship-check.d.ts.map +1 -1
- package/dist/relationship-check.js +2 -0
- package/dist/semantic-planner.d.ts.map +1 -1
- package/dist/semantic-planner.js +16 -3
- package/dist/types.d.ts +109 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/agent-catalog-projection.d.ts +11 -2
- package/dist/utils/agent-catalog-projection.d.ts.map +1 -1
- package/dist/utils/agent-catalog-projection.js +49 -5
- package/dist/utils/build-dataset-query-builder.d.ts.map +1 -1
- package/dist/utils/build-dataset-query-builder.js +4 -8
- package/dist/utils/calculation-stage-sql.d.ts +31 -0
- package/dist/utils/calculation-stage-sql.d.ts.map +1 -0
- package/dist/utils/calculation-stage-sql.js +98 -0
- package/dist/utils/compile-calculated-dataset-query.d.ts +24 -0
- package/dist/utils/compile-calculated-dataset-query.d.ts.map +1 -0
- package/dist/utils/compile-calculated-dataset-query.js +133 -0
- package/dist/utils/compile-dataset-query.d.ts.map +1 -1
- package/dist/utils/compile-dataset-query.js +11 -3
- package/dist/utils/dataset-definition-validation.d.ts.map +1 -1
- package/dist/utils/dataset-definition-validation.js +90 -6
- package/dist/utils/dataset-events.d.ts +19 -0
- package/dist/utils/dataset-events.d.ts.map +1 -0
- package/dist/utils/dataset-events.js +46 -0
- package/dist/utils/dataset-having.d.ts.map +1 -1
- package/dist/utils/dataset-having.js +6 -1
- package/dist/utils/dataset-query-result.d.ts.map +1 -1
- package/dist/utils/dataset-query-result.js +7 -1
- package/dist/utils/dataset-query-validation.d.ts +1 -1
- package/dist/utils/dataset-query-validation.d.ts.map +1 -1
- package/dist/utils/dataset-query-validation.js +25 -47
- package/dist/utils/dataset-source.d.ts +2 -2
- package/dist/utils/dataset-source.d.ts.map +1 -1
- package/dist/utils/dataset-source.js +8 -1
- package/dist/utils/dimension-selection-overrides.d.ts +19 -0
- package/dist/utils/dimension-selection-overrides.d.ts.map +1 -0
- package/dist/utils/dimension-selection-overrides.js +22 -0
- package/dist/utils/event-breakdown-sql.d.ts +15 -0
- package/dist/utils/event-breakdown-sql.d.ts.map +1 -0
- package/dist/utils/event-breakdown-sql.js +17 -0
- package/dist/utils/event-condition-sql.d.ts +18 -0
- package/dist/utils/event-condition-sql.d.ts.map +1 -0
- package/dist/utils/event-condition-sql.js +63 -0
- package/dist/utils/event-operation-shape.d.ts +8 -0
- package/dist/utils/event-operation-shape.d.ts.map +1 -0
- package/dist/utils/event-operation-shape.js +66 -0
- package/dist/utils/event-operation-spec.d.ts +43 -0
- package/dist/utils/event-operation-spec.d.ts.map +1 -0
- package/dist/utils/event-operation-spec.js +68 -0
- package/dist/utils/event-range-span.d.ts +4 -0
- package/dist/utils/event-range-span.d.ts.map +1 -0
- package/dist/utils/event-range-span.js +22 -0
- package/dist/utils/event-result-values.d.ts +8 -0
- package/dist/utils/event-result-values.d.ts.map +1 -0
- package/dist/utils/event-result-values.js +21 -0
- package/dist/utils/event-source-sql.d.ts +38 -0
- package/dist/utils/event-source-sql.d.ts.map +1 -0
- package/dist/utils/event-source-sql.js +71 -0
- package/dist/utils/filter-predicate-tree.d.ts +28 -0
- package/dist/utils/filter-predicate-tree.d.ts.map +1 -0
- package/dist/utils/filter-predicate-tree.js +80 -0
- package/dist/utils/filter-tree.d.ts +42 -0
- package/dist/utils/filter-tree.d.ts.map +1 -0
- package/dist/utils/filter-tree.js +164 -0
- package/dist/utils/filtered-aggregation-sql.d.ts.map +1 -1
- package/dist/utils/filtered-aggregation-sql.js +3 -0
- package/dist/utils/funnel-rows.d.ts +10 -0
- package/dist/utils/funnel-rows.d.ts.map +1 -0
- package/dist/utils/funnel-rows.js +30 -0
- package/dist/utils/funnel-sql.d.ts +18 -0
- package/dist/utils/funnel-sql.d.ts.map +1 -0
- package/dist/utils/funnel-sql.js +104 -0
- package/dist/utils/metric-derived-query.d.ts.map +1 -1
- package/dist/utils/metric-derived-query.js +4 -5
- package/dist/utils/metric-query-builder.d.ts.map +1 -1
- package/dist/utils/metric-query-builder.js +4 -5
- package/dist/utils/metric-query-validation.d.ts.map +1 -1
- package/dist/utils/metric-query-validation.js +18 -7
- package/dist/utils/other-bucket-sql.d.ts +23 -0
- package/dist/utils/other-bucket-sql.d.ts.map +1 -0
- package/dist/utils/other-bucket-sql.js +51 -0
- package/dist/utils/portable-aggregations.d.ts +10 -6
- package/dist/utils/portable-aggregations.d.ts.map +1 -1
- package/dist/utils/portable-aggregations.js +13 -8
- package/dist/utils/portable-grains.d.ts +17 -8
- package/dist/utils/portable-grains.d.ts.map +1 -1
- package/dist/utils/portable-grains.js +26 -11
- package/dist/utils/portable-query-calculations.d.ts +14 -0
- package/dist/utils/portable-query-calculations.d.ts.map +1 -0
- package/dist/utils/portable-query-calculations.js +31 -0
- package/dist/utils/portable-semantic-query.d.ts.map +1 -1
- package/dist/utils/portable-semantic-query.js +27 -1
- package/dist/utils/protocol-contract-3.d.ts +30 -0
- package/dist/utils/protocol-contract-3.d.ts.map +1 -0
- package/dist/utils/protocol-contract-3.js +93 -0
- package/dist/utils/protocol-metric-capabilities.d.ts.map +1 -1
- package/dist/utils/protocol-metric-capabilities.js +2 -1
- package/dist/utils/protocol-metric-expressions.d.ts.map +1 -1
- package/dist/utils/protocol-metric-expressions.js +6 -1
- package/dist/utils/protocol-rehydrate-filters.js +2 -1
- package/dist/utils/protocol-rehydrate-time-keys.d.ts +5 -0
- package/dist/utils/protocol-rehydrate-time-keys.d.ts.map +1 -0
- package/dist/utils/protocol-rehydrate-time-keys.js +5 -0
- package/dist/utils/query-calculation-errors.d.ts +6 -0
- package/dist/utils/query-calculation-errors.d.ts.map +1 -0
- package/dist/utils/query-calculation-errors.js +9 -0
- package/dist/utils/query-calculation-formula.d.ts +19 -0
- package/dist/utils/query-calculation-formula.d.ts.map +1 -0
- package/dist/utils/query-calculation-formula.js +77 -0
- package/dist/utils/query-calculation-outputs.d.ts +24 -0
- package/dist/utils/query-calculation-outputs.d.ts.map +1 -0
- package/dist/utils/query-calculation-outputs.js +72 -0
- package/dist/utils/query-calculation-plan.d.ts +67 -0
- package/dist/utils/query-calculation-plan.d.ts.map +1 -0
- package/dist/utils/query-calculation-plan.js +416 -0
- package/dist/utils/query-calculation-types.d.ts +97 -0
- package/dist/utils/query-calculation-types.d.ts.map +1 -0
- package/dist/utils/query-calculation-types.js +8 -0
- package/dist/utils/query-field-references.d.ts.map +1 -1
- package/dist/utils/query-field-references.js +2 -1
- package/dist/utils/query-filter-errors.d.ts +11 -0
- package/dist/utils/query-filter-errors.d.ts.map +1 -0
- package/dist/utils/query-filter-errors.js +65 -0
- package/dist/utils/query-timezone.d.ts +6 -3
- package/dist/utils/query-timezone.d.ts.map +1 -1
- package/dist/utils/query-timezone.js +5 -1
- package/dist/utils/relationship-builder-plan.d.ts.map +1 -1
- package/dist/utils/relationship-builder-plan.js +2 -1
- package/dist/utils/relationship-fields.d.ts.map +1 -1
- package/dist/utils/relationship-fields.js +5 -0
- package/dist/utils/relationship-measure-sql.d.ts.map +1 -1
- package/dist/utils/relationship-measure-sql.js +2 -0
- package/dist/utils/relationship-validation.d.ts +3 -1
- package/dist/utils/relationship-validation.d.ts.map +1 -1
- package/dist/utils/relationship-validation.js +8 -4
- package/dist/utils/relative-date-filters.d.ts +21 -0
- package/dist/utils/relative-date-filters.d.ts.map +1 -0
- package/dist/utils/relative-date-filters.js +86 -0
- package/dist/utils/relative-date-range.d.ts +20 -0
- package/dist/utils/relative-date-range.d.ts.map +1 -0
- package/dist/utils/relative-date-range.js +75 -0
- package/dist/utils/retention-rows.d.ts +9 -0
- package/dist/utils/retention-rows.d.ts.map +1 -0
- package/dist/utils/retention-rows.js +30 -0
- package/dist/utils/retention-sql.d.ts +16 -0
- package/dist/utils/retention-sql.d.ts.map +1 -0
- package/dist/utils/retention-sql.js +68 -0
- package/dist/utils/scoped-dataset-source.d.ts.map +1 -1
- package/dist/utils/scoped-dataset-source.js +4 -0
- package/dist/utils/segments.d.ts +3 -2
- package/dist/utils/segments.d.ts.map +1 -1
- package/dist/utils/segments.js +5 -4
- package/dist/utils/semantic-query-syntax.d.ts.map +1 -1
- package/dist/utils/semantic-query-syntax.js +8 -2
- package/dist/utils/sql-dataset-source.d.ts +36 -0
- package/dist/utils/sql-dataset-source.d.ts.map +1 -0
- package/dist/utils/sql-dataset-source.js +126 -0
- package/dist/utils/time-axis-bounds.d.ts +11 -4
- package/dist/utils/time-axis-bounds.d.ts.map +1 -1
- package/dist/utils/time-axis-bounds.js +14 -6
- package/dist/utils/time-measure-axis.d.ts +2 -2
- package/dist/utils/time-measure-axis.d.ts.map +1 -1
- package/dist/utils/time-measure-axis.js +13 -3
- package/dist/utils/time-measure-dataset-sql.d.ts +1 -1
- package/dist/utils/time-measure-dataset-sql.d.ts.map +1 -1
- package/dist/utils/time-measure-dataset-sql.js +15 -5
- package/dist/utils/time-measure-source-sql.d.ts +2 -2
- package/dist/utils/time-measure-source-sql.d.ts.map +1 -1
- package/dist/utils/time-measure-source-sql.js +7 -8
- package/dist/utils/time-query-measures.d.ts +5 -0
- package/dist/utils/time-query-measures.d.ts.map +1 -1
- package/dist/utils/time-query-measures.js +7 -0
- package/dist/utils/unsupported-contract-reasons.d.ts +5 -1
- package/dist/utils/unsupported-contract-reasons.d.ts.map +1 -1
- package/dist/utils/unsupported-contract-reasons.js +5 -1
- package/package.json +3 -3
package/dist/agent-catalog.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type WindowCatalogMetadata } from './utils/window-catalog-metadata.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProtocolDeploymentContractAnyVersion } from '@hypequery/protocol';
|
|
3
3
|
import { type DatasetCatalog, type DatasetCatalogMap, type DatasetCatalogSource } from './catalog.js';
|
|
4
4
|
import type { SemanticContract } from './contract.js';
|
|
5
5
|
import type { DatasetDefaults, DatasetFreshness, DatasetLimits, FieldType, SemanticMetadata } from './types.js';
|
|
@@ -69,7 +69,7 @@ export interface AgentCatalogProjectionOptions {
|
|
|
69
69
|
}
|
|
70
70
|
export declare const DEFAULT_AGENT_CATALOG_MAX_BYTES: number;
|
|
71
71
|
export type AgentCatalogDatasetRegistry = Readonly<Record<string, DatasetCatalogSource | DatasetCatalog>>;
|
|
72
|
-
export type AgentCatalogSource = AgentCatalogDatasetRegistry | SemanticContract |
|
|
72
|
+
export type AgentCatalogSource = AgentCatalogDatasetRegistry | SemanticContract | ProtocolDeploymentContractAnyVersion;
|
|
73
73
|
/**
|
|
74
74
|
* Proof supplied by an owning application after it authorizes a trusted-debug
|
|
75
75
|
* request. The datasets package deliberately does not manufacture this value:
|
|
@@ -86,7 +86,7 @@ export type TrustedDebugCatalog = {
|
|
|
86
86
|
readonly contract: SemanticContract;
|
|
87
87
|
} | {
|
|
88
88
|
readonly kind: 'deployment-contract';
|
|
89
|
-
readonly contract:
|
|
89
|
+
readonly contract: ProtocolDeploymentContractAnyVersion;
|
|
90
90
|
};
|
|
91
91
|
/** Build the deterministic logical catalog that may safely be shown to an agent. */
|
|
92
92
|
export declare function projectAgentSafeCatalog(source: AgentCatalogSource, options?: AgentCatalogProjectionOptions): AgentSafeCatalog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-catalog.d.ts","sourceRoot":"","sources":["../src/agent-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"agent-catalog.d.ts","sourceRoot":"","sources":["../src/agent-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAOpB,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,EAAE,qBAAqB;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,WAAW,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EA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":"","sources":["../../src/cache/protocol-cache-keys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"protocol-cache-keys.d.ts","sourceRoot":"","sources":["../../src/cache/protocol-cache-keys.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EACX,SAAS,EACV,MAAM,aAAa,CAAC;AAOrB,sEAAsE;AACtE,eAAO,MAAM,qBAAqB,cAAc,CAAC;AACjD,eAAO,MAAM,yBAAyB,YAAY,CAAC;AAInD,0EAA0E;AAC1E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAID;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,uBAAuB,EAChC,WAAW,EAAE,OAAO,GACnB,wBAAwB,CAqC1B;AA4JD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,wBAAwB,EAClC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAuBpB;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,wBAAwB,EAClC,MAAM,EAAE,SAAS,GAAG,gBAAgB,EACpC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { hasQueryCalculations } from '../utils/query-calculation-outputs.js';
|
|
1
2
|
import { buildProtocolCachePreimage, deriveProtocolCacheKey, validateCanonicalValue, } from '@hypequery/protocol';
|
|
3
|
+
import { isFilterGroup } from '../utils/filter-tree.js';
|
|
2
4
|
import { getMetricGrain, getMetricRef } from '../utils/metric-handle.js';
|
|
3
5
|
import { runtimeConstraints } from '../utils/row-scope.js';
|
|
4
6
|
import { localDefinitionIdentity, scopedDefinitionIdentity } from './definition-identity.js';
|
|
@@ -75,7 +77,23 @@ function canonicalLiteral(value) {
|
|
|
75
77
|
}
|
|
76
78
|
return validateCanonicalValue(value);
|
|
77
79
|
}
|
|
78
|
-
|
|
80
|
+
/**
|
|
81
|
+
* A caller filter as an RFC 0003 predicate: a group becomes a `logical` node
|
|
82
|
+
* (RFC 0029), a one-item group its item, since `and`/`or` take two or more.
|
|
83
|
+
*/
|
|
84
|
+
function filterNode(node) {
|
|
85
|
+
if (!isFilterGroup(node))
|
|
86
|
+
return comparisonNode(node);
|
|
87
|
+
if ('not' in node && node.not !== undefined) {
|
|
88
|
+
return { kind: 'logical', operator: 'not', operand: filterNode(node.not) };
|
|
89
|
+
}
|
|
90
|
+
const operator = 'and' in node && node.and !== undefined ? 'and' : 'or';
|
|
91
|
+
const items = (operator === 'and' ? node.and : node.or);
|
|
92
|
+
if (items.length === 1)
|
|
93
|
+
return filterNode(items[0]);
|
|
94
|
+
return { kind: 'logical', operator, operands: items.map(filterNode) };
|
|
95
|
+
}
|
|
96
|
+
function comparisonNode(filter) {
|
|
79
97
|
const left = { kind: 'reference', name: filter.field };
|
|
80
98
|
// A null check has no value, so its node has no right operand (RFC 0023).
|
|
81
99
|
if (filter.operator === 'isNull' || filter.operator === 'isNotNull') {
|
|
@@ -188,6 +206,9 @@ export function datasetCacheKey(settings, ds, query, context, scope) {
|
|
|
188
206
|
// as the Python SDK does, until the shared preimage covers `having`.
|
|
189
207
|
if (query.having !== undefined && query.having.length > 0)
|
|
190
208
|
return undefined;
|
|
209
|
+
// RFC 0026: calculations, limitBy and other have no portable key either.
|
|
210
|
+
if (hasQueryCalculations(query))
|
|
211
|
+
return undefined;
|
|
191
212
|
try {
|
|
192
213
|
const wire = {
|
|
193
214
|
kind: 'dataset',
|
|
@@ -195,6 +216,9 @@ export function datasetCacheKey(settings, ds, query, context, scope) {
|
|
|
195
216
|
...sharedQueryFields(query, context),
|
|
196
217
|
...(query.measures !== undefined ? { measures: [...query.measures] } : {}),
|
|
197
218
|
...(query.by !== undefined ? { by: query.by } : {}),
|
|
219
|
+
// RFC 0029: a filled series has no portable key, so the preimage
|
|
220
|
+
// refuses it and the call runs uncached rather than sharing a key.
|
|
221
|
+
...(query.fill === true ? { fill: true } : {}),
|
|
198
222
|
};
|
|
199
223
|
return deriveKey(settings, wire, definitionFor(settings, ds, scope, query), context, query.limit);
|
|
200
224
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-signature.d.ts","sourceRoot":"","sources":["../../src/cache/query-signature.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query-signature.d.ts","sourceRoot":"","sources":["../../src/cache/query-signature.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAElB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAGhB,WAAW,EACX,SAAS,EACV,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,CAAC;AAwG3B;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CA4BR;AAED,oDAAoD;AACpD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,GAAG,gBAAgB,EACpC,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CAuBR"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { sqlSourceSha256 } from '../utils/sql-dataset-source.js';
|
|
1
2
|
import { windowQuerySignature } from '../utils/window-query-signature.js';
|
|
3
|
+
import { isFilterGroup } from '../utils/filter-tree.js';
|
|
2
4
|
import { getMetricGrain, getMetricRef } from '../utils/metric-handle.js';
|
|
3
5
|
import { getRuntimeTenantPredicate } from '../utils/tenant-runtime.js';
|
|
4
6
|
import { runtimeConstraints } from '../utils/row-scope.js';
|
|
@@ -16,11 +18,16 @@ function scopeSignature(context) {
|
|
|
16
18
|
return cache ? cache.scope ?? null : null;
|
|
17
19
|
}
|
|
18
20
|
function filterSignature(filters) {
|
|
19
|
-
return (filters ?? []).map((filter) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return (filters ?? []).map((filter) => {
|
|
22
|
+
if (!isFilterGroup(filter)) {
|
|
23
|
+
return { field: filter.field, operator: filter.operator, value: filter.value ?? null };
|
|
24
|
+
}
|
|
25
|
+
if ('not' in filter && filter.not !== undefined)
|
|
26
|
+
return { not: filterSignature([filter.not])[0] };
|
|
27
|
+
return 'and' in filter && filter.and !== undefined
|
|
28
|
+
? { and: filterSignature([...filter.and]) }
|
|
29
|
+
: { or: filterSignature([...filter.or]) };
|
|
30
|
+
});
|
|
24
31
|
}
|
|
25
32
|
function havingSignature(having) {
|
|
26
33
|
return having.map((condition) => ({
|
|
@@ -96,6 +103,7 @@ export function buildDatasetQuerySignature(ds, query, context) {
|
|
|
96
103
|
kind: 'dataset',
|
|
97
104
|
target: ds.name,
|
|
98
105
|
source: ds.source,
|
|
106
|
+
...(ds.sqlSource ? { sourceSha256: sqlSourceSha256(ds.sqlSource) } : {}),
|
|
99
107
|
// Omitted when false so existing datasets keep their cache keys.
|
|
100
108
|
...(ds.rowResolution ? { rowResolution: ds.rowResolution } : {}),
|
|
101
109
|
dimensions: query.dimensions ?? null,
|
|
@@ -109,6 +117,8 @@ export function buildDatasetQuerySignature(ds, query, context) {
|
|
|
109
117
|
orderBy: orderBySignature(query.orderBy),
|
|
110
118
|
by: query.by ?? null,
|
|
111
119
|
...(query.timezone === undefined ? {} : { timezone: query.timezone }),
|
|
120
|
+
// Omitted unless set, so unfilled queries keep their keys (RFC 0029).
|
|
121
|
+
...(query.fill === true ? { fill: true } : {}),
|
|
112
122
|
limit: query.limit ?? null,
|
|
113
123
|
offset: query.offset ?? null,
|
|
114
124
|
tenant: tenantSignature(ds, query, context),
|
|
@@ -125,6 +135,7 @@ export function buildMetricQuerySignature(metric, query, context) {
|
|
|
125
135
|
kind: 'metric',
|
|
126
136
|
target: `${ref.dataset.name}.${ref.name}`,
|
|
127
137
|
source: ref.dataset.source,
|
|
138
|
+
...(ref.dataset.sqlSource ? { sourceSha256: sqlSourceSha256(ref.dataset.sqlSource) } : {}),
|
|
128
139
|
...(ref.dataset.rowResolution ? { rowResolution: ref.dataset.rowResolution } : {}),
|
|
129
140
|
metricKind: ref.spec.__type,
|
|
130
141
|
dimensions: query.dimensions ?? null,
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RowResolution } from './types.js';
|
|
1
|
+
import type { DatasetEvents, DatasetSqlSource, RowResolution } from './types.js';
|
|
2
2
|
import type { ProtocolExpression } from '@hypequery/protocol';
|
|
3
3
|
import type { RelationshipKey } from './types.js';
|
|
4
4
|
import { type WindowCatalogMetadata } from './utils/window-catalog-metadata.js';
|
|
@@ -85,12 +85,16 @@ export interface DatasetCatalog extends SemanticMetadata {
|
|
|
85
85
|
name: string;
|
|
86
86
|
description?: string;
|
|
87
87
|
source: string;
|
|
88
|
+
/** RFC 0028: the SQL source, when `source` aliases a derived table. */
|
|
89
|
+
sqlSource?: DatasetSqlSource;
|
|
88
90
|
rowResolution?: RowResolution;
|
|
89
91
|
freshness?: DatasetFreshness;
|
|
90
92
|
owner?: string;
|
|
91
93
|
defaults?: DatasetDefaults;
|
|
92
94
|
tenantKey?: string;
|
|
93
95
|
timeKey?: string;
|
|
96
|
+
/** Present when rows are events: funnel and retention can run (RFC 0027). */
|
|
97
|
+
events?: DatasetEvents;
|
|
94
98
|
/** Alternate time axes a query may select; absent when the dataset declares none. */
|
|
95
99
|
timeKeys?: string[];
|
|
96
100
|
dimensions: Record<string, DimensionCatalogEntry>;
|
package/dist/catalog.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEvG,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACV,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAUnF,MAAM,W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oB,GAAG,kBAAkB,GAAG;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC,CAAC;AAkFF,kGAAkG;AAClG,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE,CAIhF;AAED,4DAA4D;AAC5D,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE,CAGlF;AAED,gFAAgF;AAChF,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE,CAIhF;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,GAAG,cAAc,CA+G/E;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,iBAAiB,CAOpG"}
|
package/dist/catalog.js
CHANGED
|
@@ -114,12 +114,21 @@ export function getDatasetCatalog(dataset) {
|
|
|
114
114
|
description: dataset.description,
|
|
115
115
|
...snapshotSemanticMetadata(dataset),
|
|
116
116
|
source: dataset.source,
|
|
117
|
+
...(dataset.sqlSource === undefined ? {} : {
|
|
118
|
+
sqlSource: {
|
|
119
|
+
sql: dataset.sqlSource.sql,
|
|
120
|
+
alias: dataset.sqlSource.alias,
|
|
121
|
+
dependencies: [...dataset.sqlSource.dependencies],
|
|
122
|
+
columns: { ...dataset.sqlSource.columns },
|
|
123
|
+
},
|
|
124
|
+
}),
|
|
117
125
|
...(dataset.rowResolution === undefined ? {} : { rowResolution: { ...dataset.rowResolution } }),
|
|
118
126
|
freshness: dataset.freshness,
|
|
119
127
|
owner: dataset.owner,
|
|
120
128
|
defaults: dataset.defaults,
|
|
121
129
|
tenantKey: dataset.tenantKey,
|
|
122
130
|
timeKey: dataset.timeKey,
|
|
131
|
+
...(dataset.events === undefined ? {} : { events: { ...dataset.events } }),
|
|
123
132
|
...(dataset.timeKeys?.length ? { timeKeys: [...dataset.timeKeys] } : {}),
|
|
124
133
|
dimensions: Object.fromEntries(Object.entries(dataset.dimensions).map(([name, dimension]) => [
|
|
125
134
|
name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PreparedProtocolClientContract, type
|
|
1
|
+
import { type PreparedProtocolClientContract, type ProtocolDeploymentContractAnyVersion, type ProtocolDeploymentDataset } from '@hypequery/protocol';
|
|
2
2
|
import { type ClientContractProfile } from './deployment-profile.js';
|
|
3
3
|
export interface BuildClientContractOptions {
|
|
4
4
|
/** Ceilings the host enforces; defaults mirror Python's ClientQueryProfile. */
|
|
@@ -43,5 +43,5 @@ export interface ClientContractCapabilities {
|
|
|
43
43
|
* endpoint policy (relationship targets) are not advertised, and neither are
|
|
44
44
|
* relationship fields yet.
|
|
45
45
|
*/
|
|
46
|
-
export declare function buildClientContract(contract:
|
|
46
|
+
export declare function buildClientContract(contract: ProtocolDeploymentContractAnyVersion, options?: BuildClientContractOptions): PreparedProtocolClientContract;
|
|
47
47
|
//# sourceMappingURL=build-from-deployment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-from-deployment.d.ts","sourceRoot":"","sources":["../../src/client-contract/build-from-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,
|
|
1
|
+
{"version":3,"file":"build-from-deployment.d.ts","sourceRoot":"","sources":["../../src/client-contract/build-from-deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAI7B,OAAO,EAAmD,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEtH,MAAM,WAAW,0BAA0B;IACzC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,uGAAuG;IACvG,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,8DAA8D;IAC9D,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IACvC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC;IACnE;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,0BAA0B,CAAC;IACnD;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,0BAA0B;IACzC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AA8DD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,oCAAoC,EAC9C,OAAO,GAAE,0BAA+B,GACvC,8BAA8B,CAuBhC"}
|
|
@@ -61,6 +61,13 @@ function endpointDescriptor(dataset, options, profile) {
|
|
|
61
61
|
* relationship fields yet.
|
|
62
62
|
*/
|
|
63
63
|
export function buildClientContract(contract, options = {}) {
|
|
64
|
+
if (contract.version === 3) {
|
|
65
|
+
// Client contract 1 has no field for segments, window and shift measures'
|
|
66
|
+
// time-range requirement, or sub-day grains, so it would advertise a
|
|
67
|
+
// schema that rejects valid requests. Refuse rather than mislead.
|
|
68
|
+
throw new Error('Client export: this deployment is contract 3 (segments, window or shift measures, '
|
|
69
|
+
+ 'approxCountDistinct, or sub-day grains), which client contracts do not describe yet.');
|
|
70
|
+
}
|
|
64
71
|
const { mountPath } = options;
|
|
65
72
|
if (mountPath && (!mountPath.startsWith('/') || mountPath.endsWith('/'))) {
|
|
66
73
|
throw new Error('Client export: mountPath must be empty or an absolute path without a trailing slash.');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ProtocolBusinessContext, type ProtocolDeploymentContractAnyVersion } from '@hypequery/protocol';
|
|
2
|
+
/** Business context as authored in code: the document without its header. */
|
|
3
|
+
export type BusinessContextInput = Omit<ProtocolBusinessContext, 'kind' | 'version'>;
|
|
4
|
+
/**
|
|
5
|
+
* Everything `hypequery deploy` publishes to Cloud from a code project.
|
|
6
|
+
*
|
|
7
|
+
* The deployment contract stays the executable source of truth; the business
|
|
8
|
+
* context travels beside it in the same immutable release, so publishing,
|
|
9
|
+
* staging and rollback move both together.
|
|
10
|
+
*/
|
|
11
|
+
export interface CloudPublication {
|
|
12
|
+
readonly kind: 'hypequery-cloud-publication';
|
|
13
|
+
readonly version: 1;
|
|
14
|
+
readonly deployment: ProtocolDeploymentContractAnyVersion;
|
|
15
|
+
readonly businessContext?: ProtocolBusinessContext;
|
|
16
|
+
}
|
|
17
|
+
export interface CloudPublicationOptions {
|
|
18
|
+
/** The result of `publishToCloud({ datasets, access })`. */
|
|
19
|
+
readonly deployment: ProtocolDeploymentContractAnyVersion;
|
|
20
|
+
/** Reviewed business context: summary, KPIs, glossary, conventions, caveats. */
|
|
21
|
+
readonly businessContext?: ProtocolBusinessContext | BusinessContextInput;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Declare reviewed business context for AI analysts in Cloud.
|
|
25
|
+
*
|
|
26
|
+
* Text is trimmed and empty lists are dropped. Throws a
|
|
27
|
+
* `ProtocolBusinessContextError` naming the offending path when the document
|
|
28
|
+
* is invalid, e.g. a glossary term defined twice.
|
|
29
|
+
*/
|
|
30
|
+
export declare function defineBusinessContext(input: BusinessContextInput): ProtocolBusinessContext;
|
|
31
|
+
/**
|
|
32
|
+
* Bundle a deployment contract with its business context for Cloud.
|
|
33
|
+
* Export the result as `cloud` from the deployment entrypoint. A bare
|
|
34
|
+
* `publishToCloud(...)` export remains valid and publishes no context.
|
|
35
|
+
*/
|
|
36
|
+
export declare function defineCloudPublication(options: CloudPublicationOptions): CloudPublication;
|
|
37
|
+
//# sourceMappingURL=cloud-publication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-publication.d.ts","sourceRoot":"","sources":["../src/cloud-publication.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,oCAAoC,EAC1C,MAAM,qBAAqB,CAAC;AAE7B,6EAA6E;AAC7E,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,oCAAoC,CAAC;IAC1D,QAAQ,CAAC,eAAe,CAAC,EAAE,uBAAuB,CAAC;CACpD;AAED,MAAM,WAAW,uBAAuB;IACtC,4DAA4D;IAC5D,QAAQ,CAAC,UAAU,EAAE,oCAAoC,CAAC;IAC1D,gFAAgF;IAChF,QAAQ,CAAC,eAAe,CAAC,EAAE,uBAAuB,GAAG,oBAAoB,CAAC;CAC3E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,oBAAoB,GAAG,uBAAuB,CAS1F;AAMD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,uBAAuB,GAAG,gBAAgB,CAqBzF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { validateProtocolBusinessContext, } from '@hypequery/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Declare reviewed business context for AI analysts in Cloud.
|
|
4
|
+
*
|
|
5
|
+
* Text is trimmed and empty lists are dropped. Throws a
|
|
6
|
+
* `ProtocolBusinessContextError` naming the offending path when the document
|
|
7
|
+
* is invalid, e.g. a glossary term defined twice.
|
|
8
|
+
*/
|
|
9
|
+
export function defineBusinessContext(input) {
|
|
10
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
|
|
11
|
+
throw new TypeError('defineBusinessContext expects an object.');
|
|
12
|
+
}
|
|
13
|
+
return validateProtocolBusinessContext({
|
|
14
|
+
...input,
|
|
15
|
+
kind: 'hypequery-business-context',
|
|
16
|
+
version: 1,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function isBusinessContextDocument(value) {
|
|
20
|
+
return 'kind' in value && value.kind === 'hypequery-business-context';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Bundle a deployment contract with its business context for Cloud.
|
|
24
|
+
* Export the result as `cloud` from the deployment entrypoint. A bare
|
|
25
|
+
* `publishToCloud(...)` export remains valid and publishes no context.
|
|
26
|
+
*/
|
|
27
|
+
export function defineCloudPublication(options) {
|
|
28
|
+
const deployment = options?.deployment;
|
|
29
|
+
if (typeof deployment !== 'object' || deployment === null
|
|
30
|
+
|| deployment.kind !== 'hypequery-deployment') {
|
|
31
|
+
throw new Error('defineCloudPublication requires `deployment: publishToCloud({ datasets, access })`.');
|
|
32
|
+
}
|
|
33
|
+
const input = options.businessContext;
|
|
34
|
+
let businessContext;
|
|
35
|
+
if (input !== undefined) {
|
|
36
|
+
businessContext = isBusinessContextDocument(input)
|
|
37
|
+
? validateProtocolBusinessContext(input)
|
|
38
|
+
: defineBusinessContext(input);
|
|
39
|
+
}
|
|
40
|
+
return Object.freeze({
|
|
41
|
+
kind: 'hypequery-cloud-publication',
|
|
42
|
+
version: 1,
|
|
43
|
+
deployment: options.deployment,
|
|
44
|
+
...(businessContext ? { businessContext } : {}),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type ProtocolDeploymentContractAnyVersion, type ProtocolEndpointPolicy } from '@hypequery/protocol';
|
|
2
2
|
import type { AnyDatasetInstance } from './types.js';
|
|
3
3
|
export interface CloudPublishingOptions {
|
|
4
4
|
/** Datasets exposed to Cloud. Relationships are included as supporting datasets. */
|
|
@@ -32,5 +32,5 @@ export interface CloudPublishingOptions {
|
|
|
32
32
|
* This function performs no network request and requires no Serve API.
|
|
33
33
|
* Export its result as `cloud` from the deployment entrypoint.
|
|
34
34
|
*/
|
|
35
|
-
export declare function publishToCloud(options: CloudPublishingOptions):
|
|
35
|
+
export declare function publishToCloud(options: CloudPublishingOptions): ProtocolDeploymentContractAnyVersion;
|
|
36
36
|
//# sourceMappingURL=cloud-publishing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-publishing.d.ts","sourceRoot":"","sources":["../src/cloud-publishing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"cloud-publishing.d.ts","sourceRoot":"","sources":["../src/cloud-publishing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oCAAoC,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGrD,MAAM,WAAW,sBAAsB;IACrC,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAChE,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;KACpC,CAAC;IACF,uEAAuE;IACvE,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAC/C,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;KACpC,CAAC,CAAC,CAAC;IACJ;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;CACpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,sBAAsB,GAAG,oCAAoC,CAyEpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataset-source.d.ts","sourceRoot":"","sources":["../../src/codegen/dataset-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataset-source.d.ts","sourceRoot":"","sources":["../../src/codegen/dataset-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAKV,yBAAyB,EAK1B,MAAM,qBAAqB,CAAC;AAQ7B;;;;;;;;GAQG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACvC;AAwCD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,yBAAyB,EAClC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC;AACtC,oDAAoD;AACpD,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,aAAa,CA6Lf"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isProtocolSqlSource } from '@hypequery/protocol';
|
|
2
|
+
import { sqlSourceFromContract } from '../utils/sql-dataset-source.js';
|
|
1
3
|
import { SEMANTIC_FILTER_OPERATORS } from '../constants.js';
|
|
2
4
|
import { stableStringify } from '../utils/canonical-json.js';
|
|
3
5
|
import { ContractExportError } from './errors.js';
|
|
@@ -200,7 +202,7 @@ earlier) {
|
|
|
200
202
|
...derivedMeasures.map(item => [String(item.name), derivedMeasure(item)]),
|
|
201
203
|
];
|
|
202
204
|
const config = {
|
|
203
|
-
source: dataset.source,
|
|
205
|
+
source: isProtocolSqlSource(dataset.source) ? sqlSourceFromContract(dataset.source) : dataset.source,
|
|
204
206
|
description: dataset.description,
|
|
205
207
|
...metadata(dataset, 'the dataset'),
|
|
206
208
|
rowResolution: dataset.rowResolution,
|
|
@@ -208,6 +210,7 @@ earlier) {
|
|
|
208
210
|
owner: dataset.owner,
|
|
209
211
|
tenantKey: dataset.tenant.kind === 'required' ? dataset.tenant.field : undefined,
|
|
210
212
|
timeKey: dataset.timeField === undefined ? undefined : String(dataset.timeField),
|
|
213
|
+
events: dataset.events,
|
|
211
214
|
defaults: dataset.defaults,
|
|
212
215
|
dimensions: Object.fromEntries(dataset.dimensions.map(item => [String(item.name), dimension(item)])),
|
|
213
216
|
measures: measures.length > 0 ? Object.fromEntries(measures) : undefined,
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authoring side of `specs/datasets/contract-3-authoring-v1.json`: one
|
|
3
|
+
* dataset using every contract 3 feature an author can declare in both
|
|
4
|
+
* TypeScript and Python. Python's `tests/test_contract_3_authoring.py` builds
|
|
5
|
+
* the same definition and must emit the same contract.
|
|
6
|
+
*/
|
|
7
|
+
export declare const contract3AuthoringDataset: import("./types.js").DatasetInstance<{
|
|
8
|
+
amount: import("./types.js").DimensionDefinition<"number"> & import("./types.js").DimensionDefinition<import("./types.js").FieldType>;
|
|
9
|
+
occurredAt: import("./types.js").DimensionDefinition<"timestamp"> & import("./types.js").DimensionDefinition<import("./types.js").FieldType>;
|
|
10
|
+
plan: import("./types.js").DimensionDefinition<"string"> & import("./types.js").DimensionDefinition<import("./types.js").FieldType>;
|
|
11
|
+
status: import("./types.js").DimensionDefinition<"string"> & import("./types.js").DimensionDefinition<import("./types.js").FieldType>;
|
|
12
|
+
userId: import("./types.js").DimensionDefinition<"string"> & import("./types.js").DimensionDefinition<import("./types.js").FieldType>;
|
|
13
|
+
}, {
|
|
14
|
+
revenue: import("./types.js").MeasureDefinition & {
|
|
15
|
+
aggregation: "sum";
|
|
16
|
+
field: "amount";
|
|
17
|
+
} & import("./types.js").MeasureOptions;
|
|
18
|
+
visitors: import("./types.js").MeasureDefinition & {
|
|
19
|
+
aggregation: "approxCountDistinct";
|
|
20
|
+
field: "userId";
|
|
21
|
+
} & {
|
|
22
|
+
readonly label: "Visitors";
|
|
23
|
+
};
|
|
24
|
+
revenue7d: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
25
|
+
revenueMtd: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
26
|
+
revenueRunning: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
27
|
+
visitors7d: import("./types.js").WindowMeasureDefinition<"visitors">;
|
|
28
|
+
revenuePriorWeek: import("./types.js").ShiftMeasureDefinition<"revenue">;
|
|
29
|
+
revenueGrowth: import("./types.js").DerivedMeasureDefinition<{
|
|
30
|
+
readonly revenue: "revenue";
|
|
31
|
+
readonly revenuePriorWeek: "revenuePriorWeek";
|
|
32
|
+
}>;
|
|
33
|
+
revenuePerVisitor: import("./types.js").DerivedMeasureDefinition<{
|
|
34
|
+
readonly revenue: "revenue";
|
|
35
|
+
readonly visitors: "visitors";
|
|
36
|
+
}>;
|
|
37
|
+
}, Record<string, never>, "events", import("./types.js").DerivedMeasures<{
|
|
38
|
+
revenue: import("./types.js").MeasureDefinition & {
|
|
39
|
+
aggregation: "sum";
|
|
40
|
+
field: "amount";
|
|
41
|
+
} & import("./types.js").MeasureOptions;
|
|
42
|
+
visitors: import("./types.js").MeasureDefinition & {
|
|
43
|
+
aggregation: "approxCountDistinct";
|
|
44
|
+
field: "userId";
|
|
45
|
+
} & {
|
|
46
|
+
readonly label: "Visitors";
|
|
47
|
+
};
|
|
48
|
+
revenue7d: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
49
|
+
revenueMtd: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
50
|
+
revenueRunning: import("./types.js").WindowMeasureDefinition<"revenue">;
|
|
51
|
+
visitors7d: import("./types.js").WindowMeasureDefinition<"visitors">;
|
|
52
|
+
revenuePriorWeek: import("./types.js").ShiftMeasureDefinition<"revenue">;
|
|
53
|
+
revenueGrowth: import("./types.js").DerivedMeasureDefinition<{
|
|
54
|
+
readonly revenue: "revenue";
|
|
55
|
+
readonly revenuePriorWeek: "revenuePriorWeek";
|
|
56
|
+
}>;
|
|
57
|
+
revenuePerVisitor: import("./types.js").DerivedMeasureDefinition<{
|
|
58
|
+
readonly revenue: "revenue";
|
|
59
|
+
readonly visitors: "visitors";
|
|
60
|
+
}>;
|
|
61
|
+
}>, {
|
|
62
|
+
readonly enterprise: {
|
|
63
|
+
readonly filters: [{
|
|
64
|
+
field: "plan";
|
|
65
|
+
operator: "eq";
|
|
66
|
+
value: "enterprise";
|
|
67
|
+
}];
|
|
68
|
+
readonly description: "Enterprise plan";
|
|
69
|
+
};
|
|
70
|
+
readonly bigPaid: {
|
|
71
|
+
readonly filters: [{
|
|
72
|
+
field: "status";
|
|
73
|
+
operator: "eq";
|
|
74
|
+
value: "paid";
|
|
75
|
+
}, {
|
|
76
|
+
field: "amount";
|
|
77
|
+
operator: "gte";
|
|
78
|
+
value: 100;
|
|
79
|
+
}];
|
|
80
|
+
};
|
|
81
|
+
}, import("./types.js").SemanticFiltersDefinition | {
|
|
82
|
+
amount: Omit<import("./types.js").SemanticFilterDefinition, "operators"> & {
|
|
83
|
+
field: "amount";
|
|
84
|
+
operators?: undefined;
|
|
85
|
+
};
|
|
86
|
+
occurredAt: Omit<import("./types.js").SemanticFilterDefinition, "operators"> & {
|
|
87
|
+
field: "occurredAt";
|
|
88
|
+
operators?: undefined;
|
|
89
|
+
};
|
|
90
|
+
plan: Omit<import("./types.js").SemanticFilterDefinition, "operators"> & {
|
|
91
|
+
field: "plan";
|
|
92
|
+
operators?: undefined;
|
|
93
|
+
};
|
|
94
|
+
status: Omit<import("./types.js").SemanticFilterDefinition, "operators"> & {
|
|
95
|
+
field: "status";
|
|
96
|
+
operators?: undefined;
|
|
97
|
+
};
|
|
98
|
+
userId: Omit<import("./types.js").SemanticFilterDefinition, "operators"> & {
|
|
99
|
+
field: "userId";
|
|
100
|
+
operators?: undefined;
|
|
101
|
+
};
|
|
102
|
+
}, "occurredAt", never>;
|
|
103
|
+
//# sourceMappingURL=contract-3-authoring.fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-3-authoring.fixture.d.ts","sourceRoot":"","sources":["../src/contract-3-authoring.fixture.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAgCpC,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { dataset, dimension, divide, eq, gte, measure, nullIfZero, subtract } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The authoring side of `specs/datasets/contract-3-authoring-v1.json`: one
|
|
4
|
+
* dataset using every contract 3 feature an author can declare in both
|
|
5
|
+
* TypeScript and Python. Python's `tests/test_contract_3_authoring.py` builds
|
|
6
|
+
* the same definition and must emit the same contract.
|
|
7
|
+
*/
|
|
8
|
+
export const contract3AuthoringDataset = dataset('events', {
|
|
9
|
+
source: 'analytics.events',
|
|
10
|
+
tenantKey: 'tenant_id',
|
|
11
|
+
timeKey: 'occurredAt',
|
|
12
|
+
dimensions: {
|
|
13
|
+
amount: dimension.number(),
|
|
14
|
+
occurredAt: dimension.timestamp(),
|
|
15
|
+
plan: dimension.string(),
|
|
16
|
+
status: dimension.string(),
|
|
17
|
+
userId: dimension.string(),
|
|
18
|
+
},
|
|
19
|
+
measures: {
|
|
20
|
+
revenue: measure.sum('amount'),
|
|
21
|
+
visitors: measure.approxCountDistinct('userId', { label: 'Visitors' }),
|
|
22
|
+
revenue7d: measure.trailing('revenue', { amount: 7, unit: 'day' }),
|
|
23
|
+
revenueMtd: measure.toDate('revenue', 'month'),
|
|
24
|
+
revenueRunning: measure.cumulative('revenue'),
|
|
25
|
+
visitors7d: measure.trailing('visitors', { amount: 7, unit: 'day' }),
|
|
26
|
+
revenuePriorWeek: measure.shift('revenue', { amount: 1, unit: 'week' }),
|
|
27
|
+
revenueGrowth: measure.derived({
|
|
28
|
+
uses: { revenue: 'revenue', revenuePriorWeek: 'revenuePriorWeek' },
|
|
29
|
+
formula: ({ revenue, revenuePriorWeek }) => divide(subtract(revenue, revenuePriorWeek), nullIfZero(revenuePriorWeek)),
|
|
30
|
+
}),
|
|
31
|
+
revenuePerVisitor: measure.derived({
|
|
32
|
+
uses: { revenue: 'revenue', visitors: 'visitors' },
|
|
33
|
+
formula: ({ revenue, visitors }) => divide(revenue, nullIfZero(visitors)),
|
|
34
|
+
}),
|
|
35
|
+
},
|
|
36
|
+
segments: {
|
|
37
|
+
enterprise: { filters: [eq('plan', 'enterprise')], description: 'Enterprise plan' },
|
|
38
|
+
bigPaid: { filters: [eq('status', 'paid'), gte('amount', 100)] },
|
|
39
|
+
},
|
|
40
|
+
});
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RowResolution } from './types.js';
|
|
1
|
+
import type { DatasetEvents, DatasetSqlSource, RowResolution } from './types.js';
|
|
2
2
|
import type { RelationshipKey } from './types.js';
|
|
3
3
|
import { type WindowCatalogMetadata } from './utils/window-catalog-metadata.js';
|
|
4
4
|
import { type DatasetCatalog, type DatasetCatalogSource, type DimensionCatalogEntry, type MeasureCatalogEntry, type SegmentCatalogEntry, type MetricCatalogEntry, type FilterCatalogEntry, type RelationshipCatalogEntry } from './catalog.js';
|
|
@@ -64,6 +64,8 @@ export interface ContractDataset extends SemanticMetadata {
|
|
|
64
64
|
name: string;
|
|
65
65
|
description?: string;
|
|
66
66
|
source: string;
|
|
67
|
+
/** RFC 0028: the SQL source `source` aliases. Omitted with `includeSql: false`. */
|
|
68
|
+
sqlSource?: DatasetSqlSource;
|
|
67
69
|
rowResolution?: RowResolution;
|
|
68
70
|
freshness?: DatasetFreshness;
|
|
69
71
|
owner?: string;
|
|
@@ -71,6 +73,8 @@ export interface ContractDataset extends SemanticMetadata {
|
|
|
71
73
|
tenantKey?: string;
|
|
72
74
|
timeKey?: string;
|
|
73
75
|
timeKeys?: string[];
|
|
76
|
+
/** Present when rows are events (RFC 0027). */
|
|
77
|
+
events?: DatasetEvents;
|
|
74
78
|
requiresTenant: boolean;
|
|
75
79
|
supportedGrains: string[];
|
|
76
80
|
dimensions: Record<string, ContractDimension>;
|
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAGvG,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,MAAM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AAC,iBAAiB,CAAC,CAAC;IACpD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC/C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACpD,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,2BAA2B,GAAG,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;AAEzE,MAAM,WAAW,gCAAgC;IAC/C;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC9C,OAAO,GAAE,gCAAqC,GAC7C,gBAAgB,CAelB;AAqJD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,GAAG,2BAA2B,GACvD,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,gBAAgB,GAAG,2BAA2B,GACvD,MAAM,CAER"}
|
package/dist/contract.js
CHANGED
|
@@ -36,6 +36,14 @@ function datasetToContract(catalog, includeSql) {
|
|
|
36
36
|
...(catalog.description !== undefined ? { description: catalog.description } : {}),
|
|
37
37
|
...snapshotSemanticMetadata(catalog),
|
|
38
38
|
source: catalog.source,
|
|
39
|
+
...(includeSql && catalog.sqlSource !== undefined ? {
|
|
40
|
+
sqlSource: {
|
|
41
|
+
sql: catalog.sqlSource.sql,
|
|
42
|
+
alias: catalog.sqlSource.alias,
|
|
43
|
+
dependencies: [...catalog.sqlSource.dependencies],
|
|
44
|
+
columns: { ...catalog.sqlSource.columns },
|
|
45
|
+
},
|
|
46
|
+
} : {}),
|
|
39
47
|
...(catalog.rowResolution === undefined ? {} : { rowResolution: { ...catalog.rowResolution } }),
|
|
40
48
|
...(catalog.freshness !== undefined ? { freshness: { ...catalog.freshness } } : {}),
|
|
41
49
|
...(catalog.owner !== undefined ? { owner: catalog.owner } : {}),
|
|
@@ -54,6 +62,7 @@ function datasetToContract(catalog, includeSql) {
|
|
|
54
62
|
...(catalog.tenantKey !== undefined ? { tenantKey: catalog.tenantKey } : {}),
|
|
55
63
|
...(catalog.timeKey !== undefined ? { timeKey: catalog.timeKey } : {}),
|
|
56
64
|
...(catalog.timeKeys?.length ? { timeKeys: uniqueSorted(catalog.timeKeys) } : {}),
|
|
65
|
+
...(catalog.events === undefined ? {} : { events: { ...catalog.events } }),
|
|
57
66
|
requiresTenant: catalog.requiresTenant,
|
|
58
67
|
supportedGrains: uniqueSorted(catalog.supportedGrains),
|
|
59
68
|
dimensions: sortedRecord(Object.entries(catalog.dimensions).map(([name, entry]) => [name, dimensionToContract(entry, includeSql)])),
|