@north-light/sdk 0.3.855 → 0.3.857

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/client.d.ts CHANGED
@@ -53,10 +53,10 @@ export interface CrouterOptions {
53
53
  /** The namespaces of `Crouter` that only the owner's own daemon serves. A person's app listener answers them `404 unknown operation`. */
54
54
  export type OwnerOnly = 'spendLimits' | 'customObjects' | 'models';
55
55
  /** What an app reaches on a person's runtime (the app listener): `Crouter` without the owner-daemon namespaces, and
56
- * `customObjects` narrowed to register/publish/unregister. `Crouter` is assignable to it, so a function that takes `AppClient` takes either. */
56
+ * `customObjects` narrowed to register/publish/unregister/mergeInto. `Crouter` is assignable to it, so a function that takes `AppClient` takes either. */
57
57
  export type AppClient = Omit<Crouter, OwnerOnly> & {
58
58
  /** Register, publish to and unregister the custom objects the app owns (`receive` and `ack` are owner-daemon only). */
59
- readonly customObjects: Pick<CustomObjects, 'register' | 'publish' | 'unregister'>;
59
+ readonly customObjects: Pick<CustomObjects, 'register' | 'publish' | 'unregister' | 'mergeInto'>;
60
60
  };
61
61
  /**
62
62
  * The client an application constructs for a person's runtime. Each namespace below wraps a family of app
@@ -110,7 +110,7 @@ declare const AppCrouter: new (options: CrouterOptions) => AppClient;
110
110
  /** A runtime client on one person's stored connection (`oauth.client(userId)`): an `AppClient` that refreshes its
111
111
  * token through the `OAuth2Client`'s store, plus whose connection it is and the runtime it calls. It offers only what
112
112
  * the person's app listener serves. The owner-daemon namespaces (`spendLimits`, `models`) are absent from its
113
- * type and throw `CrouterError` if reached anyway; `customObjects` is `register`, `publish` and `unregister`.
113
+ * type and throw `CrouterError` if reached anyway; `customObjects` is `register`, `publish`, `unregister` and `mergeInto`.
114
114
  * `request` still sends any route. */
115
115
  export declare class ConnectedCrouter extends AppCrouter {
116
116
  /** The person whose connection this client uses (`user:<id>`). */
@@ -70,7 +70,7 @@ const AppCrouter = Crouter;
70
70
  /** A runtime client on one person's stored connection (`oauth.client(userId)`): an `AppClient` that refreshes its
71
71
  * token through the `OAuth2Client`'s store, plus whose connection it is and the runtime it calls. It offers only what
72
72
  * the person's app listener serves. The owner-daemon namespaces (`spendLimits`, `models`) are absent from its
73
- * type and throw `CrouterError` if reached anyway; `customObjects` is `register`, `publish` and `unregister`.
73
+ * type and throw `CrouterError` if reached anyway; `customObjects` is `register`, `publish`, `unregister` and `mergeInto`.
74
74
  * `request` still sends any route. */
75
75
  export class ConnectedCrouter extends AppCrouter {
76
76
  /** The person whose connection this client uses (`user:<id>`). */
@@ -87,7 +87,7 @@ export class ConnectedCrouter extends AppCrouter {
87
87
  } });
88
88
  }
89
89
  const { customObjects } = this;
90
- Object.defineProperty(this, 'customObjects', { value: { register: customObjects.register.bind(customObjects), publish: customObjects.publish.bind(customObjects), unregister: customObjects.unregister.bind(customObjects) } });
90
+ Object.defineProperty(this, 'customObjects', { value: { register: customObjects.register.bind(customObjects), publish: customObjects.publish.bind(customObjects), unregister: customObjects.unregister.bind(customObjects), mergeInto: customObjects.mergeInto.bind(customObjects) } });
91
91
  }
92
92
  /** Run `crtr <argv…>` in this app's sandbox on the person's runtime (`POST /v1/exec`, scopes `crtr:act` and `crtr:schedule`).
93
93
  * No shell and no stdin; the process starts in the app's files folder. A non-zero exit or a timeout resolves; a refusal
@@ -1,4 +1,4 @@
1
- import { type AckCustomDeliveriesResponseDTO, type PublishCustomObjectRequestDTO, type PublishCustomObjectResponseDTO, type QueueLineDTO, type RegisterCustomObjectRequestDTO, type RegisterCustomObjectResponseDTO } from '@north-light/api';
1
+ import { type AckCustomDeliveriesResponseDTO, type MergeCustomObjectResponseDTO, type PublishCustomObjectRequestDTO, type PublishCustomObjectResponseDTO, type QueueLineDTO, type RegisterCustomObjectRequestDTO, type RegisterCustomObjectResponseDTO } from '@north-light/api';
2
2
  import type { RequestOptions } from '../types.js';
3
3
  import type { Request } from './request.js';
4
4
  /** Queue streams replay every pending delivery on connect. `after` is accepted for compatibility but ignored for pending work. */
@@ -14,7 +14,12 @@ export declare class CustomObjects {
14
14
  constructor(request: Request, open: (path: string, options: ReceiveOptions) => Promise<Response>);
15
15
  register(body: RegisterCustomObjectRequestDTO, options?: RequestOptions): Promise<RegisterCustomObjectResponseDTO>;
16
16
  publish(ref: string, body: PublishCustomObjectRequestDTO, options?: RequestOptions): Promise<PublishCustomObjectResponseDTO>;
17
- unregister(ref: string, options?: RequestOptions): Promise<void>;
17
+ /** With `onlyIfUnwatched`, refuses with 409 `watched` and changes nothing while any node watches the object. */
18
+ unregister(ref: string, options?: RequestOptions & {
19
+ onlyIfUnwatched?: boolean;
20
+ }): Promise<void>;
21
+ /** Move every watcher of `ref` onto `into` and unregister `ref`, in one write. Both must be live and have the same owner. `404` when `ref` is already gone. */
22
+ mergeInto(ref: string, into: string, options?: RequestOptions): Promise<MergeCustomObjectResponseDTO>;
18
23
  ack(ref: string, deliveryIds: string[], options?: RequestOptions): Promise<AckCustomDeliveriesResponseDTO>;
19
24
  receive(ref: string, options?: ReceiveOptions): CustomDeliveryStream;
20
25
  }
@@ -14,8 +14,14 @@ export class CustomObjects {
14
14
  publish(ref, body, options) {
15
15
  return this.request('POST', routes.customObjectEvents(ref), body, options);
16
16
  }
17
+ /** With `onlyIfUnwatched`, refuses with 409 `watched` and changes nothing while any node watches the object. */
17
18
  unregister(ref, options) {
18
- return this.request('DELETE', routes.customObject(ref), undefined, options);
19
+ const { onlyIfUnwatched, ...request } = options ?? {};
20
+ return this.request('DELETE', onlyIfUnwatched === true ? withQuery(routes.customObject(ref), { only_if_unwatched: '1' }) : routes.customObject(ref), undefined, request);
21
+ }
22
+ /** Move every watcher of `ref` onto `into` and unregister `ref`, in one write. Both must be live and have the same owner. `404` when `ref` is already gone. */
23
+ mergeInto(ref, into, options) {
24
+ return this.request('POST', routes.customObjectMergeInto(ref), { into }, options);
19
25
  }
20
26
  ack(ref, deliveryIds, options) {
21
27
  return this.request('POST', routes.customObjectAck(ref), { delivery_ids: deliveryIds }, options);
@@ -2,7 +2,7 @@
2
2
  name: northlight
3
3
  description: "Use when building, debugging or shipping an app that signs people in with Northlight, starts runs on their Northlight runtime, or calls Northlight providers (sms, search, integrations, context, device) with @north-light/sdk."
4
4
  metadata:
5
- sdk-version: "0.3.855"
5
+ sdk-version: "0.3.857"
6
6
  ---
7
7
 
8
8
  # Building a Northlight app
@@ -27,7 +27,7 @@ Never text a person first: Comms refuses a send to anyone who has not texted you
27
27
 
28
28
  ## First: check this skill matches the SDK
29
29
 
30
- This skill is for SDK version `0.3.855`. If the project has `node_modules/@north-light/sdk/package.json`, compare its `version` with that number. If they differ, run `npx @north-light/sdk skill` in the project, then read the rewritten `.agents/skills/northlight/SKILL.md` (or `.claude/skills/northlight/SKILL.md`) instead of this copy. It needs no account. A project that has no SDK yet starts with `npx @north-light/sdk@latest init <dir>`.
30
+ This skill is for SDK version `0.3.857`. If the project has `node_modules/@north-light/sdk/package.json`, compare its `version` with that number. If they differ, run `npx @north-light/sdk skill` in the project, then read the rewritten `.agents/skills/northlight/SKILL.md` (or `.claude/skills/northlight/SKILL.md`) instead of this copy. It needs no account. A project that has no SDK yet starts with `npx @north-light/sdk@latest init <dir>`.
31
31
 
32
32
  ## Where things run
33
33
 
package/dist/version.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
2
- export declare const SDK_VERSION = "0.3.855";
2
+ export declare const SDK_VERSION = "0.3.857";
3
3
  /** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
4
4
  * contract level existed (which only knows this header) refuses this SDK, while every later runtime accepts it. */
5
5
  export declare const LEGACY_FLOOR = "0.3.423";
package/dist/version.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SDK_VERSION is written by scripts/release-version.mjs on every release; do not edit by hand.
2
2
  /** This SDK's release version. Informational only: compatibility is the contract level, not this number. */
3
- export const SDK_VERSION = '0.3.855';
3
+ export const SDK_VERSION = '0.3.857';
4
4
  // LEGACY_FLOOR is written once by `scripts/contract.mjs release`, at the first release that carries the contract level
5
5
  // (the `0.0.0` placeholder is replaced there and never again); do not edit by hand.
6
6
  /** The release sent in `Crouter-Minimum-Runtime-Version` on every request. It is frozen, so a runtime from before the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@north-light/sdk",
3
- "version": "0.3.855",
4
- "crouterContract": "1.102",
3
+ "version": "0.3.857",
4
+ "crouterContract": "1.104",
5
5
  "description": "Typed Node and browser client for running crouter agents through the crtrd /v1 API.",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -44,9 +44,9 @@
44
44
  "prepublishOnly": "node -e \"if (process.env.npm_config_tag !== 'next') { console.error('@north-light/sdk publishes only with --tag next; scripts/promote-sdk.mjs is the only mover of latest.'); process.exit(1); }\""
45
45
  },
46
46
  "dependencies": {
47
- "@north-light/api": "0.3.855",
48
- "@north-light/identity": "0.3.855",
49
- "@north-light/plugin": "0.3.855",
47
+ "@north-light/api": "0.3.857",
48
+ "@north-light/identity": "0.3.857",
49
+ "@north-light/plugin": "0.3.857",
50
50
  "jose": "^6.2.1"
51
51
  },
52
52
  "peerDependencies": {