@peers-app/peers-sdk 0.16.6 → 0.17.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.
@@ -286,12 +286,27 @@ describe("definePackage — error cases", () => {
286
286
  });
287
287
  }).toThrow("valid peer ID");
288
288
  });
289
- it("throws when no contracts are defined", () => {
290
- expect(() => {
291
- (0, builder_1.definePackage)((pkg) => {
292
- pkg.packageId = TEST_PKG_ID;
293
- });
294
- }).toThrow("at least one contract");
289
+ it("allows package with no contracts (UI-only)", () => {
290
+ const nav = { name: "Game", iconClassName: "bi-controller", navigationPath: "play" };
291
+ const result = (0, builder_1.definePackage)((pkg) => {
292
+ pkg.packageId = TEST_PKG_ID;
293
+ pkg.appNavs = [nav];
294
+ });
295
+ expect(result.contracts).toHaveLength(0);
296
+ expect(result.consumes).toHaveLength(0);
297
+ expect(result.toolInstances).toHaveLength(0);
298
+ expect(result.tableDefinitions).toHaveLength(0);
299
+ expect(result.appNavs).toEqual([nav]);
300
+ });
301
+ it("allows consumes-only package with no defined contracts", () => {
302
+ const result = (0, builder_1.definePackage)((pkg) => {
303
+ pkg.packageId = TEST_PKG_ID;
304
+ pkg.consumes(TASKS_ID, 1);
305
+ });
306
+ expect(result.contracts).toHaveLength(0);
307
+ expect(result.consumes).toHaveLength(1);
308
+ expect(result.toolInstances).toHaveLength(0);
309
+ expect(result.tableDefinitions).toHaveLength(0);
295
310
  });
296
311
  it("throws on duplicate contract ID + version", () => {
297
312
  const dupId = (0, utils_1.newid)();
@@ -50,8 +50,13 @@ export declare class ContractBuilder {
50
50
  };
51
51
  }
52
52
  /**
53
- * Top-level builder passed to the `definePackage` callback. Each package must
54
- * define at least one contract.
53
+ * Top-level builder passed to the `definePackage` callback.
54
+ *
55
+ * Packages may define **zero** contracts (e.g. UI-only apps with no persisted
56
+ * tables). Tables, tool shapes, and executable `toolInstances` /
57
+ * `tableDefinitions` are only attached via {@link PackageBuilder.contract} —
58
+ * there is no package-level API for them, so persistence always implies a
59
+ * contract.
55
60
  */
56
61
  export declare class PackageBuilder {
57
62
  private _packageId?;
@@ -93,8 +93,13 @@ class ContractBuilder {
93
93
  }
94
94
  exports.ContractBuilder = ContractBuilder;
95
95
  /**
96
- * Top-level builder passed to the `definePackage` callback. Each package must
97
- * define at least one contract.
96
+ * Top-level builder passed to the `definePackage` callback.
97
+ *
98
+ * Packages may define **zero** contracts (e.g. UI-only apps with no persisted
99
+ * tables). Tables, tool shapes, and executable `toolInstances` /
100
+ * `tableDefinitions` are only attached via {@link PackageBuilder.contract} —
101
+ * there is no package-level API for them, so persistence always implies a
102
+ * contract.
98
103
  */
99
104
  class PackageBuilder {
100
105
  _packageId;
@@ -168,9 +173,6 @@ class PackageBuilder {
168
173
  if (!this._packageId) {
169
174
  throw new Error("A package must set packageId before building");
170
175
  }
171
- if (this._contracts.length === 0) {
172
- throw new Error("A package must define at least one contract");
173
- }
174
176
  const contracts = [];
175
177
  const alsoImplementsMap = new Map();
176
178
  const allToolInstances = [];
@@ -184,6 +186,9 @@ class PackageBuilder {
184
186
  allToolInstances.push(...toolInstances);
185
187
  allTableDefinitions.push(...tableDefinitions);
186
188
  }
189
+ if (contracts.length === 0 && (allToolInstances.length > 0 || allTableDefinitions.length > 0)) {
190
+ throw new Error("Tables and executable tools must be declared on a contract (use pkg.contract(...), then assign .tables, .tools, .toolInstances, or .tableDefinitions on that builder). UI-only packages omit contracts and do not register tables or tools.");
191
+ }
187
192
  return {
188
193
  packageId: this._packageId,
189
194
  version: this._version,
@@ -3,8 +3,7 @@ import type { DataContext } from "../context/data-context";
3
3
  export declare enum IOSchemaType {
4
4
  none = "none",
5
5
  simple = "simple",
6
- complex = "complex",
7
- code = "code"
6
+ complex = "complex"
8
7
  }
9
8
  export declare const ioSchema: z.ZodObject<{
10
9
  type: z.ZodNativeEnum<typeof IOSchemaType>;
@@ -13,7 +13,6 @@ var IOSchemaType;
13
13
  IOSchemaType["none"] = "none";
14
14
  IOSchemaType["simple"] = "simple";
15
15
  IOSchemaType["complex"] = "complex";
16
- IOSchemaType["code"] = "code";
17
16
  })(IOSchemaType || (exports.IOSchemaType = IOSchemaType = {}));
18
17
  exports.ioSchema = zod_1.z.object({
19
18
  type: zod_1.z.nativeEnum(IOSchemaType),
@@ -61,6 +61,13 @@ export declare const rpcServerCalls: {
61
61
  /** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
62
62
  resetChangeTracking: () => Promise<void>;
63
63
  deleteLocalDatabase: () => Promise<void>;
64
+ /** Returns info about the pre-migration data directory, or `null` if already cleaned up. */
65
+ getOldDataDirInfo: () => Promise<{
66
+ path: string;
67
+ sizeMB: number;
68
+ } | null>;
69
+ /** Deletes the pre-migration data directory after the user confirms. */
70
+ cleanupOldDataDir: () => Promise<void>;
64
71
  importGroupShare: (groupShareJson: string) => Promise<string>;
65
72
  registerWithPeersServices: () => Promise<string>;
66
73
  appQuit: () => Promise<void>;
package/dist/rpc-types.js CHANGED
@@ -34,6 +34,10 @@ exports.rpcServerCalls = {
34
34
  /** Clear change tracking and rebuild from current rows for the default data context (same as Data Explorer). */
35
35
  resetChangeTracking: rpcStub("resetChangeTracking"),
36
36
  deleteLocalDatabase: rpcStub("deleteLocalDatabase"),
37
+ /** Returns info about the pre-migration data directory, or `null` if already cleaned up. */
38
+ getOldDataDirInfo: rpcStub("getOldDataDirInfo"),
39
+ /** Deletes the pre-migration data directory after the user confirms. */
40
+ cleanupOldDataDir: rpcStub("cleanupOldDataDir"),
37
41
  importGroupShare: rpcStub("importGroupShare"),
38
42
  registerWithPeersServices: rpcStub("registerWithPeersServices"),
39
43
  // App lifecycle commands (for CLI control)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.16.6",
3
+ "version": "0.17.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"