@appconda/sdk 1.0.681 → 1.0.683
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 +1084 -21
- package/dist/modules/emploid/schema.js +675 -53
- package/dist/modules/emploid/service.d.ts +95 -15
- package/dist/modules/emploid/service.js +127 -1
- package/dist/modules/emploid/types.d.ts +714 -6
- package/dist/modules/emploid/types.js +1 -1
- package/package.json +1 -1
- package/src/modules/emploid/schema.ts +750 -60
- package/src/modules/emploid/service.ts +395 -15
- package/src/modules/emploid/types.ts +801 -7
|
@@ -1017,6 +1017,12 @@ export const UpdateCollectionSchema = z.object({
|
|
|
1017
1017
|
collectionId: z.string(),
|
|
1018
1018
|
displayName: z.string().optional(),
|
|
1019
1019
|
description: z.string().optional(),
|
|
1020
|
+
// Legacy callers used the same fields under a `data` envelope. The
|
|
1021
|
+
// backend accepts both shapes while direct fields remain canonical.
|
|
1022
|
+
data: z.object({
|
|
1023
|
+
displayName: z.string().optional(),
|
|
1024
|
+
description: z.string().optional(),
|
|
1025
|
+
}).optional(),
|
|
1020
1026
|
});
|
|
1021
1027
|
|
|
1022
1028
|
export const DeleteCollectionSchema = z.object({
|
|
@@ -1252,6 +1258,34 @@ export const EnsureGithubImportCredentialSchema = z.object({
|
|
|
1252
1258
|
tenantId: z.string(),
|
|
1253
1259
|
});
|
|
1254
1260
|
|
|
1261
|
+
const CsvImportInvalidRowPolicySchema = z.enum(["reject", "skip-row", "set-null"]);
|
|
1262
|
+
|
|
1263
|
+
const CsvImportRowRepairSchema = z.object({
|
|
1264
|
+
rowIndex: z.number().int().nonnegative(),
|
|
1265
|
+
fieldId: z.string().min(1),
|
|
1266
|
+
value: z.any(),
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
const CsvImportFieldMappingSchema = z.object({
|
|
1270
|
+
fieldId: z.string().min(1),
|
|
1271
|
+
type: z.string(),
|
|
1272
|
+
displayName: z.string(),
|
|
1273
|
+
name: z.string(),
|
|
1274
|
+
required: z.boolean().optional(),
|
|
1275
|
+
config: z.object({}).catchall(z.any()).optional(),
|
|
1276
|
+
fallbackReason: z.string().optional(),
|
|
1277
|
+
mode: z.enum(["field", "skip", "relation"]).optional(),
|
|
1278
|
+
relation: z.object({
|
|
1279
|
+
targetCollectionId: z.string().min(1),
|
|
1280
|
+
matchFieldName: z.string().min(1),
|
|
1281
|
+
unmatchedPolicy: z.enum(["reject", "ignore", "create"]),
|
|
1282
|
+
cardinality: z.enum(["one", "many"]).optional(),
|
|
1283
|
+
inverseCardinality: z.enum(["one", "many"]).optional(),
|
|
1284
|
+
inverseDisplayName: z.string().optional(),
|
|
1285
|
+
separator: z.string().max(8).optional(),
|
|
1286
|
+
}).optional(),
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1255
1289
|
export const PreviewCsvImportSchema = z.object({
|
|
1256
1290
|
tenantId: z.string(),
|
|
1257
1291
|
fileName: z.string(),
|
|
@@ -1264,7 +1298,10 @@ export const PreviewCsvImportSchema = z.object({
|
|
|
1264
1298
|
index: z.number().int(),
|
|
1265
1299
|
})
|
|
1266
1300
|
).min(1),
|
|
1267
|
-
rows: z.array(z.object({}).catchall(z.any())).optional(),
|
|
1301
|
+
rows: z.array(z.object({}).catchall(z.any())).max(1_000).optional(),
|
|
1302
|
+
fields: z.array(CsvImportFieldMappingSchema).min(1).optional(),
|
|
1303
|
+
rowRepairs: z.array(CsvImportRowRepairSchema).max(10_000).optional(),
|
|
1304
|
+
invalidRowPolicy: CsvImportInvalidRowPolicySchema.optional(),
|
|
1268
1305
|
});
|
|
1269
1306
|
|
|
1270
1307
|
export const ListGmailImportSourcesSchema = z.object({
|
|
@@ -1302,22 +1339,14 @@ export const RunCsvImportSchema = z.object({
|
|
|
1302
1339
|
index: z.number().int(),
|
|
1303
1340
|
})
|
|
1304
1341
|
).min(1),
|
|
1305
|
-
rows: z.array(z.object({}).catchall(z.any())),
|
|
1342
|
+
rows: z.array(z.object({}).catchall(z.any())).max(1_000),
|
|
1306
1343
|
collection: z.object({
|
|
1307
1344
|
collectionKey: z.literal("rows"),
|
|
1308
1345
|
collectionName: z.string(),
|
|
1309
1346
|
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),
|
|
1347
|
+
fields: z.array(CsvImportFieldMappingSchema).min(1),
|
|
1348
|
+
invalidRowPolicy: CsvImportInvalidRowPolicySchema.optional(),
|
|
1349
|
+
rowRepairs: z.array(CsvImportRowRepairSchema).max(10_000).optional(),
|
|
1321
1350
|
}),
|
|
1322
1351
|
});
|
|
1323
1352
|
|
|
@@ -1497,18 +1526,36 @@ export const RunTrelloImportSchema = z.object({
|
|
|
1497
1526
|
).min(1),
|
|
1498
1527
|
});
|
|
1499
1528
|
|
|
1500
|
-
|
|
1529
|
+
const BulkUpdateRecordSchema = z.object({
|
|
1530
|
+
recordId: z.string(),
|
|
1531
|
+
data: z.object({}).catchall(z.any()),
|
|
1532
|
+
});
|
|
1533
|
+
|
|
1534
|
+
const LegacyBulkUpdateRecordSchema = z.object({
|
|
1535
|
+
id: z.string().optional(),
|
|
1536
|
+
recordId: z.string().optional(),
|
|
1537
|
+
data: z.object({}).catchall(z.any()),
|
|
1538
|
+
}).refine((item) => Boolean(item.id || item.recordId), {
|
|
1539
|
+
message: "Each bulk update item must include id or recordId",
|
|
1540
|
+
});
|
|
1541
|
+
|
|
1542
|
+
const BulkUpdateRecordsBaseSchema = z.object({
|
|
1501
1543
|
tenantId: z.string(),
|
|
1502
1544
|
collectionId: z.string(),
|
|
1503
|
-
|
|
1504
|
-
records: z.array(
|
|
1505
|
-
z.object({
|
|
1506
|
-
recordId: z.string(),
|
|
1507
|
-
data: z.object({}).catchall(z.any()),
|
|
1508
|
-
})
|
|
1509
|
-
),
|
|
1545
|
+
actor: z.string().optional(),
|
|
1510
1546
|
});
|
|
1511
1547
|
|
|
1548
|
+
export const BulkUpdateRecordsSchema = z.union([
|
|
1549
|
+
BulkUpdateRecordsBaseSchema.extend({
|
|
1550
|
+
records: z.array(BulkUpdateRecordSchema).min(1),
|
|
1551
|
+
items: z.array(LegacyBulkUpdateRecordSchema).optional(),
|
|
1552
|
+
}),
|
|
1553
|
+
BulkUpdateRecordsBaseSchema.extend({
|
|
1554
|
+
records: z.array(BulkUpdateRecordSchema).optional(),
|
|
1555
|
+
items: z.array(LegacyBulkUpdateRecordSchema).min(1),
|
|
1556
|
+
}),
|
|
1557
|
+
]);
|
|
1558
|
+
|
|
1512
1559
|
export const BulkDeleteRecordsSchema = z.object({
|
|
1513
1560
|
tenantId: z.string(),
|
|
1514
1561
|
collectionId: z.string(),
|
|
@@ -1534,7 +1581,10 @@ export const QueryRecordsSchema = z.object({
|
|
|
1534
1581
|
filter: z.object({}).catchall(z.any()).optional(),
|
|
1535
1582
|
|
|
1536
1583
|
// projection (hangi alanlar gelsin)
|
|
1537
|
-
fields: z.
|
|
1584
|
+
fields: z.union([
|
|
1585
|
+
z.array(z.string()),
|
|
1586
|
+
z.object({}).catchall(z.any()),
|
|
1587
|
+
]).optional(),
|
|
1538
1588
|
|
|
1539
1589
|
// sorting
|
|
1540
1590
|
sort: z.object({}).catchall(z.string()).optional(),
|
|
@@ -1542,15 +1592,26 @@ export const QueryRecordsSchema = z.object({
|
|
|
1542
1592
|
// pagination
|
|
1543
1593
|
limit: z.number().optional(),
|
|
1544
1594
|
offset: z.number().optional(),
|
|
1595
|
+
|
|
1596
|
+
// Compatibility with the original backend action, which expected the
|
|
1597
|
+
// complete query DSL in one parameter.
|
|
1598
|
+
query: z.object({
|
|
1599
|
+
where: z.object({}).catchall(z.any()).optional(),
|
|
1600
|
+
filter: z.object({}).catchall(z.any()).optional(),
|
|
1601
|
+
fields: z.union([
|
|
1602
|
+
z.array(z.string()),
|
|
1603
|
+
z.object({}).catchall(z.any()),
|
|
1604
|
+
]).optional(),
|
|
1605
|
+
sort: z.object({}).catchall(z.string()).optional(),
|
|
1606
|
+
limit: z.number().optional(),
|
|
1607
|
+
offset: z.number().optional(),
|
|
1608
|
+
}).optional(),
|
|
1545
1609
|
});
|
|
1546
1610
|
|
|
1547
|
-
|
|
1611
|
+
const SearchRecordsBaseSchema = z.object({
|
|
1548
1612
|
tenantId: z.string(),
|
|
1549
1613
|
collectionId: z.string(),
|
|
1550
1614
|
|
|
1551
|
-
// arama metni
|
|
1552
|
-
query: z.string(),
|
|
1553
|
-
|
|
1554
1615
|
// opsiyonel: hangi alanlarda aransın
|
|
1555
1616
|
fields: z.array(z.string()).optional(),
|
|
1556
1617
|
|
|
@@ -1565,6 +1626,19 @@ export const SearchRecordsSchema = z.object({
|
|
|
1565
1626
|
offset: z.number().optional(),
|
|
1566
1627
|
});
|
|
1567
1628
|
|
|
1629
|
+
export const SearchRecordsSchema = z.union([
|
|
1630
|
+
SearchRecordsBaseSchema.extend({
|
|
1631
|
+
// Canonical public name.
|
|
1632
|
+
query: z.string().min(1),
|
|
1633
|
+
q: z.string().optional(),
|
|
1634
|
+
}),
|
|
1635
|
+
SearchRecordsBaseSchema.extend({
|
|
1636
|
+
// Compatibility with the original backend action and Agent Flow node.
|
|
1637
|
+
query: z.string().optional(),
|
|
1638
|
+
q: z.string().min(1),
|
|
1639
|
+
}),
|
|
1640
|
+
]);
|
|
1641
|
+
|
|
1568
1642
|
export const CountRecordsSchema = z.object({
|
|
1569
1643
|
tenantId: z.string(),
|
|
1570
1644
|
collectionId: z.string(),
|
|
@@ -1625,6 +1699,56 @@ export const DistinctFieldValuesSchema = z.object({
|
|
|
1625
1699
|
limit: z.number().optional(),
|
|
1626
1700
|
});
|
|
1627
1701
|
|
|
1702
|
+
export const CollectionDerivedConditionSchema = z.object({
|
|
1703
|
+
fieldId: z.string(),
|
|
1704
|
+
fieldName: z.string().optional(),
|
|
1705
|
+
operator: z.enum([
|
|
1706
|
+
"eq", "neq", "contains", "not-contains", "gt", "gte", "lt", "lte",
|
|
1707
|
+
"is-empty", "is-not-empty",
|
|
1708
|
+
]),
|
|
1709
|
+
value: z.unknown().optional(),
|
|
1710
|
+
});
|
|
1711
|
+
|
|
1712
|
+
export const CollectionFieldConfigSchema = z.object({
|
|
1713
|
+
relationFieldId: z.string().optional(),
|
|
1714
|
+
relationFieldName: z.string().optional(),
|
|
1715
|
+
relationId: z.string().optional(),
|
|
1716
|
+
targetCollectionId: z.string().optional(),
|
|
1717
|
+
targetFieldId: z.string().optional(),
|
|
1718
|
+
targetFieldName: z.string().optional(),
|
|
1719
|
+
resultMode: z.enum(["first", "list"]).optional(),
|
|
1720
|
+
operation: z.enum([
|
|
1721
|
+
"count", "count-values", "count-unique", "sum", "average", "min", "max",
|
|
1722
|
+
]).optional(),
|
|
1723
|
+
condition: CollectionDerivedConditionSchema.optional(),
|
|
1724
|
+
maxItems: z.number().int().min(1).max(500).optional(),
|
|
1725
|
+
min: z.number().optional(),
|
|
1726
|
+
max: z.number().optional(),
|
|
1727
|
+
precision: z.number().int().min(0).max(4).optional(),
|
|
1728
|
+
mode: z.enum(["typed", "drawn", "both"]).optional(),
|
|
1729
|
+
source: z.enum(["organization", "users", "employees", "both"]).optional(),
|
|
1730
|
+
includeInactive: z.boolean().optional(),
|
|
1731
|
+
}).catchall(z.any());
|
|
1732
|
+
|
|
1733
|
+
export const CollectionChecklistItemSchema = z.object({
|
|
1734
|
+
id: z.string().min(1).max(128),
|
|
1735
|
+
text: z.string().min(1).max(1000),
|
|
1736
|
+
checked: z.boolean(),
|
|
1737
|
+
});
|
|
1738
|
+
|
|
1739
|
+
export const CollectionSignatureValueSchema = z.object({
|
|
1740
|
+
kind: z.enum(["typed", "drawn"]),
|
|
1741
|
+
value: z.string().min(1),
|
|
1742
|
+
signedAt: z.string().datetime(),
|
|
1743
|
+
signedBy: z.string().min(1),
|
|
1744
|
+
});
|
|
1745
|
+
|
|
1746
|
+
/** Browser/import input. signedAt and signedBy are server-managed output fields. */
|
|
1747
|
+
export const CollectionSignatureInputSchema = CollectionSignatureValueSchema.pick({
|
|
1748
|
+
kind: true,
|
|
1749
|
+
value: true,
|
|
1750
|
+
});
|
|
1751
|
+
|
|
1628
1752
|
export const CreateCollectionFieldSchema = z.object({
|
|
1629
1753
|
tenantId: z.string(),
|
|
1630
1754
|
dataModelId: z.string(),
|
|
@@ -1636,7 +1760,7 @@ export const CreateCollectionFieldSchema = z.object({
|
|
|
1636
1760
|
required: z.boolean().optional(),
|
|
1637
1761
|
|
|
1638
1762
|
// field-specific config (min, max, enum, format, relation, etc.)
|
|
1639
|
-
config:
|
|
1763
|
+
config: CollectionFieldConfigSchema.optional(),
|
|
1640
1764
|
|
|
1641
1765
|
// opsiyonel sıralama
|
|
1642
1766
|
order: z.number().optional(),
|
|
@@ -1653,7 +1777,7 @@ export const UpdateCollectionFieldSchema = z.object({
|
|
|
1653
1777
|
required: z.boolean().optional(),
|
|
1654
1778
|
|
|
1655
1779
|
// field-specific config (min, max, enum, relation vb.)
|
|
1656
|
-
config:
|
|
1780
|
+
config: CollectionFieldConfigSchema.optional(),
|
|
1657
1781
|
|
|
1658
1782
|
// opsiyonel sıralama
|
|
1659
1783
|
order: z.number().optional(),
|
|
@@ -1673,6 +1797,9 @@ export const ListCollectionAutomationRulesSchema = z.object({
|
|
|
1673
1797
|
|
|
1674
1798
|
const CollectionAutomationRuleTriggerConfigSchema = z.object({
|
|
1675
1799
|
updatedFieldId: z.string().nullable().optional(),
|
|
1800
|
+
cron: z.string().max(191).nullable().optional(),
|
|
1801
|
+
timezone: z.string().max(64).nullable().optional(),
|
|
1802
|
+
maxRecords: z.number().int().min(1).max(100).optional(),
|
|
1676
1803
|
});
|
|
1677
1804
|
|
|
1678
1805
|
const CollectionAutomationRuleConditionSchema = z.object({
|
|
@@ -1682,6 +1809,40 @@ const CollectionAutomationRuleConditionSchema = z.object({
|
|
|
1682
1809
|
value: z.union([z.string(), z.array(z.string()), z.boolean(), z.null()]).optional(),
|
|
1683
1810
|
});
|
|
1684
1811
|
|
|
1812
|
+
const CollectionAutomationRuleActionSchema: z.ZodType<Record<string, unknown>> = z.lazy(() => z.object({
|
|
1813
|
+
id: z.string().min(1),
|
|
1814
|
+
type: z.enum([
|
|
1815
|
+
"create", "update", "delete", "append-description", "script",
|
|
1816
|
+
"conditional-branch", "find-records", "for-each", "copy-record",
|
|
1817
|
+
"move-record", "webhook", "approval",
|
|
1818
|
+
]).nullable(),
|
|
1819
|
+
fieldId: z.string().nullable().optional(),
|
|
1820
|
+
value: z.string().optional(),
|
|
1821
|
+
valueMode: z.enum(["literal", "formula"]).optional(),
|
|
1822
|
+
formula: z.string().optional(),
|
|
1823
|
+
template: z.string().optional(),
|
|
1824
|
+
script: z.string().optional(),
|
|
1825
|
+
condition: CollectionAutomationRuleConditionSchema.nullable().optional(),
|
|
1826
|
+
thenActions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1827
|
+
elseActions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1828
|
+
collectionId: z.string().nullable().optional(),
|
|
1829
|
+
filters: z.array(CollectionAutomationRuleConditionSchema).max(25).optional(),
|
|
1830
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
1831
|
+
resultKey: z.string().max(80).optional(),
|
|
1832
|
+
sourceKey: z.string().max(80).optional(),
|
|
1833
|
+
maxIterations: z.number().int().min(1).max(50).optional(),
|
|
1834
|
+
actions: z.array(CollectionAutomationRuleActionSchema).max(100).optional(),
|
|
1835
|
+
targetCollectionId: z.string().nullable().optional(),
|
|
1836
|
+
fieldMap: z.record(z.string(), z.string()).optional(),
|
|
1837
|
+
url: z.string().max(2048).optional(),
|
|
1838
|
+
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).optional(),
|
|
1839
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
1840
|
+
body: z.unknown().optional(),
|
|
1841
|
+
timeoutMs: z.number().int().min(1).max(10_000).optional(),
|
|
1842
|
+
approverIds: z.array(z.string()).max(25).optional(),
|
|
1843
|
+
approvalMessage: z.string().max(2_000).optional(),
|
|
1844
|
+
}));
|
|
1845
|
+
|
|
1685
1846
|
export const CreateCollectionAutomationRuleSchema = z.object({
|
|
1686
1847
|
tenantId: z.string(),
|
|
1687
1848
|
dataModelId: z.string(),
|
|
@@ -1692,7 +1853,7 @@ export const CreateCollectionAutomationRuleSchema = z.object({
|
|
|
1692
1853
|
trigger: z.enum(["created", "updated", "linked", "unlinked", "schedule"]),
|
|
1693
1854
|
triggerConfig: CollectionAutomationRuleTriggerConfigSchema.nullable().optional(),
|
|
1694
1855
|
conditions: z.array(CollectionAutomationRuleConditionSchema).optional(),
|
|
1695
|
-
actions: z.array(
|
|
1856
|
+
actions: z.array(CollectionAutomationRuleActionSchema).min(1).max(100),
|
|
1696
1857
|
});
|
|
1697
1858
|
|
|
1698
1859
|
export const UpdateCollectionAutomationRuleSchema = z.object({
|
|
@@ -1705,7 +1866,7 @@ export const UpdateCollectionAutomationRuleSchema = z.object({
|
|
|
1705
1866
|
trigger: z.enum(["created", "updated", "linked", "unlinked", "schedule"]).optional(),
|
|
1706
1867
|
triggerConfig: CollectionAutomationRuleTriggerConfigSchema.nullable().optional(),
|
|
1707
1868
|
conditions: z.array(CollectionAutomationRuleConditionSchema).optional(),
|
|
1708
|
-
actions: z.array(
|
|
1869
|
+
actions: z.array(CollectionAutomationRuleActionSchema).min(1).max(100).optional(),
|
|
1709
1870
|
});
|
|
1710
1871
|
|
|
1711
1872
|
export const DeleteCollectionAutomationRuleSchema = z.object({
|
|
@@ -1714,6 +1875,22 @@ export const DeleteCollectionAutomationRuleSchema = z.object({
|
|
|
1714
1875
|
ruleId: z.string(),
|
|
1715
1876
|
});
|
|
1716
1877
|
|
|
1878
|
+
export const ListCollectionAutomationExecutionsSchema = z.object({
|
|
1879
|
+
tenantId: z.string(),
|
|
1880
|
+
collectionId: z.string().optional(),
|
|
1881
|
+
ruleId: z.string().optional(),
|
|
1882
|
+
status: z.enum(["queued", "running", "waiting_approval", "succeeded", "failed", "skipped", "cancelled"]).optional(),
|
|
1883
|
+
cursor: z.string().optional(),
|
|
1884
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
1885
|
+
});
|
|
1886
|
+
|
|
1887
|
+
export const DecideCollectionAutomationApprovalSchema = z.object({
|
|
1888
|
+
tenantId: z.string(),
|
|
1889
|
+
approvalId: z.string(),
|
|
1890
|
+
decision: z.enum(["approved", "rejected"]),
|
|
1891
|
+
note: z.string().max(2_000).optional(),
|
|
1892
|
+
});
|
|
1893
|
+
|
|
1717
1894
|
export const ListCollectionViewsSchema = z.object({
|
|
1718
1895
|
tenantId: z.string(),
|
|
1719
1896
|
collectionId: z.string(),
|
|
@@ -1723,18 +1900,20 @@ export const CreateCollectionViewSchema = z.object({
|
|
|
1723
1900
|
tenantId: z.string(),
|
|
1724
1901
|
dataModelId: z.string(),
|
|
1725
1902
|
collectionId: z.string(),
|
|
1726
|
-
name: z.string(),
|
|
1727
|
-
type: z.
|
|
1903
|
+
name: z.string().trim().min(1).max(191),
|
|
1904
|
+
type: z.enum(["grid", "board", "calendar", "timeline", "tree", "gallery", "map", "document"]),
|
|
1728
1905
|
config: z.object({}).catchall(z.any()),
|
|
1906
|
+
visibility: z.enum(["shared", "personal"]).optional(),
|
|
1729
1907
|
});
|
|
1730
1908
|
|
|
1731
1909
|
export const UpdateCollectionViewSchema = z.object({
|
|
1732
1910
|
tenantId: z.string(),
|
|
1733
1911
|
collectionId: z.string(),
|
|
1734
1912
|
viewId: z.string(),
|
|
1735
|
-
name: z.string().optional(),
|
|
1736
|
-
type: z.
|
|
1913
|
+
name: z.string().trim().min(1).max(191).optional(),
|
|
1914
|
+
type: z.enum(["grid", "board", "calendar", "timeline", "tree", "gallery", "map", "document"]).optional(),
|
|
1737
1915
|
config: z.object({}).catchall(z.any()).optional(),
|
|
1916
|
+
visibility: z.enum(["shared", "personal"]).optional(),
|
|
1738
1917
|
});
|
|
1739
1918
|
|
|
1740
1919
|
export const DeleteCollectionViewSchema = z.object({
|
|
@@ -1743,6 +1922,23 @@ export const DeleteCollectionViewSchema = z.object({
|
|
|
1743
1922
|
viewId: z.string(),
|
|
1744
1923
|
});
|
|
1745
1924
|
|
|
1925
|
+
export const UpsertCollectionViewPreferenceSchema = z.object({
|
|
1926
|
+
tenantId: z.string(),
|
|
1927
|
+
collectionId: z.string(),
|
|
1928
|
+
viewId: z.string(),
|
|
1929
|
+
columns: z.array(z.object({
|
|
1930
|
+
fieldName: z.string().trim().min(1).max(191),
|
|
1931
|
+
visible: z.boolean(),
|
|
1932
|
+
width: z.number().positive().max(2_000).optional(),
|
|
1933
|
+
})).max(500),
|
|
1934
|
+
});
|
|
1935
|
+
|
|
1936
|
+
export const DeleteCollectionViewPreferenceSchema = z.object({
|
|
1937
|
+
tenantId: z.string(),
|
|
1938
|
+
collectionId: z.string(),
|
|
1939
|
+
viewId: z.string(),
|
|
1940
|
+
});
|
|
1941
|
+
|
|
1746
1942
|
export const ListCollectionButtonsSchema = z.object({
|
|
1747
1943
|
tenantId: z.string(),
|
|
1748
1944
|
collectionId: z.string().optional(),
|
|
@@ -1838,18 +2034,33 @@ export const GetRecordRelationsSchema = z.object({
|
|
|
1838
2034
|
recordId: z.string(),
|
|
1839
2035
|
});
|
|
1840
2036
|
|
|
1841
|
-
|
|
2037
|
+
const ReorderCollectionFieldsBaseSchema = z.object({
|
|
1842
2038
|
tenantId: z.string(),
|
|
1843
2039
|
collectionId: z.string(),
|
|
2040
|
+
});
|
|
1844
2041
|
|
|
1845
|
-
|
|
1846
|
-
|
|
2042
|
+
export const ReorderCollectionFieldsSchema = z.union([
|
|
2043
|
+
ReorderCollectionFieldsBaseSchema.extend({
|
|
2044
|
+
// Canonical shape: explicit field/order pairs.
|
|
2045
|
+
fields: z.array(
|
|
1847
2046
|
z.object({
|
|
1848
2047
|
fieldId: z.string(),
|
|
1849
2048
|
order: z.number(),
|
|
1850
2049
|
})
|
|
1851
|
-
|
|
1852
|
-
|
|
2050
|
+
).min(1),
|
|
2051
|
+
fieldIds: z.array(z.string()).optional(),
|
|
2052
|
+
}),
|
|
2053
|
+
ReorderCollectionFieldsBaseSchema.extend({
|
|
2054
|
+
fields: z.array(
|
|
2055
|
+
z.object({
|
|
2056
|
+
fieldId: z.string(),
|
|
2057
|
+
order: z.number(),
|
|
2058
|
+
})
|
|
2059
|
+
).optional(),
|
|
2060
|
+
// Compatibility with the original backend action.
|
|
2061
|
+
fieldIds: z.array(z.string()).min(1),
|
|
2062
|
+
}),
|
|
2063
|
+
]);
|
|
1853
2064
|
|
|
1854
2065
|
export const GetCollectionSchemaSchema = z.object({
|
|
1855
2066
|
tenantId: z.string(),
|
|
@@ -1889,39 +2100,243 @@ export const CheckRecordPermissionSchema = z.object({
|
|
|
1889
2100
|
action: z.string(), // read | update | delete | restore | duplicate | custom
|
|
1890
2101
|
});
|
|
1891
2102
|
|
|
1892
|
-
export const
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
2103
|
+
export const CollectionAccessPolicyScopeTypeSchema = z.enum(["app", "list", "field"]);
|
|
2104
|
+
export const CollectionAccessPolicySubjectTypeSchema = z.enum(["user", "role", "team", "service"]);
|
|
2105
|
+
export const CollectionAccessPolicyEffectSchema = z.enum(["allow", "deny"]);
|
|
2106
|
+
export const CollectionAccessPolicyActionSchema = z.enum(["read", "create", "update", "delete", "comment", "assign"]);
|
|
2107
|
+
export const CollectionAccessPolicyRowOperatorSchema = z.enum(["me", "user", "team", "linked-record"]);
|
|
2108
|
+
|
|
2109
|
+
export const CollectionAccessPolicyRowFilterSchema = z.object({
|
|
2110
|
+
match: z.enum(["all", "any"]),
|
|
2111
|
+
conditions: z.array(z.object({
|
|
2112
|
+
fieldId: z.string().min(1),
|
|
2113
|
+
operator: CollectionAccessPolicyRowOperatorSchema,
|
|
2114
|
+
value: z.string().optional(),
|
|
2115
|
+
})).min(1).max(20),
|
|
2116
|
+
}).superRefine((filter, context) => {
|
|
2117
|
+
filter.conditions.forEach((condition, index) => {
|
|
2118
|
+
if (
|
|
2119
|
+
(condition.operator === "user"
|
|
2120
|
+
|| condition.operator === "team"
|
|
2121
|
+
|| condition.operator === "linked-record")
|
|
2122
|
+
&& !condition.value?.trim()
|
|
2123
|
+
) {
|
|
2124
|
+
context.addIssue({
|
|
2125
|
+
code: z.ZodIssueCode.custom,
|
|
2126
|
+
path: ["conditions", index, "value"],
|
|
2127
|
+
message: `${condition.operator} filters require a value`,
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
});
|
|
2132
|
+
|
|
2133
|
+
export const ListCollectionAccessPoliciesSchema = z.object({
|
|
2134
|
+
tenantId: z.string().min(1),
|
|
2135
|
+
dataModelId: z.string().optional(),
|
|
2136
|
+
collectionId: z.string().optional(),
|
|
1896
2137
|
});
|
|
1897
2138
|
|
|
1898
|
-
|
|
1899
|
-
tenantId: z.string(),
|
|
1900
|
-
|
|
1901
|
-
|
|
2139
|
+
const CollectionAccessPolicyWriteSchema = z.object({
|
|
2140
|
+
tenantId: z.string().min(1),
|
|
2141
|
+
dataModelId: z.string().min(1),
|
|
2142
|
+
policyId: z.string().optional(),
|
|
2143
|
+
name: z.string().trim().min(1).max(160),
|
|
2144
|
+
scopeType: CollectionAccessPolicyScopeTypeSchema,
|
|
2145
|
+
collectionId: z.string().optional(),
|
|
2146
|
+
fieldId: z.string().optional(),
|
|
2147
|
+
subjectType: CollectionAccessPolicySubjectTypeSchema,
|
|
2148
|
+
subjectId: z.string().trim().min(1).max(255),
|
|
2149
|
+
effect: CollectionAccessPolicyEffectSchema,
|
|
2150
|
+
actions: z.array(CollectionAccessPolicyActionSchema).min(1).max(6),
|
|
2151
|
+
rowFilter: CollectionAccessPolicyRowFilterSchema.nullable().optional(),
|
|
2152
|
+
enabled: z.boolean().optional(),
|
|
2153
|
+
});
|
|
1902
2154
|
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
2155
|
+
function validateCollectionAccessPolicyShape(
|
|
2156
|
+
policy: {
|
|
2157
|
+
scopeType: z.infer<typeof CollectionAccessPolicyScopeTypeSchema>;
|
|
2158
|
+
collectionId?: string | undefined;
|
|
2159
|
+
fieldId?: string | undefined;
|
|
2160
|
+
actions: Array<z.infer<typeof CollectionAccessPolicyActionSchema>>;
|
|
2161
|
+
rowFilter?: z.infer<typeof CollectionAccessPolicyRowFilterSchema> | null | undefined;
|
|
2162
|
+
},
|
|
2163
|
+
context: z.RefinementCtx
|
|
2164
|
+
) {
|
|
2165
|
+
if (policy.scopeType === "app") {
|
|
2166
|
+
if (policy.collectionId) {
|
|
2167
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["collectionId"], message: "App policies cannot target a collection" });
|
|
2168
|
+
}
|
|
2169
|
+
if (policy.fieldId) {
|
|
2170
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "App policies cannot target a field" });
|
|
2171
|
+
}
|
|
2172
|
+
} else if (!policy.collectionId) {
|
|
2173
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["collectionId"], message: "List and field policies require a collection" });
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
if (policy.scopeType === "field") {
|
|
2177
|
+
if (!policy.fieldId) {
|
|
2178
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "Field policies require a field" });
|
|
2179
|
+
}
|
|
2180
|
+
if (policy.actions.some((action) => action !== "read" && action !== "update")) {
|
|
2181
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["actions"], message: "Field policies only support read and update" });
|
|
2182
|
+
}
|
|
2183
|
+
} else if (policy.fieldId) {
|
|
2184
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["fieldId"], message: "Only field policies can target a field" });
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
if (policy.scopeType !== "list" && policy.rowFilter) {
|
|
2188
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["rowFilter"], message: "Data limits can only be attached to list policies" });
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
export const UpsertCollectionAccessPolicySchema = CollectionAccessPolicyWriteSchema
|
|
2193
|
+
.superRefine(validateCollectionAccessPolicyShape);
|
|
2194
|
+
|
|
2195
|
+
export const DeleteCollectionAccessPolicySchema = z.object({
|
|
2196
|
+
tenantId: z.string().min(1),
|
|
2197
|
+
policyId: z.string().min(1),
|
|
2198
|
+
});
|
|
1906
2199
|
|
|
1907
|
-
|
|
1908
|
-
|
|
2200
|
+
export const ListCollectionAccessTeamMembersSchema = z.object({
|
|
2201
|
+
tenantId: z.string().min(1),
|
|
2202
|
+
teamId: z.string().min(1),
|
|
1909
2203
|
});
|
|
1910
2204
|
|
|
1911
|
-
export const
|
|
2205
|
+
export const SetCollectionAccessTeamMembersSchema = z.object({
|
|
2206
|
+
tenantId: z.string().min(1),
|
|
2207
|
+
teamId: z.string().min(1),
|
|
2208
|
+
userIds: z.array(z.string().min(1)).max(1_000),
|
|
2209
|
+
});
|
|
2210
|
+
|
|
2211
|
+
export const PreviewCollectionAccessPolicySchema = z.object({
|
|
2212
|
+
tenantId: z.string().min(1),
|
|
2213
|
+
dataModelId: z.string().min(1),
|
|
2214
|
+
collectionId: z.string().optional(),
|
|
2215
|
+
policy: CollectionAccessPolicyWriteSchema.omit({
|
|
2216
|
+
tenantId: true,
|
|
2217
|
+
dataModelId: true,
|
|
2218
|
+
policyId: true,
|
|
2219
|
+
}).extend({
|
|
2220
|
+
dataModelId: z.string().optional(),
|
|
2221
|
+
collectionId: z.string().optional(),
|
|
2222
|
+
}).superRefine(validateCollectionAccessPolicyShape),
|
|
2223
|
+
record: z.record(z.string(), z.unknown()).optional(),
|
|
2224
|
+
});
|
|
2225
|
+
|
|
2226
|
+
const CollectionCollaborationRecordScopeSchema = z.object({
|
|
2227
|
+
tenantId: z.string().min(1),
|
|
2228
|
+
collectionId: z.string().min(1),
|
|
2229
|
+
recordId: z.string().min(1),
|
|
2230
|
+
});
|
|
2231
|
+
|
|
2232
|
+
const CollectionCollaborationRequestIdSchema = z.string().max(191).optional();
|
|
2233
|
+
|
|
2234
|
+
export const CreateCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2235
|
+
body: z.string().trim().min(1).max(10_000),
|
|
2236
|
+
parentId: z.string().min(1).optional(),
|
|
2237
|
+
mentionUserIds: z.array(z.string().min(1)).max(25).optional(),
|
|
2238
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2239
|
+
});
|
|
2240
|
+
|
|
2241
|
+
export const UpdateCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2242
|
+
commentId: z.string().min(1),
|
|
2243
|
+
body: z.string().trim().min(1).max(10_000),
|
|
2244
|
+
mentionUserIds: z.array(z.string().min(1)).max(25).optional(),
|
|
2245
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2246
|
+
});
|
|
2247
|
+
|
|
2248
|
+
export const DeleteCollectionCommentSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2249
|
+
commentId: z.string().min(1),
|
|
2250
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2251
|
+
});
|
|
2252
|
+
|
|
2253
|
+
export const ListCollectionCommentsSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2254
|
+
limit: z.coerce.number().int().min(1).max(100).optional(),
|
|
2255
|
+
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
2256
|
+
});
|
|
2257
|
+
|
|
2258
|
+
export const ListCollectionRecordActivitySchema = ListCollectionCommentsSchema;
|
|
2259
|
+
|
|
2260
|
+
export const ListCollectionRecordCollaboratorsSchema = CollectionCollaborationRecordScopeSchema;
|
|
2261
|
+
|
|
2262
|
+
export const SetCollectionRecordCollaboratorsSchema = CollectionCollaborationRecordScopeSchema.extend({
|
|
2263
|
+
assigneeIds: z.array(z.string().min(1)).max(20),
|
|
2264
|
+
watcherIds: z.array(z.string().min(1)).max(100),
|
|
2265
|
+
requestId: CollectionCollaborationRequestIdSchema,
|
|
2266
|
+
});
|
|
2267
|
+
|
|
2268
|
+
export const ListCollectionNotificationsSchema = z.object({
|
|
2269
|
+
tenantId: z.string().min(1),
|
|
2270
|
+
limit: z.coerce.number().int().min(1).max(50).optional(),
|
|
2271
|
+
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
2272
|
+
unreadOnly: z.boolean().optional(),
|
|
2273
|
+
});
|
|
2274
|
+
|
|
2275
|
+
export const MarkCollectionNotificationsReadSchema = z.object({
|
|
2276
|
+
tenantId: z.string().min(1),
|
|
2277
|
+
notificationIds: z.array(z.string().min(1)).max(100),
|
|
2278
|
+
});
|
|
2279
|
+
|
|
2280
|
+
export const ListRecordPermissionsSchema = z.object({
|
|
1912
2281
|
tenantId: z.string(),
|
|
1913
2282
|
collectionId: z.string(),
|
|
1914
2283
|
recordId: z.string(),
|
|
2284
|
+
actor: z.string().optional(),
|
|
2285
|
+
subjectType: z.string().optional(),
|
|
2286
|
+
subjectId: z.string().optional(),
|
|
2287
|
+
});
|
|
1915
2288
|
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
// kaldırılacak aksiyonlar
|
|
1921
|
-
// tamamını kaldırmak için ["*"] gönderilebilir
|
|
1922
|
-
actions: z.array(z.string()),
|
|
2289
|
+
const RecordPermissionScopeSchema = z.object({
|
|
2290
|
+
tenantId: z.string(),
|
|
2291
|
+
collectionId: z.string(),
|
|
2292
|
+
recordId: z.string(),
|
|
1923
2293
|
});
|
|
1924
2294
|
|
|
2295
|
+
export const GrantRecordPermissionSchema = z.union([
|
|
2296
|
+
RecordPermissionScopeSchema.extend({
|
|
2297
|
+
// Canonical public shape.
|
|
2298
|
+
subjectType: z.string(), // user | role | group | service | custom
|
|
2299
|
+
subjectId: z.string(),
|
|
2300
|
+
actions: z.array(z.string()).min(1),
|
|
2301
|
+
effect: z.enum(["allow", "deny"]).optional(),
|
|
2302
|
+
grantedBy: z.string().optional(),
|
|
2303
|
+
actor: z.string().optional(),
|
|
2304
|
+
action: z.string().optional(),
|
|
2305
|
+
}),
|
|
2306
|
+
RecordPermissionScopeSchema.extend({
|
|
2307
|
+
// Compatibility with the original single-action backend contract.
|
|
2308
|
+
actor: z.string(),
|
|
2309
|
+
action: z.string(),
|
|
2310
|
+
effect: z.enum(["allow", "deny"]).optional(),
|
|
2311
|
+
grantedBy: z.string().optional(),
|
|
2312
|
+
subjectType: z.string().optional(),
|
|
2313
|
+
subjectId: z.string().optional(),
|
|
2314
|
+
actions: z.array(z.string()).optional(),
|
|
2315
|
+
}),
|
|
2316
|
+
]);
|
|
2317
|
+
|
|
2318
|
+
export const RevokeRecordPermissionSchema = z.union([
|
|
2319
|
+
RecordPermissionScopeSchema.extend({
|
|
2320
|
+
// Canonical public shape.
|
|
2321
|
+
subjectType: z.string(), // user | role | group | service | custom
|
|
2322
|
+
subjectId: z.string(),
|
|
2323
|
+
// tamamını kaldırmak için ["*"] gönderilebilir
|
|
2324
|
+
actions: z.array(z.string()).min(1),
|
|
2325
|
+
revokedBy: z.string().optional(),
|
|
2326
|
+
actor: z.string().optional(),
|
|
2327
|
+
action: z.string().optional(),
|
|
2328
|
+
}),
|
|
2329
|
+
RecordPermissionScopeSchema.extend({
|
|
2330
|
+
// Compatibility with the original single-action backend contract.
|
|
2331
|
+
actor: z.string(),
|
|
2332
|
+
action: z.string(),
|
|
2333
|
+
revokedBy: z.string().optional(),
|
|
2334
|
+
subjectType: z.string().optional(),
|
|
2335
|
+
subjectId: z.string().optional(),
|
|
2336
|
+
actions: z.array(z.string()).optional(),
|
|
2337
|
+
}),
|
|
2338
|
+
]);
|
|
2339
|
+
|
|
1925
2340
|
|
|
1926
2341
|
|
|
1927
2342
|
//---wiki--------------------------------
|
|
@@ -2617,3 +3032,278 @@ export const EnhanceTopicSchema = z.object({
|
|
|
2617
3032
|
entityDescription: z.string(),
|
|
2618
3033
|
categories: z.string().array().optional()
|
|
2619
3034
|
})
|
|
3035
|
+
|
|
3036
|
+
export const CollectionFormLayoutFieldSchema = z.object({
|
|
3037
|
+
fieldId: z.string().trim().min(1).max(191),
|
|
3038
|
+
label: z.string().max(255).optional(),
|
|
3039
|
+
helpText: z.string().max(1_000).optional(),
|
|
3040
|
+
placeholder: z.string().max(500).optional(),
|
|
3041
|
+
required: z.boolean().optional(),
|
|
3042
|
+
width: z.enum(["full", "half"]).optional(),
|
|
3043
|
+
}).strict();
|
|
3044
|
+
|
|
3045
|
+
export const CollectionFormLayoutSectionSchema = z.object({
|
|
3046
|
+
id: z.string().trim().min(1).max(128),
|
|
3047
|
+
title: z.string().max(255).optional(),
|
|
3048
|
+
description: z.string().max(2_000).optional(),
|
|
3049
|
+
fields: z.array(CollectionFormLayoutFieldSchema).max(50),
|
|
3050
|
+
}).strict();
|
|
3051
|
+
|
|
3052
|
+
export const CollectionFormLayoutSchema = z.object({
|
|
3053
|
+
sections: z.array(CollectionFormLayoutSectionSchema).min(1).max(10),
|
|
3054
|
+
}).strict().superRefine((layout, context) => {
|
|
3055
|
+
const sectionIds = new Set<string>();
|
|
3056
|
+
const fieldIds = new Set<string>();
|
|
3057
|
+
let fieldCount = 0;
|
|
3058
|
+
layout.sections.forEach((section, sectionIndex) => {
|
|
3059
|
+
if (sectionIds.has(section.id)) {
|
|
3060
|
+
context.addIssue({
|
|
3061
|
+
code: z.ZodIssueCode.custom,
|
|
3062
|
+
path: ["sections", sectionIndex, "id"],
|
|
3063
|
+
message: "Form section ids must be unique",
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
3066
|
+
sectionIds.add(section.id);
|
|
3067
|
+
section.fields.forEach((field, fieldIndex) => {
|
|
3068
|
+
fieldCount += 1;
|
|
3069
|
+
if (fieldIds.has(field.fieldId)) {
|
|
3070
|
+
context.addIssue({
|
|
3071
|
+
code: z.ZodIssueCode.custom,
|
|
3072
|
+
path: ["sections", sectionIndex, "fields", fieldIndex, "fieldId"],
|
|
3073
|
+
message: "A field can appear only once in a form",
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
fieldIds.add(field.fieldId);
|
|
3077
|
+
});
|
|
3078
|
+
});
|
|
3079
|
+
if (fieldCount === 0 || fieldCount > 50) {
|
|
3080
|
+
context.addIssue({
|
|
3081
|
+
code: z.ZodIssueCode.custom,
|
|
3082
|
+
path: ["sections"],
|
|
3083
|
+
message: "A form must contain between 1 and 50 fields",
|
|
3084
|
+
});
|
|
3085
|
+
}
|
|
3086
|
+
});
|
|
3087
|
+
|
|
3088
|
+
export const ListCollectionFormsSchema = z.object({
|
|
3089
|
+
tenantId: z.string().min(1),
|
|
3090
|
+
dataModelId: z.string().min(1),
|
|
3091
|
+
collectionId: z.string().min(1),
|
|
3092
|
+
});
|
|
3093
|
+
|
|
3094
|
+
export const UpsertCollectionFormSchema = z.object({
|
|
3095
|
+
tenantId: z.string().min(1),
|
|
3096
|
+
dataModelId: z.string().min(1),
|
|
3097
|
+
collectionId: z.string().min(1),
|
|
3098
|
+
formId: z.string().min(1).optional(),
|
|
3099
|
+
name: z.string().trim().min(1).max(191),
|
|
3100
|
+
description: z.string().max(10_000).optional(),
|
|
3101
|
+
layout: CollectionFormLayoutSchema,
|
|
3102
|
+
submitLabel: z.string().trim().min(1).max(100).optional(),
|
|
3103
|
+
successMessage: z.string().trim().min(1).max(2_000).optional(),
|
|
3104
|
+
enabled: z.boolean().optional(),
|
|
3105
|
+
rateLimitPerMinute: z.number().int().min(1).max(100).optional(),
|
|
3106
|
+
maxSubmissions: z.number().int().min(1).max(1_000_000).nullable().optional(),
|
|
3107
|
+
});
|
|
3108
|
+
|
|
3109
|
+
export const ResolveCollectionFormSchema = z.object({
|
|
3110
|
+
tenantId: z.string().min(1),
|
|
3111
|
+
formId: z.string().min(1),
|
|
3112
|
+
});
|
|
3113
|
+
|
|
3114
|
+
export const SubmitCollectionFormSchema = ResolveCollectionFormSchema.extend({
|
|
3115
|
+
values: z.record(z.string(), z.unknown()).refine(
|
|
3116
|
+
(values) => Object.keys(values).length <= 50,
|
|
3117
|
+
"A form submission can contain at most 50 fields"
|
|
3118
|
+
),
|
|
3119
|
+
submissionKey: z.string().trim().min(8).max(128),
|
|
3120
|
+
});
|
|
3121
|
+
|
|
3122
|
+
export const PublishCollectionFormSchema = ResolveCollectionFormSchema.extend({
|
|
3123
|
+
expiresInDays: z.number().int().min(1).max(365).optional(),
|
|
3124
|
+
});
|
|
3125
|
+
|
|
3126
|
+
export const RevokeCollectionFormSchema = ResolveCollectionFormSchema;
|
|
3127
|
+
export const DeleteCollectionFormSchema = ResolveCollectionFormSchema;
|
|
3128
|
+
|
|
3129
|
+
export const CollectionReportTypeSchema = z.enum(["table", "metric", "chart"]);
|
|
3130
|
+
export const CollectionReportVisibilitySchema = z.enum(["personal", "shared"]);
|
|
3131
|
+
const CollectionReportFilterSchema = z.record(z.string(), z.unknown()).superRefine((filter, context) => {
|
|
3132
|
+
if (JSON.stringify(filter).length > 16 * 1024) {
|
|
3133
|
+
context.addIssue({ code: z.ZodIssueCode.custom, message: "Report filter is too large" });
|
|
3134
|
+
}
|
|
3135
|
+
});
|
|
3136
|
+
const CollectionReportBaseSchema = z.object({
|
|
3137
|
+
tenantId: z.string().min(1),
|
|
3138
|
+
dataModelId: z.string().min(1),
|
|
3139
|
+
collectionId: z.string().min(1),
|
|
3140
|
+
reportId: z.string().min(1).optional(),
|
|
3141
|
+
name: z.string().trim().min(1).max(191),
|
|
3142
|
+
description: z.string().max(4_000).optional(),
|
|
3143
|
+
visibility: CollectionReportVisibilitySchema.optional(),
|
|
3144
|
+
});
|
|
3145
|
+
export const CollectionReportTableConfigSchema = z.object({
|
|
3146
|
+
filter: CollectionReportFilterSchema.optional(),
|
|
3147
|
+
fields: z.array(z.string().min(1)).min(1).max(50),
|
|
3148
|
+
sort: z.record(z.string(), z.enum(["asc", "desc"])).refine(
|
|
3149
|
+
(sort) => Object.keys(sort).length <= 5,
|
|
3150
|
+
"Report sort cannot contain more than 5 fields"
|
|
3151
|
+
).optional(),
|
|
3152
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
3153
|
+
}).strict();
|
|
3154
|
+
const CollectionReportAggregateConfigBaseSchema = z.object({
|
|
3155
|
+
filter: CollectionReportFilterSchema.optional(),
|
|
3156
|
+
aggregate: z.enum(["count", "sum", "avg", "min", "max"]),
|
|
3157
|
+
valueField: z.string().min(1).optional(),
|
|
3158
|
+
});
|
|
3159
|
+
export const CollectionReportMetricConfigSchema = CollectionReportAggregateConfigBaseSchema.extend({
|
|
3160
|
+
limit: z.literal(1).optional(),
|
|
3161
|
+
}).strict().superRefine((config, context) => {
|
|
3162
|
+
if (config.aggregate !== "count" && !config.valueField) {
|
|
3163
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["valueField"], message: "This aggregate requires valueField" });
|
|
3164
|
+
}
|
|
3165
|
+
});
|
|
3166
|
+
export const CollectionReportChartConfigSchema = CollectionReportAggregateConfigBaseSchema.extend({
|
|
3167
|
+
groupBy: z.string().min(1),
|
|
3168
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
3169
|
+
}).strict().superRefine((config, context) => {
|
|
3170
|
+
if (config.aggregate !== "count" && !config.valueField) {
|
|
3171
|
+
context.addIssue({ code: z.ZodIssueCode.custom, path: ["valueField"], message: "This aggregate requires valueField" });
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
export const UpsertCollectionReportSchema = z.discriminatedUnion("type", [
|
|
3175
|
+
CollectionReportBaseSchema.extend({ type: z.literal("table"), config: CollectionReportTableConfigSchema }),
|
|
3176
|
+
CollectionReportBaseSchema.extend({ type: z.literal("metric"), config: CollectionReportMetricConfigSchema }),
|
|
3177
|
+
CollectionReportBaseSchema.extend({ type: z.literal("chart"), config: CollectionReportChartConfigSchema }),
|
|
3178
|
+
]);
|
|
3179
|
+
export const ListCollectionReportsSchema = z.object({
|
|
3180
|
+
tenantId: z.string().min(1),
|
|
3181
|
+
dataModelId: z.string().min(1),
|
|
3182
|
+
collectionId: z.string().min(1),
|
|
3183
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
3184
|
+
offset: z.number().int().min(0).max(10_000).optional(),
|
|
3185
|
+
});
|
|
3186
|
+
export const CollectionReportReferenceSchema = z.object({
|
|
3187
|
+
tenantId: z.string().min(1),
|
|
3188
|
+
reportId: z.string().min(1),
|
|
3189
|
+
});
|
|
3190
|
+
export const DeleteCollectionReportSchema = CollectionReportReferenceSchema;
|
|
3191
|
+
export const EvaluateCollectionReportSchema = CollectionReportReferenceSchema;
|
|
3192
|
+
|
|
3193
|
+
const CollectionDashboardWidgetBaseSchema = z.object({
|
|
3194
|
+
id: z.string().min(1).optional(),
|
|
3195
|
+
reportId: z.string().min(1),
|
|
3196
|
+
title: z.string().trim().min(1).max(191),
|
|
3197
|
+
});
|
|
3198
|
+
export const CollectionDashboardWidgetSchema = z.discriminatedUnion("type", [
|
|
3199
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3200
|
+
type: z.literal("table"),
|
|
3201
|
+
config: z.object({
|
|
3202
|
+
pageSize: z.number().int().min(1).max(100).optional(),
|
|
3203
|
+
showHeaders: z.boolean().optional(),
|
|
3204
|
+
}).strict().optional(),
|
|
3205
|
+
}),
|
|
3206
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3207
|
+
type: z.literal("metric"),
|
|
3208
|
+
config: z.object({
|
|
3209
|
+
prefix: z.string().max(32).optional(),
|
|
3210
|
+
suffix: z.string().max(32).optional(),
|
|
3211
|
+
decimals: z.number().int().min(0).max(6).optional(),
|
|
3212
|
+
}).strict().optional(),
|
|
3213
|
+
}),
|
|
3214
|
+
CollectionDashboardWidgetBaseSchema.extend({
|
|
3215
|
+
type: z.literal("chart"),
|
|
3216
|
+
config: z.object({
|
|
3217
|
+
kind: z.enum(["bar", "line", "pie"]).optional(),
|
|
3218
|
+
showLegend: z.boolean().optional(),
|
|
3219
|
+
}).strict().optional(),
|
|
3220
|
+
}),
|
|
3221
|
+
]);
|
|
3222
|
+
export const ListCollectionDashboardsSchema = z.object({
|
|
3223
|
+
tenantId: z.string().min(1),
|
|
3224
|
+
dataModelId: z.string().min(1),
|
|
3225
|
+
collectionId: z.string().min(1),
|
|
3226
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
3227
|
+
offset: z.number().int().min(0).max(10_000).optional(),
|
|
3228
|
+
});
|
|
3229
|
+
export const UpsertCollectionDashboardSchema = z.object({
|
|
3230
|
+
tenantId: z.string().min(1),
|
|
3231
|
+
dataModelId: z.string().min(1),
|
|
3232
|
+
collectionId: z.string().min(1),
|
|
3233
|
+
dashboardId: z.string().min(1).optional(),
|
|
3234
|
+
name: z.string().trim().min(1).max(191),
|
|
3235
|
+
description: z.string().max(4_000).optional(),
|
|
3236
|
+
settings: z.object({
|
|
3237
|
+
columns: z.number().int().min(1).max(4).optional(),
|
|
3238
|
+
compact: z.boolean().optional(),
|
|
3239
|
+
}).strict().optional(),
|
|
3240
|
+
visibility: CollectionReportVisibilitySchema.optional(),
|
|
3241
|
+
widgets: z.array(CollectionDashboardWidgetSchema).max(20),
|
|
3242
|
+
});
|
|
3243
|
+
export const CollectionDashboardReferenceSchema = z.object({
|
|
3244
|
+
tenantId: z.string().min(1),
|
|
3245
|
+
dashboardId: z.string().min(1),
|
|
3246
|
+
});
|
|
3247
|
+
export const DeleteCollectionDashboardSchema = CollectionDashboardReferenceSchema;
|
|
3248
|
+
export const EvaluateCollectionDashboardSchema = CollectionDashboardReferenceSchema;
|
|
3249
|
+
|
|
3250
|
+
export const PreviewCollectionAppGenerationSchema = z.object({
|
|
3251
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3252
|
+
prompt: z.string().trim().min(1).max(4_000),
|
|
3253
|
+
}).strict();
|
|
3254
|
+
|
|
3255
|
+
export const ApplyCollectionAppGenerationSchema = z.object({
|
|
3256
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3257
|
+
planId: z.string().trim().min(1).max(191),
|
|
3258
|
+
expectedProposalHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
3259
|
+
idempotencyKey: z.string().trim().min(8).max(128),
|
|
3260
|
+
}).strict();
|
|
3261
|
+
|
|
3262
|
+
export const RollbackCollectionAppGenerationSchema = z.object({
|
|
3263
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3264
|
+
runId: z.string().trim().min(1).max(191),
|
|
3265
|
+
idempotencyKey: z.string().trim().min(8).max(128),
|
|
3266
|
+
}).strict();
|
|
3267
|
+
|
|
3268
|
+
export const ResumeCollectionAppGenerationRunSchema = z.object({
|
|
3269
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3270
|
+
runId: z.string().trim().min(1).max(191),
|
|
3271
|
+
}).strict();
|
|
3272
|
+
|
|
3273
|
+
export const GetCollectionAppGenerationPlanSchema = z.object({
|
|
3274
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3275
|
+
planId: z.string().trim().min(1).max(191),
|
|
3276
|
+
}).strict();
|
|
3277
|
+
|
|
3278
|
+
export const ListCollectionAppGenerationPlansSchema = z.object({
|
|
3279
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3280
|
+
status: z.enum(["previewed", "applying", "compensating", "applied", "failed", "compensation_failed", "rollback_retained", "rolled_back"]).optional(),
|
|
3281
|
+
offset: z.number().int().min(0).max(1_000_000).optional(),
|
|
3282
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
3283
|
+
}).strict();
|
|
3284
|
+
|
|
3285
|
+
export const GetCollectionAppGenerationRunSchema = z.object({
|
|
3286
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3287
|
+
runId: z.string().trim().min(1).max(191),
|
|
3288
|
+
}).strict();
|
|
3289
|
+
|
|
3290
|
+
export const ListCollectionAppGenerationRunsSchema = z.object({
|
|
3291
|
+
tenantId: z.string().trim().min(1).max(191),
|
|
3292
|
+
planId: z.string().trim().min(1).max(191).optional(),
|
|
3293
|
+
status: z.enum([
|
|
3294
|
+
"applying",
|
|
3295
|
+
"provisioning",
|
|
3296
|
+
"compensating",
|
|
3297
|
+
"applied",
|
|
3298
|
+
"failed",
|
|
3299
|
+
"compensation_failed",
|
|
3300
|
+
"rolling_back",
|
|
3301
|
+
"rollback_cleanup",
|
|
3302
|
+
"rollback_cleanup_failed",
|
|
3303
|
+
"rollback_failed",
|
|
3304
|
+
"rollback_retained",
|
|
3305
|
+
"rolled_back",
|
|
3306
|
+
]).optional(),
|
|
3307
|
+
offset: z.number().int().min(0).max(1_000_000).optional(),
|
|
3308
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
3309
|
+
}).strict();
|