@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
@@ -11,23 +11,23 @@ function fieldsToSchema(fields, codeSchema) {
11
11
  const { name, description, type, isArray, defaultValue, optional } = argSchema;
12
12
  let propertyType;
13
13
  switch (type) {
14
- case 'id':
15
- propertyType = zod_1.z.string().refine((id => (0, utils_1.isid)(id)), { message: 'Invalid id' });
14
+ case "id":
15
+ propertyType = zod_1.z.string().refine((id) => (0, utils_1.isid)(id), { message: "Invalid id" });
16
16
  propertyType._def._fieldType = field_type_1.FieldType.id;
17
17
  break;
18
- case 'string':
18
+ case "string":
19
19
  propertyType = zod_1.z.string();
20
20
  break;
21
- case 'number':
21
+ case "number":
22
22
  propertyType = zod_1.z.number();
23
23
  break;
24
- case 'boolean':
24
+ case "boolean":
25
25
  propertyType = zod_1.z.boolean();
26
26
  break;
27
- case 'Date':
27
+ case "Date":
28
28
  propertyType = zod_1.z.date();
29
29
  break;
30
- case 'object':
30
+ case "object":
31
31
  propertyType = zod_1.z.object({});
32
32
  break;
33
33
  default:
@@ -39,13 +39,13 @@ function fieldsToSchema(fields, codeSchema) {
39
39
  if (optional) {
40
40
  propertyType = propertyType.optional();
41
41
  }
42
- if (defaultValue) {
43
- // @ts-ignore
42
+ if (defaultValue !== undefined) {
44
43
  propertyType = propertyType.default(defaultValue);
45
44
  }
46
- propertyType = propertyType.describe(description);
47
- if (codeSchema?.shape?.[name]) {
48
- propertyType = zod_1.z.intersection(propertyType, codeSchema.shape[name]);
45
+ propertyType = propertyType.describe(description ?? "");
46
+ const shapeField = codeSchema?.shape?.[name];
47
+ if (shapeField) {
48
+ propertyType = zod_1.z.intersection(propertyType, shapeField);
49
49
  }
50
50
  const newProperty = { [name]: propertyType };
51
51
  argsSchema = argsSchema.extend(newProperty);
@@ -58,10 +58,10 @@ function schemaToFields(schema) {
58
58
  const field = schema.shape[name];
59
59
  let type = field_type_1.FieldType.any;
60
60
  let _def = field._def;
61
- let isArray = undefined;
61
+ let isArray;
62
62
  let brandedFieldType;
63
63
  while (true) {
64
- if (_def.typeName === 'ZodArray') {
64
+ if (_def.typeName === "ZodArray") {
65
65
  isArray = true;
66
66
  }
67
67
  if (_def._fieldType) {
@@ -82,39 +82,40 @@ function schemaToFields(schema) {
82
82
  break;
83
83
  }
84
84
  switch (_def.typeName) {
85
- case 'ZodString':
85
+ case "ZodString":
86
86
  type = brandedFieldType || field_type_1.FieldType.string;
87
87
  break;
88
- case 'ZodNumber':
88
+ case "ZodNumber":
89
89
  type = field_type_1.FieldType.number;
90
90
  break;
91
- case 'ZodBoolean':
91
+ case "ZodBoolean":
92
92
  type = field_type_1.FieldType.boolean;
93
93
  break;
94
- case 'ZodDate':
94
+ case "ZodDate":
95
95
  type = field_type_1.FieldType.Date;
96
96
  break;
97
- case 'ZodObject':
97
+ case "ZodObject":
98
98
  type = field_type_1.FieldType.object;
99
99
  break;
100
- case 'ZodNativeEnum':
100
+ case "ZodNativeEnum": {
101
101
  // number or string
102
- const hasNumber = Object.values(_def.values).some(v => typeof v === 'number');
102
+ const hasNumber = Object.values(_def.values).some((v) => typeof v === "number");
103
103
  type = hasNumber ? field_type_1.FieldType.number : field_type_1.FieldType.string;
104
104
  break;
105
+ }
105
106
  default:
106
107
  type = field_type_1.FieldType.any;
107
108
  }
108
- if (!isArray && field._def.typeName === 'ZodArray') {
109
+ if (!isArray && field._def.typeName === "ZodArray") {
109
110
  isArray = true;
110
111
  // isArray = field._def.typeName === 'ZodArray' || undefined;
111
112
  }
112
- const optional = field._def.typeName === 'ZodOptional' || undefined;
113
+ const optional = field._def.typeName === "ZodOptional" || undefined;
113
114
  const description = field._def.description;
114
115
  const defaultValue = field._def.defaultValue;
115
116
  const newField = { name, type, isArray, optional, description, defaultValue };
116
- Object.keys(newField).forEach(k => {
117
- // @ts-ignore
117
+ Object.keys(newField).forEach((k) => {
118
+ // @ts-expect-error
118
119
  if (newField[k] === undefined)
119
120
  delete newField[k];
120
121
  });
@@ -1,38 +1,70 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const zod_1 = require("zod");
4
- const types_1 = require("./types");
5
4
  const field_type_1 = require("../../types/field-type");
6
- const utils_1 = require("../../utils");
7
5
  const zod_types_1 = require("../../types/zod-types");
8
- describe('types', () => {
9
- it('fieldsToSchema', () => {
6
+ const utils_1 = require("../../utils");
7
+ const types_1 = require("./types");
8
+ describe("types", () => {
9
+ it("fieldsToSchema", () => {
10
10
  const someDate = new Date();
11
11
  const groupFields = [
12
- { name: 'groupId', description: 'The id of the group', type: field_type_1.FieldType.id },
13
- { name: 'groupName', description: 'The name of the group', type: field_type_1.FieldType.string },
14
- { name: 'groupDescription', description: 'The description of the group', type: field_type_1.FieldType.string },
15
- { name: 'createdAt', description: 'The date the group was created', type: field_type_1.FieldType.Date, defaultValue: () => someDate },
16
- { name: 'owningUserIds', description: 'The ids of the users who own the group', type: field_type_1.FieldType.string, isArray: true },
17
- { name: 'isPublic', description: 'Whether the group is public or private', type: field_type_1.FieldType.boolean, optional: true },
18
- { name: 'fileIds', description: 'The ids of files attached to this chat entry', type: field_type_1.FieldType.string, isArray: true, optional: true },
12
+ { name: "groupId", description: "The id of the group", type: field_type_1.FieldType.id },
13
+ { name: "groupName", description: "The name of the group", type: field_type_1.FieldType.string },
14
+ {
15
+ name: "groupDescription",
16
+ description: "The description of the group",
17
+ type: field_type_1.FieldType.string,
18
+ },
19
+ {
20
+ name: "createdAt",
21
+ description: "The date the group was created",
22
+ type: field_type_1.FieldType.Date,
23
+ defaultValue: () => someDate,
24
+ },
25
+ {
26
+ name: "owningUserIds",
27
+ description: "The ids of the users who own the group",
28
+ type: field_type_1.FieldType.string,
29
+ isArray: true,
30
+ },
31
+ {
32
+ name: "isPublic",
33
+ description: "Whether the group is public or private",
34
+ type: field_type_1.FieldType.boolean,
35
+ optional: true,
36
+ },
37
+ {
38
+ name: "fileIds",
39
+ description: "The ids of files attached to this chat entry",
40
+ type: field_type_1.FieldType.string,
41
+ isArray: true,
42
+ optional: true,
43
+ },
19
44
  ];
20
45
  const groupSchema = (0, types_1.fieldsToSchema)(groupFields);
21
46
  const groupSchemaExpected = zod_1.z.object({
22
- groupId: zod_1.z.string().describe('The id of the group'),
23
- groupName: zod_1.z.string().describe('The name of the group'),
24
- groupDescription: zod_1.z.string().describe('The description of the group'),
25
- createdAt: zod_1.z.date().describe('The date the group was created').default(() => someDate),
26
- owningUserIds: zod_1.z.string().array().describe('The ids of the users who own the group'),
27
- isPublic: zod_1.z.boolean().optional().describe('Whether the group is public or private'),
28
- fileIds: zod_1.z.string().array().optional().describe('The ids of files attached to this chat entry'),
47
+ groupId: zod_1.z.string().describe("The id of the group"),
48
+ groupName: zod_1.z.string().describe("The name of the group"),
49
+ groupDescription: zod_1.z.string().describe("The description of the group"),
50
+ createdAt: zod_1.z
51
+ .date()
52
+ .describe("The date the group was created")
53
+ .default(() => someDate),
54
+ owningUserIds: zod_1.z.string().array().describe("The ids of the users who own the group"),
55
+ isPublic: zod_1.z.boolean().optional().describe("Whether the group is public or private"),
56
+ fileIds: zod_1.z
57
+ .string()
58
+ .array()
59
+ .optional()
60
+ .describe("The ids of files attached to this chat entry"),
29
61
  });
30
62
  const aGroup = {
31
63
  groupId: (0, utils_1.newid)(),
32
- groupName: 'group',
33
- groupDescription: 'group description',
64
+ groupName: "group",
65
+ groupDescription: "group description",
34
66
  createdAt: new Date(),
35
- owningUserIds: ['1'],
67
+ owningUserIds: ["1"],
36
68
  isPublic: true,
37
69
  };
38
70
  const aGroup2 = { ...aGroup, createdAt: undefined };
@@ -42,104 +74,143 @@ describe('types', () => {
42
74
  expect(r1e.createdAt).toEqual(someDate);
43
75
  // @ts-expect-error
44
76
  delete aGroup.groupId;
45
- expect(() => groupSchema.parse(aGroup)).toThrow('groupId');
46
- expect(() => groupSchemaExpected.parse(aGroup)).toThrow('groupId');
77
+ expect(() => groupSchema.parse(aGroup)).toThrow("groupId");
78
+ expect(() => groupSchemaExpected.parse(aGroup)).toThrow("groupId");
47
79
  });
48
- it('schemaToFields', () => {
80
+ it("schemaToFields", () => {
49
81
  const groupSchema = zod_1.z.object({
50
- groupId: zod_1.z.string().describe('The id of the group'),
51
- groupName: zod_1.z.string().describe('The name of the group'),
52
- groupDescription: zod_1.z.string().describe('The description of the group'),
53
- createdAt: zod_1.z.date().describe('The date the group was created'), //.default(() => new Date()),
54
- owningUserIds: zod_1.z.string().array().describe('The ids of the users who own the group'),
55
- isPublic: zod_1.z.boolean().optional().describe('Whether the group is public or private'),
56
- instructionResults: zod_1.z.any().array().describe('The results of the instructions that have been run.'),
57
- fileIds: zod_1.z.string().array().optional().describe('The ids of files attached to this chat entry'),
82
+ groupId: zod_1.z.string().describe("The id of the group"),
83
+ groupName: zod_1.z.string().describe("The name of the group"),
84
+ groupDescription: zod_1.z.string().describe("The description of the group"),
85
+ createdAt: zod_1.z.date().describe("The date the group was created"), //.default(() => new Date()),
86
+ owningUserIds: zod_1.z.string().array().describe("The ids of the users who own the group"),
87
+ isPublic: zod_1.z.boolean().optional().describe("Whether the group is public or private"),
88
+ instructionResults: zod_1.z
89
+ .any()
90
+ .array()
91
+ .describe("The results of the instructions that have been run."),
92
+ fileIds: zod_1.z
93
+ .string()
94
+ .array()
95
+ .optional()
96
+ .describe("The ids of files attached to this chat entry"),
58
97
  });
59
98
  const groupFields = (0, types_1.schemaToFields)(groupSchema);
60
99
  const groupFieldsExpected = [
61
- { name: 'groupId', description: 'The id of the group', type: field_type_1.FieldType.string },
62
- { name: 'groupName', description: 'The name of the group', type: field_type_1.FieldType.string },
63
- { name: 'groupDescription', description: 'The description of the group', type: field_type_1.FieldType.string },
64
- { name: 'createdAt', description: 'The date the group was created', type: field_type_1.FieldType.Date, }, //defaultValue: () => new Date() },
65
- { name: 'owningUserIds', description: 'The ids of the users who own the group', type: field_type_1.FieldType.string, isArray: true },
66
- { name: 'isPublic', description: 'Whether the group is public or private', type: field_type_1.FieldType.boolean, optional: true },
67
- { name: 'instructionResults', description: 'The results of the instructions that have been run.', type: field_type_1.FieldType.any, isArray: true },
68
- { name: 'fileIds', description: 'The ids of files attached to this chat entry', type: field_type_1.FieldType.string, isArray: true, optional: true },
100
+ { name: "groupId", description: "The id of the group", type: field_type_1.FieldType.string },
101
+ { name: "groupName", description: "The name of the group", type: field_type_1.FieldType.string },
102
+ {
103
+ name: "groupDescription",
104
+ description: "The description of the group",
105
+ type: field_type_1.FieldType.string,
106
+ },
107
+ { name: "createdAt", description: "The date the group was created", type: field_type_1.FieldType.Date }, //defaultValue: () => new Date() },
108
+ {
109
+ name: "owningUserIds",
110
+ description: "The ids of the users who own the group",
111
+ type: field_type_1.FieldType.string,
112
+ isArray: true,
113
+ },
114
+ {
115
+ name: "isPublic",
116
+ description: "Whether the group is public or private",
117
+ type: field_type_1.FieldType.boolean,
118
+ optional: true,
119
+ },
120
+ {
121
+ name: "instructionResults",
122
+ description: "The results of the instructions that have been run.",
123
+ type: field_type_1.FieldType.any,
124
+ isArray: true,
125
+ },
126
+ {
127
+ name: "fileIds",
128
+ description: "The ids of files attached to this chat entry",
129
+ type: field_type_1.FieldType.string,
130
+ isArray: true,
131
+ optional: true,
132
+ },
69
133
  ];
70
134
  expect(groupFields).toEqual(groupFieldsExpected);
71
135
  });
72
- it('schemaToFields should detect zodPeerId as FieldType.id', () => {
136
+ it("schemaToFields should detect zodPeerId as FieldType.id", () => {
73
137
  const schema = zod_1.z.object({
74
- recordId: zod_types_1.zodPeerId.describe('A peer id field'),
75
- optionalRef: zod_types_1.zodPeerId.optional().describe('An optional peer id'),
138
+ recordId: zod_types_1.zodPeerId.describe("A peer id field"),
139
+ optionalRef: zod_types_1.zodPeerId.optional().describe("An optional peer id"),
76
140
  });
77
141
  const fields = (0, types_1.schemaToFields)(schema);
78
- expect(fields.find(f => f.name === 'recordId').type).toBe(field_type_1.FieldType.id);
79
- expect(fields.find(f => f.name === 'optionalRef').type).toBe(field_type_1.FieldType.id);
142
+ expect(fields.find((f) => f.name === "recordId")?.type).toBe(field_type_1.FieldType.id);
143
+ expect(fields.find((f) => f.name === "optionalRef")?.type).toBe(field_type_1.FieldType.id);
80
144
  });
81
- it('schemaToFields should NOT classify plain z.string() as id just because name ends in Id', () => {
145
+ it("schemaToFields should NOT classify plain z.string() as id just because name ends in Id", () => {
82
146
  const schema = zod_1.z.object({
83
- externalId: zod_1.z.string().describe('An external system identifier'),
84
- channelId: zod_1.z.string().describe('A channel reference'),
85
- name: zod_1.z.string().describe('A plain string'),
147
+ externalId: zod_1.z.string().describe("An external system identifier"),
148
+ channelId: zod_1.z.string().describe("A channel reference"),
149
+ name: zod_1.z.string().describe("A plain string"),
86
150
  });
87
151
  const fields = (0, types_1.schemaToFields)(schema);
88
- expect(fields.find(f => f.name === 'externalId').type).toBe(field_type_1.FieldType.string);
89
- expect(fields.find(f => f.name === 'channelId').type).toBe(field_type_1.FieldType.string);
90
- expect(fields.find(f => f.name === 'name').type).toBe(field_type_1.FieldType.string);
152
+ expect(fields.find((f) => f.name === "externalId")?.type).toBe(field_type_1.FieldType.string);
153
+ expect(fields.find((f) => f.name === "channelId")?.type).toBe(field_type_1.FieldType.string);
154
+ expect(fields.find((f) => f.name === "name")?.type).toBe(field_type_1.FieldType.string);
91
155
  });
92
- it('schemaToFields should NOT classify a non-id string refinement as FieldType.id', () => {
93
- const zodEmail = zod_1.z.string().refine(val => val.includes('@'), { message: 'Must be an email' });
94
- const zodNonEmpty = zod_1.z.string().refine(val => val.length > 0, { message: 'Must not be empty' });
156
+ it("schemaToFields should NOT classify a non-id string refinement as FieldType.id", () => {
157
+ const zodEmail = zod_1.z.string().refine((val) => val.includes("@"), { message: "Must be an email" });
158
+ const zodNonEmpty = zod_1.z
159
+ .string()
160
+ .refine((val) => val.length > 0, { message: "Must not be empty" });
95
161
  const schema = zod_1.z.object({
96
- email: zodEmail.describe('An email address'),
97
- requiredField: zodNonEmpty.describe('A non-empty string'),
98
- peerId: zod_types_1.zodPeerId.describe('A real peer id'),
162
+ email: zodEmail.describe("An email address"),
163
+ requiredField: zodNonEmpty.describe("A non-empty string"),
164
+ peerId: zod_types_1.zodPeerId.describe("A real peer id"),
99
165
  });
100
166
  const fields = (0, types_1.schemaToFields)(schema);
101
- expect(fields.find(f => f.name === 'email').type).toBe(field_type_1.FieldType.string);
102
- expect(fields.find(f => f.name === 'requiredField').type).toBe(field_type_1.FieldType.string);
103
- expect(fields.find(f => f.name === 'peerId').type).toBe(field_type_1.FieldType.id);
167
+ expect(fields.find((f) => f.name === "email")?.type).toBe(field_type_1.FieldType.string);
168
+ expect(fields.find((f) => f.name === "requiredField")?.type).toBe(field_type_1.FieldType.string);
169
+ expect(fields.find((f) => f.name === "peerId")?.type).toBe(field_type_1.FieldType.id);
104
170
  });
105
- it('fieldsToSchema should merge with optional code schema for most-constrained validation', () => {
171
+ it("fieldsToSchema should merge with optional code schema for most-constrained validation", () => {
106
172
  const codeSchema = zod_1.z.object({
107
- recordId: zod_types_1.zodPeerId.describe('A peer id'),
108
- label: zod_1.z.string().min(1).describe('Non-empty label'),
173
+ recordId: zod_types_1.zodPeerId.describe("A peer id"),
174
+ label: zod_1.z.string().min(1).describe("Non-empty label"),
109
175
  });
110
176
  const fields = [
111
- { name: 'recordId', description: 'A peer id', type: field_type_1.FieldType.string },
112
- { name: 'label', description: 'Non-empty label', type: field_type_1.FieldType.string },
177
+ { name: "recordId", description: "A peer id", type: field_type_1.FieldType.string },
178
+ { name: "label", description: "Non-empty label", type: field_type_1.FieldType.string },
113
179
  ];
114
180
  const mergedSchema = (0, types_1.fieldsToSchema)(fields, codeSchema);
115
181
  const validId = (0, utils_1.newid)();
116
182
  // Valid peer id should pass the merged schema
117
- expect(() => mergedSchema.parse({ recordId: validId, label: 'hello' })).not.toThrow();
183
+ expect(() => mergedSchema.parse({ recordId: validId, label: "hello" })).not.toThrow();
118
184
  // Empty string should fail: the code schema's zodPeerId rejects it
119
- expect(() => mergedSchema.parse({ recordId: '', label: 'hello' })).toThrow();
185
+ expect(() => mergedSchema.parse({ recordId: "", label: "hello" })).toThrow();
120
186
  // Empty label should fail: the code schema's .min(1) rejects it
121
- expect(() => mergedSchema.parse({ recordId: validId, label: '' })).toThrow();
187
+ expect(() => mergedSchema.parse({ recordId: validId, label: "" })).toThrow();
122
188
  });
123
- it('round-trip: fieldsToSchema id fields should survive schemaToFields detection', () => {
189
+ it("round-trip: fieldsToSchema id fields should survive schemaToFields detection", () => {
124
190
  // fieldsToSchema creates z.string().refine(isid) for FieldType.id fields.
125
191
  // schemaToFields should detect that refinement as FieldType.id so round-trips are consistent.
126
192
  const fields = [
127
- { name: 'recordId', description: 'A peer id', type: field_type_1.FieldType.id },
128
- { name: 'label', description: 'A label', type: field_type_1.FieldType.string },
193
+ { name: "recordId", description: "A peer id", type: field_type_1.FieldType.id },
194
+ { name: "label", description: "A label", type: field_type_1.FieldType.string },
129
195
  ];
130
196
  const schema = (0, types_1.fieldsToSchema)(fields);
131
197
  const roundTrippedFields = (0, types_1.schemaToFields)(schema);
132
- expect(roundTrippedFields.find(f => f.name === 'recordId').type).toBe(field_type_1.FieldType.id);
133
- expect(roundTrippedFields.find(f => f.name === 'label').type).toBe(field_type_1.FieldType.string);
198
+ expect(roundTrippedFields.find((f) => f.name === "recordId")?.type).toBe(field_type_1.FieldType.id);
199
+ expect(roundTrippedFields.find((f) => f.name === "label")?.type).toBe(field_type_1.FieldType.string);
134
200
  });
135
- it('fieldsToSchema merge should handle optional zodPeerId fields correctly', () => {
201
+ it("fieldsToSchema merge should handle optional zodPeerId fields correctly", () => {
136
202
  const codeSchema = zod_1.z.object({
137
- ownerId: zod_types_1.zodPeerId.describe('The owner'),
138
- referrerId: zod_types_1.zodPeerId.optional().describe('Optional referrer'),
203
+ ownerId: zod_types_1.zodPeerId.describe("The owner"),
204
+ referrerId: zod_types_1.zodPeerId.optional().describe("Optional referrer"),
139
205
  });
140
206
  const fields = [
141
- { name: 'ownerId', description: 'The owner', type: field_type_1.FieldType.string },
142
- { name: 'referrerId', description: 'Optional referrer', type: field_type_1.FieldType.string, optional: true },
207
+ { name: "ownerId", description: "The owner", type: field_type_1.FieldType.string },
208
+ {
209
+ name: "referrerId",
210
+ description: "Optional referrer",
211
+ type: field_type_1.FieldType.string,
212
+ optional: true,
213
+ },
143
214
  ];
144
215
  const mergedSchema = (0, types_1.fieldsToSchema)(fields, codeSchema);
145
216
  const validId = (0, utils_1.newid)();
@@ -149,18 +220,21 @@ describe('types', () => {
149
220
  // Optional field omitted
150
221
  expect(() => mergedSchema.parse({ ownerId: validId })).not.toThrow();
151
222
  // Optional field present but invalid
152
- expect(() => mergedSchema.parse({ ownerId: validId, referrerId: 'not-a-valid-id' })).toThrow();
223
+ expect(() => mergedSchema.parse({ ownerId: validId, referrerId: "not-a-valid-id" })).toThrow();
153
224
  // Required field missing
154
225
  expect(() => mergedSchema.parse({ referrerId: validId })).toThrow();
155
226
  // Required field invalid
156
- expect(() => mergedSchema.parse({ ownerId: 'bad', referrerId: validId })).toThrow();
227
+ expect(() => mergedSchema.parse({ ownerId: "bad", referrerId: validId })).toThrow();
157
228
  });
158
- it('initRecord pattern: code schema defaults should work even after JSON round-trip of fields', () => {
229
+ it("initRecord pattern: code schema defaults should work even after JSON round-trip of fields", () => {
159
230
  const codeSchema = zod_1.z.object({
160
- recordId: zod_types_1.zodPeerId.describe('A peer id'),
161
- label: zod_1.z.string().default('untitled').describe('A label with default'),
162
- createdAt: zod_1.z.date().default(() => new Date()).describe('Date with factory default'),
163
- count: zod_1.z.number().default(0).describe('A count with default'),
231
+ recordId: zod_types_1.zodPeerId.describe("A peer id"),
232
+ label: zod_1.z.string().default("untitled").describe("A label with default"),
233
+ createdAt: zod_1.z
234
+ .date()
235
+ .default(() => new Date())
236
+ .describe("Date with factory default"),
237
+ count: zod_1.z.number().default(0).describe("A count with default"),
164
238
  });
165
239
  // Simulate the real flow: code schema -> fields -> JSON (sync) -> parse back
166
240
  const fields = (0, types_1.schemaToFields)(codeSchema);
@@ -188,19 +262,19 @@ describe('types', () => {
188
262
  }
189
263
  }
190
264
  const result = { ...defaults, ...data };
191
- expect(result.label).toBe('untitled');
265
+ expect(result.label).toBe("untitled");
192
266
  expect(result.createdAt).toBeInstanceOf(Date);
193
267
  expect(result.count).toBe(0);
194
268
  expect(result.recordId).toBe(validId);
195
269
  });
196
- it('fieldsToSchema without code schema should work as before', () => {
270
+ it("fieldsToSchema without code schema should work as before", () => {
197
271
  const fields = [
198
- { name: 'recordId', description: 'A peer id', type: field_type_1.FieldType.id },
199
- { name: 'label', description: 'A label', type: field_type_1.FieldType.string },
272
+ { name: "recordId", description: "A peer id", type: field_type_1.FieldType.id },
273
+ { name: "label", description: "A label", type: field_type_1.FieldType.string },
200
274
  ];
201
275
  const schema = (0, types_1.fieldsToSchema)(fields);
202
276
  const validId = (0, utils_1.newid)();
203
- expect(() => schema.parse({ recordId: validId, label: 'hello' })).not.toThrow();
204
- expect(() => schema.parse({ recordId: '', label: 'hello' })).toThrow();
277
+ expect(() => schema.parse({ recordId: validId, label: "hello" })).not.toThrow();
278
+ expect(() => schema.parse({ recordId: "", label: "hello" })).toThrow();
205
279
  });
206
280
  });
@@ -1,4 +1,4 @@
1
- import type { IPackage } from './packages';
1
+ import type { IPackage } from "./packages";
2
2
  /**
3
3
  * Verifies that a package update signature is valid, throws on invalid signature
4
4
  * @param packageObj The package record to verify
@@ -10,9 +10,9 @@ const group_permissions_1 = require("./group-permissions");
10
10
  */
11
11
  async function verifyPackageSignature(packageObj, groupId) {
12
12
  (0, keys_1.verifyObjectSignature)(packageObj);
13
- const signerPublicKey = (0, keys_1.getPublicKeyFromObjectSignature)(packageObj) ?? '';
13
+ const signerPublicKey = (0, keys_1.getPublicKeyFromObjectSignature)(packageObj) ?? "";
14
14
  const signerRole = await (0, group_permissions_1.getUserRoleFromPublicKey)(groupId, signerPublicKey);
15
15
  if (signerRole < group_permissions_1.GroupMemberRole.Admin) {
16
- throw new Error('Only group admins can create or update packages');
16
+ throw new Error("Only group admins can create or update packages");
17
17
  }
18
18
  }
@@ -1,4 +1,4 @@
1
- import type { IPackageVersion } from './package-versions';
1
+ import type { IPackageVersion } from "./package-versions";
2
2
  /**
3
3
  * Verifies that a package version update signature is valid, throws on invalid signature
4
4
  * @param packageVersion The package version record to verify
@@ -10,9 +10,9 @@ const group_permissions_1 = require("./group-permissions");
10
10
  */
11
11
  async function verifyPackageVersionSignature(packageVersion, groupId) {
12
12
  (0, keys_1.verifyObjectSignature)(packageVersion);
13
- const signerPublicKey = (0, keys_1.getPublicKeyFromObjectSignature)(packageVersion) ?? '';
13
+ const signerPublicKey = (0, keys_1.getPublicKeyFromObjectSignature)(packageVersion) ?? "";
14
14
  const signerRole = await (0, group_permissions_1.getUserRoleFromPublicKey)(groupId, signerPublicKey);
15
15
  if (signerRole < group_permissions_1.GroupMemberRole.Admin) {
16
- throw new Error('Only group admins can create or update package versions');
16
+ throw new Error("Only group admins can create or update package versions");
17
17
  }
18
18
  }
@@ -34,15 +34,15 @@ declare const schema: z.ZodObject<{
34
34
  createdBy: z.ZodEffects<z.ZodString, string, string>;
35
35
  createdAt: z.ZodString;
36
36
  }, "strip", z.ZodTypeAny, {
37
+ version: string;
37
38
  signature: string;
38
- createdBy: string;
39
- createdAt: string;
40
- packageId: string;
41
39
  packageVersionId: string;
42
- version: string;
40
+ packageId: string;
43
41
  packageVersionHash: string;
44
42
  packageBundleFileId: string;
45
43
  packageBundleFileHash: string;
44
+ createdBy: string;
45
+ createdAt: string;
46
46
  versionTag?: string | undefined;
47
47
  routesBundleFileId?: string | undefined;
48
48
  routesBundleFileHash?: string | undefined;
@@ -55,15 +55,15 @@ declare const schema: z.ZodObject<{
55
55
  displayName?: string | undefined;
56
56
  }[] | undefined;
57
57
  }, {
58
+ version: string;
58
59
  signature: string;
59
- createdBy: string;
60
- createdAt: string;
61
- packageId: string;
62
60
  packageVersionId: string;
63
- version: string;
61
+ packageId: string;
64
62
  packageVersionHash: string;
65
63
  packageBundleFileId: string;
66
64
  packageBundleFileHash: string;
65
+ createdBy: string;
66
+ createdAt: string;
67
67
  versionTag?: string | undefined;
68
68
  routesBundleFileId?: string | undefined;
69
69
  routesBundleFileHash?: string | undefined;
@@ -91,7 +91,7 @@ export declare function PackageVersions(dataContext?: DataContext): PackageVersi
91
91
  * Compute a hash combining the bundle file hashes to uniquely identify this version's content.
92
92
  */
93
93
  export declare function computePackageVersionHash(version: string, versionTag: string, packageBundleFileHash: string, routesBundleFileHash?: string, uiBundleFileHash?: string): string;
94
- export declare function isVersionInRange(activeVersion: string, incomingVersion: string, range: 'pinned' | 'patch' | 'minor' | 'latest'): boolean;
94
+ export declare function isVersionInRange(activeVersion: string, incomingVersion: string, range: "pinned" | "patch" | "minor" | "latest"): boolean;
95
95
  /**
96
96
  * Returns true if incomingVersion is strictly newer than activeVersion (semver comparison).
97
97
  */