@sixb/core 0.1.3 → 0.1.4
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/actions/index.js +17 -18
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/worker.js +4 -4
- package/dist/actions/worker.js.map +1 -1
- package/dist/agents/context-compaction.d.ts +40 -0
- package/dist/agents/context-compaction.d.ts.map +1 -0
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +6 -5
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +42 -37
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/streams.d.ts +17 -1
- package/dist/agents/streams.d.ts.map +1 -1
- package/dist/agents/streams.js +4 -2
- package/dist/agents/streams.js.map +1 -1
- package/dist/agents/types.d.ts +9 -0
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/auth/index.js +7 -3
- package/dist/auth/index.js.map +1 -1
- package/dist/authorization/index.js +6 -2
- package/dist/authorization/index.js.map +1 -1
- package/dist/bootstrap/index.js +30 -31
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/{chunk-xmggaxg4.js → chunk-1wk20wn3.js} +188 -21
- package/dist/{chunk-xmggaxg4.js.map → chunk-1wk20wn3.js.map} +7 -5
- package/dist/{chunk-1ywq4hzk.js → chunk-1yz3x65y.js} +7 -7
- package/dist/{chunk-gqdd7508.js → chunk-4rh2m6zg.js} +1 -1
- package/dist/{chunk-fmx1sz2h.js → chunk-72q2y8hn.js} +3 -3
- package/dist/{chunk-fmx1sz2h.js.map → chunk-72q2y8hn.js.map} +3 -3
- package/dist/{chunk-f1cyvnrk.js → chunk-7gw7mepb.js} +259 -9
- package/dist/chunk-7gw7mepb.js.map +14 -0
- package/dist/{chunk-wb4051cx.js → chunk-819wnjz8.js} +11 -5
- package/dist/chunk-819wnjz8.js.map +12 -0
- package/dist/{chunk-pxtrxm3p.js → chunk-a09jx26t.js} +1 -1
- package/dist/{chunk-ettb0cy4.js → chunk-afjpa2hs.js} +59 -29
- package/dist/{chunk-ettb0cy4.js.map → chunk-afjpa2hs.js.map} +5 -5
- package/dist/{chunk-177ed2mp.js → chunk-c43qr6s0.js} +229 -97
- package/dist/{chunk-177ed2mp.js.map → chunk-c43qr6s0.js.map} +9 -9
- package/dist/{chunk-261ag4t4.js → chunk-cbkm2vam.js} +3 -3
- package/dist/{chunk-zpw39qhj.js → chunk-dm72y8wt.js} +25 -2
- package/dist/chunk-dm72y8wt.js.map +10 -0
- package/dist/{chunk-kqxgf6kv.js → chunk-drjqm1aa.js} +16 -1
- package/dist/{chunk-kqxgf6kv.js.map → chunk-drjqm1aa.js.map} +3 -3
- package/dist/chunk-dysw7nsm.js.map +1 -1
- package/dist/{chunk-4aw0jwk0.js → chunk-f6erf2vv.js} +1 -1
- package/dist/{chunk-4z3n1dzt.js → chunk-f83ka50g.js} +131 -25
- package/dist/chunk-f83ka50g.js.map +23 -0
- package/dist/{chunk-km4rkj4t.js → chunk-g13869yf.js} +3 -3
- package/dist/{chunk-c8bw2b6c.js → chunk-hbeh8j9w.js} +2 -2
- package/dist/{chunk-n5x5y80a.js → chunk-nzw7sm3b.js} +2 -2
- package/dist/{chunk-3rsf30p4.js → chunk-pn8n8sba.js} +16 -15
- package/dist/{chunk-3rsf30p4.js.map → chunk-pn8n8sba.js.map} +3 -3
- package/dist/{chunk-63te770v.js → chunk-qewtks41.js} +8 -8
- package/dist/{chunk-63te770v.js.map → chunk-qewtks41.js.map} +2 -2
- package/dist/{chunk-4p9rh7jj.js → chunk-rs1wbvy6.js} +1 -1
- package/dist/{chunk-88ppkr54.js → chunk-rte5sm3z.js} +26 -2
- package/dist/chunk-rte5sm3z.js.map +12 -0
- package/dist/{chunk-bv41fmjn.js → chunk-s31d0qmq.js} +57 -20
- package/dist/{chunk-bv41fmjn.js.map → chunk-s31d0qmq.js.map} +8 -7
- package/dist/{chunk-c6cfqydk.js → chunk-sxwk41qa.js} +1 -1
- package/dist/chunk-t0jjkep3.js.map +1 -1
- package/dist/{chunk-d6y2wsfg.js → chunk-tek1qwgm.js} +6 -6
- package/dist/{chunk-d6y2wsfg.js.map → chunk-tek1qwgm.js.map} +1 -1
- package/dist/{chunk-d2adj15j.js → chunk-tkdscva6.js} +1 -1
- package/dist/{chunk-ttba8x6z.js → chunk-tycbzedm.js} +2 -2
- package/dist/{chunk-z8j83gzd.js → chunk-x2yw73hy.js} +1 -1
- package/dist/{chunk-qer6am8w.js → chunk-xdf9yswn.js} +1 -1
- package/dist/execution/agent.js +26 -27
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +26 -27
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +27 -28
- package/dist/execution/request.js.map +2 -2
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -53
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +2 -1
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/materializer/index.js +15 -16
- package/dist/materializer/index.js.map +1 -1
- package/dist/models/index.d.ts +40 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/objects/execution.d.ts +6 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +19 -20
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/link/endpoints.d.ts.map +1 -1
- package/dist/objects/query/executor.d.ts +1 -0
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/explain.d.ts +1 -0
- package/dist/objects/query/explain.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +3 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +30 -5
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +14 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/links.d.ts +25 -0
- package/dist/objects/query/links.d.ts.map +1 -0
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +1 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/pipelines/index.js +15 -16
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/builders.d.ts +33 -4
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +15 -16
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts +1 -0
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/projections/types.d.ts +12 -9
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts +6 -5
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/query.d.ts +2 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/runtime/create.d.ts +3 -0
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +3 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +2 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -0
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +4 -0
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +9 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +5 -0
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +1 -1
- package/dist/storage/ai-usage/in-memory.d.ts +2 -1
- package/dist/storage/ai-usage/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-usage/index.d.ts +1 -1
- package/dist/storage/ai-usage/index.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +6 -0
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/index.d.ts +3 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +19 -14
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/objects/in-memory.d.ts +6 -3
- package/dist/storage/objects/in-memory.d.ts.map +1 -1
- package/dist/storage/objects/index.d.ts +3 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/keys.d.ts +16 -0
- package/dist/storage/objects/keys.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +33 -6
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/workflow-runs/provider.js +9 -5
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +15 -16
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/effective-storage-contract.d.ts +1 -1
- package/dist/testing/effective-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.js +455 -40
- package/dist/testing/index.js.map +7 -7
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +13 -14
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workflows/index.js +27 -28
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agents/builders.ts +3 -3
- package/src/agents/context-compaction.ts +261 -0
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +18 -9
- package/src/agents/streams.ts +56 -0
- package/src/agents/types.ts +10 -0
- package/src/agents/validation.ts +35 -5
- package/src/http/api-routes.ts +7 -7
- package/src/index.ts +14 -0
- package/src/lake-storage/types.ts +2 -1
- package/src/materializer/telemetry/append.ts +33 -16
- package/src/models/index.ts +71 -0
- package/src/objects/execution.ts +20 -0
- package/src/objects/link/endpoints.ts +2 -1
- package/src/objects/query/executor.ts +42 -11
- package/src/objects/query/explain.ts +11 -0
- package/src/objects/query/index.ts +6 -0
- package/src/objects/query/ir.ts +16 -0
- package/src/objects/query/links.ts +308 -0
- package/src/objects/query/normalize.ts +40 -1
- package/src/objects/query/planner.ts +5 -0
- package/src/objects/query/validate.ts +58 -2
- package/src/projections/builders.ts +220 -15
- package/src/projections/index.ts +1 -0
- package/src/projections/ownership.ts +5 -5
- package/src/projections/registry.ts +9 -3
- package/src/projections/revision.ts +31 -5
- package/src/projections/run-dispatch.ts +10 -1
- package/src/projections/types.ts +13 -9
- package/src/projections/validation.ts +61 -19
- package/src/query.ts +2 -0
- package/src/runtime/create.ts +4 -0
- package/src/runtime/definitions.ts +3 -0
- package/src/runtime/host.ts +2 -0
- package/src/runtime/resolve-definitions.ts +28 -0
- package/src/storage/agents/in-memory.ts +15 -0
- package/src/storage/agents/types.ts +5 -0
- package/src/storage/ai-usage/in-memory.ts +23 -0
- package/src/storage/ai-usage/index.ts +1 -0
- package/src/storage/ai-usage/types.ts +10 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/objects/in-memory.ts +103 -16
- package/src/storage/objects/index.ts +9 -0
- package/src/storage/objects/keys.ts +36 -0
- package/src/storage/objects/types.ts +34 -6
- package/src/storage/ontology/provider-header-validation.ts +2 -2
- package/src/testing/agent-storage-contract.ts +12 -0
- package/src/testing/ai-usage-storage-contract.ts +35 -0
- package/src/testing/effective-storage-contract.ts +194 -4
- package/src/testing/lake-storage-contract.ts +56 -0
- package/src/testing/object-query-contract.ts +208 -1
- package/dist/agents/prompt.d.ts +0 -21
- package/dist/agents/prompt.d.ts.map +0 -1
- package/dist/chunk-4z3n1dzt.js.map +0 -23
- package/dist/chunk-6wetht33.js +0 -89
- package/dist/chunk-6wetht33.js.map +0 -10
- package/dist/chunk-88ppkr54.js.map +0 -12
- package/dist/chunk-f1cyvnrk.js.map +0 -13
- package/dist/chunk-wb4051cx.js.map +0 -12
- package/dist/chunk-zpw39qhj.js.map +0 -10
- package/src/agents/prompt.ts +0 -85
- /package/dist/{chunk-1ywq4hzk.js.map → chunk-1yz3x65y.js.map} +0 -0
- /package/dist/{chunk-gqdd7508.js.map → chunk-4rh2m6zg.js.map} +0 -0
- /package/dist/{chunk-pxtrxm3p.js.map → chunk-a09jx26t.js.map} +0 -0
- /package/dist/{chunk-261ag4t4.js.map → chunk-cbkm2vam.js.map} +0 -0
- /package/dist/{chunk-4aw0jwk0.js.map → chunk-f6erf2vv.js.map} +0 -0
- /package/dist/{chunk-km4rkj4t.js.map → chunk-g13869yf.js.map} +0 -0
- /package/dist/{chunk-c8bw2b6c.js.map → chunk-hbeh8j9w.js.map} +0 -0
- /package/dist/{chunk-n5x5y80a.js.map → chunk-nzw7sm3b.js.map} +0 -0
- /package/dist/{chunk-4p9rh7jj.js.map → chunk-rs1wbvy6.js.map} +0 -0
- /package/dist/{chunk-c6cfqydk.js.map → chunk-sxwk41qa.js.map} +0 -0
- /package/dist/{chunk-d2adj15j.js.map → chunk-tkdscva6.js.map} +0 -0
- /package/dist/{chunk-ttba8x6z.js.map → chunk-tycbzedm.js.map} +0 -0
- /package/dist/{chunk-z8j83gzd.js.map → chunk-x2yw73hy.js.map} +0 -0
- /package/dist/{chunk-qer6am8w.js.map → chunk-xdf9yswn.js.map} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
resolveSemanticType
|
|
4
|
+
} from "./chunk-rnshztfq.js";
|
|
2
5
|
import {
|
|
3
6
|
createSixbError
|
|
4
7
|
} from "./chunk-0172wgm9.js";
|
|
@@ -615,12 +618,10 @@ function computeProjectionOwnership(projection, ontology) {
|
|
|
615
618
|
return freezeOwnership({
|
|
616
619
|
objects: [],
|
|
617
620
|
links: [],
|
|
618
|
-
telemetry:
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
]
|
|
621
|
+
telemetry: Object.keys(projection.properties).sort(compareStrings).map((propertyId) => ({
|
|
622
|
+
objectTypeId: projection.objectTypeId,
|
|
623
|
+
propertyId
|
|
624
|
+
}))
|
|
624
625
|
});
|
|
625
626
|
}
|
|
626
627
|
function validateProjectionOwnership(projections) {
|
|
@@ -735,26 +736,48 @@ function validateLinkProjectionTarget(linkToken) {
|
|
|
735
736
|
throw new ProjectionValidationError(`Link '${linkToken.id}' has a wildcard target. ` + `Link projection of wildcard links is not supported.`);
|
|
736
737
|
}
|
|
737
738
|
}
|
|
738
|
-
function validateTelemetryProjectionFieldMapping(projection, objectType, datasetColumnNames, prefix) {
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
741
|
-
throw new ProjectionValidationError(`${prefix}:
|
|
742
|
-
}
|
|
743
|
-
if (property.mode !== "telemetry") {
|
|
744
|
-
throw new ProjectionValidationError(`${prefix}: property "${projection.propertyId}" on type "${projection.objectTypeId}" must be telemetry-enabled`);
|
|
739
|
+
function validateTelemetryProjectionFieldMapping(projection, objectType, datasetColumnNames, valueTypesById, prefix) {
|
|
740
|
+
const mappedProperties = Object.entries(projection.properties);
|
|
741
|
+
if (mappedProperties.length === 0) {
|
|
742
|
+
throw new ProjectionValidationError(`${prefix}: must map at least one telemetry property`);
|
|
745
743
|
}
|
|
746
744
|
const mappedFields = [
|
|
747
745
|
["objectId", projection.objectIdField],
|
|
748
|
-
["at", projection.atField]
|
|
749
|
-
["value", projection.valueField],
|
|
750
|
-
...projection.unitField !== undefined ? [["unit", projection.unitField]] : []
|
|
746
|
+
["at", projection.atField]
|
|
751
747
|
];
|
|
752
748
|
for (const [fieldRole, columnName] of mappedFields) {
|
|
753
749
|
if (!datasetColumnNames.has(columnName)) {
|
|
754
750
|
throw new ProjectionValidationError(`${prefix}: ${fieldRole} field "${columnName}" references unknown dataset column ` + `on dataset "${projection.datasetId}"`);
|
|
755
751
|
}
|
|
756
752
|
}
|
|
757
|
-
|
|
753
|
+
const propertiesById = new Map(objectType.properties.map((property) => [property.id, property]));
|
|
754
|
+
const resolvedProperties = new Map;
|
|
755
|
+
for (const [propertyId, mapping] of mappedProperties) {
|
|
756
|
+
const property = propertiesById.get(propertyId);
|
|
757
|
+
if (!property) {
|
|
758
|
+
throw new ProjectionValidationError(`${prefix}: unknown property "${propertyId}" on type "${projection.objectTypeId}"`);
|
|
759
|
+
}
|
|
760
|
+
if (property.mode !== "telemetry") {
|
|
761
|
+
throw new ProjectionValidationError(`${prefix}: property "${propertyId}" on type "${projection.objectTypeId}" must be telemetry-enabled`);
|
|
762
|
+
}
|
|
763
|
+
for (const [fieldRole, columnName] of [
|
|
764
|
+
["value", mapping.valueField],
|
|
765
|
+
...mapping.unitField !== undefined ? [["unit", mapping.unitField]] : []
|
|
766
|
+
]) {
|
|
767
|
+
if (!datasetColumnNames.has(columnName)) {
|
|
768
|
+
throw new ProjectionValidationError(`${prefix}: property "${propertyId}" ${fieldRole} field "${columnName}" references ` + `unknown dataset column on dataset "${projection.datasetId}"`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
const semanticType = resolveSemanticType(property, valueTypesById);
|
|
772
|
+
if (semanticType !== undefined && mapping.unitField === undefined) {
|
|
773
|
+
throw new ProjectionValidationError(`${prefix}: property "${propertyId}" requires a unit field because it uses semantic type "${semanticType}"`);
|
|
774
|
+
}
|
|
775
|
+
if (semanticType === undefined && mapping.unitField !== undefined) {
|
|
776
|
+
throw new ProjectionValidationError(`${prefix}: property "${propertyId}" cannot map a unit field because it has no semantic type`);
|
|
777
|
+
}
|
|
778
|
+
resolvedProperties.set(propertyId, property);
|
|
779
|
+
}
|
|
780
|
+
return resolvedProperties;
|
|
758
781
|
}
|
|
759
782
|
function validateProjectionsAtStartup(projections, ontology, datasetsById) {
|
|
760
783
|
const { objectProjections, linkProjections, telemetryProjections } = projections;
|
|
@@ -897,7 +920,7 @@ function validateProjectionsAtStartup(projections, ontology, datasetsById) {
|
|
|
897
920
|
throw new ProjectionValidationError(`${prefix}: unknown object type "${projection.objectTypeId}"`);
|
|
898
921
|
}
|
|
899
922
|
const datasetColumnNames = new Set(dataset.schema.columns.map((column) => column.name));
|
|
900
|
-
validateTelemetryProjectionFieldMapping(projection, objectType, datasetColumnNames, prefix);
|
|
923
|
+
validateTelemetryProjectionFieldMapping(projection, objectType, datasetColumnNames, ontology.getValueTypesById(), prefix);
|
|
901
924
|
validatedTelemetryProjections.push({
|
|
902
925
|
definition: projection,
|
|
903
926
|
dataset,
|
|
@@ -965,9 +988,9 @@ function defineProjection(id, target) {
|
|
|
965
988
|
return buildLinkProjection(id, target);
|
|
966
989
|
if ("property" in target)
|
|
967
990
|
return buildTelemetryProjection(id, target);
|
|
968
|
-
return
|
|
991
|
+
return buildObjectTypeProjection(id, target);
|
|
969
992
|
}
|
|
970
|
-
function
|
|
993
|
+
function buildObjectTypeProjection(id, objectType) {
|
|
971
994
|
assertNonEmpty2(id, "id");
|
|
972
995
|
return {
|
|
973
996
|
fromDataset(dataset) {
|
|
@@ -985,6 +1008,18 @@ function buildObjectProjection(id, objectType) {
|
|
|
985
1008
|
links: {},
|
|
986
1009
|
conflictResolution: { strategy: "editsWin" }
|
|
987
1010
|
});
|
|
1011
|
+
},
|
|
1012
|
+
points(mapping) {
|
|
1013
|
+
const pointMapping = lowerTelemetryPropertiesPointMapping(objectType, mapping);
|
|
1014
|
+
return {
|
|
1015
|
+
_tag: "TelemetryProjectionDefinition",
|
|
1016
|
+
id,
|
|
1017
|
+
objectTypeId: objectType.id,
|
|
1018
|
+
datasetId,
|
|
1019
|
+
objectIdField: pointMapping.objectId,
|
|
1020
|
+
atField: pointMapping.at,
|
|
1021
|
+
properties: pointMapping.properties
|
|
1022
|
+
};
|
|
988
1023
|
}
|
|
989
1024
|
};
|
|
990
1025
|
}
|
|
@@ -1034,12 +1069,15 @@ function buildTelemetryProjection(id, propertyToken) {
|
|
|
1034
1069
|
_tag: "TelemetryProjectionDefinition",
|
|
1035
1070
|
id,
|
|
1036
1071
|
objectTypeId: propertyToken.objectTypeId,
|
|
1037
|
-
propertyId: propertyToken.id,
|
|
1038
1072
|
datasetId,
|
|
1039
1073
|
objectIdField: pointMapping.objectId,
|
|
1040
1074
|
atField: pointMapping.at,
|
|
1041
|
-
|
|
1042
|
-
|
|
1075
|
+
properties: {
|
|
1076
|
+
[propertyToken.id]: {
|
|
1077
|
+
valueField: pointMapping.value,
|
|
1078
|
+
...pointMapping.unit !== undefined ? { unitField: pointMapping.unit } : {}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1043
1081
|
};
|
|
1044
1082
|
}
|
|
1045
1083
|
};
|
|
@@ -1080,6 +1118,69 @@ function lowerTelemetryPointMapping(mapping) {
|
|
|
1080
1118
|
...mapping.unit !== undefined ? { unit: mapping.unit } : {}
|
|
1081
1119
|
};
|
|
1082
1120
|
}
|
|
1121
|
+
function lowerTelemetryPropertiesPointMapping(objectType, mapping) {
|
|
1122
|
+
const allowedKeys = new Set(["objectId", "at", "properties"]);
|
|
1123
|
+
for (const key of Object.keys(mapping)) {
|
|
1124
|
+
if (!allowedKeys.has(key)) {
|
|
1125
|
+
throw new ProjectionValidationError(`Telemetry projection point mapping contains unknown key '${key}'.`);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
if (mapping.objectId === undefined) {
|
|
1129
|
+
throw new ProjectionValidationError("Telemetry projection point mapping requires objectId.");
|
|
1130
|
+
}
|
|
1131
|
+
if (mapping.at === undefined) {
|
|
1132
|
+
throw new ProjectionValidationError("Telemetry projection point mapping requires at.");
|
|
1133
|
+
}
|
|
1134
|
+
if (mapping.properties === undefined) {
|
|
1135
|
+
throw new ProjectionValidationError("Telemetry projection point mapping requires properties.");
|
|
1136
|
+
}
|
|
1137
|
+
if (!isRecord(mapping.properties)) {
|
|
1138
|
+
throw new ProjectionValidationError("Telemetry projection point mapping properties must be an object.");
|
|
1139
|
+
}
|
|
1140
|
+
assertNonEmpty2(mapping.objectId, "objectId field");
|
|
1141
|
+
assertNonEmpty2(mapping.at, "at field");
|
|
1142
|
+
const propertyEntries = Object.entries(mapping.properties);
|
|
1143
|
+
if (propertyEntries.length === 0) {
|
|
1144
|
+
throw new ProjectionValidationError("Telemetry projection point mapping requires at least one property.");
|
|
1145
|
+
}
|
|
1146
|
+
const propertiesById = new Map(objectType.properties.map((property) => [property.id, property]));
|
|
1147
|
+
const properties = {};
|
|
1148
|
+
for (const [propertyId, input] of propertyEntries) {
|
|
1149
|
+
const property = propertiesById.get(propertyId);
|
|
1150
|
+
if (!property) {
|
|
1151
|
+
throw new ProjectionValidationError(`Property '${propertyId}' does not exist on object type '${objectType.id}'.`);
|
|
1152
|
+
}
|
|
1153
|
+
if (property.mode !== "telemetry") {
|
|
1154
|
+
throw new ProjectionValidationError(`Projection property '${objectType.id}.${propertyId}' must be telemetry-enabled.`);
|
|
1155
|
+
}
|
|
1156
|
+
properties[propertyId] = lowerTelemetryPropertyMapping(propertyId, input);
|
|
1157
|
+
}
|
|
1158
|
+
return { objectId: mapping.objectId, at: mapping.at, properties };
|
|
1159
|
+
}
|
|
1160
|
+
function lowerTelemetryPropertyMapping(propertyId, input) {
|
|
1161
|
+
if (typeof input === "string") {
|
|
1162
|
+
assertNonEmpty2(input, `property '${propertyId}' value field`);
|
|
1163
|
+
return { valueField: input };
|
|
1164
|
+
}
|
|
1165
|
+
if (!isRecord(input)) {
|
|
1166
|
+
throw new ProjectionValidationError(`Telemetry projection property '${propertyId}' must map a value column or value/unit columns.`);
|
|
1167
|
+
}
|
|
1168
|
+
const allowedKeys = new Set(["value", "unit"]);
|
|
1169
|
+
for (const key of Object.keys(input)) {
|
|
1170
|
+
if (!allowedKeys.has(key)) {
|
|
1171
|
+
throw new ProjectionValidationError(`Telemetry projection property '${propertyId}' contains unknown key '${key}'.`);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
if (typeof input.value !== "string") {
|
|
1175
|
+
throw new ProjectionValidationError(`Telemetry projection property '${propertyId}' requires a value field.`);
|
|
1176
|
+
}
|
|
1177
|
+
if (typeof input.unit !== "string") {
|
|
1178
|
+
throw new ProjectionValidationError(`Telemetry projection property '${propertyId}' requires a unit field.`);
|
|
1179
|
+
}
|
|
1180
|
+
assertNonEmpty2(input.value, `property '${propertyId}' value field`);
|
|
1181
|
+
assertNonEmpty2(input.unit, `property '${propertyId}' unit field`);
|
|
1182
|
+
return { valueField: input.value, unitField: input.unit };
|
|
1183
|
+
}
|
|
1083
1184
|
function fromForeignKey(input) {
|
|
1084
1185
|
validateLinkProjectionTarget(input.link);
|
|
1085
1186
|
if (input.sourceProperty) {
|
|
@@ -1151,7 +1252,12 @@ function isLinkProjectionDefinition(value) {
|
|
|
1151
1252
|
function isTelemetryProjectionDefinition(value) {
|
|
1152
1253
|
if (!isRecord(value))
|
|
1153
1254
|
return false;
|
|
1154
|
-
return value._tag === "TelemetryProjectionDefinition" && typeof value.id === "string" && typeof value.objectTypeId === "string" && typeof value.
|
|
1255
|
+
return value._tag === "TelemetryProjectionDefinition" && typeof value.id === "string" && typeof value.objectTypeId === "string" && typeof value.datasetId === "string" && typeof value.objectIdField === "string" && typeof value.atField === "string" && isTelemetryProjectionProperties(value.properties);
|
|
1256
|
+
}
|
|
1257
|
+
function isTelemetryProjectionProperties(value) {
|
|
1258
|
+
if (!isRecord(value) || Object.keys(value).length === 0)
|
|
1259
|
+
return false;
|
|
1260
|
+
return Object.values(value).every((mapping) => isRecord(mapping) && typeof mapping.valueField === "string" && (mapping.unitField === undefined || typeof mapping.unitField === "string"));
|
|
1155
1261
|
}
|
|
1156
1262
|
function isProjectionDefinition(value) {
|
|
1157
1263
|
return isObjectProjectionDefinition(value) || isLinkProjectionDefinition(value) || isTelemetryProjectionDefinition(value);
|
|
@@ -1203,4 +1309,4 @@ function emptyGrantIndex() {
|
|
|
1203
1309
|
}
|
|
1204
1310
|
export { ProjectionValidationError, computeProjectionOwnership, validateProjectionOwnership, validateTelemetryProjectionFieldMapping, validateProjectionsAtStartup, defineProjection, fromForeignKey, isObjectProjectionDefinition, isLinkProjectionDefinition, isTelemetryProjectionDefinition, isProjectionDefinition, projectionTargetOf, GRANT_KINDS, grantKindOf, createPrincipalRuntimeAuthorization, createAgentRuntimeAuthorization, createDisabledRuntimeAuthorization, createTrustedPrimitiveRuntimeAuthorization, getAuthorizationRef, resolveExecutionScopeAuthorization, AuthorizationError, evaluate, isAllowed, assertAuthorized, assertCanEdit, assertCanAppendTelemetry, assertCanManageConnector, assertPrivileged, assertProviderAccess, isApplicationAccessControlled, canAccessApplication, canViewEvent, resolveRoleGrants, resolveAuthorizationContext, canViewActionRun, canViewWorkflowRun, canViewWorkflowIntervention, canViewPipelineRun, canViewProjectionRun, canViewProjection, emptyGrantIndex };
|
|
1205
1311
|
|
|
1206
|
-
//# debugId=
|
|
1312
|
+
//# debugId=48D20BF42F9CD3F464756E2164756E21
|