@peers-app/peers-sdk 0.14.0 → 0.15.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.
Files changed (210) hide show
  1. package/dist/context/data-context.d.ts +4 -4
  2. package/dist/context/data-context.js +1 -1
  3. package/dist/context/index.d.ts +3 -3
  4. package/dist/context/index.js +4 -0
  5. package/dist/context/user-context-singleton.js +13 -14
  6. package/dist/context/user-context.d.ts +4 -4
  7. package/dist/context/user-context.js +48 -31
  8. package/dist/data/assistants.d.ts +1 -1
  9. package/dist/data/assistants.js +35 -24
  10. package/dist/data/change-tracking.d.ts +8 -8
  11. package/dist/data/change-tracking.js +45 -39
  12. package/dist/data/channels.js +5 -5
  13. package/dist/data/data-locks.d.ts +2 -2
  14. package/dist/data/data-locks.js +21 -23
  15. package/dist/data/data-locks.test.js +73 -75
  16. package/dist/data/device-sync-info.d.ts +1 -1
  17. package/dist/data/device-sync-info.js +4 -4
  18. package/dist/data/devices.d.ts +1 -1
  19. package/dist/data/devices.js +9 -12
  20. package/dist/data/embeddings.js +14 -11
  21. package/dist/data/files/file-read-stream.d.ts +2 -2
  22. package/dist/data/files/file-read-stream.js +23 -14
  23. package/dist/data/files/file-write-stream.d.ts +2 -2
  24. package/dist/data/files/file-write-stream.js +8 -8
  25. package/dist/data/files/file.types.d.ts +2 -2
  26. package/dist/data/files/file.types.js +17 -11
  27. package/dist/data/files/files.d.ts +6 -6
  28. package/dist/data/files/files.js +17 -19
  29. package/dist/data/files/files.test.js +213 -214
  30. package/dist/data/files/index.d.ts +4 -4
  31. package/dist/data/files/index.js +4 -4
  32. package/dist/data/group-member-roles.js +2 -2
  33. package/dist/data/group-members.d.ts +5 -5
  34. package/dist/data/group-members.js +27 -18
  35. package/dist/data/group-members.test.js +73 -73
  36. package/dist/data/group-permissions.d.ts +3 -3
  37. package/dist/data/group-permissions.js +13 -11
  38. package/dist/data/group-share.d.ts +2 -2
  39. package/dist/data/group-share.js +29 -24
  40. package/dist/data/groups.d.ts +4 -4
  41. package/dist/data/groups.js +27 -19
  42. package/dist/data/groups.test.js +44 -44
  43. package/dist/data/index.d.ts +6 -6
  44. package/dist/data/index.js +6 -6
  45. package/dist/data/knowledge/peer-types.js +9 -9
  46. package/dist/data/messages.d.ts +5 -5
  47. package/dist/data/messages.js +43 -30
  48. package/dist/data/orm/client-proxy.data-source.d.ts +4 -4
  49. package/dist/data/orm/client-proxy.data-source.js +10 -12
  50. package/dist/data/orm/cursor.d.ts +1 -1
  51. package/dist/data/orm/cursor.js +2 -2
  52. package/dist/data/orm/cursor.test.js +92 -93
  53. package/dist/data/orm/data-query.d.ts +3 -3
  54. package/dist/data/orm/data-query.js +24 -18
  55. package/dist/data/orm/data-query.mongo.d.ts +1 -1
  56. package/dist/data/orm/data-query.mongo.js +49 -51
  57. package/dist/data/orm/data-query.mongo.test.js +173 -204
  58. package/dist/data/orm/data-query.sqlite.d.ts +1 -1
  59. package/dist/data/orm/data-query.sqlite.js +84 -73
  60. package/dist/data/orm/data-query.sqlite.test.js +164 -176
  61. package/dist/data/orm/data-query.test.js +216 -224
  62. package/dist/data/orm/decorators.js +3 -3
  63. package/dist/data/orm/dependency-injection.test.js +53 -56
  64. package/dist/data/orm/doc.d.ts +4 -4
  65. package/dist/data/orm/doc.js +17 -21
  66. package/dist/data/orm/event-registry.d.ts +1 -1
  67. package/dist/data/orm/event-registry.test.js +16 -16
  68. package/dist/data/orm/factory.d.ts +2 -2
  69. package/dist/data/orm/factory.js +33 -33
  70. package/dist/data/orm/index.d.ts +10 -10
  71. package/dist/data/orm/index.js +10 -10
  72. package/dist/data/orm/multi-cursors.d.ts +1 -1
  73. package/dist/data/orm/multi-cursors.js +6 -6
  74. package/dist/data/orm/multi-cursors.test.js +152 -144
  75. package/dist/data/orm/sql.data-source.d.ts +7 -7
  76. package/dist/data/orm/sql.data-source.js +88 -93
  77. package/dist/data/orm/sql.data-source.test.js +109 -101
  78. package/dist/data/orm/subscribable.data-source.d.ts +4 -4
  79. package/dist/data/orm/subscribable.data-source.js +5 -5
  80. package/dist/data/orm/table-container-events.test.js +34 -26
  81. package/dist/data/orm/table-container.d.ts +6 -6
  82. package/dist/data/orm/table-container.js +33 -21
  83. package/dist/data/orm/table-container.test.js +64 -53
  84. package/dist/data/orm/table-definitions.system.d.ts +3 -3
  85. package/dist/data/orm/table-definitions.system.js +3 -3
  86. package/dist/data/orm/table-definitions.type.d.ts +5 -5
  87. package/dist/data/orm/table-dependencies.d.ts +2 -2
  88. package/dist/data/orm/table.d.ts +5 -5
  89. package/dist/data/orm/table.event-source.test.js +105 -115
  90. package/dist/data/orm/table.js +35 -34
  91. package/dist/data/orm/types.d.ts +3 -3
  92. package/dist/data/orm/types.js +26 -25
  93. package/dist/data/orm/types.test.js +166 -92
  94. package/dist/data/package-permissions.d.ts +1 -1
  95. package/dist/data/package-permissions.js +2 -2
  96. package/dist/data/package-version-permissions.d.ts +1 -1
  97. package/dist/data/package-version-permissions.js +2 -2
  98. package/dist/data/package-versions.d.ts +9 -9
  99. package/dist/data/package-versions.js +47 -33
  100. package/dist/data/packages.d.ts +2 -2
  101. package/dist/data/packages.js +36 -18
  102. package/dist/data/packages.utils.d.ts +2 -2
  103. package/dist/data/packages.utils.js +4 -4
  104. package/dist/data/persistent-vars.d.ts +15 -15
  105. package/dist/data/persistent-vars.js +165 -154
  106. package/dist/data/table-definitions-table.d.ts +5 -5
  107. package/dist/data/table-definitions-table.js +13 -12
  108. package/dist/data/tool-tests.js +6 -6
  109. package/dist/data/tools.js +29 -19
  110. package/dist/data/user-permissions.d.ts +1 -1
  111. package/dist/data/user-permissions.js +5 -5
  112. package/dist/data/user-permissions.test.js +90 -88
  113. package/dist/data/user-trust-levels.js +10 -10
  114. package/dist/data/users.d.ts +4 -4
  115. package/dist/data/users.js +16 -15
  116. package/dist/data/voice-messages.d.ts +2 -2
  117. package/dist/data/voice-messages.js +13 -13
  118. package/dist/data/welcome-modal.pvar.js +3 -1
  119. package/dist/data/workflow-logs.js +26 -18
  120. package/dist/data/workflow-runs.d.ts +6 -6
  121. package/dist/data/workflow-runs.js +70 -44
  122. package/dist/data/workflows.d.ts +2 -2
  123. package/dist/data/workflows.js +7 -9
  124. package/dist/device/binary-peer-connection-v2.d.ts +7 -7
  125. package/dist/device/binary-peer-connection-v2.js +32 -28
  126. package/dist/device/binary-peer-connection-v2.test.js +80 -67
  127. package/dist/device/binary-peer-connection.d.ts +7 -7
  128. package/dist/device/binary-peer-connection.js +29 -28
  129. package/dist/device/binary-peer-connection.test.js +35 -31
  130. package/dist/device/connection.d.ts +5 -5
  131. package/dist/device/connection.js +59 -48
  132. package/dist/device/connection.test.js +74 -68
  133. package/dist/device/device-election.d.ts +2 -2
  134. package/dist/device/device-election.js +25 -20
  135. package/dist/device/device-election.test.js +35 -36
  136. package/dist/device/device.d.ts +2 -2
  137. package/dist/device/device.js +10 -4
  138. package/dist/device/device.test.js +16 -17
  139. package/dist/device/get-trust-level-fn.d.ts +2 -2
  140. package/dist/device/get-trust-level-fn.js +22 -11
  141. package/dist/device/get-trust-level-fn.test.js +58 -58
  142. package/dist/device/socket-io-binary-peer.d.ts +1 -1
  143. package/dist/device/socket-io-binary-peer.js +16 -13
  144. package/dist/device/socket.type.d.ts +2 -2
  145. package/dist/device/streamed-socket.d.ts +2 -2
  146. package/dist/device/streamed-socket.js +8 -8
  147. package/dist/device/streamed-socket.test.js +40 -40
  148. package/dist/device/tx-encoding.test.js +77 -77
  149. package/dist/events.d.ts +1 -1
  150. package/dist/events.js +5 -2
  151. package/dist/group-invite/group-invite.js +110 -19
  152. package/dist/group-invite/group-invite.pvars.d.ts +2 -2
  153. package/dist/group-invite/group-invite.pvars.js +21 -13
  154. package/dist/group-invite/group-invite.types.d.ts +1 -1
  155. package/dist/group-invite/index.d.ts +3 -3
  156. package/dist/group-invite/index.js +1 -1
  157. package/dist/index.d.ts +25 -24
  158. package/dist/index.js +30 -25
  159. package/dist/keys.d.ts +3 -3
  160. package/dist/keys.js +31 -30
  161. package/dist/keys.test.js +69 -61
  162. package/dist/logging/console-logger.d.ts +1 -1
  163. package/dist/logging/console-logger.js +35 -40
  164. package/dist/logging/console-logger.test.js +115 -115
  165. package/dist/logging/console-logs.table.d.ts +3 -3
  166. package/dist/logging/console-logs.table.js +28 -23
  167. package/dist/mentions.js +16 -12
  168. package/dist/observable.d.ts +2 -2
  169. package/dist/observable.js +15 -9
  170. package/dist/observable.test.js +47 -47
  171. package/dist/package-loader/get-require.js +3 -4
  172. package/dist/package-loader/package-loader.d.ts +2 -2
  173. package/dist/package-loader/package-loader.js +52 -34
  174. package/dist/peers-ui/peers-ui.d.ts +2 -2
  175. package/dist/peers-ui/peers-ui.js +2 -4
  176. package/dist/peers-ui/peers-ui.types.d.ts +3 -3
  177. package/dist/peers-ui/peers-ui.types.js +0 -1
  178. package/dist/rpc-types.d.ts +61 -59
  179. package/dist/rpc-types.js +61 -55
  180. package/dist/serial-json.d.ts +1 -1
  181. package/dist/serial-json.js +50 -43
  182. package/dist/serial-json.test.js +22 -22
  183. package/dist/system-ids.js +8 -8
  184. package/dist/tools/index.d.ts +1 -1
  185. package/dist/tools/tools-factory.d.ts +1 -1
  186. package/dist/tools/tools-factory.js +2 -2
  187. package/dist/types/assistant-runner-args.d.ts +3 -3
  188. package/dist/types/peer-device.d.ts +1 -1
  189. package/dist/types/peers-package.d.ts +3 -3
  190. package/dist/types/workflow-logger.d.ts +1 -1
  191. package/dist/types/workflow-run-context.d.ts +4 -4
  192. package/dist/types/workflow.d.ts +4 -4
  193. package/dist/types/workflow.js +27 -14
  194. package/dist/types/zod-types.d.ts +2 -1
  195. package/dist/types/zod-types.js +9 -3
  196. package/dist/user-connect/connection-code.d.ts +1 -1
  197. package/dist/user-connect/connection-code.js +7 -7
  198. package/dist/user-connect/connection-code.test.js +106 -106
  199. package/dist/user-connect/index.d.ts +3 -3
  200. package/dist/user-connect/index.js +1 -1
  201. package/dist/user-connect/user-connect.pvars.js +13 -11
  202. package/dist/user-connect/user-connect.types.d.ts +3 -3
  203. package/dist/users.query.d.ts +2 -2
  204. package/dist/users.query.js +40 -30
  205. package/dist/utils.d.ts +2 -2
  206. package/dist/utils.js +34 -32
  207. package/dist/utils.test.js +12 -8
  208. package/dist/workflow-log-formatter.d.ts +1 -1
  209. package/dist/workflow-log-formatter.js +17 -18
  210. package/package.json +14 -8
@@ -52,28 +52,31 @@ const types_1 = require("./orm/types");
52
52
  const package_version_permissions_1 = require("./package-version-permissions");
53
53
  const schema = zod_1.z.object({
54
54
  packageVersionId: zod_types_1.zodPeerId,
55
- packageId: zod_types_1.zodPeerId.describe('The package this version belongs to'),
55
+ packageId: zod_types_1.zodPeerId.describe("The package this version belongs to"),
56
56
  version: zod_1.z.string().describe('Semantic version string (e.g., "1.0.0")'),
57
57
  versionTag: zod_1.z.string().optional().describe('Version tag (e.g., "stable", "beta")'),
58
- packageVersionHash: zod_1.z.string().describe('Hash of the combined bundle file hashes'),
59
- packageBundleFileId: zod_types_1.zodPeerId.describe('File ID of the package bundle'),
60
- packageBundleFileHash: zod_1.z.string().describe('Hash of the package bundle file'),
61
- routesBundleFileId: zod_types_1.zodPeerId.optional().describe('File ID of the routes bundle'),
62
- routesBundleFileHash: zod_1.z.string().optional().describe('Hash of the routes bundle'),
63
- uiBundleFileId: zod_types_1.zodPeerId.optional().describe('File ID of the UI bundle'),
64
- uiBundleFileHash: zod_1.z.string().optional().describe('Hash of the UI bundle'),
65
- appNavs: app_nav_1.appNavSchema.array().optional().describe('The app navigation items that this version provides'),
66
- signature: zod_1.z.string().describe('The signed hash of this data excluding the signature itself'),
67
- createdBy: zod_types_1.zodPeerId.describe('The user who created this version'),
68
- createdAt: zod_1.z.string().describe('ISO timestamp of when this version was created'),
58
+ packageVersionHash: zod_1.z.string().describe("Hash of the combined bundle file hashes"),
59
+ packageBundleFileId: zod_types_1.zodPeerId.describe("File ID of the package bundle"),
60
+ packageBundleFileHash: zod_1.z.string().describe("Hash of the package bundle file"),
61
+ routesBundleFileId: zod_types_1.zodPeerId.optional().describe("File ID of the routes bundle"),
62
+ routesBundleFileHash: zod_1.z.string().optional().describe("Hash of the routes bundle"),
63
+ uiBundleFileId: zod_types_1.zodPeerId.optional().describe("File ID of the UI bundle"),
64
+ uiBundleFileHash: zod_1.z.string().optional().describe("Hash of the UI bundle"),
65
+ appNavs: app_nav_1.appNavSchema
66
+ .array()
67
+ .optional()
68
+ .describe("The app navigation items that this version provides"),
69
+ signature: zod_1.z.string().describe("The signed hash of this data excluding the signature itself"),
70
+ createdBy: zod_types_1.zodPeerId.describe("The user who created this version"),
71
+ createdAt: zod_1.z.string().describe("ISO timestamp of when this version was created"),
69
72
  });
70
73
  const metaData = {
71
- name: 'PackageVersions',
72
- description: 'Versioned builds of packages',
73
- primaryKeyName: 'packageVersionId',
74
- iconClassName: 'bi bi-tag-fill',
74
+ name: "PackageVersions",
75
+ description: "Versioned builds of packages",
76
+ primaryKeyName: "packageVersionId",
77
+ iconClassName: "bi bi-tag-fill",
75
78
  fields: (0, types_1.schemaToFields)(schema),
76
- indexes: [{ fields: ['packageId'] }],
79
+ indexes: [{ fields: ["packageId"] }],
77
80
  };
78
81
  let PackageVersionsTable = (() => {
79
82
  let _classSuper = table_1.Table;
@@ -105,20 +108,22 @@ let PackageVersionsTable = (() => {
105
108
  await (0, package_version_permissions_1.verifyPackageVersionSignature)(packageVersion, this.groupId);
106
109
  }
107
110
  catch (err) {
108
- throw new Error('Package version verification failed. Did you mean to call `signAndSave`?', { cause: err });
111
+ throw new Error("Package version verification failed. Did you mean to call `signAndSave`?", {
112
+ cause: err,
113
+ });
109
114
  }
110
115
  return super.save(packageVersion, opts);
111
116
  }
112
117
  async signAndSave(packageVersion, opts) {
113
118
  if (!PackageVersionsTable.addSignatureToPackageVersion) {
114
- throw new Error('Package version signing is not enabled. Call PackageVersionsTable.enablePackageVersionSigning(fn) to enable it.');
119
+ throw new Error("Package version signing is not enabled. Call PackageVersionsTable.enablePackageVersionSigning(fn) to enable it.");
115
120
  }
116
121
  packageVersion = await PackageVersionsTable.addSignatureToPackageVersion(packageVersion);
117
122
  return super.save(packageVersion, opts);
118
123
  }
119
124
  static addSignatureToPackageVersion = undefined;
120
125
  static enablePackageVersionSigning(fn) {
121
- this.addSignatureToPackageVersion = fn;
126
+ PackageVersionsTable.addSignatureToPackageVersion = fn;
122
127
  }
123
128
  constructor() {
124
129
  super(...arguments);
@@ -135,18 +140,24 @@ function PackageVersions(dataContext) {
135
140
  * Compute a hash combining the bundle file hashes to uniquely identify this version's content.
136
141
  */
137
142
  function computePackageVersionHash(version, versionTag, packageBundleFileHash, routesBundleFileHash, uiBundleFileHash) {
138
- return (0, keys_1.hashValue)([version, versionTag, packageBundleFileHash, routesBundleFileHash ?? '', uiBundleFileHash ?? ''].join(':'));
143
+ return (0, keys_1.hashValue)([
144
+ version,
145
+ versionTag,
146
+ packageBundleFileHash,
147
+ routesBundleFileHash ?? "",
148
+ uiBundleFileHash ?? "",
149
+ ].join(":"));
139
150
  }
140
151
  function isVersionInRange(activeVersion, incomingVersion, range) {
141
- if (range === 'pinned')
152
+ if (range === "pinned")
142
153
  return false;
143
- if (range === 'latest')
154
+ if (range === "latest")
144
155
  return true;
145
- const [aMaj, aMin] = activeVersion.split('.').map(Number);
146
- const [iMaj, iMin] = incomingVersion.split('.').map(Number);
147
- if (range === 'patch')
156
+ const [aMaj, aMin] = activeVersion.split(".").map(Number);
157
+ const [iMaj, iMin] = incomingVersion.split(".").map(Number);
158
+ if (range === "patch")
148
159
  return aMaj === iMaj && aMin === iMin;
149
- if (range === 'minor')
160
+ if (range === "minor")
150
161
  return aMaj === iMaj;
151
162
  return false;
152
163
  }
@@ -154,8 +165,8 @@ function isVersionInRange(activeVersion, incomingVersion, range) {
154
165
  * Returns true if incomingVersion is strictly newer than activeVersion (semver comparison).
155
166
  */
156
167
  function isNewerVersion(activeVersion, incomingVersion) {
157
- const [aMaj = 0, aMin = 0, aPat = 0] = activeVersion.split('.').map(Number);
158
- const [iMaj = 0, iMin = 0, iPat = 0] = incomingVersion.split('.').map(Number);
168
+ const [aMaj = 0, aMin = 0, aPat = 0] = activeVersion.split(".").map(Number);
169
+ const [iMaj = 0, iMin = 0, iPat = 0] = incomingVersion.split(".").map(Number);
159
170
  if (iMaj !== aMaj)
160
171
  return iMaj > aMaj;
161
172
  if (iMin !== aMin)
@@ -163,13 +174,16 @@ function isNewerVersion(activeVersion, incomingVersion) {
163
174
  return iPat > aPat;
164
175
  }
165
176
  function doesTagMatch(activeVersionTag, incomingVersionTag, followVersionTags, deviceVersionTag) {
166
- const inTag = incomingVersionTag || 'stable';
177
+ const inTag = incomingVersionTag || "stable";
167
178
  if (deviceVersionTag)
168
179
  return inTag === deviceVersionTag;
169
180
  if (!followVersionTags) {
170
- return inTag === (activeVersionTag || 'stable');
181
+ return inTag === (activeVersionTag || "stable");
171
182
  }
172
- if (followVersionTags === '*')
183
+ if (followVersionTags === "*")
173
184
  return true;
174
- return followVersionTags.split(',').map(t => t.trim()).includes(inTag);
185
+ return followVersionTags
186
+ .split(",")
187
+ .map((t) => t.trim())
188
+ .includes(inTag);
175
189
  }
@@ -33,8 +33,8 @@ declare const schema: z.ZodObject<{
33
33
  name: string;
34
34
  description: string;
35
35
  signature: string;
36
- createdBy: string;
37
36
  packageId: string;
37
+ createdBy: string;
38
38
  disabled?: boolean | undefined;
39
39
  appNavs?: {
40
40
  name: string;
@@ -50,8 +50,8 @@ declare const schema: z.ZodObject<{
50
50
  name: string;
51
51
  description: string;
52
52
  signature: string;
53
- createdBy: string;
54
53
  packageId: string;
54
+ createdBy: string;
55
55
  disabled?: boolean | undefined;
56
56
  appNavs?: {
57
57
  name: string;
@@ -50,20 +50,34 @@ const schema = zod_1.z.object({
50
50
  packageId: zod_types_1.zodPeerId,
51
51
  name: zod_1.z.string(),
52
52
  description: zod_1.z.string(),
53
- createdBy: zod_types_1.zodPeerId.describe('The user who created the package'),
54
- disabled: zod_1.z.boolean().optional().describe("Whether the package's components should be loaded and included in the app runtime"),
55
- remoteRepo: zod_1.z.string().optional().describe('The remote repository where the package is stored'),
56
- appNavs: app_nav_1.appNavSchema.array().optional().describe('The app navigation items that this package provides'),
57
- activePackageVersionId: zod_types_1.zodPeerId.optional().describe('FK to PackageVersions the currently active version'),
58
- versionFollowRange: zod_1.z.enum(['pinned', 'patch', 'minor', 'latest']).optional().describe('Auto-update range: pinned=never, patch=same major.minor, minor=same major, latest=always'),
59
- followVersionTags: zod_1.z.string().optional().describe('Tag policy: undefined="current" (follow active tag), "*"=any tag, or CSV like "stable,prod"'),
60
- signature: zod_1.z.string().describe('The signed hash of this data excluding the signature itself'),
53
+ createdBy: zod_types_1.zodPeerId.describe("The user who created the package"),
54
+ disabled: zod_1.z
55
+ .boolean()
56
+ .optional()
57
+ .describe("Whether the package's components should be loaded and included in the app runtime"),
58
+ remoteRepo: zod_1.z.string().optional().describe("The remote repository where the package is stored"),
59
+ appNavs: app_nav_1.appNavSchema
60
+ .array()
61
+ .optional()
62
+ .describe("The app navigation items that this package provides"),
63
+ activePackageVersionId: zod_types_1.zodPeerId
64
+ .optional()
65
+ .describe("FK to PackageVersions — the currently active version"),
66
+ versionFollowRange: zod_1.z
67
+ .enum(["pinned", "patch", "minor", "latest"])
68
+ .optional()
69
+ .describe("Auto-update range: pinned=never, patch=same major.minor, minor=same major, latest=always"),
70
+ followVersionTags: zod_1.z
71
+ .string()
72
+ .optional()
73
+ .describe('Tag policy: undefined="current" (follow active tag), "*"=any tag, or CSV like "stable,prod"'),
74
+ signature: zod_1.z.string().describe("The signed hash of this data excluding the signature itself"),
61
75
  });
62
76
  const metaData = {
63
- name: 'Packages',
64
- description: 'The Peers packages that this computer is aware of (some may be disabled)',
65
- primaryKeyName: 'packageId',
66
- iconClassName: 'bi bi-box-fill',
77
+ name: "Packages",
78
+ description: "The Peers packages that this computer is aware of (some may be disabled)",
79
+ primaryKeyName: "packageId",
80
+ iconClassName: "bi bi-box-fill",
67
81
  fields: (0, types_1.schemaToFields)(schema),
68
82
  };
69
83
  let PackagesTable = (() => {
@@ -96,20 +110,22 @@ let PackagesTable = (() => {
96
110
  await (0, package_permissions_1.verifyPackageSignature)(packageObj, this.groupId);
97
111
  }
98
112
  catch (err) {
99
- throw new Error('Package verification failed. Did you mean to call `signAndSave`?', { cause: err });
113
+ throw new Error("Package verification failed. Did you mean to call `signAndSave`?", {
114
+ cause: err,
115
+ });
100
116
  }
101
117
  return super.save(packageObj, opts);
102
118
  }
103
119
  async signAndSave(packageObj, opts) {
104
120
  if (!PackagesTable.addSignatureToPackage) {
105
- throw new Error('Package signing is not enabled. Call PackagesTable.enablePackageSigning(fn) to enable it.');
121
+ throw new Error("Package signing is not enabled. Call PackagesTable.enablePackageSigning(fn) to enable it.");
106
122
  }
107
123
  packageObj = await PackagesTable.addSignatureToPackage(packageObj);
108
124
  return super.save(packageObj, opts);
109
125
  }
110
126
  static addSignatureToPackage = undefined;
111
127
  static enablePackageSigning(fn) {
112
- this.addSignatureToPackage = fn;
128
+ PackagesTable.addSignatureToPackage = fn;
113
129
  }
114
130
  async delete(packageId) {
115
131
  // anyone (with write permissions) can delete packages since that isn't a security risk (unless something else is relying on a package to be present?)
@@ -132,6 +148,8 @@ exports.PackagesTable = PackagesTable;
132
148
  function Packages(dataContext) {
133
149
  return (0, context_1.getTableContainer)(dataContext).getTable(metaData, schema, PackagesTable);
134
150
  }
135
- exports.packagesRootDir = '~/peers/packages';
136
- exports.reloadPackagesOnPageRefresh = (0, persistent_vars_1.deviceVar)('reloadPackagesOnPageRefresh', { defaultValue: true, });
137
- exports.autoUpdatePeersCore = (0, persistent_vars_1.deviceVar)('autoUpdatePeersCore', { defaultValue: true });
151
+ exports.packagesRootDir = "~/peers/packages";
152
+ exports.reloadPackagesOnPageRefresh = (0, persistent_vars_1.deviceVar)("reloadPackagesOnPageRefresh", {
153
+ defaultValue: true,
154
+ });
155
+ exports.autoUpdatePeersCore = (0, persistent_vars_1.deviceVar)("autoUpdatePeersCore", { defaultValue: true });
@@ -1,3 +1,3 @@
1
- import { IPackage } from "./packages";
2
- import { DataContext } from "../context/data-context";
1
+ import type { DataContext } from "../context/data-context";
2
+ import { type IPackage } from "./packages";
3
3
  export declare function copyPackageToAnotherDataContext(packageId: string, fromDataContext: DataContext, toDataContext: DataContext): Promise<IPackage>;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.copyPackageToAnotherDataContext = copyPackageToAnotherDataContext;
4
- const packages_1 = require("./packages");
5
4
  const files_1 = require("./files");
6
5
  const package_versions_1 = require("./package-versions");
6
+ const packages_1 = require("./packages");
7
7
  async function copyBundleFile(fileId, fromFiles, toFiles, label) {
8
8
  if (!fileId)
9
9
  return;
@@ -29,9 +29,9 @@ async function copyPackageToAnotherDataContext(packageId, fromDataContext, toDat
29
29
  const toPvTable = (0, package_versions_1.PackageVersions)(toDataContext);
30
30
  const pv = await fromPvTable.get(pkg.activePackageVersionId);
31
31
  if (pv) {
32
- await copyBundleFile(pv.packageBundleFileId, fromFiles, toFiles, 'Version package bundle');
33
- await copyBundleFile(pv.routesBundleFileId, fromFiles, toFiles, 'Version routes bundle');
34
- await copyBundleFile(pv.uiBundleFileId, fromFiles, toFiles, 'Version UI bundle');
32
+ await copyBundleFile(pv.packageBundleFileId, fromFiles, toFiles, "Version package bundle");
33
+ await copyBundleFile(pv.routesBundleFileId, fromFiles, toFiles, "Version routes bundle");
34
+ await copyBundleFile(pv.uiBundleFileId, fromFiles, toFiles, "Version UI bundle");
35
35
  await toPvTable.signAndSave(pv, { saveAsSnapshot: true });
36
36
  }
37
37
  }
@@ -5,12 +5,12 @@
5
5
  * (requires SQLite which is not available in peers-sdk)
6
6
  */
7
7
  import { z } from "zod";
8
- import { UserContext } from "../context";
8
+ import type { UserContext } from "../context";
9
9
  import type { DataContext } from "../context/data-context";
10
- import { Observable } from "../observable";
11
- import { ISaveOptions } from "./orm";
10
+ import { type Observable } from "../observable";
11
+ import type { ISaveOptions } from "./orm";
12
12
  import { Table } from "./orm/table";
13
- import { ITableMetaData } from "./orm/types";
13
+ import { type ITableMetaData } from "./orm/types";
14
14
  declare const schema: z.ZodObject<{
15
15
  persistentVarId: z.ZodEffects<z.ZodString, string, string>;
16
16
  name: z.ZodString;
@@ -65,7 +65,7 @@ export type PersistentVar<T> = Observable<T> & {
65
65
  };
66
66
  export declare function getPersistentVar(name: string, dataContext?: DataContext): Promise<IPersistentVar | undefined>;
67
67
  interface IPersistentVarOptionsBase {
68
- scope?: 'device' | 'user' | 'group' | 'groupDevice' | 'groupUser';
68
+ scope?: "device" | "user" | "group" | "groupDevice" | "groupUser";
69
69
  userContext?: UserContext;
70
70
  dataContext?: DataContext;
71
71
  isSecret?: boolean;
@@ -81,30 +81,30 @@ interface IPersistentVarOptionsWithoutDefault<T> extends IPersistentVarOptionsBa
81
81
  /**
82
82
  * A persistent variable that is stored only on this device, in the user's personal db
83
83
  */
84
- export declare function deviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, 'scope' | 'dataContext'>): PersistentVar<T>;
85
- export declare function deviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, 'scope' | 'dataContext'>): PersistentVar<T | undefined>;
84
+ export declare function deviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope" | "dataContext">): PersistentVar<T>;
85
+ export declare function deviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope" | "dataContext">): PersistentVar<T | undefined>;
86
86
  /**
87
87
  * A persistent variable that is stored in the user's personal db and synced across all their devices
88
88
  */
89
- export declare function userVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, 'scope' | 'dataContext'>): PersistentVar<T>;
90
- export declare function userVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, 'scope' | 'dataContext'>): PersistentVar<T | undefined>;
89
+ export declare function userVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope" | "dataContext">): PersistentVar<T>;
90
+ export declare function userVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope" | "dataContext">): PersistentVar<T | undefined>;
91
91
  /**
92
92
  * A persistent variable that is shared by all users in a group. It is stored in the group's db and synced across all users and devices in the group.
93
93
  * It can have a different value for each group on the device.
94
94
  * If secret=true, it is encrypted with the group's secret key
95
95
  */
96
- export declare function groupVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, 'scope'>): PersistentVar<T>;
97
- export declare function groupVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, 'scope'>): PersistentVar<T | undefined>;
96
+ export declare function groupVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
97
+ export declare function groupVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
98
98
  /**
99
99
  * A persistent variable that is stored only on this device, in the user's personal db.
100
100
  * It can have a different value for each group on the device but is not synced to other devices.
101
101
  */
102
- export declare function groupDeviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, 'scope'>): PersistentVar<T>;
103
- export declare function groupDeviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, 'scope'>): PersistentVar<T | undefined>;
102
+ export declare function groupDeviceVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
103
+ export declare function groupDeviceVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
104
104
  /**
105
105
  * A persistent variable that is stored in the user's personal db and synced across all their devices in the group.
106
106
  * It can have a different value for each user in the group and a different value for each group the user is in.
107
107
  */
108
- export declare function groupUserVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, 'scope'>): PersistentVar<T>;
109
- export declare function groupUserVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, 'scope'>): PersistentVar<T | undefined>;
108
+ export declare function groupUserVar<T = string>(name: string, opts: Omit<IPersistentVarOptionsWithDefault<T>, "scope">): PersistentVar<T>;
109
+ export declare function groupUserVar<T = string>(name: string, opts?: Omit<IPersistentVarOptionsWithoutDefault<T>, "scope">): PersistentVar<T | undefined>;
110
110
  export {};