@camstack/types 1.2.359 → 1.2.361

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/index.js CHANGED
@@ -1949,6 +1949,7 @@ var RETRAIN_REVIEW_MATCH_IOU = .5;
1949
1949
  var RETRAIN_REVIEW_ADJUSTED_IOU = .95;
1950
1950
  /** Two boxes this close on every edge are the same rectangle (an exact match). */
1951
1951
  var EXACT_EDGE_EPSILON = 1e-6;
1952
+ var optLabel = (label) => label !== void 0 ? { label } : {};
1952
1953
  /** Intersection over union of two normalised rectangles. */
1953
1954
  function retrainBoxIou(a, b) {
1954
1955
  const inter = Math.max(0, Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x)) * Math.max(0, Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y));
@@ -1958,13 +1959,13 @@ function retrainBoxIou(a, b) {
1958
1959
  function sameRect(a, b) {
1959
1960
  return Math.abs(a.x - b.x) <= EXACT_EDGE_EPSILON && Math.abs(a.y - b.y) <= EXACT_EDGE_EPSILON && Math.abs(a.w - b.w) <= EXACT_EDGE_EPSILON && Math.abs(a.h - b.h) <= EXACT_EDGE_EPSILON;
1960
1961
  }
1961
- function labelOf(value) {
1962
+ function labelField(value) {
1962
1963
  return value?.trim() ?? "";
1963
1964
  }
1964
1965
  /** Kept box versus its baseline: class/label first, then geometry. */
1965
1966
  function compareKept(saved, baseline, adjustedIou) {
1966
1967
  const iou = retrainBoxIou(saved.bbox, baseline.bbox);
1967
- if (saved.macroClass !== baseline.macroClass || labelOf(saved.label) !== labelOf(baseline.label)) return {
1968
+ if (saved.macroClass !== baseline.macroClass || labelField(saved.label) !== labelField(baseline.label)) return {
1968
1969
  status: "reclassified",
1969
1970
  iou
1970
1971
  };
@@ -2039,6 +2040,8 @@ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2039
2040
  savedId: box.id,
2040
2041
  status: "model-error",
2041
2042
  approximate: false,
2043
+ macroClass: box.macroClass,
2044
+ ...optLabel(box.label),
2042
2045
  ...baseline !== null ? {
2043
2046
  origin: baseline,
2044
2047
  iou: retrainBoxIou(box.bbox, baseline.bbox)
@@ -2052,6 +2055,8 @@ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2052
2055
  savedId: box.id,
2053
2056
  status: "added",
2054
2057
  approximate: approximate && baseline === null,
2058
+ macroClass: box.macroClass,
2059
+ ...optLabel(box.label),
2055
2060
  ...baseline !== null ? { origin: baseline } : {}
2056
2061
  });
2057
2062
  return;
@@ -2062,6 +2067,8 @@ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2062
2067
  savedId: box.id,
2063
2068
  status: verdict.status,
2064
2069
  approximate,
2070
+ macroClass: box.macroClass,
2071
+ ...optLabel(box.label),
2065
2072
  origin: baseline,
2066
2073
  iou: verdict.iou
2067
2074
  });
@@ -2070,6 +2077,8 @@ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2070
2077
  ref: entry.ref,
2071
2078
  status: "removed",
2072
2079
  approximate: false,
2080
+ macroClass: entry.snapshot.macroClass,
2081
+ ...optLabel(entry.snapshot.label),
2073
2082
  origin: entry.snapshot
2074
2083
  });
2075
2084
  if (opts.inferRemoved === true) for (const origin of origins) {
@@ -2078,6 +2087,8 @@ function classifyRetrainReview(saved, origins, dismissed, opts = {}) {
2078
2087
  ref: origin.ref,
2079
2088
  status: "removed",
2080
2089
  approximate: true,
2090
+ macroClass: origin.macroClass,
2091
+ ...optLabel(origin.label),
2081
2092
  origin
2082
2093
  });
2083
2094
  }
@@ -12655,8 +12666,23 @@ var BulkRecordSchema = zod.z.object({
12655
12666
  data: zod.z.record(zod.z.string(), zod.z.unknown())
12656
12667
  });
12657
12668
  /**
12669
+ * The database FILES one `sqlite-settings` engine process owns (D851).
12670
+ * Closed on purpose: a file is a thing the engine opens, backs up and gives a
12671
+ * serving thread, so a new one is a code change, never a string a caller
12672
+ * invents. `settings` is `camstack.db` and the default for every collection
12673
+ * that names no file.
12674
+ */
12675
+ var DataStoreDatabaseSchema = zod.z.enum([
12676
+ "settings",
12677
+ "events",
12678
+ "history"
12679
+ ]);
12680
+ /** Every database file, in a stable order (settings first). */
12681
+ var DATA_STORE_DATABASES = DataStoreDatabaseSchema.options;
12682
+ /**
12658
12683
  * One write inside a {@link settingsStoreCapability.methods.transact} call.
12659
- * Only the three that a "replace this set, bump that revision" write needs.
12684
+ * The three that a "replace this set, bump that revision" write needs, plus
12685
+ * the batched upsert a rollup writer needs.
12660
12686
  */
12661
12687
  var TransactOpSchema = zod.z.discriminatedUnion("op", [
12662
12688
  zod.z.object({
@@ -12674,6 +12700,12 @@ var TransactOpSchema = zod.z.discriminatedUnion("op", [
12674
12700
  collection: zod.z.string(),
12675
12701
  id: zod.z.string(),
12676
12702
  data: zod.z.record(zod.z.string(), zod.z.unknown())
12703
+ }),
12704
+ zod.z.object({
12705
+ op: zod.z.literal("upsertMany"),
12706
+ collection: zod.z.string(),
12707
+ conflict: zod.z.array(zod.z.string()).readonly(),
12708
+ records: zod.z.array(BulkRecordSchema).readonly()
12677
12709
  })
12678
12710
  ]);
12679
12711
  /**
@@ -12725,6 +12757,30 @@ var CollectionIndexSchema = zod.z.object({
12725
12757
  unique: zod.z.boolean().optional()
12726
12758
  });
12727
12759
  /**
12760
+ * The input of `declareCollection` — ONE schema for the door and for the
12761
+ * engine behind it, so the two surfaces cannot drift (the dispatcher forwards
12762
+ * the payload untouched).
12763
+ *
12764
+ * - `database` — the file the collection lives in (D851). Absent means
12765
+ * `settings`. A declaration naming a file other than the one the table is
12766
+ * already in is REFUSED by the engine, never moved.
12767
+ * - `primaryKey` — a COMPOSITE key, as column names. A single name is the same
12768
+ * as `primaryKey: true` on that column. A composite-keyed collection has no
12769
+ * `id`: it is written with `insertMany` / `upsertMany` / `transact` and read
12770
+ * with `query` / `count` / `aggregate` / `deleteWhere`; the calls that
12771
+ * address one row by id are refused.
12772
+ * - `withoutRowid` — emit `WITHOUT ROWID`. Requires a primary key.
12773
+ */
12774
+ var DeclareCollectionInputSchema = zod.z.object({
12775
+ namespace: zod.z.string().optional(),
12776
+ collection: zod.z.string(),
12777
+ columns: zod.z.array(CollectionColumnSchema).readonly(),
12778
+ indexes: zod.z.array(CollectionIndexSchema).readonly().optional(),
12779
+ database: DataStoreDatabaseSchema.optional(),
12780
+ primaryKey: zod.z.array(zod.z.string()).readonly().optional(),
12781
+ withoutRowid: zod.z.boolean().optional()
12782
+ });
12783
+ /**
12728
12784
  * settings-store — singleton capability for addon-scoped persistence.
12729
12785
  *
12730
12786
  * Every method operates within a `collection`. An optional `namespace`
@@ -12862,6 +12918,29 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
12862
12918
  kind: "mutation",
12863
12919
  auth: "admin"
12864
12920
  }),
12921
+ /**
12922
+ * {@link upsert} for a BATCH, in ONE transaction on ONE prepared statement.
12923
+ *
12924
+ * The write-side twin of {@link insertMany} for rows that may already
12925
+ * exist: a rollup writer recomputes a bucket and must overwrite it, and
12926
+ * N round trips with N COMMITs is the cost {@link insertMany} was added to
12927
+ * avoid. `conflict` has the meaning it has on {@link upsert} (declared
12928
+ * columns covered by a UNIQUE index or the primary key, never empty).
12929
+ *
12930
+ * Every record of a batch must carry the SAME set of declared columns and
12931
+ * every `conflict` column: one batch is one statement shape, and a record
12932
+ * that silently bound NULL over a column it did not mention would erase
12933
+ * it. A heterogeneous batch is refused whole. **All or nothing.**
12934
+ */
12935
+ upsertMany: require_sleep.method(zod.z.object({
12936
+ namespace: zod.z.string().optional(),
12937
+ collection: zod.z.string(),
12938
+ conflict: zod.z.array(zod.z.string()).readonly(),
12939
+ records: zod.z.array(BulkRecordSchema).readonly()
12940
+ }), zod.z.object({ upserted: zod.z.number().int() }), {
12941
+ kind: "mutation",
12942
+ auth: "admin"
12943
+ }),
12865
12944
  /** Insert a new record. */
12866
12945
  insert: require_sleep.method(zod.z.object({
12867
12946
  namespace: zod.z.string().optional(),
@@ -13060,12 +13139,7 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
13060
13139
  * `pipeline-analytics:object-events`) to avoid cross-addon
13061
13140
  * clashes — no automatic prefix is added.
13062
13141
  */
13063
- declareCollection: require_sleep.method(zod.z.object({
13064
- namespace: zod.z.string().optional(),
13065
- collection: zod.z.string(),
13066
- columns: zod.z.array(CollectionColumnSchema).readonly(),
13067
- indexes: zod.z.array(CollectionIndexSchema).readonly().optional()
13068
- }), zod.z.void(), {
13142
+ declareCollection: require_sleep.method(DeclareCollectionInputSchema, zod.z.void(), {
13069
13143
  kind: "mutation",
13070
13144
  auth: "admin"
13071
13145
  })
@@ -13218,6 +13292,16 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
13218
13292
  kind: "mutation",
13219
13293
  auth: "admin"
13220
13294
  }),
13295
+ /** Upsert many records in ONE transaction; see the door's `upsertMany`. */
13296
+ upsertMany: require_sleep.method(zod.z.object({
13297
+ namespace: zod.z.string().optional(),
13298
+ collection: zod.z.string(),
13299
+ conflict: zod.z.array(zod.z.string()).readonly(),
13300
+ records: zod.z.array(BulkRecordSchema).readonly()
13301
+ }), zod.z.object({ upserted: zod.z.number().int() }), {
13302
+ kind: "mutation",
13303
+ auth: "admin"
13304
+ }),
13221
13305
  /** Insert many records in ONE transaction. All or nothing. */
13222
13306
  insertMany: require_sleep.method(zod.z.object({
13223
13307
  namespace: zod.z.string().optional(),
@@ -13310,12 +13394,7 @@ id: zod.z.union([zod.z.string(), zod.z.number()]) }), {
13310
13394
  collection: zod.z.string()
13311
13395
  }), zod.z.boolean(), { auth: "admin" }),
13312
13396
  /** Declare a typed (SQL-backed) collection with columns + indexes. */
13313
- declareCollection: require_sleep.method(zod.z.object({
13314
- namespace: zod.z.string().optional(),
13315
- collection: zod.z.string(),
13316
- columns: zod.z.array(CollectionColumnSchema).readonly(),
13317
- indexes: zod.z.array(CollectionIndexSchema).readonly().optional()
13318
- }), zod.z.void(), {
13397
+ declareCollection: require_sleep.method(DeclareCollectionInputSchema, zod.z.void(), {
13319
13398
  kind: "mutation",
13320
13399
  auth: "admin"
13321
13400
  })
@@ -25972,6 +26051,9 @@ var RetrainBoxReviewSchema = zod.z.object({
25972
26051
  /** The baseline was re-derived, not snapshotted (a pre-origin row). */
25973
26052
  approximate: zod.z.boolean(),
25974
26053
  origin: RetrainOriginSchema.optional(),
26054
+ /** The class / label the box carries NOW (a removed box: its origin's). Absent on an older hub. */
26055
+ macroClass: RetrainMacroClassSchema.optional(),
26056
+ label: zod.z.string().optional(),
25975
26057
  iou: zod.z.number().optional()
25976
26058
  });
25977
26059
  var RetrainFrameReviewSchema = zod.z.object({
@@ -56038,6 +56120,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
56038
56120
  addonId: null,
56039
56121
  access: "create"
56040
56122
  },
56123
+ "dataStoreProvider.upsertMany": {
56124
+ capName: "data-store-provider",
56125
+ capScope: "system",
56126
+ addonId: null,
56127
+ access: "create"
56128
+ },
56041
56129
  "dayNight.getOptions": {
56042
56130
  capName: "day-night",
56043
56131
  capScope: "device",
@@ -60886,6 +60974,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
60886
60974
  addonId: null,
60887
60975
  access: "create"
60888
60976
  },
60977
+ "settingsStore.upsertMany": {
60978
+ capName: "settings-store",
60979
+ capScope: "system",
60980
+ addonId: null,
60981
+ access: "create"
60982
+ },
60889
60983
  "smoke.getStatus": {
60890
60984
  capName: "smoke",
60891
60985
  capScope: "device",
@@ -71117,6 +71211,7 @@ function createSystemProxy(api) {
71117
71211
  set: (input) => dispatch("settingsStore", "set", "mutation", input),
71118
71212
  query: (input) => dispatch("settingsStore", "query", "query", input),
71119
71213
  upsert: (input) => dispatch("settingsStore", "upsert", "mutation", input),
71214
+ upsertMany: (input) => dispatch("settingsStore", "upsertMany", "mutation", input),
71120
71215
  insert: (input) => dispatch("settingsStore", "insert", "mutation", input),
71121
71216
  insertMany: (input) => dispatch("settingsStore", "insertMany", "mutation", input),
71122
71217
  transact: (input) => dispatch("settingsStore", "transact", "mutation", input),
@@ -80105,6 +80200,7 @@ exports.DATABASE_SNAPSHOT_PARTIAL_SUFFIX = DATABASE_SNAPSHOT_PARTIAL_SUFFIX;
80105
80200
  exports.DATABASE_SNAPSHOT_SUFFIX = DATABASE_SNAPSHOT_SUFFIX;
80106
80201
  exports.DATABASE_SNAPSHOT_TIMEOUT_MS = DATABASE_SNAPSHOT_TIMEOUT_MS;
80107
80202
  exports.DATAPLANE_SECRET_HEADER = require_sleep.DATAPLANE_SECRET_HEADER;
80203
+ exports.DATA_STORE_DATABASES = DATA_STORE_DATABASES;
80108
80204
  exports.DAYS_PER_WEEK = DAYS_PER_WEEK;
80109
80205
  exports.DAY_NAMES = DAY_NAMES;
80110
80206
  exports.DECLARED_DEVICE_SWEEP_LIMIT = DECLARED_DEVICE_SWEEP_LIMIT;
@@ -80164,6 +80260,7 @@ exports.DISPLAY_ICON_KEYS = DISPLAY_ICON_KEYS;
80164
80260
  exports.DISPLAY_ICON_OFFERED_KEYS = DISPLAY_ICON_OFFERED_KEYS;
80165
80261
  exports.DISPLAY_ICON_VOCABULARY = DISPLAY_ICON_VOCABULARY;
80166
80262
  exports.DOORBELL_RISE_DEBOUNCE_MS = DOORBELL_RISE_DEBOUNCE_MS;
80263
+ exports.DataStoreDatabaseSchema = DataStoreDatabaseSchema;
80167
80264
  exports.DataStoreEngineInfoSchema = EngineInfoSchema;
80168
80265
  exports.DatabaseSnapshotResultSchema = DatabaseSnapshotResultSchema;
80169
80266
  exports.DatabaseSnapshotTableSchema = DatabaseSnapshotTableSchema;
@@ -80172,6 +80269,7 @@ exports.DayNightModeSchema = DayNightModeSchema;
80172
80269
  exports.DayNightOptionsSchema = DayNightOptionsSchema;
80173
80270
  exports.DayNightSettingsPatchSchema = DayNightSettingsPatchSchema;
80174
80271
  exports.DayNightStatusSchema = DayNightStatusSchema;
80272
+ exports.DeclareCollectionInputSchema = DeclareCollectionInputSchema;
80175
80273
  exports.DeclaredDevices = DeclaredDevices;
80176
80274
  exports.DecodedAudioChunkSchema = require_sleep.DecodedAudioChunkSchema;
80177
80275
  exports.DeleteIntegrationResultSchema = DeleteIntegrationResultSchema;