schema and updates

This commit is contained in:
djkato 2024-10-30 19:22:23 +01:00
parent 399f6a6761
commit 4b53dcd652
34 changed files with 1462 additions and 1533 deletions

2399
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -17,14 +17,14 @@ tokio = { version = "1", features = [
"macros", "macros",
"rt-multi-thread", "rt-multi-thread",
], optional = true } ], optional = true }
tower = { version = "0.4", optional = true } tower = { version = "0.5.1", optional = true }
tower-http = { version = "0.5", features = ["fs"], optional = true } tower-http = { version = "0.6.1", features = ["fs"], optional = true }
wasm-bindgen = "=0.2.92" wasm-bindgen = "0.2.95"
thiserror = "1" thiserror = "1"
tracing = { version = "0.1", optional = true } tracing = { version = "0.1", optional = true }
http = "1" http = "1"
pulldown-cmark = "0.11.0" pulldown-cmark = "0.12.2"
surrealdb = { version = "<1.5.0", features = ["kv-rocksdb"], optional = true } surrealdb = { version = "2.0.4", features = ["kv-rocksdb"], optional = true }
serde = { version = "1.0.202", features = ["derive"] } serde = { version = "1.0.202", features = ["derive"] }
semver = { version = "1.0.23", features = ["serde"] } semver = { version = "1.0.23", features = ["serde"] }
saleor-app-sdk = { version = "0.2.3", default-features = false } saleor-app-sdk = { version = "0.2.3", default-features = false }

BIN
bun.lockb Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
MANIFEST-000074

View file

@ -1 +0,0 @@
b5f7ce4a-316f-4c07-b7bc-cd8d68a9439c

View file

1
db/LOG
View file

@ -1 +0,0 @@
2024/06/03-19:37:28.956980 624181 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717436248 acquiring thread 624180: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:28:21.378715 614548 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435701 acquiring thread 614547: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:28:26.433575 614548 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435706 acquiring thread 614547: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:28:49.162709 615596 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435729 acquiring thread 615595: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:29:10.753898 616639 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435750 acquiring thread 616638: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:29:58.417187 617450 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435798 acquiring thread 617449: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:32:26.481702 619379 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435946 acquiring thread 619378: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:33:04.174695 620857 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717435984 acquiring thread 620856: db/LOCK: No locks available

View file

@ -1 +0,0 @@
2024/06/03-19:37:02.174732 623193 [WARN] [db/db_impl/db_impl_open.cc:2074] DB::Open() failed: IO error: lock hold by current process, acquire time 1717436222 acquiring thread 623192: db/LOCK: No locks available

Binary file not shown.

View file

@ -1,199 +0,0 @@
# This is a RocksDB option file.
#
# For detailed file format spec, please refer to the example file
# in examples/rocksdb_option_file_example.ini
#
[Version]
rocksdb_version=8.1.1
options_file_version=1.1
[DBOptions]
compaction_readahead_size=0
strict_bytes_per_sync=false
bytes_per_sync=0
max_background_jobs=16
avoid_flush_during_shutdown=false
max_background_flushes=-1
delayed_write_rate=16777216
max_open_files=-1
max_subcompactions=1
writable_file_max_buffer_size=1048576
wal_bytes_per_sync=0
max_background_compactions=-1
max_total_wal_size=0
delete_obsolete_files_period_micros=21600000000
stats_dump_period_sec=600
stats_history_buffer_size=1048576
stats_persist_period_sec=600
enforce_single_del_contracts=true
lowest_used_cache_tier=kNonVolatileBlockTier
bgerror_resume_retry_interval=1000000
best_efforts_recovery=false
log_readahead_size=0
write_dbid_to_manifest=false
wal_compression=kNoCompression
manual_wal_flush=false
db_host_id=__hostname__
two_write_queues=false
random_access_max_buffer_size=1048576
avoid_unnecessary_blocking_io=false
skip_checking_sst_file_sizes_on_db_open=false
flush_verify_memtable_count=true
fail_if_options_file_error=false
atomic_flush=false
verify_sst_unique_id_in_manifest=true
skip_stats_update_on_db_open=false
track_and_verify_wals_in_manifest=false
paranoid_checks=true
create_if_missing=true
max_write_batch_group_size_bytes=1048576
avoid_flush_during_recovery=false
file_checksum_gen_factory=nullptr
enable_thread_tracking=false
allow_fallocate=true
allow_data_in_errors=false
error_if_exists=false
use_direct_io_for_flush_and_compaction=false
create_missing_column_families=true
WAL_size_limit_MB=0
use_direct_reads=false
persist_stats_to_disk=false
allow_mmap_reads=false
allow_mmap_writes=false
use_adaptive_mutex=false
allow_2pc=false
is_fd_close_on_exec=true
max_log_file_size=0
access_hint_on_compaction_start=NORMAL
max_file_opening_threads=16
wal_filter=nullptr
use_fsync=false
table_cache_numshardbits=6
dump_malloc_stats=false
db_write_buffer_size=0
allow_ingest_behind=false
keep_log_file_num=20
max_bgerror_resume_count=2147483647
allow_concurrent_memtable_write=true
recycle_log_file_num=0
log_file_time_to_roll=0
manifest_preallocation_size=4194304
enable_write_thread_adaptive_yield=true
WAL_ttl_seconds=0
max_manifest_file_size=1073741824
wal_recovery_mode=kPointInTimeRecovery
enable_pipelined_write=true
write_thread_slow_yield_usec=3
unordered_write=false
write_thread_max_yield_usec=100
advise_random_on_open=true
info_log_level=WARN_LEVEL
[CFOptions "default"]
compression_opts={max_dict_buffer_bytes=0;enabled=false;max_dict_bytes=0;parallel_threads=1;zstd_max_train_bytes=0;level=32767;use_zstd_dict_trainer=true;strategy=0;window_bits=-14;}
memtable_protection_bytes_per_key=0
target_file_size_multiplier=1
report_bg_io_stats=false
write_buffer_size=268435456
memtable_huge_page_size=0
max_successive_merges=0
max_write_buffer_number=32
prefix_extractor=nullptr
bottommost_compression_opts={max_dict_buffer_bytes=0;enabled=false;max_dict_bytes=0;parallel_threads=1;zstd_max_train_bytes=0;level=32767;use_zstd_dict_trainer=true;strategy=0;window_bits=-14;}
paranoid_file_checks=false
blob_garbage_collection_force_threshold=1.000000
enable_blob_files=true
blob_file_starting_level=0
memtable_prefix_bloom_size_ratio=0.000000
inplace_update_num_locks=10000
blob_compaction_readahead_size=0
ignore_max_compaction_bytes_for_input=true
arena_block_size=1048576
level0_stop_writes_trigger=36
blob_compression_type=kNoCompression
level0_slowdown_writes_trigger=20
hard_pending_compaction_bytes_limit=274877906944
soft_pending_compaction_bytes_limit=68719476736
target_file_size_base=536870912
level0_file_num_compaction_trigger=4
max_compaction_bytes=13421772800
disable_auto_compactions=false
check_flush_compaction_key_order=true
min_blob_size=4096
memtable_whole_key_filtering=false
max_bytes_for_level_base=268435456
last_level_temperature=kUnknown
compaction_options_fifo={allow_compaction=false;age_for_warm=0;max_table_files_size=1073741824;}
max_bytes_for_level_multiplier=10.000000
compression_per_level=kNoCompression:kNoCompression:kLZ4HCCompression:kLZ4HCCompression:kLZ4HCCompression
max_bytes_for_level_multiplier_additional=1:1:1:1:1:1:1
max_sequential_skip_in_iterations=8
prepopulate_blob_cache=kDisable
compression=kSnappyCompression
compaction_options_universal={incremental=false;compression_size_percent=-1;allow_trivial_move=false;max_size_amplification_percent=200;max_merge_width=4294967295;stop_style=kCompactionStopStyleTotalSize;min_merge_width=2;size_ratio=1;}
blob_garbage_collection_age_cutoff=0.250000
ttl=2592000
periodic_compaction_seconds=0
sample_for_compression=0
blob_file_size=268435456
enable_blob_garbage_collection=false
experimental_mempurge_threshold=0.000000
bottommost_compression=kDisableCompressionOption
min_write_buffer_number_to_merge=4
preserve_internal_time_seconds=0
preclude_last_level_data_seconds=0
sst_partitioner_factory=nullptr
num_levels=7
force_consistency_checks=true
memtable_insert_with_hint_prefix_extractor=nullptr
memtable_factory=SkipListFactory
level_compaction_dynamic_file_size=true
max_write_buffer_number_to_maintain=0
optimize_filters_for_hits=false
level_compaction_dynamic_level_bytes=false
compaction_style=kCompactionStyleLevel
compaction_filter=nullptr
inplace_update_support=false
merge_operator=nullptr
table_factory=BlockBasedTable
bloom_locality=0
comparator=leveldb.BytewiseComparator
compaction_filter_factory=nullptr
max_write_buffer_size_to_maintain=8589934592
compaction_pri=kMinOverlappingRatio
[TableOptions/BlockBasedTable "default"]
initial_auto_readahead_size=8192
pin_top_level_index_and_filter=true
block_align=false
block_size_deviation=10
checksum=kXXH3
index_shortening=kShortenSeparators
num_file_reads_for_auto_readahead=2
whole_key_filtering=true
data_block_index_type=kDataBlockBinarySearch
index_type=kBinarySearch
no_block_cache=false
index_block_restart_interval=1
data_block_hash_table_util_ratio=0.750000
prepopulate_block_cache=kDisable
pin_l0_filter_and_index_blocks_in_cache=false
filter_policy=nullptr
cache_index_and_filter_blocks_with_high_priority=true
verify_compression=false
block_restart_interval=16
max_auto_readahead_size=262144
flush_block_policy_factory=FlushBlockBySizePolicyFactory
partition_filters=false
cache_index_and_filter_blocks=false
block_size=4096
metadata_block_size=4096
optimize_filters_for_memory=false
detect_filter_construct_corruption=false
format_version=5
metadata_cache_options={unpartitioned_pinning=kFallback;partition_pinning=kFallback;top_level_index_pinning=kFallback;}
read_amp_bytes_per_bit=0
enable_index_compression=true

View file

@ -1,199 +0,0 @@
# This is a RocksDB option file.
#
# For detailed file format spec, please refer to the example file
# in examples/rocksdb_option_file_example.ini
#
[Version]
rocksdb_version=8.1.1
options_file_version=1.1
[DBOptions]
compaction_readahead_size=0
strict_bytes_per_sync=false
bytes_per_sync=0
max_background_jobs=16
avoid_flush_during_shutdown=false
max_background_flushes=-1
delayed_write_rate=16777216
max_open_files=-1
max_subcompactions=1
writable_file_max_buffer_size=1048576
wal_bytes_per_sync=0
max_background_compactions=-1
max_total_wal_size=0
delete_obsolete_files_period_micros=21600000000
stats_dump_period_sec=600
stats_history_buffer_size=1048576
stats_persist_period_sec=600
enforce_single_del_contracts=true
lowest_used_cache_tier=kNonVolatileBlockTier
bgerror_resume_retry_interval=1000000
best_efforts_recovery=false
log_readahead_size=0
write_dbid_to_manifest=false
wal_compression=kNoCompression
manual_wal_flush=false
db_host_id=__hostname__
two_write_queues=false
random_access_max_buffer_size=1048576
avoid_unnecessary_blocking_io=false
skip_checking_sst_file_sizes_on_db_open=false
flush_verify_memtable_count=true
fail_if_options_file_error=false
atomic_flush=false
verify_sst_unique_id_in_manifest=true
skip_stats_update_on_db_open=false
track_and_verify_wals_in_manifest=false
paranoid_checks=true
create_if_missing=true
max_write_batch_group_size_bytes=1048576
avoid_flush_during_recovery=false
file_checksum_gen_factory=nullptr
enable_thread_tracking=false
allow_fallocate=true
allow_data_in_errors=false
error_if_exists=false
use_direct_io_for_flush_and_compaction=false
create_missing_column_families=true
WAL_size_limit_MB=0
use_direct_reads=false
persist_stats_to_disk=false
allow_mmap_reads=false
allow_mmap_writes=false
use_adaptive_mutex=false
allow_2pc=false
is_fd_close_on_exec=true
max_log_file_size=0
access_hint_on_compaction_start=NORMAL
max_file_opening_threads=16
wal_filter=nullptr
use_fsync=false
table_cache_numshardbits=6
dump_malloc_stats=false
db_write_buffer_size=0
allow_ingest_behind=false
keep_log_file_num=20
max_bgerror_resume_count=2147483647
allow_concurrent_memtable_write=true
recycle_log_file_num=0
log_file_time_to_roll=0
manifest_preallocation_size=4194304
enable_write_thread_adaptive_yield=true
WAL_ttl_seconds=0
max_manifest_file_size=1073741824
wal_recovery_mode=kPointInTimeRecovery
enable_pipelined_write=true
write_thread_slow_yield_usec=3
unordered_write=false
write_thread_max_yield_usec=100
advise_random_on_open=true
info_log_level=WARN_LEVEL
[CFOptions "default"]
compression_opts={max_dict_buffer_bytes=0;enabled=false;max_dict_bytes=0;parallel_threads=1;zstd_max_train_bytes=0;level=32767;use_zstd_dict_trainer=true;strategy=0;window_bits=-14;}
memtable_protection_bytes_per_key=0
target_file_size_multiplier=1
report_bg_io_stats=false
write_buffer_size=268435456
memtable_huge_page_size=0
max_successive_merges=0
max_write_buffer_number=32
prefix_extractor=nullptr
bottommost_compression_opts={max_dict_buffer_bytes=0;enabled=false;max_dict_bytes=0;parallel_threads=1;zstd_max_train_bytes=0;level=32767;use_zstd_dict_trainer=true;strategy=0;window_bits=-14;}
paranoid_file_checks=false
blob_garbage_collection_force_threshold=1.000000
enable_blob_files=true
blob_file_starting_level=0
memtable_prefix_bloom_size_ratio=0.000000
inplace_update_num_locks=10000
blob_compaction_readahead_size=0
ignore_max_compaction_bytes_for_input=true
arena_block_size=1048576
level0_stop_writes_trigger=36
blob_compression_type=kNoCompression
level0_slowdown_writes_trigger=20
hard_pending_compaction_bytes_limit=274877906944
soft_pending_compaction_bytes_limit=68719476736
target_file_size_base=536870912
level0_file_num_compaction_trigger=4
max_compaction_bytes=13421772800
disable_auto_compactions=false
check_flush_compaction_key_order=true
min_blob_size=4096
memtable_whole_key_filtering=false
max_bytes_for_level_base=268435456
last_level_temperature=kUnknown
compaction_options_fifo={allow_compaction=false;age_for_warm=0;max_table_files_size=1073741824;}
max_bytes_for_level_multiplier=10.000000
compression_per_level=kNoCompression:kNoCompression:kLZ4HCCompression:kLZ4HCCompression:kLZ4HCCompression
max_bytes_for_level_multiplier_additional=1:1:1:1:1:1:1
max_sequential_skip_in_iterations=8
prepopulate_blob_cache=kDisable
compression=kSnappyCompression
compaction_options_universal={incremental=false;compression_size_percent=-1;allow_trivial_move=false;max_size_amplification_percent=200;max_merge_width=4294967295;stop_style=kCompactionStopStyleTotalSize;min_merge_width=2;size_ratio=1;}
blob_garbage_collection_age_cutoff=0.250000
ttl=2592000
periodic_compaction_seconds=0
sample_for_compression=0
blob_file_size=268435456
enable_blob_garbage_collection=false
experimental_mempurge_threshold=0.000000
bottommost_compression=kDisableCompressionOption
min_write_buffer_number_to_merge=4
preserve_internal_time_seconds=0
preclude_last_level_data_seconds=0
sst_partitioner_factory=nullptr
num_levels=7
force_consistency_checks=true
memtable_insert_with_hint_prefix_extractor=nullptr
memtable_factory=SkipListFactory
level_compaction_dynamic_file_size=true
max_write_buffer_number_to_maintain=0
optimize_filters_for_hits=false
level_compaction_dynamic_level_bytes=false
compaction_style=kCompactionStyleLevel
compaction_filter=nullptr
inplace_update_support=false
merge_operator=nullptr
table_factory=BlockBasedTable
bloom_locality=0
comparator=leveldb.BytewiseComparator
compaction_filter_factory=nullptr
max_write_buffer_size_to_maintain=8589934592
compaction_pri=kMinOverlappingRatio
[TableOptions/BlockBasedTable "default"]
initial_auto_readahead_size=8192
pin_top_level_index_and_filter=true
block_align=false
block_size_deviation=10
checksum=kXXH3
index_shortening=kShortenSeparators
num_file_reads_for_auto_readahead=2
whole_key_filtering=true
data_block_index_type=kDataBlockBinarySearch
index_type=kBinarySearch
no_block_cache=false
index_block_restart_interval=1
data_block_hash_table_util_ratio=0.750000
prepopulate_block_cache=kDisable
pin_l0_filter_and_index_blocks_in_cache=false
filter_policy=nullptr
cache_index_and_filter_blocks_with_high_priority=true
verify_compression=false
block_restart_interval=16
max_auto_readahead_size=262144
flush_block_policy_factory=FlushBlockBySizePolicyFactory
partition_filters=false
cache_index_and_filter_blocks=false
block_size=4096
metadata_block_size=4096
optimize_filters_for_memory=false
detect_filter_construct_corruption=false
format_version=5
metadata_cache_options={unpartitioned_pinning=kFallback;partition_pinning=kFallback;top_level_index_pinning=kFallback;}
read_amp_bytes_per_bit=0
enable_index_compression=true

View file

@ -1,2 +1,4 @@
[toolchain] [toolchain]
channel = "nightly" # channel = "nightly"
channel = "nightly-2024-10-20"
targets = ["wasm32-unknown-unknown"]

View file

@ -11,6 +11,3 @@ pub async fn get_all_apps() -> Result<Vec<SaleorApp>, ServerFnError>{
// dbg!(&apps); // dbg!(&apps);
Ok(apps) Ok(apps)
} }

View file

@ -1,40 +1,125 @@
#TODO:
# - precomputed view for landing page https://surrealdb.com/docs/surrealql/statements/define/table#pre-computed-table-views
# - Oauth for github
# - passwords and sign in
# - system user for frontend with EDITOR role scoped to only this db https://surrealdb.com/docs/surrealql/statements/define/user#roles
# - search function https://surrealdb.com/learn/fundamentals/performance/index-data-model#full-text-search-indexes
REMOVE NAMESPACE saleor_marketplace; REMOVE NAMESPACE saleor_marketplace;
REMOVE DATABASE main; REMOVE DATABASE main;
DEFINE NAMESPACE saleor_marketplace; DEFINE NAMESPACE saleor_marketplace;
DEFINE DATABASE main; DEFINE DATABASE main;
USE NS saleor_marketplace; USE NS saleor_marketplace;
USE DB main; USE DB main;
DEFINE TABLE saleor_app TYPE ANY SCHEMALESS DEFINE TABLE dashboard TYPE ANY SCHEMALESS
PERMISSIONS PERMISSIONS
FOR select FOR select
WHERE true WHERE true
FOR update, delete FOR create, update, delete
WHERE id.id()[0] = $auth.id OR $auth.admin = true WHERE id.id()[0] = $auth.id OR $auth.admin = true
FOR create
WHERE id.id()[0] = $auth.id OR $auth.admin = true //MAKE THIS QUERY FOR AMOUNT OF APPS USER HAS, LIMIT TO 20!!
; ;
DEFINE FIELD versions ON saleor_app TYPE array<string> DEFINE FIELD versions ON dashboard TYPE array<string>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE versions[*] ON saleor_app TYPE string ASSERT string::is::semver($value) DEFINE FIELD OVERWRITE versions[*] ON dashboard TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD current_version ON saleor_app TYPE string ASSERT string::is::semver($value) DEFINE FIELD current_version ON dashboard TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD last_updated ON saleor_app TYPE datetime VALUE time::now() ASSERT string::is::datetime($value) DEFINE FIELD updated_at ON dashboard TYPE datetime VALUE time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD created ON saleor_app TYPE datetime VALUE time::now() ASSERT string::is::datetime($value) DEFINE FIELD created_at ON dashboard TYPE datetime DEFAULT time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD images ON saleor_app TYPE array<string> DEFINE FIELD images ON dashboard TYPE array<string>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE images[*] ON saleor_app TYPE string ASSERT string::is::url($value) DEFINE FIELD OVERWRITE images[*] ON dashboard TYPE string ASSERT string::is::url($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD manifest ON saleor_app TYPE { DEFINE FIELD is_verified ON dashboard TYPE bool
PERMISSIONS FULL
;
DEFINE FIELD supported_deployments ON dashboard TYPE array<'Docker' | 'Podman' | 'Linux' | 'Windows' | 'MacOS' | 'WASM'>
PERMISSIONS FULL
;
DEFINE FIELD built_for_url ON dashboard TYPE option<string>
PERMISSIONS FULL
;
DEFINE FIELD minimal_docker_compose ON dashboard TYPE option<string>
PERMISSIONS FULL
;
DEFINE TABLE storefront TYPE ANY SCHEMALESS
PERMISSIONS
FOR select
WHERE true
FOR create, update, delete
WHERE id.id()[0] = $auth.id OR $auth.admin = true
;
DEFINE FIELD versions ON storefront TYPE array<string>
PERMISSIONS FULL
;
DEFINE FIELD OVERWRITE versions[*] ON storefront TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL
;
DEFINE FIELD current_version ON storefront TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL
;
DEFINE FIELD updated_at ON storefront TYPE datetime VALUE time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL
;
DEFINE FIELD created_at ON storefront TYPE datetime DEFAULT time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL
;
DEFINE FIELD images ON storefront TYPE array<string>
PERMISSIONS FULL
;
DEFINE FIELD OVERWRITE images[*] ON storefront TYPE string ASSERT string::is::url($value)
PERMISSIONS FULL
;
DEFINE FIELD is_verified ON storefront TYPE bool
PERMISSIONS FULL
;
DEFINE FIELD supported_deployments ON storefront TYPE array<'Docker' | 'Podman' | 'Linux' | 'Windows' | 'MacOS' | 'WASM'>
PERMISSIONS FULL
;
DEFINE FIELD built_for_url ON storefront TYPE option<string>
PERMISSIONS FULL
;
DEFINE FIELD minimal_docker_compose ON storefront TYPE option<string>
PERMISSIONS FULL
;
DEFINE TABLE app TYPE ANY SCHEMALESS
PERMISSIONS
FOR select
WHERE true
FOR create, update, delete
WHERE id.id()[0] = $auth.id OR $auth.admin = true
;
DEFINE FIELD versions ON app TYPE array<string>
PERMISSIONS FULL
;
DEFINE FIELD OVERWRITE versions[*] ON app TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL
;
DEFINE FIELD current_version ON app TYPE string ASSERT string::is::semver($value)
PERMISSIONS FULL
;
DEFINE FIELD updated_at ON app TYPE datetime VALUE time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL
;
DEFINE FIELD created_at ON app TYPE datetime DEFAULT time::now() ASSERT string::is::datetime($value)
PERMISSIONS FULL
;
DEFINE FIELD images ON app TYPE array<string>
PERMISSIONS FULL
;
DEFINE FIELD OVERWRITE images[*] ON app TYPE string ASSERT string::is::url($value)
PERMISSIONS FULL
;
DEFINE FIELD manifest ON app TYPE {
about: option<string>, about: option<string>,
app_permissions: array<'MANAGE_USERS' | 'MANAGE_STAFF' | 'IMPERSONATE_USER' | 'MANAGE_OBSERVABILITY' | 'MANAGE_CHECKOUTS' | 'HANDLE_CHECKOUTS' | 'HANDLE_TAXES' | 'MANAGE_TAXES' | 'MANAGE_CHANNELS' | 'MANAGE_DISCOUNTS' | 'MANAGE_GIFT_CARD' | 'MANAGE_MENUS' | 'MANAGE_ORDERS' | 'MANAGE_ORDERS_IMPORT' | 'MANAGE_PAGES' | 'MANAGE_PAGE_TYPES_AND_ATTRIBUTES' | 'HANDLE_PAYMENTS' | 'MANAGE_PLUGINS' | 'MANAGE_PRODUCTS' | 'MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES' | 'MANAGE_SHIPPING' | 'MANAGE_SETTINGS' | 'MANAGE_TRANSLATIONS' | 'MANAGE_APPS'>, app_permissions: array<'MANAGE_USERS' | 'MANAGE_STAFF' | 'IMPERSONATE_USER' | 'MANAGE_OBSERVABILITY' | 'MANAGE_CHECKOUTS' | 'HANDLE_CHECKOUTS' | 'HANDLE_TAXES' | 'MANAGE_TAXES' | 'MANAGE_CHANNELS' | 'MANAGE_DISCOUNTS' | 'MANAGE_GIFT_CARD' | 'MANAGE_MENUS' | 'MANAGE_ORDERS' | 'MANAGE_ORDERS_IMPORT' | 'MANAGE_PAGES' | 'MANAGE_PAGE_TYPES_AND_ATTRIBUTES' | 'HANDLE_PAYMENTS' | 'MANAGE_PLUGINS' | 'MANAGE_PRODUCTS' | 'MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES' | 'MANAGE_SHIPPING' | 'MANAGE_SETTINGS' | 'MANAGE_TRANSLATIONS' | 'MANAGE_APPS'>,
app_url: string, app_url: string,
@ -72,46 +157,46 @@ DEFINE FIELD manifest ON saleor_app TYPE {
} }
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.app_url ON saleor_app TYPE string ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.app_url ON app TYPE string ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.token_target_url ON saleor_app TYPE string ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.token_target_url ON app TYPE string ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.configuration_url ON saleor_app TYPE option<string> ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.configuration_url ON app TYPE option<string> ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.data_privacy_url ON saleor_app TYPE option<string> ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.data_privacy_url ON app TYPE option<string> ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.homepage_url ON saleor_app TYPE option<string> ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.homepage_url ON app TYPE option<string> ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.support_url ON saleor_app TYPE option<string> ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.support_url ON app TYPE option<string> ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.webhooks.target_url ON saleor_app TYPE string ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.webhooks.target_url ON app TYPE string ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD OVERWRITE manifest.extensions.url ON saleor_app TYPE string ASSERT $value.is_url() DEFINE FIELD OVERWRITE manifest.extensions.url ON app TYPE string ASSERT $value.is_url()
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD is_verified ON saleor_app TYPE bool DEFINE FIELD is_verified ON app TYPE bool
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD supported_deployments ON saleor_app TYPE array<'Docker' | 'Podman' | 'Linux' | 'Windows' | 'MacOS' | 'WASM'> DEFINE FIELD supported_deployments ON app TYPE array<'Docker' | 'Podman' | 'Linux' | 'Windows' | 'MacOS' | 'WASM'>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD built_for_url ON saleor_app TYPE option<string> DEFINE FIELD built_for_url ON app TYPE option<string>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD minimal_docker_compose ON saleor_app TYPE string DEFINE FIELD minimal_docker_compose ON app TYPE string
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD supported_apls ON saleor_app TYPE array<'File' | 'Redis' | 'Env' | 'Upstash'> DEFINE FIELD supported_apls ON app TYPE array<'File' | 'Redis' | 'Env' | 'Upstash'>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE FIELD categories ON saleor_app TYPE array<'CMS' | 'Messaging' | 'Taxes' | 'Payments' | 'CRM' | 'Monitoring' | 'Marketplaces' | 'Search' | 'SEO' | 'DashboardUtilities' | 'Other'> DEFINE FIELD categories ON app TYPE array<'CMS' | 'Messaging' | 'Taxes' | 'Payments' | 'CRM' | 'Monitoring' | 'Marketplaces' | 'Search' | 'SEO' | 'DashboardUtilities' | 'Other'>
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE TABLE author TYPE ANY SCHEMALESS DEFINE TABLE author TYPE ANY SCHEMALESS
@ -133,16 +218,35 @@ DEFINE FIELD OVERWRITE socials[*] ON author TYPE string ASSERT string::is::url($
DEFINE FIELD email ON author TYPE string ASSERT string::is::email($value) DEFINE FIELD email ON author TYPE string ASSERT string::is::email($value)
PERMISSIONS FULL PERMISSIONS FULL
; ;
DEFINE INDEX email ON author FIELDS email UNIQUE;
DEFINE ACCESS author ON DATABASE TYPE RECORD
SIGNUP (
CREATE author CONTENT {
name: $name,
email: $email,
socials: $socials,
password: crypto::argon2::generate($password),
}
)
SIGNIN (
SELECT * FROM user WHERE email = $email
AND crypto::argon2::compare(password, $password)
)
AUTHENTICATE {
RETURN $auth;
}
DURATION FOR SESSION 12h, FOR TOKEN 5s
;
DELETE user:djkato; DELETE author:djkato;
DELETE saleor_app:[ DELETE app:[
user:djkato, author:djkato,
'stripe-payment-gateway' 'stripe-payment-gateway'
]; ];
CREATE author:djkato SET name = 'Djkáťo', socials = [ CREATE author:djkato SET name = 'Djkáťo', socials = [
'https://twitter.com/djkato_vfx' 'https://twitter.com/djkato_vfx'
], email = 'djkatovfx@gmail.com'; ], email = 'djkatovfx@gmail.com';
CREATE saleor_app:[ CREATE app:[
author:djkato, author:djkato,
'stripe-payment-gateway' 'stripe-payment-gateway'
] SET versions = [ ] SET versions = [
@ -172,9 +276,9 @@ CREATE saleor_app:[
version: '1.0.0', version: '1.0.0',
webhooks: [] webhooks: []
}; };
SELECT manifest FROM saleor_app:[ SELECT manifest FROM app:[
user:djkato, author:djkato,
NONE NONE
]..[ ]..[
user:djkato author:djkato
]; ];