geek-cafe-saas-sdk 0.7.1__py3-none-any.whl → 0.7.2__py3-none-any.whl

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.

Potentially problematic release.


This version of geek-cafe-saas-sdk might be problematic. Click here for more details.

@@ -3,7 +3,7 @@ Geek Cafe Services - Base Reusable Services for SaaS
3
3
 
4
4
  Version 0.6.0 adds File System Service
5
5
  """
6
- __version__ = "0.7.1"
6
+ __version__ = "0.7.2"
7
7
 
8
8
  # Import main modules for easier access
9
9
  from . import services
@@ -500,12 +500,14 @@ class FileShareService(DatabaseService[FileShare]):
500
500
  def _get_file_any_user(self, tenant_id: str, file_id: str) -> ServiceResult[File]:
501
501
  """Get file without access control (for internal use)."""
502
502
  try:
503
- pk = f"FILE#{tenant_id}#{file_id}"
504
- sk = "metadata"
503
+
504
+ file = File()
505
+ file.id = file_id
506
+ file.tenant_id = tenant_id
505
507
 
506
508
  result = self.dynamodb.get(
507
509
  table_name=self.table_name,
508
- key={"pk": pk, "sk": sk}
510
+ model=file
509
511
  )
510
512
 
511
513
  if not result or 'Item' not in result:
@@ -530,21 +532,21 @@ class FileShareService(DatabaseService[FileShare]):
530
532
  ) -> Optional[FileShare]:
531
533
  """Check if share already exists."""
532
534
  try:
533
- gsi1_pk = f"FILE#{tenant_id}#{file_id}"
534
- gsi1_sk = f"USER#{shared_with_user_id}"
535
+ # Query GSI1 by file_id to get all shares for this file
536
+ temp_share = FileShare()
537
+ temp_share.file_id = file_id
535
538
 
536
- results = self.dynamodb.query(
537
- key=Key('gsi1_pk').eq(gsi1_pk) & Key('gsi1_sk').eq(gsi1_sk),
538
- table_name=self.table_name,
539
- index_name="gsi1",
540
- limit=1
541
- )
539
+ result = self._query_by_index(temp_share, "gsi1", limit=100)
542
540
 
543
- items = results.get('Items', [])
544
- if items:
545
- share = FileShare()
546
- share.map(items[0])
547
- return share
541
+ if not result.success:
542
+ return None
543
+
544
+ # Filter for matching tenant and user (active shares only)
545
+ for share in result.data:
546
+ if (share.tenant_id == tenant_id and
547
+ share.shared_with_user_id == shared_with_user_id and
548
+ share.status == "active"):
549
+ return share
548
550
 
549
551
  return None
550
552
 
@@ -559,12 +561,14 @@ class FileShareService(DatabaseService[FileShare]):
559
561
  ) -> None:
560
562
  """Increment share access count."""
561
563
  try:
562
- pk = f"FILE#{tenant_id}#{file_id}"
563
- sk = f"SHARE#{share_id}"
564
+ share = FileShare()
565
+ share.id = share_id
566
+ share.tenant_id = tenant_id
567
+ share.file_id = file_id
564
568
 
565
569
  result = self.dynamodb.get(
566
570
  table_name=self.table_name,
567
- key={"pk": pk, "sk": sk}
571
+ model=share
568
572
  )
569
573
 
570
574
  if result and 'Item' in result:
@@ -575,6 +579,9 @@ class FileShareService(DatabaseService[FileShare]):
575
579
  share.last_accessed_at = dt.datetime.now(dt.UTC).timestamp()
576
580
 
577
581
  share.prep_for_save()
578
- self._save_model(share)
582
+ self.dynamodb.save(
583
+ table_name=self.table_name,
584
+ item=share
585
+ )
579
586
  except Exception:
580
587
  pass # Best effort
@@ -350,11 +350,12 @@ class FileSystemService(DatabaseService[File]):
350
350
  )
351
351
 
352
352
  # Delete from DynamoDB
353
- pk = f"FILE#{tenant_id}#{resource_id}"
354
- sk = "metadata"
353
+ file = File()
354
+ file.id = resource_id
355
+ file.tenant_id = tenant_id
355
356
 
356
357
  self.dynamodb.delete(
357
- primary_key={"pk": pk, "sk": sk},
358
+ model=file,
358
359
  table_name=self.table_name
359
360
  )
360
361
  else:
@@ -515,12 +515,13 @@ class FileVersionService(DatabaseService[FileVersion]):
515
515
  def _get_file(self, tenant_id: str, file_id: str, user_id: str) -> ServiceResult[File]:
516
516
  """Get file with access control."""
517
517
  try:
518
- pk = f"FILE#{tenant_id}#{file_id}"
519
- sk = "metadata"
518
+ file = File()
519
+ file.id = file_id
520
+ file.tenant_id = tenant_id
520
521
 
521
522
  result = self.dynamodb.get(
522
523
  table_name=self.table_name,
523
- key={"pk": pk, "sk": sk}
524
+ model=file
524
525
  )
525
526
 
526
527
  if not result or 'Item' not in result:
@@ -543,10 +544,13 @@ class FileVersionService(DatabaseService[FileVersion]):
543
544
  def _get_latest_version_number(self, tenant_id: str, file_id: str) -> int:
544
545
  """Get the latest version number for a file."""
545
546
  try:
546
- gsi1_pk = f"FILE#{tenant_id}#{file_id}"
547
+ file = File()
548
+ file.id = file_id
549
+ file.tenant_id = tenant_id
547
550
 
551
+ key = file.get_key("gsi1")
548
552
  results = self.dynamodb.query(
549
- key=Key('gsi1_pk').eq(gsi1_pk) & Key('gsi1_sk').begins_with("VERSION#"),
553
+ key=key,
550
554
  table_name=self.table_name,
551
555
  index_name="gsi1",
552
556
  limit=1,
@@ -572,12 +576,14 @@ class FileVersionService(DatabaseService[FileVersion]):
572
576
  ) -> None:
573
577
  """Mark a version as not current."""
574
578
  try:
575
- pk = f"FILE#{tenant_id}#{file_id}"
576
- sk = f"VERSION#{version_id}"
579
+ version = FileVersion()
580
+ version.id = version_id
581
+ version.tenant_id = tenant_id
582
+ version.file_id = file_id
577
583
 
578
584
  result = self.dynamodb.get(
579
585
  table_name=self.table_name,
580
- key={"pk": pk, "sk": sk}
586
+ model=version
581
587
  )
582
588
 
583
589
  if result and 'Item' in result:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: geek_cafe_saas_sdk
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Base Reusable Services for SaaS
5
5
  Project-URL: Homepage, https://github.com/geekcafe/geek-cafe-services
6
6
  Project-URL: Documentation, https://github.com/geekcafe/geek-cafe-services/blob/main/README.md
@@ -1,4 +1,4 @@
1
- geek_cafe_saas_sdk/__init__.py,sha256=cLF_Fa1JQqGWMYk2J8hp9nX4IuMyO4gKR7qmaKV_xcs,187
1
+ geek_cafe_saas_sdk/__init__.py,sha256=6akqUf1q618584Azt24YKOhlq0r6YcNVl0Be6BQjh2A,187
2
2
  geek_cafe_saas_sdk/core/__init__.py,sha256=3o3-n1ojO_a_X2bEfzhnxmcjAzuzAU73VTcuRva_f5U,279
3
3
  geek_cafe_saas_sdk/core/audit_mixin.py,sha256=hQz0XYUr_Trqpv4JXxywVNxqJJehQwLu79Y1NBpRwzo,1150
4
4
  geek_cafe_saas_sdk/core/error_codes.py,sha256=vf82TDaJ0qIQLzgjTu96nK9cAaSWK7pYfnOW8HCvSxE,5010
@@ -86,9 +86,9 @@ geek_cafe_saas_sdk/domains/files/models/file_version.py,sha256=L15TvTfzhEDbs_Lwf
86
86
  geek_cafe_saas_sdk/domains/files/services/__init__.py,sha256=tzbye87Sk50h7XZJtcvhFF9uAKQr-HgckPfh0wsYVyk,556
87
87
  geek_cafe_saas_sdk/domains/files/services/directory_service.py,sha256=4WKyEB5ho_4dnvljQq0VHY_mSt07p6tyrJvIZRQXpM0,22836
88
88
  geek_cafe_saas_sdk/domains/files/services/file_lineage_service.py,sha256=TdYPTu0fun71RtGaFzrnMI0ONSb1Je7NE8qSkBZz0eM,17545
89
- geek_cafe_saas_sdk/domains/files/services/file_share_service.py,sha256=bkz7A59ZzMRL996fN4laTqn0dUWApALZ7OqSlv2xr2k,20119
90
- geek_cafe_saas_sdk/domains/files/services/file_system_service.py,sha256=LEC7CjdL04OwP8X3o62-GicQIzjcAG-UcKRLJNjXMeU,19077
91
- geek_cafe_saas_sdk/domains/files/services/file_version_service.py,sha256=-Ckm3XZVzDFinqSiA5X3bkURde8EMTSuKek1eoMYD7U,23421
89
+ geek_cafe_saas_sdk/domains/files/services/file_share_service.py,sha256=mlw2k5t8VeVJ-6RAqOBgbSuJ3F1vVC4FZpYNnRoALEU,20376
90
+ geek_cafe_saas_sdk/domains/files/services/file_system_service.py,sha256=uoO3RT_FZuGZxA4S3YmpXUIKymj6M8qcnL2DIyoCD9o,19079
91
+ geek_cafe_saas_sdk/domains/files/services/file_version_service.py,sha256=nzGVoQb94QbfZbtt7pvCrTEPnuY0uzwLEGDWS8eQ_No,23498
92
92
  geek_cafe_saas_sdk/domains/files/services/s3_file_service.py,sha256=T0lyUK97w-L-PrqzTRhdqxKmiW_w15k2y3BslE6WvQw,16920
93
93
  geek_cafe_saas_sdk/domains/messaging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
94
94
  geek_cafe_saas_sdk/domains/messaging/handlers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -259,7 +259,7 @@ geek_cafe_saas_sdk/utilities/logging_utility.py,sha256=3VwPGleoRw7c4Bn43_Kujl1CQ
259
259
  geek_cafe_saas_sdk/utilities/message_query_helper.py,sha256=8iMuacRPfom_T06-VMhaSp-90D8604q7waM-GVcpPNQ,11500
260
260
  geek_cafe_saas_sdk/utilities/response.py,sha256=0sylVbm_ieIsNGsm9mWXSIdLSyOeoACwFZQQUxyim3s,5964
261
261
  geek_cafe_saas_sdk/utilities/string_functions.py,sha256=_1F4dGyzuD3fAcV1w7A8bv1e-3p0DbNAv_i6-fsekg8,5973
262
- geek_cafe_saas_sdk-0.7.1.dist-info/METADATA,sha256=wpZ4YyWHwza7H9saWsOBmuDc9vHwHE4ppkDdRbg3df4,16068
263
- geek_cafe_saas_sdk-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
264
- geek_cafe_saas_sdk-0.7.1.dist-info/licenses/LICENSE,sha256=EHsHc4GFN0U63LgqDSY2aQRKRupbq6QgixCwopdIU2E,2097
265
- geek_cafe_saas_sdk-0.7.1.dist-info/RECORD,,
262
+ geek_cafe_saas_sdk-0.7.2.dist-info/METADATA,sha256=2ZK6Bof_jeNVM1sbJyp4ttGPK4HKAOlbPoHZKnE5b2o,16068
263
+ geek_cafe_saas_sdk-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
264
+ geek_cafe_saas_sdk-0.7.2.dist-info/licenses/LICENSE,sha256=EHsHc4GFN0U63LgqDSY2aQRKRupbq6QgixCwopdIU2E,2097
265
+ geek_cafe_saas_sdk-0.7.2.dist-info/RECORD,,