@stndrds/schema 0.1.0-alpha.14

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 (128) hide show
  1. package/dist/chunk-3ABIOLKO.mjs +4624 -0
  2. package/dist/chunk-3IRX2BDY.mjs +3970 -0
  3. package/dist/chunk-4OTLPWSP.mjs +4448 -0
  4. package/dist/chunk-54ODQBUN.mjs +3867 -0
  5. package/dist/chunk-6HIA3FR2.mjs +4230 -0
  6. package/dist/chunk-6P3XHNLD.mjs +4171 -0
  7. package/dist/chunk-7LJECNAS.mjs +4167 -0
  8. package/dist/chunk-A2WNLUKV.mjs +4475 -0
  9. package/dist/chunk-AA3234RM.mjs +4475 -0
  10. package/dist/chunk-ADNXDLLD.mjs +3136 -0
  11. package/dist/chunk-B4DCDQUI.mjs +4695 -0
  12. package/dist/chunk-B4PSXY6I.mjs +4527 -0
  13. package/dist/chunk-BJHJBZCM.mjs +4228 -0
  14. package/dist/chunk-C3ZWTO6G.mjs +4474 -0
  15. package/dist/chunk-CLOGNKDD.mjs +4040 -0
  16. package/dist/chunk-EW4V63PA.mjs +3053 -0
  17. package/dist/chunk-FR2LCO6R.mjs +2485 -0
  18. package/dist/chunk-GJSF2RKL.mjs +2786 -0
  19. package/dist/chunk-GO5NPP2X.mjs +4726 -0
  20. package/dist/chunk-H3ZYJUDS.mjs +3050 -0
  21. package/dist/chunk-IDDLSFSK.mjs +4230 -0
  22. package/dist/chunk-JRADUJQ7.mjs +4726 -0
  23. package/dist/chunk-NEDR6N7R.mjs +3118 -0
  24. package/dist/chunk-NESPRMDF.mjs +2482 -0
  25. package/dist/chunk-NWFGRJBW.mjs +4612 -0
  26. package/dist/chunk-NXJ57GSN.mjs +2918 -0
  27. package/dist/chunk-O4C5FCTS.mjs +3961 -0
  28. package/dist/chunk-O4PRB27Q.mjs +2513 -0
  29. package/dist/chunk-OJDFNUCR.mjs +4463 -0
  30. package/dist/chunk-OSEKVBHC.mjs +4627 -0
  31. package/dist/chunk-QX4U6U6K.mjs +2484 -0
  32. package/dist/chunk-RMDQ6LKV.mjs +3046 -0
  33. package/dist/chunk-SBXKDATH.mjs +2673 -0
  34. package/dist/chunk-SKMP3AP3.mjs +2918 -0
  35. package/dist/chunk-STMS7WZD.mjs +2623 -0
  36. package/dist/chunk-T3T6PTFG.mjs +3057 -0
  37. package/dist/chunk-TPW72RAH.mjs +4624 -0
  38. package/dist/chunk-TUQEGNGV.mjs +2534 -0
  39. package/dist/chunk-TVKFS3YN.mjs +2449 -0
  40. package/dist/chunk-TZTH3BHG.mjs +3110 -0
  41. package/dist/chunk-W6MU3XPG.mjs +4612 -0
  42. package/dist/chunk-WL7Z3YFR.mjs +4603 -0
  43. package/dist/chunk-XNVVYHH3.mjs +4602 -0
  44. package/dist/chunk-XTA3WY64.mjs +2918 -0
  45. package/dist/chunk-YV7DEZFZ.mjs +2528 -0
  46. package/dist/chunk-ZLJPJND6.mjs +4474 -0
  47. package/dist/chunk-ZNZXTCEX.mjs +4234 -0
  48. package/dist/index.d.mts +1222 -0
  49. package/dist/index.d.ts +1222 -0
  50. package/dist/index.js +5320 -0
  51. package/dist/index.mjs +635 -0
  52. package/dist/runtime-2iKarXtl.d.mts +1924 -0
  53. package/dist/runtime-2iKarXtl.d.ts +1924 -0
  54. package/dist/runtime-4l2ddHZ7.d.mts +2242 -0
  55. package/dist/runtime-4l2ddHZ7.d.ts +2243 -0
  56. package/dist/runtime-8hKS6zAv.d.mts +2226 -0
  57. package/dist/runtime-8hKS6zAv.d.ts +2226 -0
  58. package/dist/runtime-B6yjtoR3.d.mts +4142 -0
  59. package/dist/runtime-B6yjtoR3.d.ts +4142 -0
  60. package/dist/runtime-BGCShrZB.d.mts +2001 -0
  61. package/dist/runtime-BGCShrZB.d.ts +2001 -0
  62. package/dist/runtime-BRW4NGAk.d.mts +1668 -0
  63. package/dist/runtime-BRW4NGAk.d.ts +1668 -0
  64. package/dist/runtime-BnfBr314.d.mts +1683 -0
  65. package/dist/runtime-BnfBr314.d.ts +1683 -0
  66. package/dist/runtime-BrqhiJUF.d.mts +4151 -0
  67. package/dist/runtime-BrqhiJUF.d.ts +4151 -0
  68. package/dist/runtime-Bvj8c-BE.d.mts +4277 -0
  69. package/dist/runtime-Bvj8c-BE.d.ts +4277 -0
  70. package/dist/runtime-C03qT4qU.d.mts +4267 -0
  71. package/dist/runtime-C03qT4qU.d.ts +4267 -0
  72. package/dist/runtime-CaCZ7mSf.d.mts +2974 -0
  73. package/dist/runtime-CaCZ7mSf.d.ts +2974 -0
  74. package/dist/runtime-CaIzNX0Z.d.mts +4091 -0
  75. package/dist/runtime-CaIzNX0Z.d.ts +4091 -0
  76. package/dist/runtime-ChPTgmLP.d.mts +4320 -0
  77. package/dist/runtime-ChPTgmLP.d.ts +4320 -0
  78. package/dist/runtime-CnImZ1Vv.d.mts +4267 -0
  79. package/dist/runtime-CnImZ1Vv.d.ts +4267 -0
  80. package/dist/runtime-Cp-B26Nj.d.mts +2890 -0
  81. package/dist/runtime-Cp-B26Nj.d.ts +2890 -0
  82. package/dist/runtime-Cq8jfk3c.d.mts +4277 -0
  83. package/dist/runtime-Cq8jfk3c.d.ts +4277 -0
  84. package/dist/runtime-CqDFXhhP.d.mts +1685 -0
  85. package/dist/runtime-CqDFXhhP.d.ts +1685 -0
  86. package/dist/runtime-CqtpZLdL.d.mts +4280 -0
  87. package/dist/runtime-CqtpZLdL.d.ts +4280 -0
  88. package/dist/runtime-D-4DblaZ.d.mts +4147 -0
  89. package/dist/runtime-D-4DblaZ.d.ts +4147 -0
  90. package/dist/runtime-D59sSqNl.d.mts +4146 -0
  91. package/dist/runtime-D59sSqNl.d.ts +4146 -0
  92. package/dist/runtime-DEfPk3wT.d.mts +1840 -0
  93. package/dist/runtime-DEfPk3wT.d.ts +1840 -0
  94. package/dist/runtime-DGV-7vES.d.mts +1685 -0
  95. package/dist/runtime-DGV-7vES.d.ts +1685 -0
  96. package/dist/runtime-DNacghqc.d.mts +3971 -0
  97. package/dist/runtime-DNacghqc.d.ts +3971 -0
  98. package/dist/runtime-DPLsUHYK.d.mts +3977 -0
  99. package/dist/runtime-DPLsUHYK.d.ts +3977 -0
  100. package/dist/runtime-DTxCw60F.d.mts +2973 -0
  101. package/dist/runtime-DTxCw60F.d.ts +2973 -0
  102. package/dist/runtime-DUXJ-zNS.d.mts +2788 -0
  103. package/dist/runtime-DUXJ-zNS.d.ts +2788 -0
  104. package/dist/runtime-DbljInhV.d.mts +2237 -0
  105. package/dist/runtime-DbljInhV.d.ts +2237 -0
  106. package/dist/runtime-DcH3y6Yu.d.mts +4272 -0
  107. package/dist/runtime-DcH3y6Yu.d.ts +4272 -0
  108. package/dist/runtime-DdBFz85g.d.mts +4229 -0
  109. package/dist/runtime-DdBFz85g.d.ts +4229 -0
  110. package/dist/runtime-DjMWhjkm.d.mts +4321 -0
  111. package/dist/runtime-DjMWhjkm.d.ts +4321 -0
  112. package/dist/runtime-Djz3fOBE.d.mts +2078 -0
  113. package/dist/runtime-Djz3fOBE.d.ts +2078 -0
  114. package/dist/runtime-Dli8g3Aq.d.mts +2082 -0
  115. package/dist/runtime-Dli8g3Aq.d.ts +2082 -0
  116. package/dist/runtime-a8J378im.d.mts +4123 -0
  117. package/dist/runtime-a8J378im.d.ts +4123 -0
  118. package/dist/runtime-dp3rb3Lf.d.mts +2968 -0
  119. package/dist/runtime-dp3rb3Lf.d.ts +2968 -0
  120. package/dist/runtime-iWXlSN_H.d.mts +1683 -0
  121. package/dist/runtime-iWXlSN_H.d.ts +1683 -0
  122. package/dist/runtime-yMql0npY.d.mts +4321 -0
  123. package/dist/runtime-yMql0npY.d.ts +4321 -0
  124. package/dist/runtime.d.mts +3 -0
  125. package/dist/runtime.d.ts +3 -0
  126. package/dist/runtime.js +3626 -0
  127. package/dist/runtime.mjs +48 -0
  128. package/package.json +58 -0
@@ -0,0 +1,2513 @@
1
+ // src/utils.ts
2
+ function generateId() {
3
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
4
+ return crypto.randomUUID();
5
+ }
6
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
7
+ const r = Math.random() * 16 | 0;
8
+ const v = c === "x" ? r : r & 3 | 8;
9
+ return v.toString(16);
10
+ });
11
+ }
12
+ function generatePrefixedId(prefix) {
13
+ return `${prefix}_${generateId()}`;
14
+ }
15
+
16
+ // src/runtime/mock-adapter.ts
17
+ function createMockObjectsRepository(stores) {
18
+ return {
19
+ findById(id) {
20
+ return Promise.resolve(stores.objects.get(id) ?? null);
21
+ },
22
+ findByName(tenantId, name) {
23
+ for (const obj of stores.objects.values()) {
24
+ if (obj.tenantId === tenantId && obj.name === name) {
25
+ return Promise.resolve(obj);
26
+ }
27
+ }
28
+ return Promise.resolve(null);
29
+ },
30
+ findSystemByName(name) {
31
+ for (const obj of stores.objects.values()) {
32
+ if (obj.system && obj.name === name) {
33
+ return Promise.resolve(obj);
34
+ }
35
+ }
36
+ return Promise.resolve(null);
37
+ },
38
+ create(data) {
39
+ const obj = {
40
+ id: generateId(),
41
+ tenantId: data.tenantId,
42
+ name: data.name,
43
+ label: data.label,
44
+ description: data.description,
45
+ system: data.system ?? false,
46
+ metadata: data.metadata,
47
+ createdAt: /* @__PURE__ */ new Date(),
48
+ updatedAt: /* @__PURE__ */ new Date()
49
+ };
50
+ stores.objects.set(obj.id, obj);
51
+ return Promise.resolve(obj);
52
+ },
53
+ update(id, data) {
54
+ const existing = stores.objects.get(id);
55
+ if (!existing) {
56
+ return Promise.reject(new Error(`Object ${id} not found`));
57
+ }
58
+ const updated = {
59
+ ...existing,
60
+ ...data,
61
+ updatedAt: /* @__PURE__ */ new Date()
62
+ };
63
+ stores.objects.set(id, updated);
64
+ return Promise.resolve(updated);
65
+ },
66
+ delete(id) {
67
+ stores.objects.delete(id);
68
+ return Promise.resolve();
69
+ },
70
+ list(tenantId) {
71
+ const results = Array.from(stores.objects.values()).filter(
72
+ (obj) => obj.tenantId === tenantId
73
+ );
74
+ return Promise.resolve(results);
75
+ },
76
+ upsert(data) {
77
+ for (const obj of stores.objects.values()) {
78
+ if (obj.system && obj.name === data.name) {
79
+ const updated = {
80
+ ...obj,
81
+ label: data.label,
82
+ description: data.description,
83
+ metadata: data.metadata,
84
+ updatedAt: /* @__PURE__ */ new Date()
85
+ };
86
+ stores.objects.set(obj.id, updated);
87
+ return Promise.resolve(updated);
88
+ }
89
+ }
90
+ const newObj = {
91
+ id: generateId(),
92
+ tenantId: data.tenantId,
93
+ name: data.name,
94
+ label: data.label,
95
+ description: data.description,
96
+ system: data.system,
97
+ metadata: data.metadata,
98
+ createdAt: /* @__PURE__ */ new Date(),
99
+ updatedAt: /* @__PURE__ */ new Date()
100
+ };
101
+ stores.objects.set(newObj.id, newObj);
102
+ return Promise.resolve(newObj);
103
+ }
104
+ };
105
+ }
106
+ function createMockAttributesRepository(stores) {
107
+ return {
108
+ findById(id) {
109
+ return Promise.resolve(stores.attributes.get(id) ?? null);
110
+ },
111
+ findByObjectId(objectId) {
112
+ const results = Array.from(stores.attributes.values()).filter(
113
+ (attr) => attr.objectId === objectId
114
+ );
115
+ return Promise.resolve(results);
116
+ },
117
+ create(data) {
118
+ const attr = {
119
+ id: generateId(),
120
+ objectId: data.objectId,
121
+ name: data.name,
122
+ label: data.label,
123
+ type: data.type,
124
+ system: data.system ?? false,
125
+ required: data.required ?? false,
126
+ unique: data.unique ?? false,
127
+ orderIndex: data.orderIndex ?? 0,
128
+ config: data.config ?? {},
129
+ createdAt: /* @__PURE__ */ new Date(),
130
+ updatedAt: /* @__PURE__ */ new Date()
131
+ };
132
+ stores.attributes.set(attr.id, attr);
133
+ return Promise.resolve(attr);
134
+ },
135
+ update(id, data) {
136
+ const existing = stores.attributes.get(id);
137
+ if (!existing) {
138
+ return Promise.reject(new Error(`Attribute ${id} not found`));
139
+ }
140
+ const updated = {
141
+ ...existing,
142
+ ...data,
143
+ updatedAt: /* @__PURE__ */ new Date()
144
+ };
145
+ stores.attributes.set(id, updated);
146
+ return Promise.resolve(updated);
147
+ },
148
+ delete(id) {
149
+ stores.attributes.delete(id);
150
+ return Promise.resolve();
151
+ },
152
+ deleteByNames(objectId, excludeNames) {
153
+ let count = 0;
154
+ for (const [id, attr] of stores.attributes.entries()) {
155
+ if (attr.objectId === objectId && !excludeNames.includes(attr.name)) {
156
+ stores.attributes.delete(id);
157
+ count++;
158
+ }
159
+ }
160
+ return Promise.resolve(count);
161
+ },
162
+ upsert(data) {
163
+ for (const attr of stores.attributes.values()) {
164
+ if (attr.objectId === data.objectId && attr.name === data.name) {
165
+ const updated = {
166
+ ...attr,
167
+ label: data.label ?? attr.label,
168
+ type: data.type ?? attr.type,
169
+ system: data.system ?? attr.system,
170
+ required: data.required ?? attr.required,
171
+ unique: data.unique ?? attr.unique,
172
+ orderIndex: data.orderIndex ?? attr.orderIndex,
173
+ config: data.config ?? attr.config,
174
+ updatedAt: /* @__PURE__ */ new Date()
175
+ };
176
+ stores.attributes.set(attr.id, updated);
177
+ return Promise.resolve(updated);
178
+ }
179
+ }
180
+ return this.create(data);
181
+ }
182
+ };
183
+ }
184
+ function createMockUserProfilesRepository(stores) {
185
+ return {
186
+ findById(id) {
187
+ return Promise.resolve(stores.userProfiles.get(id) ?? null);
188
+ },
189
+ findByAuthId(authId) {
190
+ for (const profile of stores.userProfiles.values()) {
191
+ if (profile.authId === authId) {
192
+ return Promise.resolve(profile);
193
+ }
194
+ }
195
+ return Promise.resolve(null);
196
+ },
197
+ findByEmail(tenantId, email) {
198
+ for (const profile of stores.userProfiles.values()) {
199
+ if (profile.tenantId === tenantId && profile.email === email) {
200
+ return Promise.resolve(profile);
201
+ }
202
+ }
203
+ return Promise.resolve(null);
204
+ },
205
+ create(data) {
206
+ const profile = {
207
+ id: generateId(),
208
+ tenantId: data.tenantId,
209
+ authId: data.authId,
210
+ email: data.email,
211
+ firstName: data.firstName,
212
+ lastName: data.lastName,
213
+ avatarUrl: data.avatarUrl,
214
+ role: data.role ?? "member",
215
+ status: data.status ?? "active",
216
+ createdAt: /* @__PURE__ */ new Date(),
217
+ updatedAt: /* @__PURE__ */ new Date()
218
+ };
219
+ stores.userProfiles.set(profile.id, profile);
220
+ return Promise.resolve(profile);
221
+ },
222
+ update(id, data) {
223
+ const existing = stores.userProfiles.get(id);
224
+ if (!existing) {
225
+ return Promise.reject(new Error(`UserProfile ${id} not found`));
226
+ }
227
+ const updated = {
228
+ ...existing,
229
+ ...data,
230
+ updatedAt: /* @__PURE__ */ new Date()
231
+ };
232
+ stores.userProfiles.set(id, updated);
233
+ return Promise.resolve(updated);
234
+ },
235
+ delete(id) {
236
+ stores.userProfiles.delete(id);
237
+ return Promise.resolve();
238
+ },
239
+ list(tenantId, options) {
240
+ let results = Array.from(stores.userProfiles.values()).filter((p) => p.tenantId === tenantId);
241
+ if (options?.limit) {
242
+ results = results.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit);
243
+ }
244
+ return Promise.resolve(results);
245
+ },
246
+ updateLastLogin(id) {
247
+ const profile = stores.userProfiles.get(id);
248
+ if (profile) {
249
+ profile.lastLoginAt = /* @__PURE__ */ new Date();
250
+ stores.userProfiles.set(id, profile);
251
+ }
252
+ return Promise.resolve();
253
+ }
254
+ };
255
+ }
256
+ function createMockFilesRepository(stores) {
257
+ return {
258
+ findById(id) {
259
+ const file2 = stores.files.get(id);
260
+ if (file2?.deletedAt) return Promise.resolve(null);
261
+ return Promise.resolve(file2 ?? null);
262
+ },
263
+ create(data) {
264
+ const file2 = {
265
+ id: generateId(),
266
+ tenantId: data.tenantId,
267
+ name: data.name,
268
+ originalName: data.originalName,
269
+ mimeType: data.mimeType,
270
+ size: data.size,
271
+ storageProvider: data.storageProvider,
272
+ storagePath: data.storagePath,
273
+ storageBucket: data.storageBucket,
274
+ url: data.url,
275
+ uploadedBy: data.uploadedBy,
276
+ folderPath: data.folderPath,
277
+ tags: data.tags,
278
+ visibility: data.visibility ?? "private",
279
+ allowedUsers: data.allowedUsers,
280
+ createdAt: /* @__PURE__ */ new Date(),
281
+ updatedAt: /* @__PURE__ */ new Date()
282
+ };
283
+ stores.files.set(file2.id, file2);
284
+ return Promise.resolve(file2);
285
+ },
286
+ update(id, data) {
287
+ const existing = stores.files.get(id);
288
+ if (!existing) {
289
+ return Promise.reject(new Error(`File ${id} not found`));
290
+ }
291
+ const updated = {
292
+ ...existing,
293
+ ...data,
294
+ updatedAt: /* @__PURE__ */ new Date()
295
+ };
296
+ stores.files.set(id, updated);
297
+ return Promise.resolve(updated);
298
+ },
299
+ delete(id) {
300
+ const file2 = stores.files.get(id);
301
+ if (file2) {
302
+ file2.deletedAt = /* @__PURE__ */ new Date();
303
+ stores.files.set(id, file2);
304
+ }
305
+ return Promise.resolve();
306
+ },
307
+ hardDelete(id) {
308
+ stores.files.delete(id);
309
+ return Promise.resolve();
310
+ },
311
+ list(tenantId, options) {
312
+ let results = Array.from(stores.files.values()).filter(
313
+ (f) => f.tenantId === tenantId && !f.deletedAt
314
+ );
315
+ if (options?.mimeType) {
316
+ results = results.filter((f) => f.mimeType === options.mimeType);
317
+ }
318
+ if (options?.limit) {
319
+ results = results.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit);
320
+ }
321
+ return Promise.resolve(results);
322
+ },
323
+ findByFolder(tenantId, folderPath) {
324
+ const results = Array.from(stores.files.values()).filter(
325
+ (f) => f.tenantId === tenantId && f.folderPath === folderPath && !f.deletedAt
326
+ );
327
+ return Promise.resolve(results);
328
+ },
329
+ findByUploader(uploadedBy) {
330
+ const results = Array.from(stores.files.values()).filter(
331
+ (f) => f.uploadedBy === uploadedBy && !f.deletedAt
332
+ );
333
+ return Promise.resolve(results);
334
+ }
335
+ };
336
+ }
337
+ function createMockObjectRecordsRepository(stores) {
338
+ return {
339
+ findById(id) {
340
+ const internal = stores.objectRecords.get(id);
341
+ if (!internal) return Promise.resolve(null);
342
+ const { tenantId: _, ...record } = internal;
343
+ return Promise.resolve(record);
344
+ },
345
+ create(data) {
346
+ const internal = {
347
+ id: generateId(),
348
+ tenantId: data.tenantId,
349
+ objectId: data.objectId,
350
+ values: data.data,
351
+ createdAt: /* @__PURE__ */ new Date(),
352
+ updatedAt: /* @__PURE__ */ new Date()
353
+ };
354
+ stores.objectRecords.set(internal.id, internal);
355
+ const { tenantId: _, ...record } = internal;
356
+ return Promise.resolve(record);
357
+ },
358
+ update(id, data) {
359
+ const existing = stores.objectRecords.get(id);
360
+ if (!existing) {
361
+ return Promise.reject(new Error(`ObjectRecord ${id} not found`));
362
+ }
363
+ const updated = {
364
+ ...existing,
365
+ values: { ...existing.values, ...data },
366
+ updatedAt: /* @__PURE__ */ new Date()
367
+ };
368
+ stores.objectRecords.set(id, updated);
369
+ const { tenantId: _, ...record } = updated;
370
+ return Promise.resolve(record);
371
+ },
372
+ delete(id) {
373
+ stores.objectRecords.delete(id);
374
+ return Promise.resolve();
375
+ },
376
+ list(tenantId, objectId, options) {
377
+ let results = Array.from(stores.objectRecords.values()).filter(
378
+ (r) => r.tenantId === tenantId && r.objectId === objectId
379
+ );
380
+ const total = results.length;
381
+ if (options?.limit) {
382
+ results = results.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit);
383
+ }
384
+ const records = results.map(({ tenantId: _, ...r }) => r);
385
+ return Promise.resolve({ records, total });
386
+ },
387
+ search(tenantId, objectId, query, options) {
388
+ const lowerQuery = query.toLowerCase();
389
+ let results = Array.from(stores.objectRecords.values()).filter((r) => {
390
+ if (r.tenantId !== tenantId || r.objectId !== objectId) return false;
391
+ return Object.values(r.values).some(
392
+ (val) => String(val).toLowerCase().includes(lowerQuery)
393
+ );
394
+ });
395
+ const total = results.length;
396
+ if (options?.limit) {
397
+ results = results.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit);
398
+ }
399
+ const records = results.map(({ tenantId: _, ...r }) => r);
400
+ return Promise.resolve({ records, total });
401
+ }
402
+ };
403
+ }
404
+ function createMockAdapter() {
405
+ const stores = {
406
+ objects: /* @__PURE__ */ new Map(),
407
+ attributes: /* @__PURE__ */ new Map(),
408
+ userProfiles: /* @__PURE__ */ new Map(),
409
+ files: /* @__PURE__ */ new Map(),
410
+ objectRecords: /* @__PURE__ */ new Map()
411
+ };
412
+ const adapter = {
413
+ objects: createMockObjectsRepository(stores),
414
+ attributes: createMockAttributesRepository(stores),
415
+ userProfiles: createMockUserProfilesRepository(stores),
416
+ files: createMockFilesRepository(stores),
417
+ objectRecords: createMockObjectRecordsRepository(stores),
418
+ async transaction(callback) {
419
+ return await callback(adapter);
420
+ },
421
+ // Expose stores for testing inspection
422
+ _stores: stores,
423
+ // Reset all stores (useful between tests)
424
+ reset() {
425
+ stores.objects.clear();
426
+ stores.attributes.clear();
427
+ stores.userProfiles.clear();
428
+ stores.files.clear();
429
+ stores.objectRecords.clear();
430
+ }
431
+ };
432
+ return adapter;
433
+ }
434
+
435
+ // src/runtime/services/file.service.ts
436
+ var FileService = class {
437
+ constructor(adapter, tenantId) {
438
+ this.adapter = adapter;
439
+ this.tenantId = tenantId;
440
+ }
441
+ /**
442
+ * Create a new file record (after upload to storage)
443
+ *
444
+ * @param data - File metadata
445
+ * @returns Created file record
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * const service = new FileService(adapter, "tenant-123");
450
+ *
451
+ * // After uploading to S3
452
+ * const file = await service.createFile({
453
+ * tenantId: "tenant-123",
454
+ * name: "contract-2025.pdf",
455
+ * originalName: "Contract Acme Corp 2025.pdf",
456
+ * mimeType: "application/pdf",
457
+ * size: 2458624,
458
+ * storageProvider: "s3",
459
+ * storagePath: "tenants/123/files/2025/contract.pdf",
460
+ * storageBucket: "my-app-files",
461
+ * url: "https://cdn.example.com/files/file-123",
462
+ * uploadedBy: "profile-456",
463
+ * visibility: "private"
464
+ * });
465
+ * ```
466
+ */
467
+ async createFile(data) {
468
+ if (data.tenantId !== this.tenantId) {
469
+ throw new Error(
470
+ `Tenant mismatch: service initialized with "${this.tenantId}" but data has "${data.tenantId}"`
471
+ );
472
+ }
473
+ return await this.adapter.files.create(data);
474
+ }
475
+ /**
476
+ * Get file by ID
477
+ */
478
+ async getFile(fileId) {
479
+ const file2 = await this.adapter.files.findById(fileId);
480
+ if (file2?.deletedAt) {
481
+ return null;
482
+ }
483
+ return file2;
484
+ }
485
+ /**
486
+ * Get file by ID or throw
487
+ */
488
+ async getFileOrThrow(fileId) {
489
+ const file2 = await this.getFile(fileId);
490
+ if (!file2) {
491
+ throw new Error(`File with id "${fileId}" not found`);
492
+ }
493
+ return file2;
494
+ }
495
+ /**
496
+ * Update file metadata
497
+ *
498
+ * @param fileId - File UUID
499
+ * @param data - Data to update
500
+ * @returns Updated file
501
+ */
502
+ async updateFile(fileId, data) {
503
+ await this.getFileOrThrow(fileId);
504
+ return await this.adapter.files.update(fileId, data);
505
+ }
506
+ /**
507
+ * Delete file (soft delete)
508
+ *
509
+ * @param fileId - File UUID
510
+ * @param options - Delete options
511
+ */
512
+ async deleteFile(fileId, options) {
513
+ if (options?.checkOwnership && options.userId) {
514
+ const file2 = await this.getFileOrThrow(fileId);
515
+ if (file2.uploadedBy !== options.userId) {
516
+ throw new Error("You can only delete files you uploaded");
517
+ }
518
+ }
519
+ if (options?.hard) {
520
+ await this.adapter.files.hardDelete(fileId);
521
+ } else {
522
+ await this.adapter.files.delete(fileId);
523
+ }
524
+ }
525
+ /**
526
+ * List files for the tenant
527
+ */
528
+ async listFiles(options) {
529
+ return await this.adapter.files.list(this.tenantId, options);
530
+ }
531
+ /**
532
+ * List files by folder
533
+ */
534
+ async listFilesByFolder(folderPath) {
535
+ return await this.adapter.files.findByFolder(this.tenantId, folderPath);
536
+ }
537
+ /**
538
+ * List files uploaded by a specific user
539
+ */
540
+ async listFilesByUploader(uploadedBy) {
541
+ return await this.adapter.files.findByUploader(uploadedBy);
542
+ }
543
+ /**
544
+ * Change file visibility
545
+ *
546
+ * @param fileId - File UUID
547
+ * @param visibility - New visibility level
548
+ * @param allowedUsers - Users allowed to access (if restricted)
549
+ */
550
+ async changeVisibility(fileId, visibility, allowedUsers) {
551
+ const updateData = { visibility };
552
+ if (visibility === "restricted" && allowedUsers) {
553
+ updateData.allowedUsers = allowedUsers;
554
+ }
555
+ return await this.updateFile(fileId, updateData);
556
+ }
557
+ /**
558
+ * Grant access to a file for specific users
559
+ *
560
+ * @param fileId - File UUID
561
+ * @param userIds - User IDs to grant access
562
+ */
563
+ async grantAccess(fileId, userIds) {
564
+ const file2 = await this.getFileOrThrow(fileId);
565
+ const currentAllowed = file2.allowedUsers || [];
566
+ const newAllowed = [.../* @__PURE__ */ new Set([...currentAllowed, ...userIds])];
567
+ return await this.updateFile(fileId, {
568
+ visibility: "restricted",
569
+ allowedUsers: newAllowed
570
+ });
571
+ }
572
+ /**
573
+ * Revoke access to a file for specific users
574
+ *
575
+ * @param fileId - File UUID
576
+ * @param userIds - User IDs to revoke access
577
+ */
578
+ async revokeAccess(fileId, userIds) {
579
+ const file2 = await this.getFileOrThrow(fileId);
580
+ const currentAllowed = file2.allowedUsers || [];
581
+ const newAllowed = currentAllowed.filter((id) => !userIds.includes(id));
582
+ return await this.updateFile(fileId, {
583
+ allowedUsers: newAllowed
584
+ });
585
+ }
586
+ /**
587
+ * Check if user has access to a file
588
+ *
589
+ * @param fileId - File UUID
590
+ * @param userId - User ID to check
591
+ * @returns true if user can access the file
592
+ */
593
+ async canAccess(fileId, userId) {
594
+ const file2 = await this.getFile(fileId);
595
+ if (!file2) {
596
+ return false;
597
+ }
598
+ if (file2.visibility === "public") {
599
+ return true;
600
+ }
601
+ if (file2.uploadedBy === userId) {
602
+ return true;
603
+ }
604
+ if (file2.visibility === "restricted") {
605
+ return file2.allowedUsers?.includes(userId) ?? false;
606
+ }
607
+ return false;
608
+ }
609
+ /**
610
+ * Move file to different folder
611
+ */
612
+ async moveToFolder(fileId, newFolderPath) {
613
+ return await this.updateFile(fileId, { folderPath: newFolderPath });
614
+ }
615
+ /**
616
+ * Add tags to file
617
+ */
618
+ async addTags(fileId, tags) {
619
+ const file2 = await this.getFileOrThrow(fileId);
620
+ const currentTags = file2.tags || [];
621
+ const newTags = [.../* @__PURE__ */ new Set([...currentTags, ...tags])];
622
+ return await this.updateFile(fileId, { tags: newTags });
623
+ }
624
+ /**
625
+ * Remove tags from file
626
+ */
627
+ async removeTags(fileId, tags) {
628
+ const file2 = await this.getFileOrThrow(fileId);
629
+ const currentTags = file2.tags || [];
630
+ const newTags = currentTags.filter((tag) => !tags.includes(tag));
631
+ return await this.updateFile(fileId, { tags: newTags });
632
+ }
633
+ };
634
+
635
+ // src/builders/attribute-builders.ts
636
+ import { z } from "zod";
637
+ var BaseAttributeBuilder = class {
638
+ constructor(type, name, label) {
639
+ this.validateVariableName(name);
640
+ this.attr = {
641
+ name,
642
+ label,
643
+ type,
644
+ required: false
645
+ };
646
+ }
647
+ /**
648
+ * Validate attribute name as valid variable identifier
649
+ * Accepts: camelCase, snake_case, PascalCase, UPPER_CASE
650
+ */
651
+ validateVariableName(name) {
652
+ const variableNameSchema = z.string().min(1, "Attribute name cannot be empty").max(63, "Attribute name is too long (max 63 characters)").regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/, {
653
+ message: "Invalid attribute name format.\nName must be a valid variable identifier:\n \u2705 Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'\n \u274C Invalid: 'first-name', 'first name', '123name', 'first.name'"
654
+ });
655
+ try {
656
+ variableNameSchema.parse(name);
657
+ } catch (error) {
658
+ if (error instanceof z.ZodError) {
659
+ throw new Error(`[AttributeBuilder] ${error.errors[0].message}`);
660
+ }
661
+ throw error;
662
+ }
663
+ }
664
+ setRequired(value) {
665
+ this.attr.required = value;
666
+ }
667
+ system() {
668
+ this.attr.system = true;
669
+ return this;
670
+ }
671
+ disabled() {
672
+ this.attr.disabled = true;
673
+ return this;
674
+ }
675
+ hidden() {
676
+ this.attr.hidden = true;
677
+ return this;
678
+ }
679
+ placeholder(value) {
680
+ this.attr.placeholder = value;
681
+ return this;
682
+ }
683
+ description(value) {
684
+ this.attr.description = value;
685
+ return this;
686
+ }
687
+ icon(value) {
688
+ this.attr.icon = value;
689
+ return this;
690
+ }
691
+ order(value) {
692
+ this.attr.order = value;
693
+ return this;
694
+ }
695
+ defaultValue(value) {
696
+ this.attr.defaultValue = value;
697
+ return this;
698
+ }
699
+ metadata(value) {
700
+ this.attr.metadata = value;
701
+ return this;
702
+ }
703
+ build() {
704
+ return this.attr;
705
+ }
706
+ };
707
+ var TextAttributeBuilder = class extends BaseAttributeBuilder {
708
+ constructor(name, label) {
709
+ super("text", name, label);
710
+ }
711
+ minLength(value) {
712
+ this.attr.minLength = value;
713
+ return this;
714
+ }
715
+ maxLength(value) {
716
+ this.attr.maxLength = value;
717
+ return this;
718
+ }
719
+ pattern(value) {
720
+ this.attr.pattern = value;
721
+ return this;
722
+ }
723
+ required() {
724
+ this.setRequired(true);
725
+ return this;
726
+ }
727
+ optional() {
728
+ this.setRequired(false);
729
+ return this;
730
+ }
731
+ /**
732
+ * Set email validation pattern
733
+ */
734
+ email() {
735
+ this.attr.pattern = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
736
+ return this;
737
+ }
738
+ /**
739
+ * Set URL validation pattern
740
+ */
741
+ url() {
742
+ this.attr.pattern = "^https?:\\/\\/[\\w\\-]+(\\.[\\w\\-]+)+[/#?]?.*$";
743
+ return this;
744
+ }
745
+ /**
746
+ * Set slug validation pattern
747
+ */
748
+ slug() {
749
+ this.attr.pattern = "^[a-z0-9]+(?:-[a-z0-9]+)*$";
750
+ return this;
751
+ }
752
+ };
753
+ function text(config) {
754
+ return new TextAttributeBuilder(config.name, config.label);
755
+ }
756
+ var TextAreaAttributeBuilder = class extends BaseAttributeBuilder {
757
+ constructor(name, label) {
758
+ super("textarea", name, label);
759
+ }
760
+ required() {
761
+ this.setRequired(true);
762
+ return this;
763
+ }
764
+ optional() {
765
+ this.setRequired(false);
766
+ return this;
767
+ }
768
+ };
769
+ function textarea(config) {
770
+ return new TextAreaAttributeBuilder(config.name, config.label);
771
+ }
772
+ var NumberAttributeBuilder = class extends BaseAttributeBuilder {
773
+ constructor(name, label) {
774
+ super("number", name, label);
775
+ }
776
+ min(value) {
777
+ this.attr.min = value;
778
+ return this;
779
+ }
780
+ max(value) {
781
+ this.attr.max = value;
782
+ return this;
783
+ }
784
+ integer() {
785
+ this.attr.unit = "integer";
786
+ this.attr.decimals = 0;
787
+ return this;
788
+ }
789
+ decimal(decimals = 2) {
790
+ this.attr.unit = "decimal";
791
+ this.attr.decimals = decimals;
792
+ return this;
793
+ }
794
+ percentage() {
795
+ this.attr.unit = "percentage";
796
+ return this;
797
+ }
798
+ required() {
799
+ this.setRequired(true);
800
+ return this;
801
+ }
802
+ optional() {
803
+ this.setRequired(false);
804
+ return this;
805
+ }
806
+ };
807
+ function number(config) {
808
+ return new NumberAttributeBuilder(config.name, config.label);
809
+ }
810
+ var CheckboxAttributeBuilder = class extends BaseAttributeBuilder {
811
+ constructor(name, label) {
812
+ super("checkbox", name, label);
813
+ }
814
+ required() {
815
+ this.setRequired(true);
816
+ return this;
817
+ }
818
+ optional() {
819
+ this.setRequired(false);
820
+ return this;
821
+ }
822
+ };
823
+ function checkbox(config) {
824
+ return new CheckboxAttributeBuilder(config.name, config.label);
825
+ }
826
+ var DateAttributeBuilder = class extends BaseAttributeBuilder {
827
+ constructor(name, label) {
828
+ super("date", name, label);
829
+ }
830
+ format(value) {
831
+ this.attr.dateFormat = value;
832
+ return this;
833
+ }
834
+ minDate(value) {
835
+ this.attr.minDate = value;
836
+ return this;
837
+ }
838
+ maxDate(value) {
839
+ this.attr.maxDate = value;
840
+ return this;
841
+ }
842
+ required() {
843
+ this.setRequired(true);
844
+ return this;
845
+ }
846
+ optional() {
847
+ this.setRequired(false);
848
+ return this;
849
+ }
850
+ };
851
+ function date(config) {
852
+ return new DateAttributeBuilder(config.name, config.label);
853
+ }
854
+ var PhoneAttributeBuilder = class extends BaseAttributeBuilder {
855
+ constructor(name, label) {
856
+ super("phone", name, label);
857
+ }
858
+ defaultCountry(value) {
859
+ this.attr.defaultCountryCode = value;
860
+ return this;
861
+ }
862
+ required() {
863
+ this.setRequired(true);
864
+ return this;
865
+ }
866
+ optional() {
867
+ this.setRequired(false);
868
+ return this;
869
+ }
870
+ };
871
+ function phone(config) {
872
+ return new PhoneAttributeBuilder(config.name, config.label);
873
+ }
874
+ var CurrencyAttributeBuilder = class extends BaseAttributeBuilder {
875
+ constructor(name, label) {
876
+ super("currency", name, label);
877
+ }
878
+ defaultCurrency(value) {
879
+ this.attr.defaultCurrency = value;
880
+ return this;
881
+ }
882
+ allowedCurrencies(value) {
883
+ this.attr.allowedCurrencies = value;
884
+ return this;
885
+ }
886
+ required() {
887
+ this.setRequired(true);
888
+ return this;
889
+ }
890
+ optional() {
891
+ this.setRequired(false);
892
+ return this;
893
+ }
894
+ };
895
+ function currency(config) {
896
+ return new CurrencyAttributeBuilder(config.name, config.label);
897
+ }
898
+ var StatusAttributeBuilder = class extends BaseAttributeBuilder {
899
+ constructor(name, label) {
900
+ super("status", name, label);
901
+ }
902
+ /**
903
+ * Set all options at once (preserves literal types for values)
904
+ */
905
+ options(value) {
906
+ this.attr.options = value;
907
+ return this;
908
+ }
909
+ option(config) {
910
+ if (!this.attr.options) {
911
+ this.attr.options = [];
912
+ }
913
+ this.attr.options.push(config);
914
+ return this;
915
+ }
916
+ required() {
917
+ this.setRequired(true);
918
+ return this;
919
+ }
920
+ optional() {
921
+ this.setRequired(false);
922
+ return this;
923
+ }
924
+ };
925
+ function status(config) {
926
+ return new StatusAttributeBuilder(config.name, config.label);
927
+ }
928
+ var SelectAttributeBuilder = class extends BaseAttributeBuilder {
929
+ constructor(name, label) {
930
+ super("select", name, label);
931
+ }
932
+ /**
933
+ * Set all options at once (preserves literal types for values)
934
+ */
935
+ options(value) {
936
+ this.attr.options = value;
937
+ return this;
938
+ }
939
+ option(config) {
940
+ if (!this.attr.options) {
941
+ this.attr.options = [];
942
+ }
943
+ this.attr.options.push(config);
944
+ return this;
945
+ }
946
+ required() {
947
+ this.setRequired(true);
948
+ return this;
949
+ }
950
+ optional() {
951
+ this.setRequired(false);
952
+ return this;
953
+ }
954
+ };
955
+ function select(config) {
956
+ return new SelectAttributeBuilder(config.name, config.label);
957
+ }
958
+ var MultiselectAttributeBuilder = class extends BaseAttributeBuilder {
959
+ constructor(name, label) {
960
+ super("multiselect", name, label);
961
+ }
962
+ /**
963
+ * Set all options at once (preserves literal types for values)
964
+ */
965
+ options(value) {
966
+ this.attr.options = value;
967
+ return this;
968
+ }
969
+ option(config) {
970
+ if (!this.attr.options) {
971
+ this.attr.options = [];
972
+ }
973
+ this.attr.options.push(config);
974
+ return this;
975
+ }
976
+ required() {
977
+ this.setRequired(true);
978
+ return this;
979
+ }
980
+ optional() {
981
+ this.setRequired(false);
982
+ return this;
983
+ }
984
+ };
985
+ function multiselect(config) {
986
+ return new MultiselectAttributeBuilder(config.name, config.label);
987
+ }
988
+ var LocationAttributeBuilder = class extends BaseAttributeBuilder {
989
+ constructor(name, label) {
990
+ super("location", name, label);
991
+ }
992
+ granularity(value) {
993
+ this.attr.granularity = value;
994
+ return this;
995
+ }
996
+ enableAutocomplete() {
997
+ this.attr.enableAutocomplete = true;
998
+ return this;
999
+ }
1000
+ enableMap() {
1001
+ this.attr.enableMap = true;
1002
+ return this;
1003
+ }
1004
+ defaultCountry(value) {
1005
+ this.attr.defaultCountry = value;
1006
+ return this;
1007
+ }
1008
+ allowedCountries(value) {
1009
+ this.attr.allowedCountries = value;
1010
+ return this;
1011
+ }
1012
+ displayFormat(value) {
1013
+ this.attr.displayFormat = value;
1014
+ return this;
1015
+ }
1016
+ required() {
1017
+ this.setRequired(true);
1018
+ return this;
1019
+ }
1020
+ optional() {
1021
+ this.setRequired(false);
1022
+ return this;
1023
+ }
1024
+ };
1025
+ function location(config) {
1026
+ return new LocationAttributeBuilder(config.name, config.label);
1027
+ }
1028
+ var TimestampAttributeBuilder = class extends BaseAttributeBuilder {
1029
+ constructor(name, label) {
1030
+ super("timestamp", name, label);
1031
+ }
1032
+ autoUpdate() {
1033
+ this.attr.autoUpdate = true;
1034
+ return this;
1035
+ }
1036
+ required() {
1037
+ this.setRequired(true);
1038
+ return this;
1039
+ }
1040
+ optional() {
1041
+ this.setRequired(false);
1042
+ return this;
1043
+ }
1044
+ };
1045
+ function timestamp(config) {
1046
+ return new TimestampAttributeBuilder(config.name, config.label);
1047
+ }
1048
+ var FileAttributeBuilder = class extends BaseAttributeBuilder {
1049
+ constructor(name, label) {
1050
+ super("file", name, label);
1051
+ }
1052
+ maxFiles(value) {
1053
+ this.attr.maxFiles = value;
1054
+ return this;
1055
+ }
1056
+ maxSize(bytes) {
1057
+ this.attr.maxSize = bytes;
1058
+ return this;
1059
+ }
1060
+ allowedTypes(types) {
1061
+ this.attr.allowedTypes = types;
1062
+ return this;
1063
+ }
1064
+ verification(config) {
1065
+ this.attr.verification = config;
1066
+ return this;
1067
+ }
1068
+ required() {
1069
+ this.setRequired(true);
1070
+ return this;
1071
+ }
1072
+ optional() {
1073
+ this.setRequired(false);
1074
+ return this;
1075
+ }
1076
+ };
1077
+ function file(config) {
1078
+ return new FileAttributeBuilder(config.name, config.label);
1079
+ }
1080
+ var UserAttributeBuilder = class extends BaseAttributeBuilder {
1081
+ constructor(name, label) {
1082
+ super("user", name, label);
1083
+ }
1084
+ allowedRoles(roles) {
1085
+ this.attr.allowedRoles = roles;
1086
+ return this;
1087
+ }
1088
+ required() {
1089
+ this.setRequired(true);
1090
+ return this;
1091
+ }
1092
+ optional() {
1093
+ this.setRequired(false);
1094
+ return this;
1095
+ }
1096
+ };
1097
+ function user(config) {
1098
+ return new UserAttributeBuilder(config.name, config.label);
1099
+ }
1100
+ var RelationAttributeBuilder = class extends BaseAttributeBuilder {
1101
+ constructor(name, label) {
1102
+ super("relation", name, label);
1103
+ }
1104
+ relation(objectIds) {
1105
+ this.attr.relation = objectIds;
1106
+ return this;
1107
+ }
1108
+ limit(value) {
1109
+ this.attr.limit = value;
1110
+ return this;
1111
+ }
1112
+ cascadeDelete() {
1113
+ this.attr.cascadeDelete = true;
1114
+ return this;
1115
+ }
1116
+ required() {
1117
+ this.setRequired(true);
1118
+ return this;
1119
+ }
1120
+ optional() {
1121
+ this.setRequired(false);
1122
+ return this;
1123
+ }
1124
+ };
1125
+ function relation(config) {
1126
+ return new RelationAttributeBuilder(config.name, config.label);
1127
+ }
1128
+ var RatingAttributeBuilder = class extends BaseAttributeBuilder {
1129
+ constructor(name, label) {
1130
+ super("rating", name, label);
1131
+ }
1132
+ max(value) {
1133
+ this.attr.max = value;
1134
+ return this;
1135
+ }
1136
+ iconType(value) {
1137
+ this.attr.iconType = value;
1138
+ return this;
1139
+ }
1140
+ required() {
1141
+ this.setRequired(true);
1142
+ return this;
1143
+ }
1144
+ optional() {
1145
+ this.setRequired(false);
1146
+ return this;
1147
+ }
1148
+ };
1149
+ function rating(config) {
1150
+ return new RatingAttributeBuilder(config.name, config.label);
1151
+ }
1152
+
1153
+ // src/builders/object-builder.ts
1154
+ import z2 from "zod";
1155
+ var ObjectBuilder = class {
1156
+ constructor(config) {
1157
+ this.validateName(config.name);
1158
+ this.obj = {
1159
+ name: config.name,
1160
+ label: config.label,
1161
+ attributes: [],
1162
+ system: false
1163
+ };
1164
+ }
1165
+ /**
1166
+ * Set object description
1167
+ */
1168
+ description(value) {
1169
+ this.obj.description = value;
1170
+ return this;
1171
+ }
1172
+ /**
1173
+ * Set object icon
1174
+ */
1175
+ icon(value) {
1176
+ this.obj.icon = value;
1177
+ return this;
1178
+ }
1179
+ /**
1180
+ * Mark as system/native object (defined in code, protected)
1181
+ * System objects cannot be deleted/modified by clients
1182
+ */
1183
+ system() {
1184
+ this.obj.system = true;
1185
+ return this;
1186
+ }
1187
+ /**
1188
+ * Add an attribute to the object with type accumulation
1189
+ *
1190
+ * The return type accumulates the attribute's name and value type
1191
+ * into the TRecord generic, enabling full inference.
1192
+ *
1193
+ * @param attr - Attribute definition or builder (auto-builds if builder)
1194
+ */
1195
+ attribute(attr) {
1196
+ if (!this.obj.attributes) {
1197
+ this.obj.attributes = [];
1198
+ }
1199
+ const finalAttr = "build" in attr && typeof attr.build === "function" ? attr.build() : attr;
1200
+ this.obj.attributes.push(finalAttr);
1201
+ return this;
1202
+ }
1203
+ /**
1204
+ * Add multiple attributes at once
1205
+ * Note: For full type inference, prefer chaining .attribute() calls
1206
+ */
1207
+ attributes(attrs) {
1208
+ if (!this.obj.attributes) {
1209
+ this.obj.attributes = [];
1210
+ }
1211
+ const finalAttrs = attrs.map((attr) => "build" in attr ? attr.build() : attr);
1212
+ this.obj.attributes.push(...finalAttrs);
1213
+ return this;
1214
+ }
1215
+ /**
1216
+ * Set metadata
1217
+ */
1218
+ metadata(value) {
1219
+ this.obj.metadata = value;
1220
+ return this;
1221
+ }
1222
+ /**
1223
+ * Set the title attribute (the text attribute used to display the object's name)
1224
+ * Must reference a text attribute that has been added to the object.
1225
+ * If not set, the first text attribute becomes the title attribute.
1226
+ *
1227
+ * @param attributeName - The name of a text attribute
1228
+ */
1229
+ titleAttribute(attributeName) {
1230
+ this._titleAttribute = attributeName;
1231
+ return this;
1232
+ }
1233
+ /**
1234
+ * Build the final ObjectDefinition
1235
+ * @throws Error if required fields are missing or invalid
1236
+ */
1237
+ build() {
1238
+ if (!this.obj.name) {
1239
+ throw new Error("[ObjectBuilder] Missing required field: name");
1240
+ }
1241
+ if (!this.obj.label) {
1242
+ throw new Error("[ObjectBuilder] Missing required field: label");
1243
+ }
1244
+ const textAttributes = (this.obj.attributes ?? []).filter((attr) => attr.type === "text");
1245
+ if (textAttributes.length === 0) {
1246
+ throw new Error(
1247
+ `[ObjectBuilder] Object "${this.obj.name}" must have at least one text attribute.
1248
+ A text attribute is required to serve as the object's title/display name.
1249
+ \u2705 Example: .attribute(text({ name: 'name', label: 'Name' }).required())`
1250
+ );
1251
+ }
1252
+ const titleAttrName = this._titleAttribute ?? textAttributes[0].name;
1253
+ const titleAttr = textAttributes.find((attr) => attr.name === titleAttrName);
1254
+ if (!titleAttr) {
1255
+ const availableTextAttrs = textAttributes.map((a) => `'${a.name}'`).join(", ");
1256
+ throw new Error(
1257
+ `[ObjectBuilder] titleAttribute "${titleAttrName}" must be a text attribute.
1258
+ Available text attributes: ${availableTextAttrs}`
1259
+ );
1260
+ }
1261
+ const metadata = this.obj.metadata ?? {};
1262
+ metadata.titleAttribute = titleAttrName;
1263
+ this.obj.metadata = metadata;
1264
+ return this.obj;
1265
+ }
1266
+ /**
1267
+ * Validate object name format
1268
+ * Must be kebab-case (slug format), max 63 characters
1269
+ * @internal
1270
+ */
1271
+ validateName(name) {
1272
+ if (name === void 0) {
1273
+ return;
1274
+ }
1275
+ const objectNameSchema = z2.string().min(1, "Object name cannot be empty").max(63, "Object name is too long (max 63 characters)").regex(/^[a-z][a-z0-9-]*$/, {
1276
+ message: "Invalid object name format.\nName must be in kebab-case (slug format):\n \u2705 Valid: 'products', 'user-profiles', 'order-items'\n \u274C Invalid: 'Products', 'userProfiles', 'user_profiles'"
1277
+ });
1278
+ try {
1279
+ objectNameSchema.parse(name);
1280
+ } catch (error) {
1281
+ if (error instanceof z2.ZodError) {
1282
+ throw new Error(`[ObjectBuilder] ${error.errors[0].message}`);
1283
+ }
1284
+ throw error;
1285
+ }
1286
+ }
1287
+ };
1288
+ function object(config) {
1289
+ return new ObjectBuilder(config);
1290
+ }
1291
+
1292
+ // src/runtime/services/object-schema.service.ts
1293
+ var ObjectSchemaService = class {
1294
+ constructor(adapter, nativeRegistry) {
1295
+ this.adapter = adapter;
1296
+ this.nativeRegistry = nativeRegistry;
1297
+ }
1298
+ /**
1299
+ * Create a new custom object
1300
+ * Validates name format and ensures system=false
1301
+ *
1302
+ * @param definition - Object definition (attributes can be raw definitions or builders)
1303
+ * @param tenantId - Tenant ID owning the object
1304
+ * @returns Created ObjectDefinition
1305
+ */
1306
+ async createCustomObject(definition, tenantId) {
1307
+ const builder = object({
1308
+ name: definition.name,
1309
+ label: definition.label
1310
+ });
1311
+ if (definition.description) builder.description(definition.description);
1312
+ if (definition.icon) builder.icon(definition.icon);
1313
+ if (definition.metadata) builder.metadata(definition.metadata);
1314
+ if (definition.attributes && definition.attributes.length > 0) {
1315
+ builder.attributes(definition.attributes);
1316
+ }
1317
+ const objectDef = builder.build();
1318
+ const existing = await this.adapter.objects.findByName(tenantId, objectDef.name);
1319
+ if (existing) {
1320
+ throw new Error(`Object with name "${objectDef.name}" already exists`);
1321
+ }
1322
+ const metadata = {
1323
+ ...objectDef.metadata,
1324
+ icon: objectDef.icon
1325
+ };
1326
+ const dbObject = await this.adapter.objects.create({
1327
+ tenantId,
1328
+ name: objectDef.name,
1329
+ label: objectDef.label,
1330
+ description: objectDef.description,
1331
+ system: false,
1332
+ // Always false for custom objects
1333
+ metadata
1334
+ });
1335
+ const createdAttributes = [];
1336
+ if (objectDef.attributes.length > 0) {
1337
+ for (const attr of objectDef.attributes) {
1338
+ const dbAttr = await this.adapter.attributes.create({
1339
+ objectId: dbObject.id,
1340
+ name: attr.name,
1341
+ label: attr.label,
1342
+ type: attr.type,
1343
+ required: attr.required ?? false,
1344
+ system: false,
1345
+ // Always false for custom attributes
1346
+ config: {
1347
+ ...attr,
1348
+ // Remove common fields stored in columns
1349
+ id: void 0,
1350
+ name: void 0,
1351
+ label: void 0,
1352
+ type: void 0,
1353
+ required: void 0,
1354
+ system: void 0
1355
+ }
1356
+ });
1357
+ createdAttributes.push(this.convertDBAttributeToAttribute(dbAttr));
1358
+ }
1359
+ }
1360
+ return {
1361
+ ...objectDef,
1362
+ id: dbObject.id,
1363
+ attributes: createdAttributes,
1364
+ system: false
1365
+ };
1366
+ }
1367
+ /**
1368
+ * Add a custom attribute to an existing object
1369
+ * Can be used on both custom and native objects
1370
+ * Attributes added via API are always custom (system=false)
1371
+ *
1372
+ * @param objectId - Object UUID from database
1373
+ * @param attribute - Attribute definition
1374
+ * @returns Created Attribute
1375
+ */
1376
+ async addAttributeToObject(objectId, attribute) {
1377
+ this.validateAttributeName(attribute.name);
1378
+ const dbObject = await this.adapter.objects.findById(objectId);
1379
+ if (!dbObject) {
1380
+ throw new Error(`Object with id "${objectId}" not found`);
1381
+ }
1382
+ const existingAttributes = await this.adapter.attributes.findByObjectId(objectId);
1383
+ const duplicate = existingAttributes.find((attr) => attr.name === attribute.name);
1384
+ if (duplicate) {
1385
+ throw new Error(
1386
+ `Attribute with name "${attribute.name}" already exists on object "${dbObject.name}"`
1387
+ );
1388
+ }
1389
+ const dbAttr = await this.adapter.attributes.create({
1390
+ objectId,
1391
+ name: attribute.name,
1392
+ label: attribute.label,
1393
+ type: attribute.type,
1394
+ required: attribute.required ?? false,
1395
+ unique: attribute.unique ?? false,
1396
+ system: false,
1397
+ // Always false for attributes added via API
1398
+ config: {
1399
+ // Store all extra properties in config
1400
+ ...attribute,
1401
+ // Remove common fields stored in columns
1402
+ name: void 0,
1403
+ label: void 0,
1404
+ type: void 0,
1405
+ required: void 0,
1406
+ unique: void 0,
1407
+ system: void 0
1408
+ }
1409
+ });
1410
+ return this.convertDBAttributeToAttribute(dbAttr);
1411
+ }
1412
+ /**
1413
+ * Update an attribute
1414
+ * Can only update custom attributes (system=false)
1415
+ *
1416
+ * @param attributeId - Attribute UUID
1417
+ * @param updates - Partial attribute updates
1418
+ * @returns Updated Attribute
1419
+ */
1420
+ async updateAttribute(attributeId, updates) {
1421
+ const dbAttr = await this.adapter.attributes.findById(attributeId);
1422
+ if (!dbAttr) {
1423
+ throw new Error(`Attribute with id "${attributeId}" not found`);
1424
+ }
1425
+ if (dbAttr.system) {
1426
+ throw new Error(
1427
+ `Cannot modify system attribute "${dbAttr.name}". System attributes are protected.`
1428
+ );
1429
+ }
1430
+ if (updates.name && updates.name !== dbAttr.name) {
1431
+ throw new Error(
1432
+ "Attribute name cannot be changed after creation. Create a new attribute instead."
1433
+ );
1434
+ }
1435
+ if (updates.type && updates.type !== dbAttr.type) {
1436
+ throw new Error(
1437
+ "Attribute type cannot be changed after creation. Create a new attribute instead."
1438
+ );
1439
+ }
1440
+ const updatedDbAttr = await this.adapter.attributes.update(attributeId, {
1441
+ label: updates.label,
1442
+ required: updates.required,
1443
+ config: updates ? {
1444
+ ...dbAttr.config,
1445
+ ...updates,
1446
+ // Remove common fields
1447
+ name: void 0,
1448
+ label: void 0,
1449
+ type: void 0,
1450
+ required: void 0,
1451
+ unique: void 0,
1452
+ system: void 0
1453
+ } : dbAttr.config
1454
+ });
1455
+ return this.convertDBAttributeToAttribute(updatedDbAttr);
1456
+ }
1457
+ /**
1458
+ * Delete an attribute
1459
+ * Can only delete custom attributes (system=false)
1460
+ *
1461
+ * @param attributeId - Attribute UUID
1462
+ */
1463
+ async deleteAttribute(attributeId) {
1464
+ const dbAttr = await this.adapter.attributes.findById(attributeId);
1465
+ if (!dbAttr) {
1466
+ throw new Error(`Attribute with id "${attributeId}" not found`);
1467
+ }
1468
+ if (dbAttr.system) {
1469
+ throw new Error(
1470
+ `Cannot delete system attribute "${dbAttr.name}". System attributes are protected.`
1471
+ );
1472
+ }
1473
+ await this.adapter.attributes.delete(attributeId);
1474
+ }
1475
+ /**
1476
+ * List attributes for an object
1477
+ *
1478
+ * @param objectId - Object UUID
1479
+ * @param options - Filter options
1480
+ * @returns List of attributes
1481
+ */
1482
+ async listAttributes(objectId, options) {
1483
+ const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
1484
+ let filtered = dbAttributes;
1485
+ if (options?.systemOnly) {
1486
+ filtered = dbAttributes.filter((attr) => attr.system);
1487
+ } else if (options?.customOnly) {
1488
+ filtered = dbAttributes.filter((attr) => !attr.system);
1489
+ }
1490
+ return filtered.map((attr) => this.convertDBAttributeToAttribute(attr));
1491
+ }
1492
+ /**
1493
+ * Validate attribute name format (variable identifier)
1494
+ * @internal
1495
+ */
1496
+ validateAttributeName(name) {
1497
+ const variableNameRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
1498
+ if (!name || name.length === 0) {
1499
+ throw new Error("Attribute name cannot be empty");
1500
+ }
1501
+ if (name.length > 63) {
1502
+ throw new Error("Attribute name is too long (max 63 characters)");
1503
+ }
1504
+ if (!variableNameRegex.test(name)) {
1505
+ throw new Error(
1506
+ "Invalid attribute name format.\nName must be a valid variable identifier:\n \u2705 Valid: 'firstName', 'first_name', 'FirstName', 'FIRST_NAME'\n \u274C Invalid: 'first-name', 'first name', '123name', 'first.name'"
1507
+ );
1508
+ }
1509
+ }
1510
+ /**
1511
+ * Get complete object schema (system + custom attributes)
1512
+ * If object is native, merges registry definition with DB custom attributes
1513
+ * If object is custom, returns DB definition only
1514
+ *
1515
+ * @param objectId - Object UUID from database
1516
+ * @returns Complete ObjectDefinition with all attributes
1517
+ *
1518
+ * @example
1519
+ * ```typescript
1520
+ * const service = new ObjectSchemaService(adapter, registry);
1521
+ * const productSchema = await service.getObjectSchema("obj-123");
1522
+ *
1523
+ * console.log(productSchema.attributes); // System + custom attributes
1524
+ * ```
1525
+ */
1526
+ async getObjectSchema(objectId) {
1527
+ const dbObject = await this.adapter.objects.findById(objectId);
1528
+ if (!dbObject) {
1529
+ throw new Error(`Object with id "${objectId}" not found`);
1530
+ }
1531
+ const dbAttributes = await this.adapter.attributes.findByObjectId(objectId);
1532
+ if (dbObject.system) {
1533
+ return this.mergeNativeObject(dbObject, dbAttributes);
1534
+ }
1535
+ return this.convertDBObjectToDefinition(dbObject, dbAttributes);
1536
+ }
1537
+ /**
1538
+ * Get object schema by name (for system/native objects)
1539
+ */
1540
+ async getObjectSchemaByName(name) {
1541
+ const dbObject = await this.adapter.objects.findSystemByName(name);
1542
+ if (!dbObject) {
1543
+ throw new Error(`Native object "${name}" not found in database`);
1544
+ }
1545
+ const dbAttributes = await this.adapter.attributes.findByObjectId(dbObject.id);
1546
+ return this.mergeNativeObject(dbObject, dbAttributes);
1547
+ }
1548
+ /**
1549
+ * List all object schemas for a tenant
1550
+ */
1551
+ async listObjectSchemas(tenantId) {
1552
+ const dbObjects = await this.adapter.objects.list(tenantId);
1553
+ const schemas = await Promise.all(
1554
+ dbObjects.map(async (dbObject) => {
1555
+ const dbAttributes = await this.adapter.attributes.findByObjectId(dbObject.id);
1556
+ if (dbObject.system) {
1557
+ return this.mergeNativeObject(dbObject, dbAttributes);
1558
+ }
1559
+ return this.convertDBObjectToDefinition(dbObject, dbAttributes);
1560
+ })
1561
+ );
1562
+ return schemas;
1563
+ }
1564
+ /**
1565
+ * Merge native object from registry with custom attributes from DB
1566
+ * @internal
1567
+ */
1568
+ mergeNativeObject(dbObject, dbAttributes) {
1569
+ const nativeObject = this.nativeRegistry.getByName(dbObject.name);
1570
+ if (!nativeObject) {
1571
+ throw new Error(
1572
+ `Native object "${dbObject.name}" not found in registry. Make sure to register it before querying.`
1573
+ );
1574
+ }
1575
+ const customAttributes = dbAttributes.filter((attr) => !attr.system);
1576
+ const customAttrs = customAttributes.map(
1577
+ (dbAttr) => this.convertDBAttributeToAttribute(dbAttr)
1578
+ );
1579
+ return {
1580
+ ...nativeObject,
1581
+ id: dbObject.id,
1582
+ attributes: [
1583
+ ...nativeObject.attributes,
1584
+ // System attributes from code
1585
+ ...customAttrs
1586
+ // Custom attributes from DB
1587
+ ]
1588
+ };
1589
+ }
1590
+ /**
1591
+ * Convert DB object + attributes to ObjectDefinition
1592
+ * @internal
1593
+ */
1594
+ convertDBObjectToDefinition(dbObject, dbAttributes) {
1595
+ const attributes = dbAttributes.map(
1596
+ (dbAttr) => this.convertDBAttributeToAttribute(dbAttr)
1597
+ );
1598
+ return {
1599
+ id: dbObject.id,
1600
+ name: dbObject.name,
1601
+ label: dbObject.label,
1602
+ description: dbObject.description,
1603
+ icon: dbObject.metadata?.icon,
1604
+ attributes,
1605
+ system: dbObject.system,
1606
+ metadata: dbObject.metadata
1607
+ };
1608
+ }
1609
+ /**
1610
+ * Convert DB attribute to Attribute type
1611
+ * @internal
1612
+ */
1613
+ convertDBAttributeToAttribute(dbAttr) {
1614
+ const baseAttr = {
1615
+ ...dbAttr.config,
1616
+ id: dbAttr.id,
1617
+ name: dbAttr.name,
1618
+ label: dbAttr.label,
1619
+ type: dbAttr.type,
1620
+ required: dbAttr.required,
1621
+ system: dbAttr.system,
1622
+ unique: dbAttr.unique
1623
+ };
1624
+ return baseAttr;
1625
+ }
1626
+ };
1627
+
1628
+ // src/native/registry.ts
1629
+ var NativeObjectRegistryClass = class {
1630
+ constructor() {
1631
+ this.objects = /* @__PURE__ */ new Map();
1632
+ }
1633
+ /**
1634
+ * Register one or more native objects
1635
+ * Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
1636
+ * @param objects - Single object/builder or array of objects/builders to register
1637
+ * @returns this (for chaining)
1638
+ * @throws Error if object is invalid or already registered
1639
+ *
1640
+ * @example
1641
+ * ```typescript
1642
+ * // No .build() needed - registry auto-builds!
1643
+ * const PRODUCT = object({ id: "obj-product", name: "products", label: "Product" })
1644
+ * .system()
1645
+ * .attribute(text({ id: "attr-name", name: "name", label: "Name" }));
1646
+ *
1647
+ * registry.register(PRODUCT); // ← Auto-builds here
1648
+ *
1649
+ * // Can still explicitly .build() if you want
1650
+ * registry.register(PRODUCT.build());
1651
+ *
1652
+ * // Register multiple
1653
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1654
+ * ```
1655
+ */
1656
+ register(objects) {
1657
+ const objectsArray = Array.isArray(objects) ? objects : [objects];
1658
+ for (const obj of objectsArray) {
1659
+ const object2 = "build" in obj && typeof obj.build === "function" ? obj.build() : obj;
1660
+ this.validateAndRegister(object2);
1661
+ }
1662
+ return this;
1663
+ }
1664
+ /**
1665
+ * Validate and register a single object
1666
+ * @internal
1667
+ */
1668
+ validateAndRegister(object2) {
1669
+ if (!object2.system) {
1670
+ throw new Error(
1671
+ `[NativeObjectRegistry] Cannot register object "${object2.name}" (id: ${object2.id}): missing system flag.
1672
+ Native objects must have system=true. Did you forget to call .system() in your builder?`
1673
+ );
1674
+ }
1675
+ if (this.objects.has(object2.name)) {
1676
+ const existing = this.objects.get(object2.name);
1677
+ throw new Error(
1678
+ `[NativeObjectRegistry] Duplicate object name "${object2.name}":
1679
+ - Existing: "${existing?.label}" (id: ${existing?.id})
1680
+ - New: "${object2.label}" (id: ${object2.id})
1681
+ Please use unique names for each native object.`
1682
+ );
1683
+ }
1684
+ this.objects.set(object2.name, object2);
1685
+ }
1686
+ /**
1687
+ * Get a native object by its name
1688
+ * @param name - The object name
1689
+ * @returns The object definition or undefined if not found
1690
+ *
1691
+ * @example
1692
+ * ```typescript
1693
+ * const product = registry.getByName("products");
1694
+ * if (product) {
1695
+ * console.log(product.label); // "Product"
1696
+ * }
1697
+ * ```
1698
+ */
1699
+ getByName(name) {
1700
+ return this.objects.get(name);
1701
+ }
1702
+ /**
1703
+ * Get a native object or throw if not found
1704
+ * @param name - The object name
1705
+ * @returns The object definition
1706
+ * @throws Error if not found
1707
+ */
1708
+ getByNameOrThrow(name) {
1709
+ const object2 = this.objects.get(name);
1710
+ if (!object2) {
1711
+ throw new Error(
1712
+ `[NativeObjectRegistry] Native object "${name}" not found.
1713
+ Available objects: ${this.listNames().join(", ")}`
1714
+ );
1715
+ }
1716
+ return object2;
1717
+ }
1718
+ /**
1719
+ * Get all registered native objects
1720
+ * @returns Array of all registered object definitions
1721
+ */
1722
+ getAll() {
1723
+ return Array.from(this.objects.values());
1724
+ }
1725
+ /**
1726
+ * Get all registered native object names
1727
+ * @returns Array of object names
1728
+ */
1729
+ listNames() {
1730
+ return Array.from(this.objects.keys());
1731
+ }
1732
+ /**
1733
+ * Check if a native object is registered
1734
+ * @param name - The object name
1735
+ * @returns true if registered, false otherwise
1736
+ */
1737
+ has(name) {
1738
+ return this.objects.has(name);
1739
+ }
1740
+ /**
1741
+ * Get the number of registered objects
1742
+ */
1743
+ get size() {
1744
+ return this.objects.size;
1745
+ }
1746
+ /**
1747
+ * Clear all registered objects (useful for testing)
1748
+ * @internal
1749
+ */
1750
+ clear() {
1751
+ this.objects.clear();
1752
+ }
1753
+ /**
1754
+ * Get registry summary for debugging
1755
+ */
1756
+ summary() {
1757
+ const objects = this.getAll();
1758
+ return [
1759
+ `[NativeObjectRegistry] ${this.size} native object(s) registered:`,
1760
+ ...objects.map(
1761
+ (obj) => ` - ${obj.name}: "${obj.label}" (${obj.attributes.length} attributes)`
1762
+ )
1763
+ ].join("\n");
1764
+ }
1765
+ /**
1766
+ * Log registry summary to console
1767
+ */
1768
+ debug() {
1769
+ console.info(this.summary());
1770
+ }
1771
+ };
1772
+ var registry = new NativeObjectRegistryClass();
1773
+
1774
+ // src/validation/validators.ts
1775
+ import { z as z3 } from "zod";
1776
+ function createTextValidator(attr) {
1777
+ let schema = z3.string();
1778
+ if (attr.minLength !== void 0) {
1779
+ schema = schema.min(
1780
+ attr.minLength,
1781
+ `${attr.label} must be at least ${attr.minLength} characters`
1782
+ );
1783
+ }
1784
+ if (attr.maxLength !== void 0) {
1785
+ schema = schema.max(
1786
+ attr.maxLength,
1787
+ `${attr.label} must be at most ${attr.maxLength} characters`
1788
+ );
1789
+ }
1790
+ if (attr.pattern) {
1791
+ schema = schema.regex(new RegExp(attr.pattern), `${attr.label} format is invalid`);
1792
+ }
1793
+ return schema;
1794
+ }
1795
+ function createNumberValidator(attr) {
1796
+ let schema = z3.number();
1797
+ if (attr.min !== void 0) {
1798
+ schema = schema.min(attr.min, `${attr.label} must be at least ${attr.min}`);
1799
+ }
1800
+ if (attr.max !== void 0) {
1801
+ schema = schema.max(attr.max, `${attr.label} must be at most ${attr.max}`);
1802
+ }
1803
+ if (attr.unit === "integer") {
1804
+ schema = schema.int(`${attr.label} must be an integer`);
1805
+ }
1806
+ return schema;
1807
+ }
1808
+ function createCheckboxValidator(_attr) {
1809
+ return z3.boolean();
1810
+ }
1811
+ function createDateValidator(attr) {
1812
+ return z3.string().datetime({ message: `${attr.label} must be a valid ISO date` });
1813
+ }
1814
+ function createPhoneValidator(_attr) {
1815
+ return z3.object({
1816
+ countryCode: z3.string().length(3),
1817
+ phoneNumber: z3.string().min(1)
1818
+ });
1819
+ }
1820
+ function createCurrencyValidator(_attr) {
1821
+ return z3.object({
1822
+ code: z3.string().length(3),
1823
+ value: z3.number().min(0)
1824
+ });
1825
+ }
1826
+ function createStatusValidator(attr) {
1827
+ const validValues = attr.options.map((opt) => opt.value);
1828
+ return z3.enum(validValues, {
1829
+ errorMap: () => ({
1830
+ message: `${attr.label} must be one of: ${validValues.join(", ")}`
1831
+ })
1832
+ });
1833
+ }
1834
+ function createSelectValidator(attr) {
1835
+ const validValues = attr.options.map((opt) => opt.value);
1836
+ return z3.enum(validValues, {
1837
+ errorMap: () => ({
1838
+ message: `${attr.label} must be one of: ${validValues.join(", ")}`
1839
+ })
1840
+ });
1841
+ }
1842
+ function createMultiselectValidator(attr) {
1843
+ const validValues = attr.options.map((opt) => opt.value);
1844
+ return z3.array(
1845
+ z3.enum(validValues, {
1846
+ errorMap: () => ({
1847
+ message: `Each value must be one of: ${validValues.join(", ")}`
1848
+ })
1849
+ })
1850
+ );
1851
+ }
1852
+ function createLocationValidator(_attr) {
1853
+ return z3.object({
1854
+ address: z3.string().optional(),
1855
+ address2: z3.string().optional(),
1856
+ city: z3.string().optional(),
1857
+ state: z3.string().optional(),
1858
+ postalCode: z3.string().optional(),
1859
+ country: z3.string().length(3).optional(),
1860
+ latitude: z3.number().optional(),
1861
+ longitude: z3.number().optional()
1862
+ });
1863
+ }
1864
+ function createTimestampValidator(_attr) {
1865
+ return z3.number().int().positive();
1866
+ }
1867
+ function createFileValidator(_attr) {
1868
+ return z3.string().uuid();
1869
+ }
1870
+ function createUserValidator(_attr) {
1871
+ return z3.string().uuid();
1872
+ }
1873
+ function createRelationValidator(_attr) {
1874
+ return z3.string().uuid();
1875
+ }
1876
+ function createRatingValidator(attr) {
1877
+ let schema = z3.number().int().min(0);
1878
+ if (attr.max !== void 0) {
1879
+ schema = schema.max(attr.max, `${attr.label} must be at most ${attr.max}`);
1880
+ }
1881
+ return schema;
1882
+ }
1883
+ function createAttributeValidator(attr) {
1884
+ switch (attr.type) {
1885
+ case "text":
1886
+ return createTextValidator(attr);
1887
+ case "number":
1888
+ return createNumberValidator(attr);
1889
+ case "checkbox":
1890
+ return createCheckboxValidator(attr);
1891
+ case "date":
1892
+ return createDateValidator(attr);
1893
+ case "phone":
1894
+ return createPhoneValidator(attr);
1895
+ case "currency":
1896
+ return createCurrencyValidator(attr);
1897
+ case "status":
1898
+ return createStatusValidator(attr);
1899
+ case "location":
1900
+ return createLocationValidator(attr);
1901
+ case "timestamp":
1902
+ return createTimestampValidator(attr);
1903
+ case "select":
1904
+ return createSelectValidator(attr);
1905
+ case "multiselect":
1906
+ return createMultiselectValidator(attr);
1907
+ case "file":
1908
+ return createFileValidator(attr);
1909
+ case "user":
1910
+ return createUserValidator(attr);
1911
+ case "relation":
1912
+ return createRelationValidator(attr);
1913
+ case "rating":
1914
+ return createRatingValidator(attr);
1915
+ default:
1916
+ return z3.unknown();
1917
+ }
1918
+ }
1919
+ function createObjectValidator(objectDef) {
1920
+ const shape = {};
1921
+ for (const attr of objectDef.attributes) {
1922
+ let validator = createAttributeValidator(attr);
1923
+ if (!attr.required) {
1924
+ validator = validator.optional();
1925
+ }
1926
+ shape[attr.name] = validator;
1927
+ }
1928
+ return z3.object(shape);
1929
+ }
1930
+ function validateAttribute(attr, value) {
1931
+ const validator = createAttributeValidator(attr);
1932
+ if (!attr.required && (value === void 0 || value === null)) {
1933
+ return { success: true, data: { [attr.name]: value } };
1934
+ }
1935
+ const result = validator.safeParse(value);
1936
+ if (result.success) {
1937
+ return {
1938
+ success: true,
1939
+ data: { [attr.name]: result.data }
1940
+ };
1941
+ }
1942
+ return {
1943
+ success: false,
1944
+ errors: result.error.errors.map((err) => ({
1945
+ path: [attr.name, ...err.path.map(String)],
1946
+ message: err.message
1947
+ }))
1948
+ };
1949
+ }
1950
+ function validateObject(objectDef, data) {
1951
+ const validator = createObjectValidator(objectDef);
1952
+ const result = validator.safeParse(data);
1953
+ if (result.success) {
1954
+ return {
1955
+ success: true,
1956
+ data: result.data
1957
+ };
1958
+ }
1959
+ return {
1960
+ success: false,
1961
+ errors: result.error.errors.map((err) => ({
1962
+ path: err.path.map(String),
1963
+ message: err.message
1964
+ }))
1965
+ };
1966
+ }
1967
+ function validateObjectOrThrow(objectDef, data) {
1968
+ const result = validateObject(objectDef, data);
1969
+ if (!result.success) {
1970
+ const errorMessages = result.errors?.map((err) => `${err.path.join(".")}: ${err.message}`).join("\n") || "Unknown validation error";
1971
+ throw new Error(`Validation failed for ${objectDef.label}:
1972
+ ${errorMessages}`);
1973
+ }
1974
+ return result.data;
1975
+ }
1976
+
1977
+ // src/runtime/services/record.service.ts
1978
+ var RecordService = class {
1979
+ constructor(adapter, tenantId) {
1980
+ this.adapter = adapter;
1981
+ this.tenantId = tenantId;
1982
+ this.schemaService = new ObjectSchemaService(adapter, registry);
1983
+ }
1984
+ /**
1985
+ * Create a new record with validation
1986
+ *
1987
+ * @param objectId - Object UUID
1988
+ * @param data - Record data (attribute values)
1989
+ * @param options - Creation options
1990
+ * @returns Created record
1991
+ *
1992
+ * @example
1993
+ * ```typescript
1994
+ * const service = new RecordService(adapter, "tenant-123");
1995
+ *
1996
+ * const product = await service.createRecord("obj-product", {
1997
+ * name: "Nike Air Max",
1998
+ * price: 129.99,
1999
+ * sku: "NIKE-AM-001"
2000
+ * });
2001
+ * ```
2002
+ */
2003
+ async createRecord(objectId, data, options) {
2004
+ const schema = await this.schemaService.getObjectSchema(objectId);
2005
+ if (options?.validate !== false) {
2006
+ validateObjectOrThrow(schema, data);
2007
+ }
2008
+ const record = await this.adapter.objectRecords.create({
2009
+ tenantId: this.tenantId,
2010
+ objectId,
2011
+ data
2012
+ });
2013
+ return record;
2014
+ }
2015
+ /**
2016
+ * Get a record by ID
2017
+ *
2018
+ * @param recordId - Record UUID
2019
+ * @param options - Query options
2020
+ * @returns Record or null if not found
2021
+ */
2022
+ async getRecord(recordId, options) {
2023
+ const record = await this.adapter.objectRecords.findById(recordId);
2024
+ if (!record) {
2025
+ return null;
2026
+ }
2027
+ if (options?.includeSchema) {
2028
+ const schema = await this.schemaService.getObjectSchema(record.objectId);
2029
+ const recordWithSchema = record;
2030
+ recordWithSchema.schema = schema;
2031
+ return recordWithSchema;
2032
+ }
2033
+ return record;
2034
+ }
2035
+ /**
2036
+ * Get a record by ID or throw if not found
2037
+ */
2038
+ async getRecordOrThrow(recordId) {
2039
+ const record = await this.getRecord(recordId);
2040
+ if (!record) {
2041
+ throw new Error(`Record with id "${recordId}" not found`);
2042
+ }
2043
+ return record;
2044
+ }
2045
+ /**
2046
+ * Update a record with validation
2047
+ *
2048
+ * @param recordId - Record UUID
2049
+ * @param data - Partial data to update
2050
+ * @param options - Update options
2051
+ * @returns Updated record
2052
+ */
2053
+ async updateRecord(recordId, data, options) {
2054
+ const existing = await this.getRecordOrThrow(recordId);
2055
+ const schema = await this.schemaService.getObjectSchema(existing.objectId);
2056
+ const mergedData = { ...existing.values, ...data };
2057
+ if (options?.validate !== false && !options?.partial) {
2058
+ validateObjectOrThrow(schema, mergedData);
2059
+ }
2060
+ const updated = await this.adapter.objectRecords.update(recordId, data);
2061
+ return updated;
2062
+ }
2063
+ /**
2064
+ * Delete a record
2065
+ *
2066
+ * @param recordId - Record UUID
2067
+ * @param options - Delete options
2068
+ */
2069
+ async deleteRecord(recordId, options) {
2070
+ if (options?.checkSystem) {
2071
+ const record = await this.getRecordOrThrow(recordId);
2072
+ const schema = await this.schemaService.getObjectSchema(record.objectId);
2073
+ if (schema.system) {
2074
+ throw new Error(`Cannot delete record of system object "${schema.label}"`);
2075
+ }
2076
+ }
2077
+ await this.adapter.objectRecords.delete(recordId);
2078
+ }
2079
+ /**
2080
+ * List records for an object with pagination
2081
+ *
2082
+ * @param objectId - Object UUID
2083
+ * @param options - List options
2084
+ * @returns Records and total count
2085
+ */
2086
+ async listRecords(objectId, options) {
2087
+ return await this.adapter.objectRecords.list(this.tenantId, objectId, options);
2088
+ }
2089
+ /**
2090
+ * Search records using full-text search
2091
+ *
2092
+ * @param objectId - Object UUID
2093
+ * @param query - Search query
2094
+ * @param options - Search options
2095
+ * @returns Matching records and total count
2096
+ */
2097
+ async searchRecords(objectId, query, options) {
2098
+ return await this.adapter.objectRecords.search(this.tenantId, objectId, query, options);
2099
+ }
2100
+ /**
2101
+ * Validate data against object schema without saving
2102
+ *
2103
+ * @param objectId - Object UUID
2104
+ * @param data - Data to validate
2105
+ * @returns Validation result
2106
+ */
2107
+ async validateData(objectId, data) {
2108
+ const schema = await this.schemaService.getObjectSchema(objectId);
2109
+ return validateObject(schema, data);
2110
+ }
2111
+ };
2112
+
2113
+ // src/runtime/services/user-profile.service.ts
2114
+ var UserProfileService = class {
2115
+ constructor(adapter, tenantId) {
2116
+ this.adapter = adapter;
2117
+ this.tenantId = tenantId;
2118
+ }
2119
+ /**
2120
+ * Create a new user profile (typically after first auth)
2121
+ *
2122
+ * @param data - User profile creation data
2123
+ * @returns Created user profile
2124
+ *
2125
+ * @example
2126
+ * ```typescript
2127
+ * const service = new UserProfileService(adapter, "tenant-123");
2128
+ *
2129
+ * // After Supabase auth
2130
+ * const profile = await service.createProfile({
2131
+ * tenantId: "tenant-123",
2132
+ * authId: authUser.id,
2133
+ * email: authUser.email,
2134
+ * firstName: authUser.user_metadata.first_name,
2135
+ * lastName: authUser.user_metadata.last_name,
2136
+ * role: "member",
2137
+ * status: "active"
2138
+ * });
2139
+ * ```
2140
+ */
2141
+ async createProfile(data) {
2142
+ if (data.tenantId !== this.tenantId) {
2143
+ throw new Error(
2144
+ `Tenant mismatch: service initialized with "${this.tenantId}" but data has "${data.tenantId}"`
2145
+ );
2146
+ }
2147
+ const existing = await this.adapter.userProfiles.findByAuthId(data.authId);
2148
+ if (existing) {
2149
+ throw new Error(`User profile with authId "${data.authId}" already exists`);
2150
+ }
2151
+ const existingEmail = await this.adapter.userProfiles.findByEmail(this.tenantId, data.email);
2152
+ if (existingEmail) {
2153
+ throw new Error(`User profile with email "${data.email}" already exists in this tenant`);
2154
+ }
2155
+ return await this.adapter.userProfiles.create(data);
2156
+ }
2157
+ /**
2158
+ * Get user profile by ID
2159
+ */
2160
+ async getProfile(profileId) {
2161
+ return await this.adapter.userProfiles.findById(profileId);
2162
+ }
2163
+ /**
2164
+ * Get user profile by ID or throw
2165
+ */
2166
+ async getProfileOrThrow(profileId) {
2167
+ const profile = await this.getProfile(profileId);
2168
+ if (!profile) {
2169
+ throw new Error(`User profile with id "${profileId}" not found`);
2170
+ }
2171
+ return profile;
2172
+ }
2173
+ /**
2174
+ * Get user profile by auth provider ID
2175
+ *
2176
+ * @param authId - Auth provider user ID (Supabase, Clerk, etc.)
2177
+ * @returns User profile or null
2178
+ */
2179
+ async getProfileByAuthId(authId) {
2180
+ return await this.adapter.userProfiles.findByAuthId(authId);
2181
+ }
2182
+ /**
2183
+ * Get or create user profile (idempotent operation)
2184
+ * Useful for auth callbacks - ensures profile exists
2185
+ *
2186
+ * @param authId - Auth provider user ID
2187
+ * @param data - Profile data to create if doesn't exist
2188
+ * @returns Existing or newly created profile
2189
+ *
2190
+ * @example
2191
+ * ```typescript
2192
+ * // In Supabase auth callback
2193
+ * const profile = await service.getOrCreateProfile(
2194
+ * authUser.id,
2195
+ * {
2196
+ * tenantId: "tenant-123",
2197
+ * authId: authUser.id,
2198
+ * email: authUser.email,
2199
+ * role: "member",
2200
+ * status: "active"
2201
+ * }
2202
+ * );
2203
+ * ```
2204
+ */
2205
+ async getOrCreateProfile(authId, data) {
2206
+ const existing = await this.getProfileByAuthId(authId);
2207
+ if (existing) {
2208
+ return existing;
2209
+ }
2210
+ return await this.createProfile(data);
2211
+ }
2212
+ /**
2213
+ * Update user profile
2214
+ */
2215
+ async updateProfile(profileId, data) {
2216
+ await this.getProfileOrThrow(profileId);
2217
+ return await this.adapter.userProfiles.update(profileId, data);
2218
+ }
2219
+ /**
2220
+ * Delete user profile
2221
+ *
2222
+ * @param profileId - Profile UUID
2223
+ * @param options - Delete options
2224
+ */
2225
+ async deleteProfile(profileId, options) {
2226
+ if (options?.checkAdmin) {
2227
+ const profile = await this.getProfileOrThrow(profileId);
2228
+ if (profile.role === "admin") {
2229
+ const allProfiles = await this.listProfiles();
2230
+ const adminCount = allProfiles.filter((p) => p.role === "admin").length;
2231
+ if (adminCount <= 1) {
2232
+ throw new Error("Cannot delete the last admin user");
2233
+ }
2234
+ }
2235
+ }
2236
+ await this.adapter.userProfiles.delete(profileId);
2237
+ }
2238
+ /**
2239
+ * List all user profiles for the tenant
2240
+ */
2241
+ async listProfiles(options) {
2242
+ return await this.adapter.userProfiles.list(this.tenantId, options);
2243
+ }
2244
+ /**
2245
+ * Update last login timestamp
2246
+ *
2247
+ * @param profileId - Profile UUID
2248
+ *
2249
+ * @example
2250
+ * ```typescript
2251
+ * // After successful auth
2252
+ * await service.updateLastLogin(profile.id);
2253
+ * ```
2254
+ */
2255
+ async updateLastLogin(profileId) {
2256
+ await this.adapter.userProfiles.updateLastLogin(profileId);
2257
+ }
2258
+ /**
2259
+ * Change user role
2260
+ *
2261
+ * @param profileId - Profile UUID
2262
+ * @param newRole - New role
2263
+ */
2264
+ async changeRole(profileId, newRole) {
2265
+ return await this.updateProfile(profileId, { role: newRole });
2266
+ }
2267
+ /**
2268
+ * Change user status
2269
+ *
2270
+ * @param profileId - Profile UUID
2271
+ * @param newStatus - New status
2272
+ */
2273
+ async changeStatus(profileId, newStatus) {
2274
+ return await this.updateProfile(profileId, { status: newStatus });
2275
+ }
2276
+ /**
2277
+ * Get user by email
2278
+ */
2279
+ async getProfileByEmail(email) {
2280
+ return await this.adapter.userProfiles.findByEmail(this.tenantId, email);
2281
+ }
2282
+ /**
2283
+ * Check if user has role
2284
+ */
2285
+ async hasRole(profileId, role) {
2286
+ const profile = await this.getProfile(profileId);
2287
+ return profile?.role === role;
2288
+ }
2289
+ /**
2290
+ * Check if user is admin
2291
+ */
2292
+ async isAdmin(profileId) {
2293
+ return await this.hasRole(profileId, "admin");
2294
+ }
2295
+ };
2296
+
2297
+ // src/runtime/sync.ts
2298
+ var BASE_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
2299
+ "id",
2300
+ "name",
2301
+ "label",
2302
+ "type",
2303
+ "required",
2304
+ "system",
2305
+ "unique",
2306
+ "order"
2307
+ ]);
2308
+ function extractAttributeConfig(attr) {
2309
+ return Object.fromEntries(
2310
+ Object.entries(attr).filter(
2311
+ ([key, value]) => !BASE_ATTRIBUTE_KEYS.has(key) && value !== void 0
2312
+ )
2313
+ );
2314
+ }
2315
+ async function syncNativeObjects(adapter, nativeRegistry, options = {}) {
2316
+ const result = {
2317
+ success: true,
2318
+ objectsSynced: 0,
2319
+ attributesSynced: 0,
2320
+ objectsCreated: 0,
2321
+ objectsUpdated: 0,
2322
+ attributesCreated: 0,
2323
+ attributesUpdated: 0,
2324
+ attributesDeleted: 0,
2325
+ errors: []
2326
+ };
2327
+ const nativeObjects = nativeRegistry.getAll();
2328
+ if (options.verbose) {
2329
+ console.info(`[SyncService] Starting sync for ${nativeObjects.length} native objects...`);
2330
+ }
2331
+ try {
2332
+ await adapter.transaction(async (tx) => {
2333
+ for (const nativeObject of nativeObjects) {
2334
+ try {
2335
+ await syncSingleObject(tx, nativeObject, result, options);
2336
+ } catch (error) {
2337
+ result.success = false;
2338
+ result.errors.push({
2339
+ objectName: nativeObject.name,
2340
+ error: error instanceof Error ? error.message : String(error)
2341
+ });
2342
+ if (options.verbose) {
2343
+ console.error(`[SyncService] \u2717 Failed to sync ${nativeObject.name}:`, error);
2344
+ }
2345
+ }
2346
+ }
2347
+ });
2348
+ } catch (error) {
2349
+ result.success = false;
2350
+ result.errors.push({
2351
+ objectName: "transaction",
2352
+ error: error instanceof Error ? error.message : String(error)
2353
+ });
2354
+ }
2355
+ if (options.verbose) {
2356
+ console.info(
2357
+ `[SyncService] ${result.success ? "\u2713" : "\u2717"} Sync complete:
2358
+ Objects: ${result.objectsCreated} created, ${result.objectsUpdated} updated
2359
+ Attributes: ${result.attributesCreated} created, ${result.attributesUpdated} updated, ${result.attributesDeleted} deleted
2360
+ Errors: ${result.errors.length}`
2361
+ );
2362
+ }
2363
+ return result;
2364
+ }
2365
+ async function syncSingleObject(adapter, nativeObject, result, options) {
2366
+ if (!nativeObject.system) {
2367
+ throw new Error(`Object ${nativeObject.name} is not marked as system`);
2368
+ }
2369
+ const existingObject = await adapter.objects.findSystemByName(nativeObject.name);
2370
+ const isNew = !existingObject;
2371
+ updateObjectStats(result, isNew);
2372
+ if (options.dryRun) {
2373
+ await handleDryRun(adapter, nativeObject, existingObject, result, options, isNew);
2374
+ return;
2375
+ }
2376
+ const dbObject = await upsertObject(adapter, nativeObject, options);
2377
+ await syncAttributes(adapter, nativeObject, dbObject, existingObject, result);
2378
+ if (!isNew) {
2379
+ await cleanupAttributes(adapter, dbObject.id, nativeObject, result);
2380
+ }
2381
+ logSyncSuccess(nativeObject, options);
2382
+ }
2383
+ function updateObjectStats(result, isNew) {
2384
+ if (isNew) {
2385
+ result.objectsCreated++;
2386
+ } else {
2387
+ result.objectsUpdated++;
2388
+ }
2389
+ result.objectsSynced++;
2390
+ }
2391
+ async function handleDryRun(adapter, nativeObject, existingObject, result, options, isNew) {
2392
+ if (options.verbose) {
2393
+ console.info(`[SyncService] Would ${isNew ? "create" : "update"} object: ${nativeObject.name}`);
2394
+ }
2395
+ for (const attr of nativeObject.attributes) {
2396
+ const existingAttr = existingObject ? await adapter.attributes.findByObjectId(existingObject.id).then((attrs) => attrs.find((a) => a.name === attr.name)) : null;
2397
+ if (existingAttr) {
2398
+ result.attributesUpdated++;
2399
+ } else {
2400
+ result.attributesCreated++;
2401
+ }
2402
+ result.attributesSynced++;
2403
+ }
2404
+ }
2405
+ async function upsertObject(adapter, nativeObject, options) {
2406
+ return await adapter.objects.upsert({
2407
+ tenantId: options.tenantId || "default",
2408
+ system: true,
2409
+ name: nativeObject.name,
2410
+ label: nativeObject.label,
2411
+ description: nativeObject.description,
2412
+ metadata: nativeObject.metadata
2413
+ });
2414
+ }
2415
+ async function syncAttributes(adapter, nativeObject, dbObject, existingObject, result) {
2416
+ for (const [index, attr] of nativeObject.attributes.entries()) {
2417
+ const existingAttr = existingObject ? await adapter.attributes.findByObjectId(dbObject.id).then((attrs) => attrs.find((a) => a.name === attr.name)) : null;
2418
+ await adapter.attributes.upsert({
2419
+ objectId: dbObject.id,
2420
+ name: attr.name,
2421
+ label: attr.label,
2422
+ type: attr.type,
2423
+ system: attr.system ?? true,
2424
+ required: attr.required ?? false,
2425
+ orderIndex: attr.order ?? index,
2426
+ config: extractAttributeConfig(attr)
2427
+ });
2428
+ if (existingAttr) {
2429
+ result.attributesUpdated++;
2430
+ } else {
2431
+ result.attributesCreated++;
2432
+ }
2433
+ result.attributesSynced++;
2434
+ }
2435
+ }
2436
+ async function cleanupAttributes(adapter, objectId, nativeObject, result) {
2437
+ const attributeNames = nativeObject.attributes.map((attr) => attr.name);
2438
+ const deletedCount = await adapter.attributes.deleteByNames(objectId, attributeNames);
2439
+ result.attributesDeleted += deletedCount;
2440
+ }
2441
+ function logSyncSuccess(nativeObject, options) {
2442
+ if (options.verbose) {
2443
+ console.info(
2444
+ `[SyncService] \u2713 Synced ${nativeObject.name}: ${nativeObject.attributes.length} attributes`
2445
+ );
2446
+ }
2447
+ }
2448
+ async function verifyNativeObjectsSync(adapter, nativeRegistry) {
2449
+ const nativeObjects = nativeRegistry.getAll();
2450
+ for (const obj of nativeObjects) {
2451
+ if (!obj.system) continue;
2452
+ const existing = await adapter.objects.findSystemByName(obj.name);
2453
+ if (!existing) {
2454
+ return false;
2455
+ }
2456
+ }
2457
+ return true;
2458
+ }
2459
+ async function getSyncPreview(adapter, nativeRegistry) {
2460
+ return await syncNativeObjects(adapter, nativeRegistry, { dryRun: true });
2461
+ }
2462
+
2463
+ export {
2464
+ generateId,
2465
+ generatePrefixedId,
2466
+ text,
2467
+ textarea,
2468
+ number,
2469
+ checkbox,
2470
+ date,
2471
+ phone,
2472
+ currency,
2473
+ status,
2474
+ select,
2475
+ multiselect,
2476
+ location,
2477
+ timestamp,
2478
+ file,
2479
+ user,
2480
+ relation,
2481
+ rating,
2482
+ ObjectBuilder,
2483
+ object,
2484
+ registry,
2485
+ createTextValidator,
2486
+ createNumberValidator,
2487
+ createCheckboxValidator,
2488
+ createDateValidator,
2489
+ createPhoneValidator,
2490
+ createCurrencyValidator,
2491
+ createStatusValidator,
2492
+ createSelectValidator,
2493
+ createMultiselectValidator,
2494
+ createLocationValidator,
2495
+ createTimestampValidator,
2496
+ createFileValidator,
2497
+ createUserValidator,
2498
+ createRelationValidator,
2499
+ createRatingValidator,
2500
+ createAttributeValidator,
2501
+ createObjectValidator,
2502
+ validateAttribute,
2503
+ validateObject,
2504
+ validateObjectOrThrow,
2505
+ createMockAdapter,
2506
+ FileService,
2507
+ ObjectSchemaService,
2508
+ RecordService,
2509
+ UserProfileService,
2510
+ syncNativeObjects,
2511
+ verifyNativeObjectsSync,
2512
+ getSyncPreview
2513
+ };