@north-light/api 0.3.739 → 0.3.741

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.
@@ -30,6 +30,12 @@ export declare function renameClashingProfiles(db: CanvasDb, schema: string, tar
30
30
  * different amounts. A staged one whose id the target holds with a different payer, units or usd is renamed `<id>:install-<install id>`; one the target holds unchanged keeps its
31
31
  * id and is skipped by the copy. A second load of the same bundle derives the same id. Runs before the pre-check. */
32
32
  export declare function renameClashingLegacyCharges(db: CanvasDb, schema: string, target: string, installId: string): Promise<number>;
33
+ /** A staged watch whose (watcher, object) the target already holds is already imported (a hosted person's nodes watching shared objects): it and its subscriptions are
34
+ * dropped, the target's rows stand. Only this key is skipped; any other unique conflict still fails the pre-check. Returns the dropped watches and subscriptions. Runs before the pre-check. */
35
+ export declare function dropExistingWatches(db: CanvasDb, schema: string, target: string): Promise<{
36
+ watches: number;
37
+ watch_subscriptions: number;
38
+ }>;
33
39
  /** Fill: a staged profile with no environment gets the source's machine environment (a Mac) or the person's Blaxel environment (hosted, created if
34
40
  * absent). Runs in the copy transaction: it writes target objects. */
35
41
  export declare function fillEnvironments(tx: CanvasDb, schema: string, target: string, source: SourceJson, person: string): Promise<number>;
@@ -112,6 +112,14 @@ export async function renameClashingLegacyCharges(db, schema, target, installId)
112
112
  WHERE s.id LIKE 'legacy:%' AND t.id = s.id AND (s.payer IS DISTINCT FROM t.payer OR s.units IS DISTINCT FROM t.units OR s.usd IS DISTINCT FROM t.usd)`).run(installId);
113
113
  return Number(done.changes);
114
114
  }
115
+ /** A staged watch whose (watcher, object) the target already holds is already imported (a hosted person's nodes watching shared objects): it and its subscriptions are
116
+ * dropped, the target's rows stand. Only this key is skipped; any other unique conflict still fails the pre-check. Returns the dropped watches and subscriptions. Runs before the pre-check. */
117
+ export async function dropExistingWatches(db, schema, target) {
118
+ const same = `FROM ${sq(target, 'watches')} t WHERE t.watcher = s.watcher AND t.object = s.object`;
119
+ const subs = await db.prepareUncached(`DELETE FROM ${sq(schema, 'watch_subscriptions')} u USING ${sq(schema, 'watches')} s WHERE u.watch = s.watch_id AND EXISTS (SELECT 1 ${same})`).run();
120
+ const watches = await db.prepareUncached(`DELETE FROM ${sq(schema, 'watches')} s WHERE EXISTS (SELECT 1 ${same})`).run();
121
+ return { watches: Number(watches.changes), watch_subscriptions: Number(subs.changes) };
122
+ }
115
123
  /** Fill: a staged profile with no environment gets the source's machine environment (a Mac) or the person's Blaxel environment (hosted, created if
116
124
  * absent). Runs in the copy transaction: it writes target objects. */
117
125
  export async function fillEnvironments(tx, schema, target, source, person) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/api",
3
- "version": "0.3.739",
3
+ "version": "0.3.741",
4
4
  "description": "Typed crtrd /v1 API contract — DTOs, route builders, the error contract, the CrtrClient, and the command-plugin manifest format. Zero runtime dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/api/index.js",