@stoker-platform/web-app 0.5.74 → 0.5.76

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.76
4
+
5
+ ### Patch Changes
6
+
7
+ - feat!: simplify SDK API parameters
8
+ - Updated dependencies
9
+ - @stoker-platform/node-client@0.5.44
10
+ - @stoker-platform/web-client@0.5.44
11
+
12
+ ## 0.5.75
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @stoker-platform/utils@0.5.37
18
+ - @stoker-platform/node-client@0.5.43
19
+ - @stoker-platform/web-client@0.5.43
20
+
3
21
  ## 0.5.74
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.74",
3
+ "version": "0.5.76",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
@@ -51,9 +51,9 @@
51
51
  "@radix-ui/react-tooltip": "^1.2.8",
52
52
  "@react-google-maps/api": "^2.20.8",
53
53
  "@sentry/react": "^10.47.0",
54
- "@stoker-platform/node-client": "0.5.42",
55
- "@stoker-platform/utils": "0.5.36",
56
- "@stoker-platform/web-client": "0.5.42",
54
+ "@stoker-platform/node-client": "0.5.44",
55
+ "@stoker-platform/utils": "0.5.37",
56
+ "@stoker-platform/web-client": "0.5.44",
57
57
  "@tanstack/react-table": "^8.21.3",
58
58
  "@types/react": "18.3.13",
59
59
  "@types/react-dom": "18.3.1",
package/src/Calendar.tsx CHANGED
@@ -498,7 +498,6 @@ export function Calendar({
498
498
  // TODO: subcollection support
499
499
  const result = await subscribeMany(
500
500
  [labels.collection],
501
- [...(constraints as QueryConstraint[]), where(calendarConfig.startField, "==", null)],
502
501
  (docs) => {
503
502
  docs.sort((a, b) => {
504
503
  // eslint-disable-next-line security/detect-object-injection
@@ -516,6 +515,10 @@ export function Calendar({
516
515
  console.error(error)
517
516
  },
518
517
  {
518
+ constraints: [
519
+ ...(constraints as QueryConstraint[]),
520
+ where(calendarConfig.startField, "==", null),
521
+ ],
519
522
  pagination: {
520
523
  number: 250,
521
524
  },
@@ -781,7 +784,7 @@ export function Calendar({
781
784
 
782
785
  const originalRecord = cloneDeep(record)
783
786
  setGlobalLoading("+", record.id, serverWrite, !(serverWrite || isServerReadOnly))
784
- updateRecord(record.Collection_Path, record.id, updatedFields, undefined, undefined, originalRecord)
787
+ updateRecord(record.Collection_Path, record.id, updatedFields, { originalRecord })
785
788
  .then(() => {
786
789
  if (serverWrite || isServerReadOnly) {
787
790
  toast({
package/src/Cards.tsx CHANGED
@@ -618,9 +618,7 @@ function DropZone({
618
618
  record.Collection_Path,
619
619
  record.id,
620
620
  { [statusField.name]: statusValue },
621
- undefined,
622
- undefined,
623
- originalRecord,
621
+ { originalRecord },
624
622
  )
625
623
  .then(() => {
626
624
  if (serverWrite || isServerReadOnly) {
@@ -655,9 +653,7 @@ function DropZone({
655
653
  {
656
654
  [statusField.name]: statusValue === statusValues[0],
657
655
  },
658
- undefined,
659
- undefined,
660
- originalRecord,
656
+ { originalRecord },
661
657
  )
662
658
  .then(() => {
663
659
  if (serverWrite || isServerReadOnly) {
@@ -611,12 +611,6 @@ function Collection({
611
611
  // TODO: subcollection support
612
612
  const result = await subscribeMany(
613
613
  [labels.collection],
614
- [
615
- ...(currentQuery.constraints as QueryConstraint[]),
616
- ...(additionalConstraintsRef.current?.map((constraint) =>
617
- where(constraint[0], constraint[1] as WhereFilterOp, constraint[2]),
618
- ) || []),
619
- ],
620
614
  (docs: StokerRecord[], cursor?: Cursor) => {
621
615
  loadedDocs = docs
622
616
  newCursor = {
@@ -640,6 +634,12 @@ function Collection({
640
634
  },
641
635
  {
642
636
  ...currentQuery.options,
637
+ constraints: [
638
+ ...(currentQuery.constraints as QueryConstraint[]),
639
+ ...(additionalConstraintsRef.current?.map((constraint) =>
640
+ where(constraint[0], constraint[1] as WhereFilterOp, constraint[2]),
641
+ ) || []),
642
+ ],
643
643
  tempCache:
644
644
  isPreloadCacheEnabled && relationList?.loadAll
645
645
  ? {
@@ -668,14 +668,13 @@ function Collection({
668
668
  const options = cloneDeep(query.queries[0].options)
669
669
  delete options.pagination
670
670
  // TODO: subcollection support
671
- const data = await getSome(
672
- [labels.collection],
673
- [
671
+ const data = await getSome([labels.collection], {
672
+ ...(options as GetSomeOptions),
673
+ constraints: [
674
674
  ...(query.queries[0].constraints as [string, WhereFilterOp, unknown][]),
675
675
  ...(additionalConstraintsRef.current || []),
676
676
  ],
677
- options as GetSomeOptions,
678
- )
677
+ })
679
678
  setServerList((prev) => ({ ...prev, [key]: data.docs }))
680
679
  setOptimisticList(data.docs, key)
681
680
  setIsRouteLoading("-", location.pathname)
@@ -1402,10 +1401,10 @@ function Collection({
1402
1401
  // TODO: subcollection support
1403
1402
  const serverData = await getSome(
1404
1403
  [labels.collection],
1405
- finalConstraints,
1406
1404
  isServerReadOnly
1407
- ? undefined
1405
+ ? { constraints: finalConstraints }
1408
1406
  : {
1407
+ constraints: finalConstraints,
1409
1408
  pagination: { orderByField, orderByDirection, number: 10000 },
1410
1409
  },
1411
1410
  )
@@ -1554,17 +1553,14 @@ function Collection({
1554
1553
  }
1555
1554
 
1556
1555
  // TODO: subcollection support
1557
- const data = await getSome(
1558
- [labels.collection],
1559
- (isServerReadOnly ? serverConstraints : webConstraints) as
1556
+ const data = await getSome([labels.collection], {
1557
+ constraints: (isServerReadOnly ? serverConstraints : webConstraints) as
1560
1558
  | [string, WhereFilterOp, unknown][]
1561
1559
  | QueryConstraint[],
1562
- {
1563
- only: isPreloadCacheEnabled ? "cache" : undefined,
1564
- pagination: isPreloadCacheEnabled ? undefined : { number: 10 },
1565
- noEmbeddingFields: true,
1566
- },
1567
- )
1560
+ only: isPreloadCacheEnabled ? "cache" : undefined,
1561
+ pagination: isPreloadCacheEnabled ? undefined : { number: 10 },
1562
+ noEmbeddingFields: true,
1563
+ })
1568
1564
 
1569
1565
  const parentId = relationParent?.id
1570
1566
  const relationArrayField = `${relationList.field}_Array`
@@ -1625,7 +1621,7 @@ function Collection({
1625
1621
  isRelationServerWrite,
1626
1622
  !(isRelationServerWrite || isRelationServerReadOnly),
1627
1623
  )
1628
- updateRecord(record.Collection_Path, record.id, updatedFields, undefined, undefined, originalRecord)
1624
+ updateRecord(record.Collection_Path, record.id, updatedFields, { originalRecord })
1629
1625
  .then(() => {
1630
1626
  if (isRelationServerWrite || isRelationServerReadOnly) {
1631
1627
  if (isRelationServerReadOnly) {
package/src/Filters.tsx CHANGED
@@ -292,7 +292,8 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
292
292
  }
293
293
 
294
294
  // TODO: subcollection support
295
- getSome([collection], newConstraints as QueryConstraint[] | [string, WhereFilterOp, unknown][], {
295
+ getSome([collection], {
296
+ constraints: newConstraints as QueryConstraint[] | [string, WhereFilterOp, unknown][],
296
297
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
297
298
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
298
299
  noEmbeddingFields: true,
package/src/Form.tsx CHANGED
@@ -1921,7 +1921,8 @@ function RelationField({
1921
1921
  }
1922
1922
 
1923
1923
  // TODO: subcollection support
1924
- getSome([labels.collection], newConstraints, {
1924
+ getSome([labels.collection], {
1925
+ constraints: newConstraints,
1925
1926
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
1926
1927
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
1927
1928
  noEmbeddingFields: true,
@@ -3978,14 +3979,11 @@ function RecordForm({
3978
3979
  }
3979
3980
  }
3980
3981
 
3981
- addRecord(
3982
- path,
3983
- recordToSave,
3984
- userData as UserData & { password: string; passwordConfirm: string },
3985
- undefined,
3986
- docId,
3982
+ addRecord(path, recordToSave, {
3983
+ user: userData as UserData & { password: string; passwordConfirm: string },
3984
+ id: docId,
3987
3985
  onValid,
3988
- )
3986
+ })
3989
3987
  .then((record: Partial<StokerRecord>) => {
3990
3988
  if (serverWrite || isServerReadOnly) {
3991
3989
  toast({
@@ -4027,7 +4025,7 @@ function RecordForm({
4027
4025
  const filePath = `${basePath}/${filename}`
4028
4026
  const storageRef = ref(storage, filePath)
4029
4027
  const url = await getDownloadURL(storageRef)
4030
- await updateRecord(path, docId, { [fieldName]: url }, undefined, undefined, originalRecord)
4028
+ await updateRecord(path, docId, { [fieldName]: url }, { originalRecord })
4031
4029
  }
4032
4030
  setQueuedImageUploads({})
4033
4031
  })
@@ -4086,14 +4084,10 @@ function RecordForm({
4086
4084
 
4087
4085
  const finalRecord = { ...originalRecord, ...cloneDeep(recordToSave) } as StokerRecord
4088
4086
 
4089
- updateRecord(
4090
- path,
4091
- id,
4092
- recordToSave,
4093
- userData as UserData & { operation: "create" | "update" | "delete" },
4094
- undefined,
4087
+ updateRecord(path, id, recordToSave, {
4088
+ user: userData as UserData & { operation: "create" | "update" | "delete" },
4095
4089
  originalRecord,
4096
- )
4090
+ })
4097
4091
  .then(async () => {
4098
4092
  if (serverWrite || isServerReadOnly) {
4099
4093
  toast({
@@ -4152,14 +4146,9 @@ function RecordForm({
4152
4146
  const serverWrite = isServerUpdate(collection, { ...recordToSave, id: selectedRecord.id })
4153
4147
  setGlobalLoading("+", selectedRecord.id, serverWrite, !(serverWrite || isServerReadOnly))
4154
4148
 
4155
- const updatePromise = updateRecord(
4156
- path,
4157
- selectedRecord.id,
4158
- recordToSave,
4159
- undefined,
4160
- undefined,
4161
- selectedRecord,
4162
- )
4149
+ const updatePromise = updateRecord(path, selectedRecord.id, recordToSave, {
4150
+ originalRecord: selectedRecord,
4151
+ })
4163
4152
  .catch((error) => {
4164
4153
  console.error(`Failed to update record ${selectedRecord.id}:`, error)
4165
4154
  toast({
package/src/Map.tsx CHANGED
@@ -480,7 +480,7 @@ export function Map({
480
480
 
481
481
  setGlobalLoading("+", record.id, serverWrite, !(serverWrite || isServerReadOnly))
482
482
  isUpdatingRecord.current = false
483
- updateRecord(record.Collection_Path, record.id, updatedFields, undefined, undefined, originalRecord)
483
+ updateRecord(record.Collection_Path, record.id, updatedFields, { originalRecord })
484
484
  .then(() => {
485
485
  if (serverWrite || isServerReadOnly) {
486
486
  toast({
@@ -124,7 +124,8 @@ export const PermissionPicker = ({
124
124
  }
125
125
 
126
126
  // TODO: subcollection support
127
- getSome([labels.collection], newConstraints, {
127
+ getSome([labels.collection], {
128
+ constraints: newConstraints,
128
129
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
129
130
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
130
131
  noEmbeddingFields: true,
@@ -110,7 +110,6 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
110
110
 
111
111
  const result = await subscribeMany(
112
112
  [labels.collection],
113
- currentQuery.constraints as QueryConstraint[],
114
113
  (docs: StokerRecord[]) => {
115
114
  loadedDocs = docs
116
115
  queryLoaded = true
@@ -126,6 +125,7 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
126
125
  resolve()
127
126
  },
128
127
  {
128
+ constraints: currentQuery.constraints as QueryConstraint[],
129
129
  pagination: {
130
130
  number: 5,
131
131
  },
@@ -145,15 +145,12 @@ export function SearchAllResults({ collection, search }: { collection: Collectio
145
145
  }
146
146
 
147
147
  const getServerData = async () => {
148
- const data = await getSome(
149
- [labels.collection],
150
- query.queries[0].constraints as [string, WhereFilterOp, unknown][],
151
- {
152
- pagination: {
153
- number: 5,
154
- },
148
+ const data = await getSome([labels.collection], {
149
+ constraints: query.queries[0].constraints as [string, WhereFilterOp, unknown][],
150
+ pagination: {
151
+ number: 5,
155
152
  },
156
- )
153
+ })
157
154
  setResults(data.docs)
158
155
  setLoading(false)
159
156
  resolve()
@@ -51,7 +51,6 @@ export const getData = async (
51
51
  // TODO: subcollection support
52
52
  const result = await subscribeMany(
53
53
  [labels.collection],
54
- currentQuery.constraints as QueryConstraint[],
55
54
  (docs: StokerRecord[]) => {
56
55
  loadedDocs = docs
57
56
  queryLoaded = true
@@ -66,6 +65,7 @@ export const getData = async (
66
65
  }
67
66
  resolve()
68
67
  },
68
+ { constraints: currentQuery.constraints as QueryConstraint[] },
69
69
  )
70
70
  const { unsubscribe: newUnsubscribe } = result
71
71
  promiseLoaded = true
@@ -82,10 +82,9 @@ export const getData = async (
82
82
 
83
83
  const getServerData = async () => {
84
84
  // TODO: subcollection support
85
- const data = await getSome(
86
- [labels.collection],
87
- query.queries[0].constraints as [string, WhereFilterOp, unknown][],
88
- )
85
+ const data = await getSome([labels.collection], {
86
+ constraints: query.queries[0].constraints as [string, WhereFilterOp, unknown][],
87
+ })
89
88
  setResults(data.docs)
90
89
  setLoading(false)
91
90
  resolve()