@stoker-platform/web-app 0.2.12 → 0.3.1

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,28 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - feat!: restructure user permissions
8
+ - Updated dependencies
9
+ - @stoker-platform/node-client@0.3.2
10
+ - @stoker-platform/web-client@0.3.1
11
+ - @stoker-platform/utils@0.3.1
12
+
13
+ ## 0.3.0
14
+
15
+ ### Minor Changes
16
+
17
+ - feat!: restructure projects / tenants
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies
22
+ - @stoker-platform/web-client@0.3.0
23
+ - @stoker-platform/utils@0.3.0
24
+ - @stoker-platform/node-client@0.3.1
25
+
3
26
  ## 0.2.12
4
27
 
5
28
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.2.12",
3
+ "version": "0.3.1",
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.7",
53
53
  "@sentry/react": "^10.29.0",
54
- "@stoker-platform/node-client": "0.2.8",
55
- "@stoker-platform/utils": "0.2.7",
56
- "@stoker-platform/web-client": "0.2.9",
54
+ "@stoker-platform/node-client": "0.3.2",
55
+ "@stoker-platform/utils": "0.3.1",
56
+ "@stoker-platform/web-client": "0.3.1",
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
@@ -486,6 +486,7 @@ export function Calendar({
486
486
  ) {
487
487
  const subscribe = async () => {
488
488
  const constraints = constraintsWithoutRangeFilter(filters)
489
+ // TODO: subcollection support
489
490
  const result = await subscribeMany(
490
491
  [labels.collection],
491
492
  [...(constraints as QueryConstraint[]), where(calendarConfig.startField, "==", null)],
package/src/Cards.tsx CHANGED
@@ -873,6 +873,7 @@ function DropZone({
873
873
  ))
874
874
  )
875
875
  return
876
+ // TODO: subcollection support
876
877
  subscribeOne([labels.collection], id, (record) => {
877
878
  if (
878
879
  record &&
@@ -555,6 +555,7 @@ function Collection({
555
555
  }
556
556
  }
557
557
 
558
+ // TODO: subcollection support
558
559
  const result = await subscribeMany(
559
560
  [labels.collection],
560
561
  [
@@ -604,6 +605,7 @@ function Collection({
604
605
  const getServerData = async () => {
605
606
  const options = cloneDeep(query.queries[0].options)
606
607
  delete options.pagination
608
+ // TODO: subcollection support
607
609
  const data = await getSome(
608
610
  [labels.collection],
609
611
  [
@@ -668,6 +670,7 @@ function Collection({
668
670
 
669
671
  const getSingleton = async () => {
670
672
  if (collection.singleton) {
673
+ // TODO: subcollection support
671
674
  const records = await getSome([labels.collection])
672
675
 
673
676
  if (records.docs.length > 0) {
@@ -1254,6 +1257,7 @@ function Collection({
1254
1257
  ) || []),
1255
1258
  ]
1256
1259
  }
1260
+ // TODO: subcollection support
1257
1261
  const serverData = await getSome(
1258
1262
  [labels.collection],
1259
1263
  finalConstraints,
@@ -1407,6 +1411,7 @@ function Collection({
1407
1411
  }
1408
1412
  }
1409
1413
 
1414
+ // TODO: subcollection support
1410
1415
  const data = await getSome(
1411
1416
  [labels.collection],
1412
1417
  (isServerReadOnly ? serverConstraints : webConstraints) as
package/src/Files.tsx CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  deleteFolder,
16
16
  getCurrentUserPermissions,
17
17
  getGlobalConfigModule,
18
+ getTenant,
18
19
  } from "@stoker-platform/web-client"
19
20
  import {
20
21
  getStorage,
@@ -74,6 +75,7 @@ interface FilesProps {
74
75
  }
75
76
 
76
77
  export const RecordFiles = ({ collection, record }: FilesProps) => {
78
+ const tenantId = getTenant()
77
79
  const { labels } = collection
78
80
  const customization = getCollectionConfigModule(labels.collection)
79
81
  const { toast } = useToast()
@@ -127,7 +129,7 @@ export const RecordFiles = ({ collection, record }: FilesProps) => {
127
129
  }, 150)
128
130
  }, [])
129
131
 
130
- const basePath = record ? `${record.Collection_Path.join("/")}/${record.id}` : ""
132
+ const basePath = record ? `${tenantId}/${record.Collection_Path.join("/")}/${record.id}` : ""
131
133
 
132
134
  const totalPages = Math.ceil(items.length / itemsPerPage)
133
135
  const startIndex = (currentPage - 1) * itemsPerPage
package/src/Filters.tsx CHANGED
@@ -126,6 +126,7 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
126
126
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
127
127
  [filter.field]: filter.value!,
128
128
  }))
129
+ // TODO: subcollection support
129
130
  getOne([field.collection], filter.value).then((record) => {
130
131
  setDisplay((prev) => ({
131
132
  ...prev,
@@ -282,6 +283,7 @@ export function Filters({ collection, excluded, relationList }: FiltersProps) {
282
283
  }
283
284
  }
284
285
 
286
+ // TODO: subcollection support
285
287
  getSome([collection], newConstraints as QueryConstraint[] | [string, WhereFilterOp, unknown][], {
286
288
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
287
289
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
package/src/Form.tsx CHANGED
@@ -54,6 +54,7 @@ import {
54
54
  removeTimezone,
55
55
  serializeTimestamps,
56
56
  getFiles,
57
+ getTenant,
57
58
  } from "@stoker-platform/web-client"
58
59
  import { createElement, forwardRef, startTransition, useCallback, useEffect, useMemo, useRef, useState } from "react"
59
60
  import { useNavigate, useParams } from "react-router"
@@ -1753,6 +1754,7 @@ function RelationField({
1753
1754
  }
1754
1755
  }
1755
1756
 
1757
+ // TODO: subcollection support
1756
1758
  getSome([labels.collection], newConstraints, {
1757
1759
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
1758
1760
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
@@ -1813,6 +1815,7 @@ function RelationField({
1813
1815
  if (["ManyToOne", "ManyToMany"].includes(field.type)) {
1814
1816
  let relation = data?.find((record) => record.id === inputValue)
1815
1817
  if (!relation) {
1818
+ // TODO: subcollection support
1816
1819
  relation = await getOne([relationCollection.labels.collection], inputValue, {
1817
1820
  noEmbeddingFields: true,
1818
1821
  })
@@ -2113,6 +2116,7 @@ function RecordForm({
2113
2116
  fromRelationList,
2114
2117
  }: FormProps) {
2115
2118
  const { labels, access, fields, auth, recordTitleField, softDelete, relationLists } = collection
2119
+ const tenantId = getTenant()
2116
2120
  const schema = getSchema()
2117
2121
  const softDeleteField = softDelete?.archivedField
2118
2122
  const softDeleteTimestampField = softDelete?.timestampField
@@ -2917,7 +2921,7 @@ function RecordForm({
2917
2921
  unsubscribe.current?.()
2918
2922
  permissionsLoaded.current = true
2919
2923
  const unsubscribePermissions = onSnapshot(
2920
- doc(db, "system_user_permissions", record.User_ID),
2924
+ doc(db, "tenants", tenantId, "system_user_permissions", record.User_ID),
2921
2925
  { includeMetadataChanges: true },
2922
2926
  (doc) => {
2923
2927
  if (doc.metadata.fromCache) return
@@ -2997,6 +3001,7 @@ function RecordForm({
2997
3001
  return
2998
3002
  }
2999
3003
  const relationFields = getRelationFields(collection)
3004
+ // TODO: subcollection support
3000
3005
  const record = await getOne([collection.labels.collection], entity, {
3001
3006
  noEmbeddingFields: true,
3002
3007
  relations: { fields: relationFields, depth: 1 },
@@ -3056,6 +3061,7 @@ function RecordForm({
3056
3061
  const relationCollection =
3057
3062
  schema.collections[collectionField.collection]
3058
3063
  const relationFields = getRelationFields(relationCollection)
3064
+ // TODO: subcollection support
3059
3065
  const record = await getOne([collectionField.collection], entity, {
3060
3066
  noEmbeddingFields: true,
3061
3067
  relations: { fields: relationFields, depth: 1 },
@@ -3718,7 +3724,7 @@ function RecordForm({
3718
3724
 
3719
3725
  if (operation === "create") {
3720
3726
  const serverWrite = isServerCreate(collection, userData)
3721
- const docId = doc(dbCollection(db, labels.collection)).id
3727
+ const docId = doc(dbCollection(db, "tenants", tenantId, labels.collection)).id
3722
3728
 
3723
3729
  setGlobalLoading("+", docId, serverWrite, !(serverWrite || isServerReadOnly))
3724
3730
  if (isServerReadOnly) {
package/src/Images.tsx CHANGED
@@ -500,6 +500,7 @@ export const Images = memo(
500
500
  const removedIds = Array.from(prevIds.difference(newIds))
501
501
  removedIds.forEach((id) => {
502
502
  let unsubscribeOne: () => void
503
+ // TODO: subcollection support
503
504
  subscribeOne([labels.collection], id, (record) => {
504
505
  if (
505
506
  record &&
@@ -123,6 +123,7 @@ export const PermissionPicker = ({
123
123
  }
124
124
  }
125
125
 
126
+ // TODO: subcollection support
126
127
  getSome([labels.collection], newConstraints, {
127
128
  only: isCollectionPreloadCacheEnabled ? "cache" : undefined,
128
129
  pagination: isCollectionPreloadCacheEnabled ? undefined : { number: 10 },
@@ -168,6 +169,7 @@ export const PermissionPicker = ({
168
169
  const handleChange = useCallback(async () => {
169
170
  let relation = data?.find((record) => record.id === inputValue)
170
171
  if (!relation) {
172
+ // TODO: subcollection support
171
173
  relation = await getOne([labels.collection], inputValue, { noEmbeddingFields: true })
172
174
  }
173
175
  form.setValue(`accessible-${mainCollection.labels.collection}-${collection.labels.collection}`, {
@@ -190,6 +192,7 @@ export const PermissionPicker = ({
190
192
 
191
193
  let relation = data?.find((record) => record.id === inputValue)
192
194
  if (!relation) {
195
+ // TODO: subcollection support
193
196
  relation = await getOne([labels.collection], inputValue, { noEmbeddingFields: true })
194
197
  }
195
198
 
@@ -48,6 +48,7 @@ export const getData = async (
48
48
  }
49
49
  }
50
50
 
51
+ // TODO: subcollection support
51
52
  const result = await subscribeMany(
52
53
  [labels.collection],
53
54
  currentQuery.constraints as QueryConstraint[],
@@ -80,6 +81,7 @@ export const getData = async (
80
81
  }
81
82
 
82
83
  const getServerData = async () => {
84
+ // TODO: subcollection support
83
85
  const data = await getSome(
84
86
  [labels.collection],
85
87
  query.queries[0].constraints as [string, WhereFilterOp, unknown][],