@peers-app/peers-sdk 0.18.4 → 0.18.6

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.
@@ -56,10 +56,11 @@ const schema = zod_1.z.object({
56
56
  .optional()
57
57
  .describe("Whether the package's components should be loaded and included in the app runtime"),
58
58
  remoteRepo: zod_1.z.string().optional().describe("The remote repository where the package is stored"),
59
+ /** @deprecated Read appNavs from the active IPackageVersion record instead. */
59
60
  appNavs: app_nav_1.appNavSchema
60
61
  .array()
61
62
  .optional()
62
- .describe("The app navigation items that this package provides"),
63
+ .describe("DEPRECATED: Read appNavs from the active IPackageVersion record instead"),
63
64
  activePackageVersionId: zod_types_1.zodPeerId
64
65
  .optional()
65
66
  .describe("FK to PackageVersions — the currently active version"),
@@ -106,14 +107,7 @@ let PackagesTable = (() => {
106
107
  // users can do whatever they want to packages in their personal space
107
108
  return super.save(packageObj, opts);
108
109
  }
109
- try {
110
- await (0, package_permissions_1.verifyPackageSignature)(packageObj, this.groupId);
111
- }
112
- catch (err) {
113
- throw new Error("Package verification failed. Did you mean to call `signAndSave`?", {
114
- cause: err,
115
- });
116
- }
110
+ await (0, package_permissions_1.verifyPackageSignature)(packageObj, this.groupId);
117
111
  return super.save(packageObj, opts);
118
112
  }
119
113
  async signAndSave(packageObj, opts) {
@@ -121,7 +115,7 @@ let PackagesTable = (() => {
121
115
  throw new Error("Package signing is not enabled. Call PackagesTable.enablePackageSigning(fn) to enable it.");
122
116
  }
123
117
  packageObj = await PackagesTable.addSignatureToPackage(packageObj);
124
- return super.save(packageObj, opts);
118
+ return this.save(packageObj, opts);
125
119
  }
126
120
  static addSignatureToPackage = undefined;
127
121
  static enablePackageSigning(fn) {
@@ -32,7 +32,6 @@ export declare const workflowRunSchema: z.ZodObject<{
32
32
  parentWorkflowRunId: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
33
33
  defaultAssistantId: z.ZodEffects<z.ZodString, string, string>;
34
34
  }, "strip", z.ZodTypeAny, {
35
- createdAt: Date;
36
35
  defaultAssistantId: string;
37
36
  instructions: {
38
37
  markdown?: string | undefined;
@@ -40,6 +39,7 @@ export declare const workflowRunSchema: z.ZodObject<{
40
39
  directCallToolId?: string | undefined;
41
40
  subWorkflowId?: string | undefined;
42
41
  }[];
42
+ createdAt: Date;
43
43
  workflowRunId: string;
44
44
  parentMessageId: string;
45
45
  currentInstructionIndex: number;
@@ -57,7 +57,6 @@ export declare const workflowRunSchema: z.ZodObject<{
57
57
  defaultAssistantId: string;
58
58
  workflowRunId: string;
59
59
  parentMessageId: string;
60
- createdAt?: Date | undefined;
61
60
  workflowId?: string | undefined;
62
61
  instructions?: {
63
62
  markdown?: string | undefined;
@@ -65,6 +64,7 @@ export declare const workflowRunSchema: z.ZodObject<{
65
64
  directCallToolId?: string | undefined;
66
65
  subWorkflowId?: string | undefined;
67
66
  }[] | undefined;
67
+ createdAt?: Date | undefined;
68
68
  scheduleDT?: Date | undefined;
69
69
  currentInstructionIndex?: number | undefined;
70
70
  instructionResults?: any[] | undefined;
@@ -2,8 +2,6 @@ import type { DataContext } from "../context/data-context";
2
2
  export declare function Workflows(dataContext?: DataContext): import("./orm").Table<{
3
3
  name: string;
4
4
  description: string;
5
- createdBy: string;
6
- createdAt: Date;
7
5
  workflowId: string;
8
6
  defaultAssistantId: string;
9
7
  instructions: {
@@ -12,6 +10,8 @@ export declare function Workflows(dataContext?: DataContext): import("./orm").Ta
12
10
  directCallToolId?: string | undefined;
13
11
  subWorkflowId?: string | undefined;
14
12
  }[];
13
+ createdBy: string;
14
+ createdAt: Date;
15
15
  updatedAt: Date;
16
16
  packageId?: string | undefined;
17
17
  }>;
@@ -18,6 +18,7 @@ export declare class PackageLoader {
18
18
  loadPackage(pkg: IPackage, opts?: {
19
19
  force?: boolean;
20
20
  localPath?: string;
21
+ packageVersionId?: string;
21
22
  }): Promise<IPeersPackage | undefined>;
22
23
  private _readLocalBundle;
23
24
  /**
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageLoader = void 0;
4
4
  exports.setDefaultRequire = setDefaultRequire;
5
5
  const files_1 = require("../data/files");
6
+ const package_version_resolver_1 = require("../data/package-version-resolver");
6
7
  const package_versions_1 = require("../data/package-versions");
7
8
  const packages_1 = require("../data/packages");
8
9
  const tools_1 = require("../data/tools");
@@ -25,7 +26,9 @@ class PackageLoader {
25
26
  }
26
27
  async loadAllPackages(opts) {
27
28
  const packages = await (0, packages_1.Packages)(this.dataContext).list();
28
- await Promise.all(packages.filter((pkg) => !pkg.disabled).map((pkg) => this.loadPackage(pkg, opts)));
29
+ await Promise.all(packages
30
+ .filter((pkg) => !pkg.disabled)
31
+ .map((pkg) => (0, package_version_resolver_1.resolveDevicePackageVersion)(pkg, this.dataContext, opts)));
29
32
  }
30
33
  async loadPackage(pkg, opts) {
31
34
  if (this.packageInstances[pkg.packageId] && !opts?.force) {
@@ -35,9 +38,10 @@ class PackageLoader {
35
38
  try {
36
39
  let bundleCode = "";
37
40
  let bundleFileId;
38
- if (pkg.activePackageVersionId) {
41
+ const pvId = opts?.packageVersionId ?? pkg.activePackageVersionId;
42
+ if (pvId) {
39
43
  try {
40
- const pv = await (0, package_versions_1.PackageVersions)(this.dataContext).get(pkg.activePackageVersionId);
44
+ const pv = await (0, package_versions_1.PackageVersions)(this.dataContext).get(pvId);
41
45
  if (pv) {
42
46
  bundleFileId = pv.packageBundleFileId;
43
47
  }
@@ -110,12 +114,17 @@ class PackageLoader {
110
114
  if (!def.version)
111
115
  return;
112
116
  const pvTable = (0, package_versions_1.PackageVersions)(this.dataContext);
113
- pvTable.get(pkg.activePackageVersionId).then((pv) => {
117
+ pvTable
118
+ .get(pkg.activePackageVersionId)
119
+ .then((pv) => {
114
120
  if (!pv)
115
121
  return;
116
122
  if (def.version && pv.version !== def.version) {
117
- pvTable.save({ ...pv, version: def.version });
123
+ return pvTable.signAndSave({ ...pv, version: def.version });
118
124
  }
125
+ })
126
+ .catch((err) => {
127
+ console.warn(`[PackageLoader] Failed to correct version for ${pkg.name}:`, err.message);
119
128
  });
120
129
  }
121
130
  async _evaluateBundle(pkg, bundleCode) {
@@ -44,8 +44,6 @@ export declare const workflowSchema: z.ZodObject<{
44
44
  }, "strip", z.ZodTypeAny, {
45
45
  name: string;
46
46
  description: string;
47
- createdBy: string;
48
- createdAt: Date;
49
47
  workflowId: string;
50
48
  defaultAssistantId: string;
51
49
  instructions: {
@@ -54,22 +52,24 @@ export declare const workflowSchema: z.ZodObject<{
54
52
  directCallToolId?: string | undefined;
55
53
  subWorkflowId?: string | undefined;
56
54
  }[];
55
+ createdBy: string;
56
+ createdAt: Date;
57
57
  updatedAt: Date;
58
58
  packageId?: string | undefined;
59
59
  }, {
60
60
  name: string;
61
61
  description: string;
62
- createdBy: string;
63
62
  workflowId: string;
64
63
  defaultAssistantId: string;
64
+ createdBy: string;
65
65
  packageId?: string | undefined;
66
- createdAt?: Date | undefined;
67
66
  instructions?: {
68
67
  markdown?: string | undefined;
69
68
  onError?: string | undefined;
70
69
  directCallToolId?: string | undefined;
71
70
  subWorkflowId?: string | undefined;
72
71
  }[] | undefined;
72
+ createdAt?: Date | undefined;
73
73
  updatedAt?: Date | undefined;
74
74
  }>;
75
75
  export type IWorkflow = z.infer<typeof workflowSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.18.4",
3
+ "version": "0.18.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"