@appconda/sdk 1.0.681 → 1.0.685
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.
- package/dist/modules/emploid/schema.d.ts +1106 -21
- package/dist/modules/emploid/schema.js +699 -53
- package/dist/modules/emploid/service.d.ts +101 -15
- package/dist/modules/emploid/service.js +139 -1
- package/dist/modules/emploid/types.d.ts +727 -8
- package/dist/modules/emploid/types.js +1 -1
- package/package.json +1 -1
- package/publish.sh +34 -2
- package/src/modules/emploid/schema.ts +779 -60
- package/src/modules/emploid/service.ts +421 -15
- package/src/modules/emploid/types.ts +816 -9
|
@@ -291,6 +291,35 @@ export const ListAgentFlowsSchema = z.object({
|
|
|
291
291
|
tenantId: z.string()
|
|
292
292
|
});
|
|
293
293
|
|
|
294
|
+
const DataModelAgentFlowNameSchema = z.string().trim().min(1).max(255);
|
|
295
|
+
const DataModelAgentFlowDescriptionSchema = z.string().trim().max(180).nullable().optional();
|
|
296
|
+
|
|
297
|
+
export const CreateDataModelAgentFlowSchema = z.object({
|
|
298
|
+
tenantId: z.string().min(1),
|
|
299
|
+
dataModelId: z.string().min(1),
|
|
300
|
+
name: DataModelAgentFlowNameSchema,
|
|
301
|
+
description: DataModelAgentFlowDescriptionSchema,
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
export const ListDataModelAgentFlowsSchema = z.object({
|
|
305
|
+
tenantId: z.string().min(1),
|
|
306
|
+
dataModelId: z.string().min(1),
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
export const UpdateDataModelAgentFlowSchema = z.object({
|
|
310
|
+
tenantId: z.string().min(1),
|
|
311
|
+
dataModelId: z.string().min(1),
|
|
312
|
+
agentFlowId: z.string().min(1),
|
|
313
|
+
name: DataModelAgentFlowNameSchema,
|
|
314
|
+
description: DataModelAgentFlowDescriptionSchema,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
export const DeleteDataModelAgentFlowSchema = z.object({
|
|
318
|
+
tenantId: z.string().min(1),
|
|
319
|
+
dataModelId: z.string().min(1),
|
|
320
|
+
agentFlowId: z.string().min(1),
|
|
321
|
+
});
|
|
322
|
+
|
|
294
323
|
export const CreateAgentFlowFolderSchema = z.object({
|
|
295
324
|
tenantId: z.string(),
|
|
296
325
|
name: z.string(),
|
|
@@ -1017,6 +1046,12 @@ export const UpdateCollectionSchema = z.object({
|
|
|
1017
1046
|
collectionId: z.string(),
|
|
1018
1047
|
displayName: z.string().optional(),
|
|
1019
1048
|
description: z.string().optional(),
|
|
1049
|
+
// Legacy callers used the same fields under a `data` envelope. The
|
|
1050
|
+
// backend accepts both shapes while direct fields remain canonical.
|
|
1051
|
+
data: z.object({
|
|
1052
|
+
displayName: z.string().optional(),
|
|
1053
|
+
description: z.string().optional(),
|
|
1054
|
+
}).optional(),
|
|
1020
1055
|
});
|
|
1021
1056
|
|
|
1022
1057
|
export const DeleteCollectionSchema = z.object({
|
|
@@ -1252,6 +1287,34 @@ export const EnsureGithubImportCredentialSchema = z.object({
|
|
|
1252
1287
|
tenantId: z.string(),
|
|
1253
1288
|
});
|
|
1254
1289
|
|
|
1290
|
+
const CsvImportInvalidRowPolicySchema = z.enum(["reject", "skip-row", "set-null"]);
|
|
1291
|
+
|
|
1292
|
+
const CsvImportRowRepairSchema = z.object({
|
|
1293
|
+
rowIndex: z.number().int().nonnegative(),
|
|
1294
|
+
fieldId: z.string().min(1),
|
|
1295
|
+
value: z.any(),
|
|
1296
|
+
});
|
|
1297
|
+
|
|
1298
|
+
const CsvImportFieldMappingSchema = z.object({
|
|
1299
|
+
fieldId: z.string().min(1),
|
|
1300
|
+
type: z.string(),
|
|
1301
|
+
displayName: z.string(),
|
|
1302
|
+
name: z.string(),
|
|
1303
|
+
required: z.boolean().optional(),
|
|
1304
|
+
config: z.object({}).catchall(z.any()).optional(),
|
|
1305
|
+
fallbackReason: z.string().optional(),
|
|
1306
|
+
mode: z.enum(["field", "skip", "relation"]).optional(),
|
|
1307
|
+
relation: z.object({
|
|
1308
|
+
targetCollectionId: z.string().min(1),
|
|
1309
|
+
matchFieldName: z.string().min(1),
|
|
1310
|
+
unmatchedPolicy: z.enum(["reject", "ignore", "create"]),
|
|
1311
|
+
cardinality: z.enum(["one", "many"]).optional(),
|
|
1312
|
+
inverseCardinality: z.enum(["one", "many"]).optional(),
|
|
1313
|
+
inverseDisplayName: z.string().optional(),
|
|
1314
|
+
separator: z.string().max(8).optional(),
|
|
1315
|
+
}).optional(),
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1255
1318
|
export const PreviewCsvImportSchema = z.object({
|
|
1256
1319
|
tenantId: z.string(),
|
|
1257
1320
|
fileName: z.string(),
|
|
@@ -1264,7 +1327,10 @@ export const PreviewCsvImportSchema = z.object({
|
|
|
1264
1327
|
index: z.number().int(),
|
|
1265
1328
|
})
|
|
1266
1329
|
).min(1),
|
|
1267
|
-
rows: z.array(z.object({}).catchall(z.any())).optional(),
|
|
1330
|
+
rows: z.array(z.object({}).catchall(z.any())).max(1_000).optional(),
|
|
1331
|
+
fields: z.array(CsvImportFieldMappingSchema).min(1).optional(),
|
|
1332
|
+
rowRepairs: z.array(CsvImportRowRepairSchema).max(10_000).optional(),
|
|
1333
|
+
invalidRowPolicy: CsvImportInvalidRowPolicySchema.optional(),
|
|
1268
1334
|
});
|
|
1269
1335
|
|
|
1270
1336
|
export const ListGmailImportSourcesSchema = z.object({
|
|
@@ -1302,22 +1368,14 @@ export const RunCsvImportSchema = z.object({
|
|
|
1302
1368
|
index: z.number().int(),
|
|
1303
1369
|
})
|
|
1304
1370
|
).min(1),
|
|
1305
|
-
rows: z.array(z.object({}).catchall(z.any())),
|
|
1371
|
+
rows: z.array(z.object({}).catchall(z.any())).max(1_000),
|
|
1306
1372
|
collection: z.object({
|
|
1307
1373
|
collectionKey: z.literal("rows"),
|
|
1308
1374
|
collectionName: z.string(),
|
|
1309
1375
|
collectionDisplayName: z.string(),
|
|
1310
|
-
fields: z.array(
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
type: z.string(),
|
|
1314
|
-
displayName: z.string(),
|
|
1315
|
-
name: z.string(),
|
|
1316
|
-
required: z.boolean().optional(),
|
|
1317
|
-
config: z.object({}).catchall(z.any()).optional(),
|
|
1318
|
-
fallbackReason: z.string().optional(),
|
|
1319
|
-
})
|
|
1320
|
-
).min(1),
|
|
1376
|
+
fields: z.array(CsvImportFieldMappingSchema).min(1),
|
|
1377
|
+
invalidRowPolicy: CsvImportInvalidRowPolicySchema.optional(),
|
|
1378
|
+
rowRepairs: z.array(CsvImportRowRepairSchema).max(10_000).optional(),
|
|
1321
1379
|
}),
|
|
1322
1380
|
});
|
|
1323
1381
|
|
|
@@ -1497,18 +1555,36 @@ export const RunTrelloImportSchema = z.object({
|
|
|
1497
1555
|
).min(1),
|
|
1498
1556
|
});
|
|
1499
1557
|
|
|
1500
|
-
|
|
1558
|
+
const BulkUpdateRecordSchema = z.object({
|
|
1559
|
+
recordId: z.string(),
|
|
1560
|
+
data: z.object({}).catchall(z.any()),
|
|
1561
|
+
});
|
|
1562
|
+
|
|
1563
|
+
const LegacyBulkUpdateRecordSchema = z.object({
|
|
1564
|
+
id: z.string().optional(),
|
|
1565
|
+
recordId: z.string().optional(),
|
|
1566
|
+
data: z.object({}).catchall(z.any()),
|
|
1567
|
+
}).refine((item) => Boolean(item.id || item.recordId), {
|
|
1568
|
+
message: "Each bulk update item must include id or recordId",
|
|
1569
|
+
});
|
|
1570
|
+
|
|
1571
|
+
const BulkUpdateRecordsBaseSchema = z.object({
|
|
1501
1572
|
tenantId: z.string(),
|
|
1502
1573
|
collectionId: z.string(),
|
|
1503
|
-
|
|
1504
|
-
records: z.array(
|
|
1505
|
-
z.object({
|
|
1506
|
-
recordId: z.string(),
|
|
1507
|
-
data: z.object({}).catchall(z.any()),
|
|
1508
|
-
})
|
|
1509
|
-
),
|
|
1574
|
+
actor: z.string().optional(),
|
|
1510
1575
|
});
|
|
1511
1576
|
|
|
1577
|
+
export const BulkUpdateRecordsSchema = z.union([
|
|
1578
|
+
BulkUpdateRecordsBaseSchema.extend({
|
|
1579
|
+
records: z.array(BulkUpdateRecordSchema).min(1),
|
|
1580
|
+
items: z.array(LegacyBulkUpdateRecordSchema).optional(),
|
|
1581
|
+
}),
|
|
1582
|
+
BulkUpdateRecordsBaseSchema.extend({
|
|
1583
|
+
records: z.array(BulkUpdateRecordSchema).optional(),
|
|
1584
|
+
items: z.array(LegacyBulkUpdateRecordSchema).min(1),
|
|
1585
|
+
}),
|
|
1586
|
+
]);
|
|
1587
|
+
|
|
1512
1588
|
export const BulkDeleteRecordsSchema = z.object({
|
|
1513
1589
|
tenantId: z.string(),
|
|
1514
1590
|
collectionId: z.string(),
|
|
@@ -1534,7 +1610,10 @@ export const QueryRecordsSchema = z.object({
|
|
|
1534
1610
|
filter: z.object({}).catchall(z.any()).optional(),
|
|
1535
1611
|
|
|
1536
1612
|
// projection (hangi alanlar gelsin)
|
|
1537
|
-
fields: z.
|
|
1613
|
+
fields: z.union([
|
|
1614
|
+
z.array(z.string()),
|
|
1615
|
+
z.object({}).catchall(z.any()),
|
|
1616
|
+
]).optional(),
|
|
1538
1617
|
|
|
1539
1618
|
// sorting
|
|
1540
1619
|
sort: z.object({}).catchall(z.string()).optional(),
|
|
@@ -1542,15 +1621,26 @@ export const QueryRecordsSchema = z.object({
|
|
|
1542
1621
|
// pagination
|
|
1543
1622
|
limit: z.number().optional(),
|
|
1544
1623
|
offset: z.number().optional(),
|
|
1624
|
+
|
|
1625
|
+
// Compatibility with the original backend action, which expected the
|
|
1626
|
+
// complete query DSL in one parameter.
|
|
1627
|
+
query: z.object({
|
|
1628
|
+
where: z.object({}).catchall(z.any()).optional(),
|
|
1629
|
+
filter: z.object({}).catchall(z.any()).optional(),
|
|
1630
|
+
fields: z.union([
|
|
1631
|
+
z.array(z.string()),
|
|
1632
|
+
z.object({}).catchall(z.any()),
|
|
1633
|
+
]).optional(),
|
|
1634
|
+
sort: z.object({}).catchall(z.string()).optional(),
|
|
1635
|
+
limit: z.number().optional(),
|
|
1636
|
+
offset: z.number().optional(),
|
|
1637
|
+
}).optional(),
|
|
1545
1638
|
});
|
|
1546
1639
|
|
|
1547
|
-
|
|
1640
|
+
const SearchRecordsBaseSchema = z.object({
|
|
1548
1641
|
tenantId: z.string(),
|
|
1549
1642
|
collectionId: z.string(),
|
|
1550
1643
|
|
|
1551
|
-
// arama metni
|
|
1552
|
-
query: z.string(),
|
|
1553
|
-
|
|
1554
1644
|
// opsiyonel: hangi alanlarda aransın
|
|
1555
1645
|
fields: z.array(z.string()).optional(),
|
|
1556
1646
|
|
|
@@ -1565,6 +1655,19 @@ export const SearchRecordsSchema = z.object({
|
|
|
1565
1655
|
offset: z.number().optional(),
|
|
1566
1656
|
});
|
|
1567
1657
|
|
|
1658
|
+
export const SearchRecordsSchema = z.union([
|
|
1659
|
+
SearchRecordsBaseSchema.extend({
|
|
1660
|
+
// Canonical public name.
|
|
1661
|
+
query: z.string().min(1),
|
|
1662
|
+
q: z.string().optional(),
|
|
1663
|
+
}),
|
|
1664
|
+
SearchRecordsBaseSchema.extend({
|
|
1665
|
+
// Compatibility with the original backend action and Agent Flow node.
|
|
1666
|
+
query: z.string().optional(),
|
|
1667
|
+
q: z.string().min(1),
|
|
1668
|
+
}),
|
|
1669
|
+
]);
|
|
1670
|
+
|
|
1568
1671
|
export const CountRecordsSchema = z.object({
|
|
1569
1672
|
tenantId: z.string(),
|
|
1570
1673
|
collectionId: z.string(),
|
|
@@ -1625,6 +1728,56 @@ export const DistinctFieldValuesSchema = z.object({
|
|
|
1625
1728
|
limit: z.number().optional(),
|
|
1626
1729
|
});
|
|
1627
1730
|
|
|
1731
|
+
export const CollectionDerivedConditionSchema = z.object({
|
|
1732
|
+
fieldId: z.string(),
|
|
1733
|
+
fieldName: z.string().optional(),
|
|
1734
|
+
operator: z.enum([
|
|
1735
|
+
"eq", "neq", "contains", "not-contains", "gt", "gte", "lt", "lte",
|
|
1736
|
+
"is-empty", "is-not-empty",
|
|
1737
|
+
]),
|
|
1738
|
+
value: z.unknown().optional(),
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
export const CollectionFieldConfigSchema = z.object({
|
|
1742
|
+
relationFieldId: z.string().optional(),
|
|
1743
|
+
relationFieldName: z.string().optional(),
|
|
1744
|
+
relationId: z.string().optional(),
|
|
1745
|
+
targetCollectionId: z.string().optional(),
|
|
1746
|
+
targetFieldId: z.string().optional(),
|
|
1747
|
+
targetFieldName: z.string().optional(),
|
|
1748
|
+
resultMode: z.enum(["first", "list"]).optional(),
|
|
1749
|
+
operation: z.enum([
|
|
1750
|
+
"count", "count-values", "count-unique", "sum", "average", "min", "max",
|
|
1751
|
+
]).optional(),
|
|
1752
|
+
condition: CollectionDerivedConditionSchema.optional(),
|
|
1753
|
+
maxItems: z.number().int().min(1).max(500).optional(),
|
|
1754
|
+
min: z.number().optional(),
|
|
1755
|
+
max: z.number().optional(),
|
|
1756
|
+
precision: z.number().int().min(0).max(4).optional(),
|
|
1757
|
+
mode: z.enum(["typed", "drawn", "both"]).optional(),
|
|
1758
|
+
source: z.enum(["organization", "users", "employees", "both"]).optional(),
|
|
1759
|
+
includeInactive: z.boolean().optional(),
|
|
1760
|
+
}).catchall(z.any());
|
|
1761
|
+
|
|
1762
|
+
export const CollectionChecklistItemSchema = z.object({
|
|
1763
|
+
id: z.string().min(1).max(128),
|
|
1764
|
+
text: z.string().min(1).max(1000),
|
|
1765
|
+
checked: z.boolean(),
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1768
|
+
export const CollectionSignatureValueSchema = z.object({
|
|
1769
|
+
kind: z.enum(["typed", "drawn"]),
|
|
1770
|
+
value: z.string().min(1),
|
|
1771
|
+
signedAt: z.string().datetime(),
|
|
1772
|
+
signedBy: z.string().min(1),
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
/** Browser/import input. signedAt and signedBy are server-managed output fields. */
|
|
1776
|
+
export const CollectionSignatureInputSchema = CollectionSignatureValueSchema.pick({
|
|
1777
|
+
kind: true,
|
|
1778
|
+
value: true,
|
|
1779
|
+
});
|
|
1780
|
+
|
|
1628
1781
|
export const CreateCollectionFieldSchema = z.object({
|
|
1629
1782
|
tenantId: z.string(),
|
|
1630
1783
|
dataModelId: z.string(),
|
|
@@ -1636,7 +1789,7 @@ export const CreateCollectionFieldSchema = z.object({
|
|
|
1636
1789
|
required: z.boolean().optional(),
|
|
1637
1790
|
|
|
1638
1791
|
// field-specific config (min, max, enum, format, relation, etc.)
|
|
1639
|
-
config:
|
|
1792
|
+
config: CollectionFieldConfigSchema.optional(),
|
|
1640
1793
|
|
|
1641
1794
|
// opsiyonel sıralama
|
|
1642
1795
|
order: z.number().optional(),
|
|
@@ -1653,7 +1806,7 @@ export const UpdateCollectionFieldSchema = z.object({
|
|
|
1653
1806
|
required: z.boolean().optional(),
|
|
1654
1807
|
|
|
1655
1808
|
// field-specific config (min, max, enum, relation vb.)
|
|
1656
|
-
config:
|
|
1809
|
+
config: CollectionFieldConfigSchema.optional(),
|
|
1657
1810
|
|
|
1658
1811
|
// opsiyonel sıralama
|
|
1659
1812
|
order: z.number().optional(),
|
|
@@ -1673,6 +1826,9 @@ export const ListCollectionAutomationRulesSchema = z.object({
|
|
|
1673
1826
|
|
|
1674
1827
|
const CollectionAutomationRuleTriggerConfigSchema = z.object({
|
|
1675
1828
|
updatedFieldId: z.string().nullable().optional(),
|
|
1829
|
+
cron: z.string().max(191).nullable().optional(),
|
|
1830
|
+
timezone: z.string().max(64).nullable().optional(),
|
|
1831
|
+
maxRecords: z.number().int().min(1).max(100).optional(),
|
|
1676
1832
|
});
|
|
1677
1833
|
|
|
1678
1834
|
const CollectionAutomationRuleConditionSchema = z.object({
|
|
@@ -1682,6 +1838,40 @@ const CollectionAutomationRuleConditionSchema = z.object({
|
|
|
1682
1838
|
value: z.union([z.string(), z.array(z.string()), z.boolean(), z.null()]).optional(),
|
|
1683
1839
|
});
|
|
1684
1840
|
|
|
1841
|
+
const CollectionAutomationRuleActionSchema: z.ZodType<Record<string, unknown>> = z.lazy(() => z.object({
|
|
1842
|
+
id: z.string().min(1),
|
|
1843
|
+
type: z.enum([
|
|
1844
|
+
"create", "update", "delete", "append-description", "script",
|
|
1845
|
+
"conditional-branch", "find-records", "for-each", "copy-record",
|
|
1846
|
+
"move-record", "webhook", "approval",
|
|
1847
|
+
]).nullable(),
|
|
1848
|
+
fieldId: z.string().nullable().optional(),
|
|
1849
|
+
value: z.string().optional(),
|
|
1850
|
+
valueMode: z.enum(["literal", "formula"]).optional(),
|
|
1851
|
+
formula: z.string().optional(),
|
|
1852
|
+
template: z.string().optional(),
|
|
1853
|
+
script: z.string().optional(),
|
|
1854
|
+
condition: CollectionAutomationRuleConditionSchema.nullable().optional(),
|
|
1855
|
+
thenActions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1856
|
+
elseActions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1857
|
+
collectionId: z.string().nullable().optional(),
|
|
1858
|
+
filters: z.array(CollectionAutomationRuleConditionSchema).max(25).optional(),
|
|
1859
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
1860
|
+
resultKey: z.string().max(80).optional(),
|
|
1861
|
+
sourceKey: z.string().max(80).optional(),
|
|
1862
|
+
maxIterations: z.number().int().min(1).max(50).optional(),
|
|
1863
|
+
actions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1864
|
+
targetCollectionId: z.string().nullable().optional(),
|
|
1865
|
+
fieldMap: z.record(z.string(), z.string()).optional(),
|
|
1866
|
+
url: z.string().max(2048).optional(),
|
|
1867
|
+
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).optional(),
|
|
1868
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
1869
|
+
body: z.unknown().optional(),
|
|
1870
|
+
timeoutMs: z.number().int().min(1).max(10_000).optional(),
|
|
1871
|
+
approverIds: z.array(z.string()).max(25).optional(),
|
|
1872
|
+
approvalMessage: z.string().max(2_000).optional(),
|
|
1873
|
+
}));
|
|
1874
|
+
|
|
1685
1875
|
export const CreateCollectionAutomationRuleSchema = z.object({
|
|
1686
1876
|
tenantId: z.string(),
|
|
1687
1877
|
dataModelId: z.string(),
|
|
@@ -1692,7 +1882,7 @@ export const CreateCollectionAutomationRuleSchema = z.object({
|
|
|
1692
1882
|
trigger: z.enum(["created", "updated", "linked", "unlinked", "schedule"]),
|
|
1693
1883
|
triggerConfig: CollectionAutomationRuleTriggerConfigSchema.nullable().optional(),
|
|
1694
1884
|
conditions: z.array(CollectionAutomationRuleConditionSchema).optional(),
|
|
1695
|
-
actions: z.array(
|
|
1885
|
+
actions: z.array(CollectionAutomationRuleActionSchema).min(1).max(100),
|
|
1696
1886
|
});
|
|
1697
1887
|
|
|
1698
1888
|
export const UpdateCollectionAutomationRuleSchema = z.object({
|
|
@@ -1705,7 +1895,7 @@ export const UpdateCollectionAutomationRuleSchema = z.object({
|
|
|
1705
1895
|
trigger: z.enum(["created", "updated", "linked", "unlinked", "schedule"]).optional(),
|
|
1706
1896
|
triggerConfig: CollectionAutomationRuleTriggerConfigSchema.nullable().optional(),
|
|
1707
1897
|
conditions: z.array(CollectionAutomationRuleConditionSchema).optional(),
|
|
1708
|
-
actions: z.array(
|
|
1898
|
+
actions: z.array(CollectionAutomationRuleActionSchema).min(1).max(100).optional(),
|
|
1709
1899
|
});
|
|
1710
1900
|
|
|
1711
1901
|
export const DeleteCollectionAutomationRuleSchema = z.object({
|
|
@@ -1714,6 +1904,22 @@ export const DeleteCollectionAutomationRuleSchema = z.object({
|
|
|
1714
1904
|
ruleId: z.string(),
|
|
1715
1905
|
});
|
|
1716
1906
|
|
|
1907
|
+
export const ListCollectionAutomationExecutionsSchema = z.object({
|
|
1908
|
+
tenantId: z.string(),
|
|
1909
|
+
collectionId: z.string().optional(),
|
|
1910
|
+
ruleId: z.string().optional(),
|
|
1911
|
+
status: z.enum(["queued", "running", "waiting_approval", "succeeded", "failed", "skipped", "cancelled"]).optional(),
|
|
1912
|
+
cursor: z.string().optional(),
|
|
1913
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
1914
|
+
});
|
|
1915
|
+
|
|
1916
|
+
export const DecideCollectionAutomationApprovalSchema = z.object({
|
|
1917
|
+
tenantId: z.string(),
|
|
1918
|
+
approvalId: z.string(),
|
|
1919
|
+
decision: z.enum(["approved", "rejected"]),
|
|
1920
|
+
note: z.string().max(2_000).optional(),
|
|
1921
|
+
});
|
|
1922
|
+
|
|
1717
1923
|
export const ListCollectionViewsSchema = z.object({
|
|
1718
1924
|
tenantId: z.string(),
|
|
1719
1925
|
collectionId: z.string(),
|
|
@@ -1723,18 +1929,20 @@ export const CreateCollectionViewSchema = z.object({
|
|
|
1723
1929
|
tenantId: z.string(),
|
|
1724
1930
|
dataModelId: z.string(),
|
|
1725
1931
|
collectionId: z.string(),
|
|
1726
|
-
name: z.string(),
|
|
1727
|
-
type: z.
|
|
1932
|
+
name: z.string().trim().min(1).max(191),
|
|
1933
|
+
type: z.enum(["grid", "board", "calendar", "timeline", "tree", "gallery", "map", "document"]),
|
|
1728
1934
|
config: z.object({}).catchall(z.any()),
|
|
1935
|
+
visibility: z.enum(["shared", "personal"]).optional(),
|
|
1729
1936
|
});
|
|
1730
1937
|
|
|
1731
1938
|
export const UpdateCollectionViewSchema = z.object({
|
|
1732
1939
|
tenantId: z.string(),
|
|
1733
1940
|
collectionId: z.string(),
|
|
1734
1941
|
viewId: z.string(),
|
|
1735
|
-
name: z.string().optional(),
|
|
1736
|
-
type: z.
|
|
1942
|
+
name: z.string().trim().min(1).max(191).optional(),
|
|
1943
|
+
type: z.enum(["grid", "board", "calendar", "timeline", "tree", "gallery", "map", "document"]).optional(),
|
|
1737
1944
|
config: z.object({}).catchall(z.any()).optional(),
|
|
1945
|
+
visibility: z.enum(["shared", "personal"]).optional(),
|
|
1738
1946
|
});
|
|
1739
1947
|
|
|
1740
1948
|
export const DeleteCollectionViewSchema = z.object({
|
|
@@ -1743,6 +1951,23 @@ export const DeleteCollectionViewSchema = z.object({
|
|
|
1743
1951
|
viewId: z.string(),
|
|
1744
1952
|
});
|
|
1745
1953
|
|
|
1954
|
+
export const UpsertCollectionViewPreferenceSchema = z.object({
|
|
1955
|
+
tenantId: z.string(),
|
|
1956
|
+
collectionId: z.string(),
|
|
1957
|
+
viewId: z.string(),
|
|
1958
|
+
columns: z.array(z.object({
|
|
1959
|
+
fieldName: z.string().trim().min(1).max(191),
|
|
1960
|
+
visible: z.boolean(),
|
|
1961
|
+
width: z.number().positive().max(2_000).optional(),
|
|
1962
|
+
})).max(500),
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1965
|
+
export const DeleteCollectionViewPreferenceSchema = z.object({
|
|
1966
|
+
tenantId: z.string(),
|
|
1967
|
+
collectionId: z.string(),
|
|
1968
|
+
viewId: z.string(),
|
|
1969
|
+
});
|
|
1970
|
+
|
|
1746
1971
|
export const ListCollectionButtonsSchema = z.object({
|
|
1747
1972
|
tenantId: z.string(),
|
|
1748
1973
|
collectionId: z.string().optional(),
|
|
@@ -1838,18 +2063,33 @@ export const GetRecordRelationsSchema = z.object({
|
|
|
1838
2063
|
recordId: z.string(),
|
|
1839
2064
|
});
|
|
1840
2065
|
|
|
1841
|
-
|
|
2066
|
+
const ReorderCollectionFieldsBaseSchema = z.object({
|
|
1842
2067
|
tenantId: z.string(),
|
|
1843
2068
|
collectionId: z.string(),
|
|
2069
|
+
});
|
|
1844
2070
|
|
|
1845
|
-
|
|
1846
|
-
|
|
2071
|
+
export const ReorderCollectionFieldsSchema = z.union([
|
|
2072
|
+
ReorderCollectionFieldsBaseSchema.extend({
|
|
2073
|
+
// Canonical shape: explicit field/order pairs.
|
|
2074
|
+
fields: z.array(
|
|
1847
2075
|
z.object({
|
|
1848
2076
|
fieldId: z.string(),
|
|
1849
2077
|
order: z.number(),
|
|
1850
2078
|
})
|
|
1851
|
-
|
|
1852
|
-
|
|
2079
|
+
).min(1),
|
|
2080
|
+
fieldIds: z.array(z.string()).optional(),
|
|
2081
|
+
}),
|
|
2082
|
+
ReorderCollectionFieldsBaseSchema.extend({
|
|
2083
|
+
fields: z.array(
|
|
2084
|
+
z.object({
|
|
2085
|
+
fieldId: z.string(),
|
|
2086
|
+
order: z.number(),
|
|
2087
|
+
})
|
|
2088
|
+
).optional(),
|
|
2089
|
+
// Compatibility with the original backend action.
|
|
2090
|
+
fieldIds: z.array(z.string()).min(1),
|
|
2091
|
+
}),
|
|
2092
|
+
]);
|
|
1853
2093
|
|
|
1854
2094
|
export const GetCollectionSchemaSchema = z.object({
|
|
1855
2095
|
tenantId: z.string(),
|
|
@@ -1889,39 +2129,243 @@ export const CheckRecordPermissionSchema = z.object({
|
|
|
1889
2129
|
action: z.string(), // read | update | delete | restore | duplicate | custom
|
|
1890
2130
|
});
|
|
1891
2131
|
|
|
1892
|
-
export const
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
2132
|
+
export const CollectionAccessPolicyScopeTypeSchema = z.enum(["app", "list", "field"]);
|
|
2133
|
+
export const CollectionAccessPolicySubjectTypeSchema = z.enum(["user", "role", "team", "service"]);
|
|
2134
|
+
export const CollectionAccessPolicyEffectSchema = z.enum(["allow", "deny"]);
|
|
2135
|
+
export const CollectionAccessPolicyActionSchema = z.enum(["read", "create", "update", "delete", "comment", "assign"]);
|
|
2136
|
+
export const CollectionAccessPolicyRowOperatorSchema = z.enum(["me", "user", "team", "linked-record"]);
|
|
2137
|
+
|
|
2138
|
+
export const CollectionAccessPolicyRowFilterSchema = z.object({
|
|
2139
|
+
match: z.enum(["all", "any"]),
|
|
2140
|
+
conditions: z.array(z.object({
|
|
2141
|
+
fieldId: z.string().min(1),
|
|
2142
|
+
operator: CollectionAccessPolicyRowOperatorSchema,
|
|
2143
|
+
value: z.string().optional(),
|
|
2144
|
+
})).min(1).max(20),
|
|
2145
|
+
}).superRefine((filter, context) => {
|
|
2146
|
+
filter.conditions.forEach((condition, index) => {
|
|
2147
|
+
if (
|
|
2148
|
+
(condition.operator === "user"
|
|
2149
|
+
|| condition.operator === "team"
|
|
2150
|
+
|| condition.operator === "linked-record")
|
|
2151
|
+
&& !condition.value?.trim()
|
|
2152
|
+
) {
|
|
2153
|
+
context.addIssue({
|
|
2154
|
+
code: z.ZodIssueCode.custom,
|
|
2155
|
+
path: ["conditions", index, "value"],
|
|
2156
|
+
message: `${condition.operator} filters require a value`,
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
});
|
|
2160
|
+
});
|
|
2161
|
+
|
|
2162
|
+
export const ListCollectionAccessPoliciesSchema = z.object({
|
|
2163
|
+
tenantId: z.string().min(1),
|
|
2164
|
+
dataModelId: z.string().optional(),
|
|
2165
|
+
collectionId: z.string().optional(),
|
|
1896
2166
|
});
|
|
1897
2167
|
|
|
1898
|
-
|
|
1899
|
-
tenantId: z.string(),
|
|
1900
|
-
|
|
1901
|
-
|
|
2168
|
+
const CollectionAccessPolicyWriteSchema = z.object({
|
|
2169
|
+
tenantId: z.string().min(1),
|
|
2170
|
+
dataModelId: z.string().min(1),
|
|
2171
|
+
policyId: z.string().optional(),
|
|
2172
|
+
name: z.string().trim().min(1).max(160),
|
|
2173
|
+
scopeType: CollectionAccessPolicyScopeTypeSchema,
|
|
2174
|
+
collectionId: z.string().optional(),
|
|
2175
|
+
fieldId: z.string().optional(),
|
|
2176
|
+
subjectType: CollectionAccessPolicySubjectTypeSchema,
|
|
2177
|
+
subjectId: z.string().trim().min(1).max(255),
|
|
2178
|
+
effect: CollectionAccessPolicyEffectSchema,
|
|
2179
|
+
actions: z.array(CollectionAccessPolicyActionSchema).min(1).max(6),
|
|
2180
|
+
rowFilter: CollectionAccessPolicyRowFilterSchema.nullable().optional(),
|
|
2181
|
+
enabled: z.boolean().optional(),
|
|
2182
|
+
});
|
|
1902
2183
|
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
2184
|
+
function validateCollectionAccessPolicyShape(
|
|
2185
|
+
policy: {
|
|
2186
|
+
scopeType: z.infer<typeof CollectionAccessPolicyScopeTypeSchema>;
|
|
2187
|
+
collectionId?: string | undefined;
|
|
2188
|
+
fieldId?: string | undefined;
|
|
2189
|
+
actions: Array<z.infer<typeof CollectionAccessPolicyActionSchema>>;
|
|
2190
|
+
rowFilter?: z.infer<typeof CollectionAccessPolicyRowFilterSchema> | null | undefined;
|
|
2191
|
+
},
|
|
2192
|
+
context: z.RefinementCtx
|
|
2193
|
+
) {
|
|
2194
|
+
if (policy.scopeType === "app") {
|
|
2195
|
+
if (policy.collectionId) {
|
|
2196
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["collectionId"], message: "App policies cannot target a collection" });
|
|
2197
|
+
}
|
|
2198
|
+
if (policy.fieldId) {
|
|
2199
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "App policies cannot target a field" });
|
|
2200
|
+
}
|
|
2201
|
+
} else if (!policy.collectionId) {
|
|
2202
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["collectionId"], message: "List and field policies require a collection" });
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
if (policy.scopeType === "field") {
|
|
2206
|
+
if (!policy.fieldId) {
|
|
2207
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "Field policies require a field" });
|
|
2208
|
+
}
|
|
2209
|
+
if (policy.actions.some((action) => action !== "read" && action !== "update")) {
|
|
2210
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["actions"], message: "Field policies only support read and update" });
|
|
2211
|
+
}
|
|
2212
|
+
} else if (policy.fieldId) {
|
|
2213
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "Only field policies can target a field" });
|
|
2214
|
+
}
|
|
2215
|
+
|
|
2216
|
+
if (policy.scopeType !== "list" && policy.rowFilter) {
|
|
2217
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["rowFilter"], message: "Data limits can only be attached to list policies" });
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
export const UpsertCollectionAccessPolicySchema = CollectionAccessPolicyWriteSchema
|
|
2222
|
+
.superRefine(validateCollectionAccessPolicyShape);
|
|
2223
|
+
|
|
2224
|
+
export const DeleteCollectionAccessPolicySchema = z.object({
|
|
2225
|
+
tenantId: z.string().min(1),
|
|
2226
|
+
policyId: z.string().min(1),
|
|
2227
|
+
});
|
|
1906
2228
|
|
|
1907
|
-
|
|
1908
|
-
|
|
2229
|
+
export const ListCollectionAccessTeamMembersSchema = z.object({
|
|
2230
|
+
tenantId: z.string().min(1),
|
|
2231
|
+
teamId: z.string().min(1),
|
|
1909
2232
|
});
|
|
1910
2233
|
|
|
1911
|
-
export const
|
|
2234
|
+
export const SetCollectionAccessTeamMembersSchema = z.object({
|
|
2235
|
+
tenantId: z.string().min(1),
|
|
2236
|
+
teamId: z.string().min(1),
|
|
2237
|
+
userIds: z.array(z.string().min(1)).max(1_000),
|
|
2238
|
+
});
|
|
2239
|
+
|
|
2240
|
+
export const PreviewCollectionAccessPolicySchema = z.object({
|
|
2241
|
+
tenantId: z.string().min(1),
|
|
2242
|
+
dataModelId: z.string().min(1),
|
|
2243
|
+
collectionId: z.string().optional(),
|
|
2244
|
+
policy: CollectionAccessPolicyWriteSchema.omit({
|
|
2245
|
+
tenantId: true,
|
|
2246
|
+
dataModelId: true,
|
|
2247
|
+
policyId: true,
|
|
2248
|
+
}).extend({
|
|
2249
|
+
dataModelId: z.string().optional(),
|
|
2250
|
+
collectionId: z.string().optional(),
|
|
2251
|
+
}).superRefine(validateCollectionAccessPolicyShape),
|
|
2252
|
+
record: z.record(z.string(), z.unknown()).optional(),
|
|
2253
|
+
});
|
|
2254
|
+
|
|
2255
|
+
const CollectionCollaborationRecordScopeSchema = z.object({
|
|
2256
|
+
tenantId: z.string().min(1),
|
|
2257
|
+
collectionId: z.string().min(1),
|
|
2258
|
+
recordId: z.string().min(1),
|
|
2259
|
+
});
|
|
2260
|
+
|
|
2261
|
+
const CollectionCollaborationRequestIdSchema = z.string().max(191).optional();
|
|
2262
|
+
|
|
2263
|
+
export const CreateCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2264
|
+
body: z.string().trim().min(1).max(10_000),
|
|
2265
|
+
parentId: z.string().min(1).optional(),
|
|
2266
|
+
mentionUserIds: z.array(z.string().min(1)).max(25).optional(),
|
|
2267
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2268
|
+
});
|
|
2269
|
+
|
|
2270
|
+
export const UpdateCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2271
|
+
commentId: z.string().min(1),
|
|
2272
|
+
body: z.string().trim().min(1).max(10_000),
|
|
2273
|
+
mentionUserIds: z.array(z.string().min(1)).max(25).optional(),
|
|
2274
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2275
|
+
});
|
|
2276
|
+
|
|
2277
|
+
export const DeleteCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2278
|
+
commentId: z.string().min(1),
|
|
2279
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2280
|
+
});
|
|
2281
|
+
|
|
2282
|
+
export const ListCollectionCommentsSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2283
|
+
limit: z.coerce.number().int().min(1).max(100).optional(),
|
|
2284
|
+
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
2285
|
+
});
|
|
2286
|
+
|
|
2287
|
+
export const ListCollectionRecordActivitySchema = ListCollectionCommentsSchema;
|
|
2288
|
+
|
|
2289
|
+
export const ListCollectionRecordCollaboratorsSchema = CollectionCollaborationRecordScopeSchema;
|
|
2290
|
+
|
|
2291
|
+
export const SetCollectionRecordCollaboratorsSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2292
|
+
assigneeIds: z.array(z.string().min(1)).max(20),
|
|
2293
|
+
watcherIds: z.array(z.string().min(1)).max(100),
|
|
2294
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2295
|
+
});
|
|
2296
|
+
|
|
2297
|
+
export const ListCollectionNotificationsSchema = z.object({
|
|
2298
|
+
tenantId: z.string().min(1),
|
|
2299
|
+
limit: z.coerce.number().int().min(1).max(50).optional(),
|
|
2300
|
+
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
2301
|
+
unreadOnly: z.boolean().optional(),
|
|
2302
|
+
});
|
|
2303
|
+
|
|
2304
|
+
export const MarkCollectionNotificationsReadSchema = z.object({
|
|
2305
|
+
tenantId: z.string().min(1),
|
|
2306
|
+
notificationIds: z.array(z.string().min(1)).max(100),
|
|
2307
|
+
});
|
|
2308
|
+
|
|
2309
|
+
export const ListRecordPermissionsSchema = z.object({
|
|
1912
2310
|
tenantId: z.string(),
|
|
1913
2311
|
collectionId: z.string(),
|
|
1914
2312
|
recordId: z.string(),
|
|
2313
|
+
actor: z.string().optional(),
|
|
2314
|
+
subjectType: z.string().optional(),
|
|
2315
|
+
subjectId: z.string().optional(),
|
|
2316
|
+
});
|
|
1915
2317
|
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
// kaldırılacak aksiyonlar
|
|
1921
|
-
// tamamını kaldırmak için ["*"] gönderilebilir
|
|
1922
|
-
actions: z.array(z.string()),
|
|
2318
|
+
const RecordPermissionScopeSchema = z.object({
|
|
2319
|
+
tenantId: z.string(),
|
|
2320
|
+
collectionId: z.string(),
|
|
2321
|
+
recordId: z.string(),
|
|
1923
2322
|
});
|
|
1924
2323
|
|
|
2324
|
+
export const GrantRecordPermissionSchema = z.union([
|
|
2325
|
+
RecordPermissionScopeSchema.extend({
|
|
2326
|
+
// Canonical public shape.
|
|
2327
|
+
subjectType: z.string(), // user | role | group | service | custom
|
|
2328
|
+
subjectId: z.string(),
|
|
2329
|
+
actions: z.array(z.string()).min(1),
|
|
2330
|
+
effect: z.enum(["allow", "deny"]).optional(),
|
|
2331
|
+
grantedBy: z.string().optional(),
|
|
2332
|
+
actor: z.string().optional(),
|
|
2333
|
+
action: z.string().optional(),
|
|
2334
|
+
}),
|
|
2335
|
+
RecordPermissionScopeSchema.extend({
|
|
2336
|
+
// Compatibility with the original single-action backend contract.
|
|
2337
|
+
actor: z.string(),
|
|
2338
|
+
action: z.string(),
|
|
2339
|
+
effect: z.enum(["allow", "deny"]).optional(),
|
|
2340
|
+
grantedBy: z.string().optional(),
|
|
2341
|
+
subjectType: z.string().optional(),
|
|
2342
|
+
subjectId: z.string().optional(),
|
|
2343
|
+
actions: z.array(z.string()).optional(),
|
|
2344
|
+
}),
|
|
2345
|
+
]);
|
|
2346
|
+
|
|
2347
|
+
export const RevokeRecordPermissionSchema = z.union([
|
|
2348
|
+
RecordPermissionScopeSchema.extend({
|
|
2349
|
+
// Canonical public shape.
|
|
2350
|
+
subjectType: z.string(), // user | role | group | service | custom
|
|
2351
|
+
subjectId: z.string(),
|
|
2352
|
+
// tamamını kaldırmak için ["*"] gönderilebilir
|
|
2353
|
+
actions: z.array(z.string()).min(1),
|
|
2354
|
+
revokedBy: z.string().optional(),
|
|
2355
|
+
actor: z.string().optional(),
|
|
2356
|
+
action: z.string().optional(),
|
|
2357
|
+
}),
|
|
2358
|
+
RecordPermissionScopeSchema.extend({
|
|
2359
|
+
// Compatibility with the original single-action backend contract.
|
|
2360
|
+
actor: z.string(),
|
|
2361
|
+
action: z.string(),
|
|
2362
|
+
revokedBy: z.string().optional(),
|
|
2363
|
+
subjectType: z.string().optional(),
|
|
2364
|
+
subjectId: z.string().optional(),
|
|
2365
|
+
actions: z.array(z.string()).optional(),
|
|
2366
|
+
}),
|
|
2367
|
+
]);
|
|
2368
|
+
|
|
1925
2369
|
|
|
1926
2370
|
|
|
1927
2371
|
//---wiki--------------------------------
|
|
@@ -2617,3 +3061,278 @@ export const EnhanceTopicSchema = z.object({
|
|
|
2617
3061
|
entityDescription: z.string(),
|
|
2618
3062
|
categories: z.string().array().optional()
|
|
2619
3063
|
})
|
|
3064
|
+
|
|
3065
|
+
export const CollectionFormLayoutFieldSchema = z.object({
|
|
3066
|
+
fieldId: z.string().trim().min(1).max(191),
|
|
3067
|
+
label: z.string().max(255).optional(),
|
|
3068
|
+
helpText: z.string().max(1_000).optional(),
|
|
3069
|
+
placeholder: z.string().max(500).optional(),
|
|
3070
|
+
required: z.boolean().optional(),
|
|
3071
|
+
width: z.enum(["full", "half"]).optional(),
|
|
3072
|
+
}).strict();
|
|
3073
|
+
|
|
3074
|
+
export const CollectionFormLayoutSectionSchema = z.object({
|
|
3075
|
+
id: z.string().trim().min(1).max(128),
|
|
3076
|
+
title: z.string().max(255).optional(),
|
|
3077
|
+
description: z.string().max(2_000).optional(),
|
|
3078
|
+
fields: z.array(CollectionFormLayoutFieldSchema).max(50),
|
|
3079
|
+
}).strict();
|
|
3080
|
+
|
|
3081
|
+
export const CollectionFormLayoutSchema = z.object({
|
|
3082
|
+
sections: z.array(CollectionFormLayoutSectionSchema).min(1).max(10),
|
|
3083
|
+
}).strict().superRefine((layout, context) => {
|
|
3084
|
+
const sectionIds = new Set<string>();
|
|
3085
|
+
const fieldIds = new Set<string>();
|
|
3086
|
+
let fieldCount = 0;
|
|
3087
|
+
layout.sections.forEach((section, sectionIndex) => {
|
|
3088
|
+
if (sectionIds.has(section.id)) {
|
|
3089
|
+
context.addIssue({
|
|
3090
|
+
code: z.ZodIssueCode.custom,
|
|
3091
|
+
path: ["sections", sectionIndex, "id"],
|
|
3092
|
+
message: "Form section ids must be unique",
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
sectionIds.add(section.id);
|
|
3096
|
+
section.fields.forEach((field, fieldIndex) => {
|
|
3097
|
+
fieldCount += 1;
|
|
3098
|
+
if (fieldIds.has(field.fieldId)) {
|
|
3099
|
+
context.addIssue({
|
|
3100
|
+
code: z.ZodIssueCode.custom,
|
|
3101
|
+
path: ["sections", sectionIndex, "fields", fieldIndex, "fieldId"],
|
|
3102
|
+
message: "A field can appear only once in a form",
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
fieldIds.add(field.fieldId);
|
|
3106
|
+
});
|
|
3107
|
+
});
|
|
3108
|
+
if (fieldCount === 0 || fieldCount > 50) {
|
|
3109
|
+
context.addIssue({
|
|
3110
|
+
code: z.ZodIssueCode.custom,
|
|
3111
|
+
path: ["sections"],
|
|
3112
|
+
message: "A form must contain between 1 and 50 fields",
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
});
|
|
3116
|
+
|
|
3117
|
+
export const ListCollectionFormsSchema = z.object({
|
|
3118
|
+
tenantId: z.string().min(1),
|
|
3119
|
+
dataModelId: z.string().min(1),
|
|
3120
|
+
collectionId: z.string().min(1),
|
|
3121
|
+
});
|
|
3122
|
+
|
|
3123
|
+
export const UpsertCollectionFormSchema = z.object({
|
|
3124
|
+
tenantId: z.string().min(1),
|
|
3125
|
+
dataModelId: z.string().min(1),
|
|
3126
|
+
collectionId: z.string().min(1),
|
|
3127
|
+
formId: z.string().min(1).optional(),
|
|
3128
|
+
name: z.string().trim().min(1).max(191),
|
|
3129
|
+
description: z.string().max(10_000).optional(),
|
|
3130
|
+
layout: CollectionFormLayoutSchema,
|
|
3131
|
+
submitLabel: z.string().trim().min(1).max(100).optional(),
|
|
3132
|
+
successMessage: z.string().trim().min(1).max(2_000).optional(),
|
|
3133
|
+
enabled: z.boolean().optional(),
|
|
3134
|
+
rateLimitPerMinute: z.number().int().min(1).max(100).optional(),
|
|
3135
|
+
maxSubmissions: z.number().int().min(1).max(1_000_000).nullable().optional(),
|
|
3136
|
+
});
|
|
3137
|
+
|
|
3138
|
+
export const ResolveCollectionFormSchema = z.object({
|
|
3139
|
+
tenantId: z.string().min(1),
|
|
3140
|
+
formId: z.string().min(1),
|
|
3141
|
+
});
|
|
3142
|
+
|
|
3143
|
+
export const SubmitCollectionFormSchema = ResolveCollectionFormSchema.extend({
|
|
3144
|
+
values: z.record(z.string(), z.unknown()).refine(
|
|
3145
|
+
(values) => Object.keys(values).length <= 50,
|
|
3146
|
+
"A form submission can contain at most 50 fields"
|
|
3147
|
+
),
|
|
3148
|
+
submissionKey: z.string().trim().min(8).max(128),
|
|
3149
|
+
});
|
|
3150
|
+
|
|
3151
|
+
export const PublishCollectionFormSchema = ResolveCollectionFormSchema.extend({
|
|
3152
|
+
expiresInDays: z.number().int().min(1).max(365).optional(),
|
|
3153
|
+
});
|
|
3154
|
+
|
|
3155
|
+
export const RevokeCollectionFormSchema = ResolveCollectionFormSchema;
|
|
3156
|
+
export const DeleteCollectionFormSchema = ResolveCollectionFormSchema;
|
|
3157
|
+
|
|
3158
|
+
export const CollectionReportTypeSchema = z.enum(["table", "metric", "chart"]);
|
|
3159
|
+
export const CollectionReportVisibilitySchema = z.enum(["personal", "shared"]);
|
|
3160
|
+
const CollectionReportFilterSchema = z.record(z.string(), z.unknown()).superRefine((filter, context) => {
|
|
3161
|
+
if (JSON.stringify(filter).length > 16 * 1024) {
|
|
3162
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: "Report filter is too large" });
|
|
3163
|
+
}
|
|
3164
|
+
});
|
|
3165
|
+
const CollectionReportBaseSchema = z.object({
|
|
3166
|
+
tenantId: z.string().min(1),
|
|
3167
|
+
dataModelId: z.string().min(1),
|
|
3168
|
+
collectionId: z.string().min(1),
|
|
3169
|
+
reportId: z.string().min(1).optional(),
|
|
3170
|
+
name: z.string().trim().min(1).max(191),
|
|
3171
|
+
description: z.string().max(4_000).optional(),
|
|
3172
|
+
visibility: CollectionReportVisibilitySchema.optional(),
|
|
3173
|
+
});
|
|
3174
|
+
export const CollectionReportTableConfigSchema = z.object({
|
|
3175
|
+
filter: CollectionReportFilterSchema.optional(),
|
|
3176
|
+
fields: z.array(z.string().min(1)).min(1).max(50),
|
|
3177
|
+
sort: z.record(z.string(), z.enum(["asc", "desc"])).refine(
|
|
3178
|
+
(sort) => Object.keys(sort).length <= 5,
|
|
3179
|
+
"Report sort cannot contain more than 5 fields"
|
|
3180
|
+
).optional(),
|
|
3181
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
3182
|
+
}).strict();
|
|
3183
|
+
const CollectionReportAggregateConfigBaseSchema = z.object({
|
|
3184
|
+
filter: CollectionReportFilterSchema.optional(),
|
|
3185
|
+
aggregate: z.enum(["count", "sum", "avg", "min", "max"]),
|
|
3186
|
+
valueField: z.string().min(1).optional(),
|
|
3187
|
+
});
|
|
3188
|
+
export const CollectionReportMetricConfigSchema = CollectionReportAggregateConfigBaseSchema.extend({
|
|
3189
|
+
limit: z.literal(1).optional(),
|
|
3190
|
+
}).strict().superRefine((config, context) => {
|
|
3191
|
+
if (config.aggregate !== "count" && !config.valueField) {
|
|
3192
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["valueField"], message: "This aggregate requires valueField" });
|
|
3193
|
+
}
|
|
3194
|
+
});
|
|
3195
|
+
export const CollectionReportChartConfigSchema = CollectionReportAggregateConfigBaseSchema.extend({
|
|
3196
|
+
groupBy: z.string().min(1),
|
|
3197
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
3198
|
+
}).strict().superRefine((config, context) => {
|
|
3199
|
+
if (config.aggregate !== "count" && !config.valueField) {
|
|
3200
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["valueField"], message: "This aggregate requires valueField" });
|
|
3201
|
+
}
|
|
3202
|
+
});
|
|
3203
|
+
export const UpsertCollectionReportSchema = z.discriminatedUnion("type", [
|
|
3204
|
+
CollectionReportBaseSchema.extend({ type: z.literal("table"), config: CollectionReportTableConfigSchema }),
|
|
3205
|
+
CollectionReportBaseSchema.extend({ type: z.literal("metric"), config: CollectionReportMetricConfigSchema }),
|
|
3206
|
+
CollectionReportBaseSchema.extend({ type: z.literal("chart"), config: CollectionReportChartConfigSchema }),
|
|
3207
|
+
]);
|
|
3208
|
+
export const ListCollectionReportsSchema = z.object({
|
|
3209
|
+
tenantId: z.string().min(1),
|
|
3210
|
+
dataModelId: z.string().min(1),
|
|
3211
|
+
collectionId: z.string().min(1),
|
|
3212
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
3213
|
+
offset: z.number().int().min(0).max(10_000).optional(),
|
|
3214
|
+
});
|
|
3215
|
+
export const CollectionReportReferenceSchema = z.object({
|
|
3216
|
+
tenantId: z.string().min(1),
|
|
3217
|
+
reportId: z.string().min(1),
|
|
3218
|
+
});
|
|
3219
|
+
export const DeleteCollectionReportSchema = CollectionReportReferenceSchema;
|
|
3220
|
+
export const EvaluateCollectionReportSchema = CollectionReportReferenceSchema;
|
|
3221
|
+
|
|
3222
|
+
const CollectionDashboardWidgetBaseSchema = z.object({
|
|
3223
|
+
id: z.string().min(1).optional(),
|
|
3224
|
+
reportId: z.string().min(1),
|
|
3225
|
+
title: z.string().trim().min(1).max(191),
|
|
3226
|
+
});
|
|
3227
|
+
export const CollectionDashboardWidgetSchema = z.discriminatedUnion("type", [
|
|
3228
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3229
|
+
type: z.literal("table"),
|
|
3230
|
+
config: z.object({
|
|
3231
|
+
pageSize: z.number().int().min(1).max(100).optional(),
|
|
3232
|
+
showHeaders: z.boolean().optional(),
|
|
3233
|
+
}).strict().optional(),
|
|
3234
|
+
}),
|
|
3235
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3236
|
+
type: z.literal("metric"),
|
|
3237
|
+
config: z.object({
|
|
3238
|
+
prefix: z.string().max(32).optional(),
|
|
3239
|
+
suffix: z.string().max(32).optional(),
|
|
3240
|
+
decimals: z.number().int().min(0).max(6).optional(),
|
|
3241
|
+
}).strict().optional(),
|
|
3242
|
+
}),
|
|
3243
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3244
|
+
type: z.literal("chart"),
|
|
3245
|
+
config: z.object({
|
|
3246
|
+
kind: z.enum(["bar", "line", "pie"]).optional(),
|
|
3247
|
+
showLegend: z.boolean().optional(),
|
|
3248
|
+
}).strict().optional(),
|
|
3249
|
+
}),
|
|
3250
|
+
]);
|
|
3251
|
+
export const ListCollectionDashboardsSchema = z.object({
|
|
3252
|
+
tenantId: z.string().min(1),
|
|
3253
|
+
dataModelId: z.string().min(1),
|
|
3254
|
+
collectionId: z.string().min(1),
|
|
3255
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
3256
|
+
offset: z.number().int().min(0).max(10_000).optional(),
|
|
3257
|
+
});
|
|
3258
|
+
export const UpsertCollectionDashboardSchema = z.object({
|
|
3259
|
+
tenantId: z.string().min(1),
|
|
3260
|
+
dataModelId: z.string().min(1),
|
|
3261
|
+
collectionId: z.string().min(1),
|
|
3262
|
+
dashboardId: z.string().min(1).optional(),
|
|
3263
|
+
name: z.string().trim().min(1).max(191),
|
|
3264
|
+
description: z.string().max(4_000).optional(),
|
|
3265
|
+
settings: z.object({
|
|
3266
|
+
columns: z.number().int().min(1).max(4).optional(),
|
|
3267
|
+
compact: z.boolean().optional(),
|
|
3268
|
+
}).strict().optional(),
|
|
3269
|
+
visibility: CollectionReportVisibilitySchema.optional(),
|
|
3270
|
+
widgets: z.array(CollectionDashboardWidgetSchema).max(20),
|
|
3271
|
+
});
|
|
3272
|
+
export const CollectionDashboardReferenceSchema = z.object({
|
|
3273
|
+
tenantId: z.string().min(1),
|
|
3274
|
+
dashboardId: z.string().min(1),
|
|
3275
|
+
});
|
|
3276
|
+
export const DeleteCollectionDashboardSchema = CollectionDashboardReferenceSchema;
|
|
3277
|
+
export const EvaluateCollectionDashboardSchema = CollectionDashboardReferenceSchema;
|
|
3278
|
+
|
|
3279
|
+
export const PreviewCollectionAppGenerationSchema = z.object({
|
|
3280
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3281
|
+
prompt: z.string().trim().min(1).max(4_000),
|
|
3282
|
+
}).strict();
|
|
3283
|
+
|
|
3284
|
+
export const ApplyCollectionAppGenerationSchema = z.object({
|
|
3285
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3286
|
+
planId: z.string().trim().min(1).max(191),
|
|
3287
|
+
expectedProposalHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
3288
|
+
idempotencyKey: z.string().trim().min(8).max(128),
|
|
3289
|
+
}).strict();
|
|
3290
|
+
|
|
3291
|
+
export const RollbackCollectionAppGenerationSchema = z.object({
|
|
3292
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3293
|
+
runId: z.string().trim().min(1).max(191),
|
|
3294
|
+
idempotencyKey: z.string().trim().min(8).max(128),
|
|
3295
|
+
}).strict();
|
|
3296
|
+
|
|
3297
|
+
export const ResumeCollectionAppGenerationRunSchema = z.object({
|
|
3298
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3299
|
+
runId: z.string().trim().min(1).max(191),
|
|
3300
|
+
}).strict();
|
|
3301
|
+
|
|
3302
|
+
export const GetCollectionAppGenerationPlanSchema = z.object({
|
|
3303
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3304
|
+
planId: z.string().trim().min(1).max(191),
|
|
3305
|
+
}).strict();
|
|
3306
|
+
|
|
3307
|
+
export const ListCollectionAppGenerationPlansSchema = z.object({
|
|
3308
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3309
|
+
status: z.enum(["previewed", "applying", "compensating", "applied", "failed", "compensation_failed", "rollback_retained", "rolled_back"]).optional(),
|
|
3310
|
+
offset: z.number().int().min(0).max(1_000_000).optional(),
|
|
3311
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
3312
|
+
}).strict();
|
|
3313
|
+
|
|
3314
|
+
export const GetCollectionAppGenerationRunSchema = z.object({
|
|
3315
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3316
|
+
runId: z.string().trim().min(1).max(191),
|
|
3317
|
+
}).strict();
|
|
3318
|
+
|
|
3319
|
+
export const ListCollectionAppGenerationRunsSchema = z.object({
|
|
3320
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3321
|
+
planId: z.string().trim().min(1).max(191).optional(),
|
|
3322
|
+
status: z.enum([
|
|
3323
|
+
"applying",
|
|
3324
|
+
"provisioning",
|
|
3325
|
+
"compensating",
|
|
3326
|
+
"applied",
|
|
3327
|
+
"failed",
|
|
3328
|
+
"compensation_failed",
|
|
3329
|
+
"rolling_back",
|
|
3330
|
+
"rollback_cleanup",
|
|
3331
|
+
"rollback_cleanup_failed",
|
|
3332
|
+
"rollback_failed",
|
|
3333
|
+
"rollback_retained",
|
|
3334
|
+
"rolled_back",
|
|
3335
|
+
]).optional(),
|
|
3336
|
+
offset: z.number().int().min(0).max(1_000_000).optional(),
|
|
3337
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
3338
|
+
}).strict();
|