realtimex-crm 0.1.2
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/LICENSE.md +21 -0
- package/README.md +104 -0
- package/dist/assets/DealList-DqDrFeDV.js +59 -0
- package/dist/assets/DealList-DqDrFeDV.js.map +1 -0
- package/dist/assets/index-BiQoGq1P.css +1 -0
- package/dist/assets/index-CDIy4x-0.js +152 -0
- package/dist/assets/index-CDIy4x-0.js.map +1 -0
- package/dist/auth-callback.html +140 -0
- package/dist/favicon.ico +0 -0
- package/dist/img/adding-users.png +0 -0
- package/dist/img/empty.svg +42 -0
- package/dist/index.html +1 -0
- package/dist/logo192.png +0 -0
- package/dist/logo512.png +0 -0
- package/dist/logos/0.png +0 -0
- package/dist/logos/1.png +0 -0
- package/dist/logos/10.png +0 -0
- package/dist/logos/11.png +0 -0
- package/dist/logos/12.png +0 -0
- package/dist/logos/13.png +0 -0
- package/dist/logos/14.png +0 -0
- package/dist/logos/15.png +0 -0
- package/dist/logos/16.png +0 -0
- package/dist/logos/17.png +0 -0
- package/dist/logos/18.png +0 -0
- package/dist/logos/19.png +0 -0
- package/dist/logos/2.png +0 -0
- package/dist/logos/20.png +0 -0
- package/dist/logos/21.png +0 -0
- package/dist/logos/22.png +0 -0
- package/dist/logos/23.png +0 -0
- package/dist/logos/24.png +0 -0
- package/dist/logos/25.png +0 -0
- package/dist/logos/26.png +0 -0
- package/dist/logos/27.png +0 -0
- package/dist/logos/28.png +0 -0
- package/dist/logos/29.png +0 -0
- package/dist/logos/3.png +0 -0
- package/dist/logos/30.png +0 -0
- package/dist/logos/31.png +0 -0
- package/dist/logos/32.png +0 -0
- package/dist/logos/33.png +0 -0
- package/dist/logos/34.png +0 -0
- package/dist/logos/35.png +0 -0
- package/dist/logos/36.png +0 -0
- package/dist/logos/37.png +0 -0
- package/dist/logos/38.png +0 -0
- package/dist/logos/39.png +0 -0
- package/dist/logos/4.png +0 -0
- package/dist/logos/40.png +0 -0
- package/dist/logos/41.png +0 -0
- package/dist/logos/42.png +0 -0
- package/dist/logos/43.png +0 -0
- package/dist/logos/44.png +0 -0
- package/dist/logos/45.png +0 -0
- package/dist/logos/46.png +0 -0
- package/dist/logos/47.png +0 -0
- package/dist/logos/48.png +0 -0
- package/dist/logos/49.png +0 -0
- package/dist/logos/5.png +0 -0
- package/dist/logos/50.png +0 -0
- package/dist/logos/51.png +0 -0
- package/dist/logos/52.png +0 -0
- package/dist/logos/53.png +0 -0
- package/dist/logos/54.png +0 -0
- package/dist/logos/55.png +0 -0
- package/dist/logos/6.png +0 -0
- package/dist/logos/7.png +0 -0
- package/dist/logos/8.png +0 -0
- package/dist/logos/9.png +0 -0
- package/dist/logos/Readme.md +1 -0
- package/dist/logos/logo_atomic_crm.svg +14 -0
- package/dist/logos/logo_atomic_crm_dark.svg +14 -0
- package/dist/logos/logo_atomic_crm_light.svg +14 -0
- package/dist/manifest.json +25 -0
- package/dist/robots.txt +3 -0
- package/dist/stats.html +4949 -0
- package/package.json +152 -0
- package/public/auth-callback.html +140 -0
- package/public/favicon.ico +0 -0
- package/public/img/adding-users.png +0 -0
- package/public/img/empty.svg +42 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/logos/0.png +0 -0
- package/public/logos/1.png +0 -0
- package/public/logos/10.png +0 -0
- package/public/logos/11.png +0 -0
- package/public/logos/12.png +0 -0
- package/public/logos/13.png +0 -0
- package/public/logos/14.png +0 -0
- package/public/logos/15.png +0 -0
- package/public/logos/16.png +0 -0
- package/public/logos/17.png +0 -0
- package/public/logos/18.png +0 -0
- package/public/logos/19.png +0 -0
- package/public/logos/2.png +0 -0
- package/public/logos/20.png +0 -0
- package/public/logos/21.png +0 -0
- package/public/logos/22.png +0 -0
- package/public/logos/23.png +0 -0
- package/public/logos/24.png +0 -0
- package/public/logos/25.png +0 -0
- package/public/logos/26.png +0 -0
- package/public/logos/27.png +0 -0
- package/public/logos/28.png +0 -0
- package/public/logos/29.png +0 -0
- package/public/logos/3.png +0 -0
- package/public/logos/30.png +0 -0
- package/public/logos/31.png +0 -0
- package/public/logos/32.png +0 -0
- package/public/logos/33.png +0 -0
- package/public/logos/34.png +0 -0
- package/public/logos/35.png +0 -0
- package/public/logos/36.png +0 -0
- package/public/logos/37.png +0 -0
- package/public/logos/38.png +0 -0
- package/public/logos/39.png +0 -0
- package/public/logos/4.png +0 -0
- package/public/logos/40.png +0 -0
- package/public/logos/41.png +0 -0
- package/public/logos/42.png +0 -0
- package/public/logos/43.png +0 -0
- package/public/logos/44.png +0 -0
- package/public/logos/45.png +0 -0
- package/public/logos/46.png +0 -0
- package/public/logos/47.png +0 -0
- package/public/logos/48.png +0 -0
- package/public/logos/49.png +0 -0
- package/public/logos/5.png +0 -0
- package/public/logos/50.png +0 -0
- package/public/logos/51.png +0 -0
- package/public/logos/52.png +0 -0
- package/public/logos/53.png +0 -0
- package/public/logos/54.png +0 -0
- package/public/logos/55.png +0 -0
- package/public/logos/6.png +0 -0
- package/public/logos/7.png +0 -0
- package/public/logos/8.png +0 -0
- package/public/logos/9.png +0 -0
- package/public/logos/Readme.md +1 -0
- package/public/logos/logo_atomic_crm.svg +14 -0
- package/public/logos/logo_atomic_crm_dark.svg +14 -0
- package/public/logos/logo_atomic_crm_light.svg +14 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App.css +42 -0
- package/src/App.tsx +58 -0
- package/src/assets/react.svg +1 -0
- package/src/components/admin/Readme.md +40 -0
- package/src/components/admin/admin.tsx +132 -0
- package/src/components/admin/app-sidebar.tsx +166 -0
- package/src/components/admin/array-field.tsx +59 -0
- package/src/components/admin/array-input.tsx +201 -0
- package/src/components/admin/authentication.tsx +86 -0
- package/src/components/admin/autocomplete-array-input.tsx +254 -0
- package/src/components/admin/autocomplete-input.tsx +296 -0
- package/src/components/admin/badge-field.tsx +65 -0
- package/src/components/admin/boolean-input.tsx +116 -0
- package/src/components/admin/breadcrumb.tsx +135 -0
- package/src/components/admin/bulk-actions-toolbar.tsx +83 -0
- package/src/components/admin/bulk-delete-button.tsx +70 -0
- package/src/components/admin/bulk-export-button.tsx +76 -0
- package/src/components/admin/cancel-button.tsx +46 -0
- package/src/components/admin/columns-button.tsx +345 -0
- package/src/components/admin/confirm.tsx +166 -0
- package/src/components/admin/count.tsx +94 -0
- package/src/components/admin/create-button.tsx +58 -0
- package/src/components/admin/create.tsx +132 -0
- package/src/components/admin/data-table.tsx +520 -0
- package/src/components/admin/date-field.tsx +136 -0
- package/src/components/admin/date-input.tsx +317 -0
- package/src/components/admin/date-time-input.tsx +331 -0
- package/src/components/admin/delete-button.tsx +113 -0
- package/src/components/admin/edit-button.tsx +64 -0
- package/src/components/admin/edit-guesser.tsx +157 -0
- package/src/components/admin/edit.tsx +152 -0
- package/src/components/admin/email-field.tsx +74 -0
- package/src/components/admin/error.tsx +111 -0
- package/src/components/admin/export-button.tsx +126 -0
- package/src/components/admin/field-toggle.tsx +164 -0
- package/src/components/admin/file-field.tsx +123 -0
- package/src/components/admin/file-input.tsx +361 -0
- package/src/components/admin/filter-form.tsx +510 -0
- package/src/components/admin/form.tsx +312 -0
- package/src/components/admin/icon-button-with-tooltip.tsx +85 -0
- package/src/components/admin/index.ts +73 -0
- package/src/components/admin/input-helper-text.tsx +29 -0
- package/src/components/admin/layout.tsx +69 -0
- package/src/components/admin/list-guesser.tsx +239 -0
- package/src/components/admin/list-pagination.tsx +247 -0
- package/src/components/admin/list.tsx +178 -0
- package/src/components/admin/loading.tsx +40 -0
- package/src/components/admin/locales-menu-button.tsx +60 -0
- package/src/components/admin/login-page.tsx +104 -0
- package/src/components/admin/notification.tsx +114 -0
- package/src/components/admin/number-field.tsx +84 -0
- package/src/components/admin/number-input.tsx +124 -0
- package/src/components/admin/radio-button-group-input.tsx +184 -0
- package/src/components/admin/ready.tsx +55 -0
- package/src/components/admin/record-field.tsx +132 -0
- package/src/components/admin/reference-array-field.tsx +152 -0
- package/src/components/admin/reference-array-input.tsx +68 -0
- package/src/components/admin/reference-field.tsx +153 -0
- package/src/components/admin/reference-input.tsx +46 -0
- package/src/components/admin/reference-many-count.tsx +92 -0
- package/src/components/admin/reference-many-field.tsx +132 -0
- package/src/components/admin/refresh-button.tsx +31 -0
- package/src/components/admin/saved-queries.tsx +174 -0
- package/src/components/admin/search-input.tsx +57 -0
- package/src/components/admin/select-field.tsx +111 -0
- package/src/components/admin/select-input.tsx +323 -0
- package/src/components/admin/show-button.tsx +57 -0
- package/src/components/admin/show-guesser.tsx +215 -0
- package/src/components/admin/show.tsx +184 -0
- package/src/components/admin/simple-form-iterator.tsx +582 -0
- package/src/components/admin/simple-form.tsx +95 -0
- package/src/components/admin/simple-show-layout.tsx +8 -0
- package/src/components/admin/single-field-list.tsx +67 -0
- package/src/components/admin/sort-button.tsx +152 -0
- package/src/components/admin/spinner.tsx +46 -0
- package/src/components/admin/text-field.tsx +60 -0
- package/src/components/admin/text-input.tsx +77 -0
- package/src/components/admin/theme-mode-toggle.tsx +48 -0
- package/src/components/admin/theme-provider.tsx +74 -0
- package/src/components/admin/toggle-filter-button.tsx +77 -0
- package/src/components/admin/url-field.tsx +83 -0
- package/src/components/admin/user-menu.tsx +84 -0
- package/src/components/atomic-crm/activity/ActivityLog.tsx +54 -0
- package/src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx +50 -0
- package/src/components/atomic-crm/activity/ActivityLogContactCreated.tsx +42 -0
- package/src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx +71 -0
- package/src/components/atomic-crm/activity/ActivityLogContext.tsx +11 -0
- package/src/components/atomic-crm/activity/ActivityLogDealCreated.tsx +41 -0
- package/src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx +84 -0
- package/src/components/atomic-crm/activity/ActivityLogIterator.tsx +80 -0
- package/src/components/atomic-crm/activity/ActivityLogNote.tsx +36 -0
- package/src/components/atomic-crm/companies/AutocompleteCompanyInput.tsx +43 -0
- package/src/components/atomic-crm/companies/CompanyAside.tsx +207 -0
- package/src/components/atomic-crm/companies/CompanyAvatar.tsx +29 -0
- package/src/components/atomic-crm/companies/CompanyCard.tsx +88 -0
- package/src/components/atomic-crm/companies/CompanyCreate.tsx +41 -0
- package/src/components/atomic-crm/companies/CompanyEdit.tsx +33 -0
- package/src/components/atomic-crm/companies/CompanyEmpty.tsx +26 -0
- package/src/components/atomic-crm/companies/CompanyInputs.tsx +160 -0
- package/src/components/atomic-crm/companies/CompanyList.tsx +54 -0
- package/src/components/atomic-crm/companies/CompanyListFilter.tsx +55 -0
- package/src/components/atomic-crm/companies/CompanyShow.tsx +241 -0
- package/src/components/atomic-crm/companies/GridList.tsx +46 -0
- package/src/components/atomic-crm/companies/index.ts +11 -0
- package/src/components/atomic-crm/companies/sizes.ts +7 -0
- package/src/components/atomic-crm/consts.ts +5 -0
- package/src/components/atomic-crm/contacts/Avatar.tsx +40 -0
- package/src/components/atomic-crm/contacts/ContactAside.tsx +187 -0
- package/src/components/atomic-crm/contacts/ContactCreate.tsx +34 -0
- package/src/components/atomic-crm/contacts/ContactEdit.tsx +32 -0
- package/src/components/atomic-crm/contacts/ContactEmpty.tsx +28 -0
- package/src/components/atomic-crm/contacts/ContactImportButton.tsx +213 -0
- package/src/components/atomic-crm/contacts/ContactInputs.tsx +209 -0
- package/src/components/atomic-crm/contacts/ContactList.tsx +116 -0
- package/src/components/atomic-crm/contacts/ContactListContent.tsx +107 -0
- package/src/components/atomic-crm/contacts/ContactListFilter.tsx +126 -0
- package/src/components/atomic-crm/contacts/ContactMergeButton.tsx +263 -0
- package/src/components/atomic-crm/contacts/ContactShow.tsx +76 -0
- package/src/components/atomic-crm/contacts/ExportVCardButton.tsx +79 -0
- package/src/components/atomic-crm/contacts/TagsList.tsx +33 -0
- package/src/components/atomic-crm/contacts/TagsListEdit.tsx +155 -0
- package/src/components/atomic-crm/contacts/contacts_export.csv +3 -0
- package/src/components/atomic-crm/contacts/exportToVCard.ts +104 -0
- package/src/components/atomic-crm/contacts/index.tsx +14 -0
- package/src/components/atomic-crm/contacts/useContactImport.tsx +206 -0
- package/src/components/atomic-crm/dashboard/Dashboard.tsx +66 -0
- package/src/components/atomic-crm/dashboard/DashboardActivityLog.tsx +22 -0
- package/src/components/atomic-crm/dashboard/DashboardStepper.tsx +72 -0
- package/src/components/atomic-crm/dashboard/DealsChart.tsx +202 -0
- package/src/components/atomic-crm/dashboard/DealsPipeline.tsx +90 -0
- package/src/components/atomic-crm/dashboard/HotContacts.tsx +92 -0
- package/src/components/atomic-crm/dashboard/LatestNotes.tsx +116 -0
- package/src/components/atomic-crm/dashboard/TasksList.tsx +69 -0
- package/src/components/atomic-crm/dashboard/TasksListEmpty.tsx +22 -0
- package/src/components/atomic-crm/dashboard/TasksListFilter.tsx +72 -0
- package/src/components/atomic-crm/dashboard/Welcome.tsx +41 -0
- package/src/components/atomic-crm/deals/ContactList.tsx +31 -0
- package/src/components/atomic-crm/deals/DealArchivedList.tsx +105 -0
- package/src/components/atomic-crm/deals/DealCard.tsx +78 -0
- package/src/components/atomic-crm/deals/DealColumn.tsx +52 -0
- package/src/components/atomic-crm/deals/DealCreate.tsx +95 -0
- package/src/components/atomic-crm/deals/DealEdit.tsx +81 -0
- package/src/components/atomic-crm/deals/DealEmpty.tsx +63 -0
- package/src/components/atomic-crm/deals/DealInputs.tsx +103 -0
- package/src/components/atomic-crm/deals/DealList.tsx +95 -0
- package/src/components/atomic-crm/deals/DealListContent.tsx +245 -0
- package/src/components/atomic-crm/deals/DealShow.tsx +260 -0
- package/src/components/atomic-crm/deals/OnlyMineInput.tsx +30 -0
- package/src/components/atomic-crm/deals/deal.ts +5 -0
- package/src/components/atomic-crm/deals/dealUtils.ts +26 -0
- package/src/components/atomic-crm/deals/index.ts +6 -0
- package/src/components/atomic-crm/deals/stages.ts +28 -0
- package/src/components/atomic-crm/filters/FilterCategory.tsx +20 -0
- package/src/components/atomic-crm/layout/FormToolbar.tsx +12 -0
- package/src/components/atomic-crm/layout/Header.tsx +134 -0
- package/src/components/atomic-crm/layout/Layout.tsx +21 -0
- package/src/components/atomic-crm/layout/TopToolbar.tsx +24 -0
- package/src/components/atomic-crm/login/LoginSkeleton.tsx +18 -0
- package/src/components/atomic-crm/login/SignupPage.tsx +150 -0
- package/src/components/atomic-crm/login/StartPage.tsx +27 -0
- package/src/components/atomic-crm/misc/AsideSection.tsx +21 -0
- package/src/components/atomic-crm/misc/ContactOption.tsx +26 -0
- package/src/components/atomic-crm/misc/ImageEditorField.tsx +206 -0
- package/src/components/atomic-crm/misc/RelativeDate.tsx +5 -0
- package/src/components/atomic-crm/misc/Status.tsx +28 -0
- package/src/components/atomic-crm/misc/fetchWithTimeout.ts +19 -0
- package/src/components/atomic-crm/misc/isLinkedInUrl.ts +15 -0
- package/src/components/atomic-crm/misc/unsupportedDomains.const.ts +105 -0
- package/src/components/atomic-crm/misc/useAppBarHeight.ts +9 -0
- package/src/components/atomic-crm/misc/usePapaParse.tsx +144 -0
- package/src/components/atomic-crm/notes/Note.tsx +187 -0
- package/src/components/atomic-crm/notes/NoteAttachments.tsx +56 -0
- package/src/components/atomic-crm/notes/NoteCreate.tsx +112 -0
- package/src/components/atomic-crm/notes/NoteInputs.tsx +92 -0
- package/src/components/atomic-crm/notes/NotesIterator.tsx +37 -0
- package/src/components/atomic-crm/notes/StatusSelector.tsx +39 -0
- package/src/components/atomic-crm/notes/index.ts +3 -0
- package/src/components/atomic-crm/notes/utils.ts +13 -0
- package/src/components/atomic-crm/providers/commons/activity.ts +174 -0
- package/src/components/atomic-crm/providers/commons/canAccess.ts +26 -0
- package/src/components/atomic-crm/providers/commons/getCompanyAvatar.spec.ts +20 -0
- package/src/components/atomic-crm/providers/commons/getCompanyAvatar.ts +21 -0
- package/src/components/atomic-crm/providers/commons/getContactAvatar.spec.ts +80 -0
- package/src/components/atomic-crm/providers/commons/getContactAvatar.ts +70 -0
- package/src/components/atomic-crm/providers/commons/mergeContacts.ts +185 -0
- package/src/components/atomic-crm/providers/fakerest/authProvider.ts +74 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/companies.ts +53 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/contactNotes.ts +25 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.ts +103 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/dealNotes.ts +19 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/deals.ts +53 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/finalize.ts +10 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/index.ts +25 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/sales.ts +37 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/tags.ts +14 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/tasks.ts +55 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/types.ts +21 -0
- package/src/components/atomic-crm/providers/fakerest/dataGenerator/utils.ts +28 -0
- package/src/components/atomic-crm/providers/fakerest/dataProvider.ts +518 -0
- package/src/components/atomic-crm/providers/fakerest/index.ts +2 -0
- package/src/components/atomic-crm/providers/fakerest/internal/listParser.ts +48 -0
- package/src/components/atomic-crm/providers/fakerest/internal/supabaseAdapter.spec.ts +721 -0
- package/src/components/atomic-crm/providers/fakerest/internal/supabaseAdapter.ts +49 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformContainsFilter.spec.ts +35 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformContainsFilter.ts +17 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformFilter.ts +57 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformInFilter.spec.ts +32 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformInFilter.ts +17 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformOrFilter.spec.ts +23 -0
- package/src/components/atomic-crm/providers/fakerest/internal/transformOrFilter.ts +17 -0
- package/src/components/atomic-crm/providers/supabase/authProvider.ts +121 -0
- package/src/components/atomic-crm/providers/supabase/dataProvider.ts +407 -0
- package/src/components/atomic-crm/providers/supabase/index.ts +2 -0
- package/src/components/atomic-crm/providers/supabase/supabase.ts +34 -0
- package/src/components/atomic-crm/providers/types.ts +1 -0
- package/src/components/atomic-crm/root/CRM.tsx +167 -0
- package/src/components/atomic-crm/root/ConfigurationContext.tsx +80 -0
- package/src/components/atomic-crm/root/defaultConfiguration.ts +64 -0
- package/src/components/atomic-crm/root/i18nProvider.tsx +25 -0
- package/src/components/atomic-crm/sales/SaleName.tsx +13 -0
- package/src/components/atomic-crm/sales/SalesCreate.tsx +51 -0
- package/src/components/atomic-crm/sales/SalesEdit.tsx +82 -0
- package/src/components/atomic-crm/sales/SalesInputs.tsx +31 -0
- package/src/components/atomic-crm/sales/SalesList.tsx +62 -0
- package/src/components/atomic-crm/sales/index.ts +12 -0
- package/src/components/atomic-crm/settings/DatabaseSettings.tsx +169 -0
- package/src/components/atomic-crm/settings/SettingsPage.tsx +259 -0
- package/src/components/atomic-crm/setup/SupabaseSetupWizard.tsx +215 -0
- package/src/components/atomic-crm/simple-list/ListNoResults.tsx +53 -0
- package/src/components/atomic-crm/simple-list/ListPlaceholder.tsx +9 -0
- package/src/components/atomic-crm/simple-list/SimpleList.tsx +245 -0
- package/src/components/atomic-crm/simple-list/SimpleListItem.tsx +138 -0
- package/src/components/atomic-crm/simple-list/SimpleListLoading.tsx +60 -0
- package/src/components/atomic-crm/tags/RoundButton.tsx +10 -0
- package/src/components/atomic-crm/tags/TagChip.tsx +45 -0
- package/src/components/atomic-crm/tags/TagCreateModal.tsx +39 -0
- package/src/components/atomic-crm/tags/TagDialog.tsx +118 -0
- package/src/components/atomic-crm/tags/TagEditModal.tsx +42 -0
- package/src/components/atomic-crm/tags/colors.ts +12 -0
- package/src/components/atomic-crm/tasks/AddTask.tsx +191 -0
- package/src/components/atomic-crm/tasks/Task.tsx +184 -0
- package/src/components/atomic-crm/tasks/TaskEdit.tsx +96 -0
- package/src/components/atomic-crm/tasks/TasksIterator.tsx +30 -0
- package/src/components/atomic-crm/types.ts +226 -0
- package/src/components/supabase/forgot-password-page.tsx +86 -0
- package/src/components/supabase/layout.tsx +27 -0
- package/src/components/supabase/set-password-page.tsx +119 -0
- package/src/components/ui/README.md +34 -0
- package/src/components/ui/accordion.tsx +64 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/avatar.tsx +99 -0
- package/src/components/ui/badge.tsx +46 -0
- package/src/components/ui/breadcrumb.tsx +109 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/command.tsx +175 -0
- package/src/components/ui/dialog.tsx +133 -0
- package/src/components/ui/drawer.tsx +133 -0
- package/src/components/ui/dropdown-menu.tsx +255 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/navigation-menu.tsx +168 -0
- package/src/components/ui/pagination.tsx +127 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/progress.tsx +29 -0
- package/src/components/ui/radio-group.tsx +43 -0
- package/src/components/ui/select.tsx +183 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sheet.tsx +137 -0
- package/src/components/ui/sidebar.tsx +724 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/sonner.tsx +38 -0
- package/src/components/ui/spinner.tsx +51 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/table.tsx +114 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/hooks/saved-queries.tsx +67 -0
- package/src/hooks/simple-form-iterator-context.tsx +70 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/hooks/useBulkExport.tsx +61 -0
- package/src/hooks/useSupportCreateSuggestion.tsx +188 -0
- package/src/hooks/user-menu-context.tsx +24 -0
- package/src/index.css +170 -0
- package/src/lib/field.type.ts +22 -0
- package/src/lib/genericMemo.ts +18 -0
- package/src/lib/i18nProvider.ts +9 -0
- package/src/lib/sanitizeInputRestProps.ts +46 -0
- package/src/lib/supabase-config.ts +123 -0
- package/src/lib/utils.ts +6 -0
- package/src/main.tsx +10 -0
- package/src/setupTests.js +5 -0
- package/src/vite-env.d.ts +1 -0
- package/supabase/config.toml +157 -0
- package/supabase/functions/.env.development +7 -0
- package/supabase/functions/_shared/db.ts +187 -0
- package/supabase/functions/_shared/supabaseAdmin.ts +13 -0
- package/supabase/functions/_shared/utils.ts +13 -0
- package/supabase/functions/mergeContacts/index.ts +215 -0
- package/supabase/functions/postmark/addNoteToContact.ts +129 -0
- package/supabase/functions/postmark/extractMailContactData.ts +41 -0
- package/supabase/functions/postmark/getExpectedAuthorization.ts +4 -0
- package/supabase/functions/postmark/getNoteContent.ts +6 -0
- package/supabase/functions/postmark/index.ts +210 -0
- package/supabase/functions/updatePassword/index.ts +50 -0
- package/supabase/functions/users/index.ts +206 -0
- package/supabase/migrations/20240730075029_init_db.sql +600 -0
- package/supabase/migrations/20240730075425_init_triggers.sql +57 -0
- package/supabase/migrations/20240806124555_task_sales_id.sql +1 -0
- package/supabase/migrations/20240807082449_remove-aquisition.sql +20 -0
- package/supabase/migrations/20240808141826_init_state_configure.sql +9 -0
- package/supabase/migrations/20240813084010_tags_policy.sql +18 -0
- package/supabase/migrations/20241104153231_sales_policies.sql +7 -0
- package/supabase/migrations/20250109152531_email_jsonb.sql +43 -0
- package/supabase/migrations/20250113132531_phone_jsonb.sql +67 -0
- package/supabase/migrations/20251204172855_merge_contacts_function.sql +153 -0
- package/supabase/migrations/20251204201317_drop_merge_contacts_function.sql +2 -0
- package/supabase/seed.sql +0 -0
- package/supabase/templates/invite.html +70 -0
- package/supabase/templates/recovery.html +75 -0
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
create table "public"."companies" (
|
|
2
|
+
"id" bigint generated by default as identity not null,
|
|
3
|
+
"created_at" timestamp with time zone not null default now(),
|
|
4
|
+
"name" text not null,
|
|
5
|
+
"sector" text,
|
|
6
|
+
"size" smallint,
|
|
7
|
+
"linkedin_url" text,
|
|
8
|
+
"website" text,
|
|
9
|
+
"phone_number" text,
|
|
10
|
+
"address" text,
|
|
11
|
+
"zipcode" text,
|
|
12
|
+
"city" text,
|
|
13
|
+
"stateAbbr" text,
|
|
14
|
+
"sales_id" bigint,
|
|
15
|
+
"context_links" json,
|
|
16
|
+
"country" text,
|
|
17
|
+
"description" text,
|
|
18
|
+
"revenue" text,
|
|
19
|
+
"tax_identifier" text,
|
|
20
|
+
"logo" jsonb
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
alter table "public"."companies" enable row level security;
|
|
25
|
+
|
|
26
|
+
create table "public"."contactNotes" (
|
|
27
|
+
"id" bigint generated by default as identity not null,
|
|
28
|
+
"contact_id" bigint not null,
|
|
29
|
+
"text" text,
|
|
30
|
+
"date" timestamp with time zone default now(),
|
|
31
|
+
"sales_id" bigint,
|
|
32
|
+
"status" text,
|
|
33
|
+
"attachments" jsonb[]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
alter table "public"."contactNotes" enable row level security;
|
|
38
|
+
|
|
39
|
+
create table "public"."contacts" (
|
|
40
|
+
"id" bigint generated by default as identity not null,
|
|
41
|
+
"first_name" text,
|
|
42
|
+
"last_name" text,
|
|
43
|
+
"gender" text,
|
|
44
|
+
"title" text,
|
|
45
|
+
"email" text,
|
|
46
|
+
"phone_1_number" text,
|
|
47
|
+
"phone_1_type" text,
|
|
48
|
+
"phone_2_number" text,
|
|
49
|
+
"phone_2_type" text,
|
|
50
|
+
"background" text,
|
|
51
|
+
"acquisition" text,
|
|
52
|
+
"avatar" jsonb,
|
|
53
|
+
"first_seen" timestamp with time zone,
|
|
54
|
+
"last_seen" timestamp with time zone,
|
|
55
|
+
"has_newsletter" boolean,
|
|
56
|
+
"status" text,
|
|
57
|
+
"tags" bigint[],
|
|
58
|
+
"company_id" bigint,
|
|
59
|
+
"sales_id" bigint,
|
|
60
|
+
"linkedin_url" text
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
alter table "public"."contacts" enable row level security;
|
|
65
|
+
|
|
66
|
+
create table "public"."dealNotes" (
|
|
67
|
+
"id" bigint generated by default as identity not null,
|
|
68
|
+
"deal_id" bigint not null,
|
|
69
|
+
"type" text,
|
|
70
|
+
"text" text,
|
|
71
|
+
"date" timestamp with time zone default now(),
|
|
72
|
+
"sales_id" bigint,
|
|
73
|
+
"attachments" jsonb[]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
alter table "public"."dealNotes" enable row level security;
|
|
78
|
+
|
|
79
|
+
create table "public"."deals" (
|
|
80
|
+
"id" bigint generated by default as identity not null,
|
|
81
|
+
"name" text not null,
|
|
82
|
+
"company_id" bigint,
|
|
83
|
+
"contact_ids" bigint[],
|
|
84
|
+
"category" text,
|
|
85
|
+
"stage" text not null,
|
|
86
|
+
"description" text,
|
|
87
|
+
"amount" bigint,
|
|
88
|
+
"created_at" timestamp with time zone not null default now(),
|
|
89
|
+
"updated_at" timestamp with time zone not null default now(),
|
|
90
|
+
"archived_at" timestamp with time zone default null,
|
|
91
|
+
"expected_closing_date" timestamp with time zone default null,
|
|
92
|
+
"sales_id" bigint,
|
|
93
|
+
"index" smallint
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
alter table "public"."deals" enable row level security;
|
|
98
|
+
|
|
99
|
+
create table "public"."sales" (
|
|
100
|
+
"id" bigint generated by default as identity not null,
|
|
101
|
+
"first_name" text not null,
|
|
102
|
+
"last_name" text not null,
|
|
103
|
+
"email" text not null,
|
|
104
|
+
"administrator" boolean not null,
|
|
105
|
+
"user_id" uuid not null,
|
|
106
|
+
"avatar" jsonb,
|
|
107
|
+
"disabled" boolean not null default FALSE
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
alter table "public"."sales" enable row level security;
|
|
112
|
+
|
|
113
|
+
create table "public"."tags" (
|
|
114
|
+
"id" bigint generated by default as identity not null,
|
|
115
|
+
"name" text not null,
|
|
116
|
+
"color" text not null
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
alter table "public"."tags" enable row level security;
|
|
121
|
+
|
|
122
|
+
create table "public"."tasks" (
|
|
123
|
+
"id" bigint generated by default as identity not null,
|
|
124
|
+
"contact_id" bigint not null,
|
|
125
|
+
"type" text,
|
|
126
|
+
"text" text,
|
|
127
|
+
"due_date" timestamp with time zone not null,
|
|
128
|
+
"done_date" timestamp with time zone
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
alter table "public"."tasks" enable row level security;
|
|
133
|
+
|
|
134
|
+
CREATE UNIQUE INDEX companies_pkey ON public.companies USING btree (id);
|
|
135
|
+
|
|
136
|
+
CREATE UNIQUE INDEX "contactNotes_pkey" ON public."contactNotes" USING btree (id);
|
|
137
|
+
|
|
138
|
+
CREATE UNIQUE INDEX contacts_pkey ON public.contacts USING btree (id);
|
|
139
|
+
|
|
140
|
+
CREATE UNIQUE INDEX "dealNotes_pkey" ON public."dealNotes" USING btree (id);
|
|
141
|
+
|
|
142
|
+
CREATE UNIQUE INDEX deals_pkey ON public.deals USING btree (id);
|
|
143
|
+
|
|
144
|
+
CREATE UNIQUE INDEX sales_pkey ON public.sales USING btree (id);
|
|
145
|
+
|
|
146
|
+
CREATE UNIQUE INDEX tags_pkey ON public.tags USING btree (id);
|
|
147
|
+
|
|
148
|
+
CREATE UNIQUE INDEX tasks_pkey ON public.tasks USING btree (id);
|
|
149
|
+
|
|
150
|
+
alter table "public"."companies" add constraint "companies_pkey" PRIMARY KEY using index "companies_pkey";
|
|
151
|
+
|
|
152
|
+
alter table "public"."contactNotes" add constraint "contactNotes_pkey" PRIMARY KEY using index "contactNotes_pkey";
|
|
153
|
+
|
|
154
|
+
alter table "public"."contacts" add constraint "contacts_pkey" PRIMARY KEY using index "contacts_pkey";
|
|
155
|
+
|
|
156
|
+
alter table "public"."dealNotes" add constraint "dealNotes_pkey" PRIMARY KEY using index "dealNotes_pkey";
|
|
157
|
+
|
|
158
|
+
alter table "public"."deals" add constraint "deals_pkey" PRIMARY KEY using index "deals_pkey";
|
|
159
|
+
|
|
160
|
+
alter table "public"."sales" add constraint "sales_pkey" PRIMARY KEY using index "sales_pkey";
|
|
161
|
+
|
|
162
|
+
alter table "public"."tags" add constraint "tags_pkey" PRIMARY KEY using index "tags_pkey";
|
|
163
|
+
|
|
164
|
+
alter table "public"."tasks" add constraint "tasks_pkey" PRIMARY KEY using index "tasks_pkey";
|
|
165
|
+
|
|
166
|
+
alter table "public"."companies" add constraint "companies_sales_id_fkey" FOREIGN KEY (sales_id) REFERENCES sales(id) not valid;
|
|
167
|
+
|
|
168
|
+
alter table "public"."companies" validate constraint "companies_sales_id_fkey";
|
|
169
|
+
|
|
170
|
+
alter table "public"."contactNotes" add constraint "contactNotes_contact_id_fkey" FOREIGN KEY (contact_id) REFERENCES contacts(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
171
|
+
|
|
172
|
+
alter table "public"."contactNotes" validate constraint "contactNotes_contact_id_fkey";
|
|
173
|
+
|
|
174
|
+
alter table "public"."contactNotes" add constraint "contactNotes_sales_id_fkey" FOREIGN KEY (sales_id) REFERENCES sales(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
175
|
+
|
|
176
|
+
alter table "public"."contactNotes" validate constraint "contactNotes_sales_id_fkey";
|
|
177
|
+
|
|
178
|
+
alter table "public"."contacts" add constraint "contacts_company_id_fkey" FOREIGN KEY (company_id) REFERENCES companies(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
179
|
+
|
|
180
|
+
alter table "public"."contacts" validate constraint "contacts_company_id_fkey";
|
|
181
|
+
|
|
182
|
+
alter table "public"."contacts" add constraint "contacts_sales_id_fkey" FOREIGN KEY (sales_id) REFERENCES sales(id) not valid;
|
|
183
|
+
|
|
184
|
+
alter table "public"."contacts" validate constraint "contacts_sales_id_fkey";
|
|
185
|
+
|
|
186
|
+
alter table "public"."dealNotes" add constraint "dealNotes_deal_id_fkey" FOREIGN KEY (deal_id) REFERENCES deals(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
187
|
+
|
|
188
|
+
alter table "public"."dealNotes" validate constraint "dealNotes_deal_id_fkey";
|
|
189
|
+
|
|
190
|
+
alter table "public"."dealNotes" add constraint "dealNotes_sales_id_fkey" FOREIGN KEY (sales_id) REFERENCES sales(id) not valid;
|
|
191
|
+
|
|
192
|
+
alter table "public"."dealNotes" validate constraint "dealNotes_sales_id_fkey";
|
|
193
|
+
|
|
194
|
+
alter table "public"."deals" add constraint "deals_company_id_fkey" FOREIGN KEY (company_id) REFERENCES companies(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
195
|
+
|
|
196
|
+
alter table "public"."deals" validate constraint "deals_company_id_fkey";
|
|
197
|
+
|
|
198
|
+
alter table "public"."deals" add constraint "deals_sales_id_fkey" FOREIGN KEY (sales_id) REFERENCES sales(id) not valid;
|
|
199
|
+
|
|
200
|
+
alter table "public"."deals" validate constraint "deals_sales_id_fkey";
|
|
201
|
+
|
|
202
|
+
alter table "public"."sales" add constraint "sales_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) not valid;
|
|
203
|
+
|
|
204
|
+
alter table "public"."sales" validate constraint "sales_user_id_fkey";
|
|
205
|
+
|
|
206
|
+
alter table "public"."tasks" add constraint "tasks_contact_id_fkey" FOREIGN KEY (contact_id) REFERENCES contacts(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
|
|
207
|
+
|
|
208
|
+
alter table "public"."tasks" validate constraint "tasks_contact_id_fkey";
|
|
209
|
+
|
|
210
|
+
set check_function_bodies = off;
|
|
211
|
+
|
|
212
|
+
grant delete on table "public"."companies" to "authenticated";
|
|
213
|
+
grant insert on table "public"."companies" to "authenticated";
|
|
214
|
+
grant select on table "public"."companies" to "authenticated";
|
|
215
|
+
grant update on table "public"."companies" to "authenticated";
|
|
216
|
+
|
|
217
|
+
grant delete on table "public"."companies" to "service_role";
|
|
218
|
+
grant insert on table "public"."companies" to "service_role";
|
|
219
|
+
grant references on table "public"."companies" to "service_role";
|
|
220
|
+
grant select on table "public"."companies" to "service_role";
|
|
221
|
+
grant trigger on table "public"."companies" to "service_role";
|
|
222
|
+
grant truncate on table "public"."companies" to "service_role";
|
|
223
|
+
grant update on table "public"."companies" to "service_role";
|
|
224
|
+
|
|
225
|
+
grant delete on table "public"."contactNotes" to "authenticated";
|
|
226
|
+
grant insert on table "public"."contactNotes" to "authenticated";
|
|
227
|
+
grant select on table "public"."contactNotes" to "authenticated";
|
|
228
|
+
grant update on table "public"."contactNotes" to "authenticated";
|
|
229
|
+
|
|
230
|
+
grant delete on table "public"."contactNotes" to "service_role";
|
|
231
|
+
grant insert on table "public"."contactNotes" to "service_role";
|
|
232
|
+
grant references on table "public"."contactNotes" to "service_role";
|
|
233
|
+
grant select on table "public"."contactNotes" to "service_role";
|
|
234
|
+
grant trigger on table "public"."contactNotes" to "service_role";
|
|
235
|
+
grant truncate on table "public"."contactNotes" to "service_role";
|
|
236
|
+
grant update on table "public"."contactNotes" to "service_role";
|
|
237
|
+
|
|
238
|
+
grant delete on table "public"."contacts" to "authenticated";
|
|
239
|
+
grant insert on table "public"."contacts" to "authenticated";
|
|
240
|
+
grant select on table "public"."contacts" to "authenticated";
|
|
241
|
+
grant update on table "public"."contacts" to "authenticated";
|
|
242
|
+
|
|
243
|
+
grant delete on table "public"."contacts" to "service_role";
|
|
244
|
+
grant insert on table "public"."contacts" to "service_role";
|
|
245
|
+
grant references on table "public"."contacts" to "service_role";
|
|
246
|
+
grant select on table "public"."contacts" to "service_role";
|
|
247
|
+
grant trigger on table "public"."contacts" to "service_role";
|
|
248
|
+
grant truncate on table "public"."contacts" to "service_role";
|
|
249
|
+
grant update on table "public"."contacts" to "service_role";
|
|
250
|
+
|
|
251
|
+
grant delete on table "public"."dealNotes" to "authenticated";
|
|
252
|
+
grant insert on table "public"."dealNotes" to "authenticated";
|
|
253
|
+
grant select on table "public"."dealNotes" to "authenticated";
|
|
254
|
+
grant update on table "public"."dealNotes" to "authenticated";
|
|
255
|
+
|
|
256
|
+
grant delete on table "public"."dealNotes" to "service_role";
|
|
257
|
+
grant insert on table "public"."dealNotes" to "service_role";
|
|
258
|
+
grant references on table "public"."dealNotes" to "service_role";
|
|
259
|
+
grant select on table "public"."dealNotes" to "service_role";
|
|
260
|
+
grant trigger on table "public"."dealNotes" to "service_role";
|
|
261
|
+
grant truncate on table "public"."dealNotes" to "service_role";
|
|
262
|
+
grant update on table "public"."dealNotes" to "service_role";
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
grant delete on table "public"."deals" to "authenticated";
|
|
266
|
+
grant insert on table "public"."deals" to "authenticated";
|
|
267
|
+
grant select on table "public"."deals" to "authenticated";
|
|
268
|
+
grant update on table "public"."deals" to "authenticated";
|
|
269
|
+
|
|
270
|
+
grant delete on table "public"."deals" to "service_role";
|
|
271
|
+
grant insert on table "public"."deals" to "service_role";
|
|
272
|
+
grant references on table "public"."deals" to "service_role";
|
|
273
|
+
grant select on table "public"."deals" to "service_role";
|
|
274
|
+
grant trigger on table "public"."deals" to "service_role";
|
|
275
|
+
grant truncate on table "public"."deals" to "service_role";
|
|
276
|
+
grant update on table "public"."deals" to "service_role";
|
|
277
|
+
|
|
278
|
+
grant delete on table "public"."sales" to "authenticated";
|
|
279
|
+
grant insert on table "public"."sales" to "authenticated";
|
|
280
|
+
grant select on table "public"."sales" to "authenticated";
|
|
281
|
+
grant update on table "public"."sales" to "authenticated";
|
|
282
|
+
|
|
283
|
+
grant delete on table "public"."sales" to "service_role";
|
|
284
|
+
grant insert on table "public"."sales" to "service_role";
|
|
285
|
+
grant references on table "public"."sales" to "service_role";
|
|
286
|
+
grant select on table "public"."sales" to "service_role";
|
|
287
|
+
grant trigger on table "public"."sales" to "service_role";
|
|
288
|
+
grant truncate on table "public"."sales" to "service_role";
|
|
289
|
+
grant update on table "public"."sales" to "service_role";
|
|
290
|
+
|
|
291
|
+
grant delete on table "public"."tags" to "authenticated";
|
|
292
|
+
grant insert on table "public"."tags" to "authenticated";
|
|
293
|
+
grant select on table "public"."tags" to "authenticated";
|
|
294
|
+
grant update on table "public"."tags" to "authenticated";
|
|
295
|
+
|
|
296
|
+
grant delete on table "public"."tags" to "service_role";
|
|
297
|
+
grant insert on table "public"."tags" to "service_role";
|
|
298
|
+
grant references on table "public"."tags" to "service_role";
|
|
299
|
+
grant select on table "public"."tags" to "service_role";
|
|
300
|
+
grant trigger on table "public"."tags" to "service_role";
|
|
301
|
+
grant truncate on table "public"."tags" to "service_role";
|
|
302
|
+
grant update on table "public"."tags" to "service_role";
|
|
303
|
+
|
|
304
|
+
grant delete on table "public"."tasks" to "authenticated";
|
|
305
|
+
grant insert on table "public"."tasks" to "authenticated";
|
|
306
|
+
grant select on table "public"."tasks" to "authenticated";
|
|
307
|
+
grant update on table "public"."tasks" to "authenticated";
|
|
308
|
+
|
|
309
|
+
grant delete on table "public"."tasks" to "service_role";
|
|
310
|
+
grant insert on table "public"."tasks" to "service_role";
|
|
311
|
+
grant references on table "public"."tasks" to "service_role";
|
|
312
|
+
grant select on table "public"."tasks" to "service_role";
|
|
313
|
+
grant trigger on table "public"."tasks" to "service_role";
|
|
314
|
+
grant truncate on table "public"."tasks" to "service_role";
|
|
315
|
+
grant update on table "public"."tasks" to "service_role";
|
|
316
|
+
|
|
317
|
+
create policy "Enable insert for authenticated users only"
|
|
318
|
+
on "public"."companies"
|
|
319
|
+
as permissive
|
|
320
|
+
for insert
|
|
321
|
+
to authenticated
|
|
322
|
+
with check (true);
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
create policy "Enable read access for authenticated users"
|
|
326
|
+
on "public"."companies"
|
|
327
|
+
as permissive
|
|
328
|
+
for select
|
|
329
|
+
to authenticated
|
|
330
|
+
using (true);
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
create policy "Enable update for authenticated users only"
|
|
334
|
+
on "public"."companies"
|
|
335
|
+
as permissive
|
|
336
|
+
for update
|
|
337
|
+
to authenticated
|
|
338
|
+
using (true)
|
|
339
|
+
with check (true);
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
create policy "Enable insert for authenticated users only"
|
|
343
|
+
on "public"."contactNotes"
|
|
344
|
+
as permissive
|
|
345
|
+
for insert
|
|
346
|
+
to authenticated
|
|
347
|
+
with check (true);
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
create policy "Enable read access for authenticated users"
|
|
351
|
+
on "public"."contactNotes"
|
|
352
|
+
as permissive
|
|
353
|
+
for select
|
|
354
|
+
to authenticated
|
|
355
|
+
using (true);
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
create policy "Enable insert for authenticated users only"
|
|
359
|
+
on "public"."contacts"
|
|
360
|
+
as permissive
|
|
361
|
+
for insert
|
|
362
|
+
to authenticated
|
|
363
|
+
with check (true);
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
create policy "Enable read access for authenticated users"
|
|
367
|
+
on "public"."contacts"
|
|
368
|
+
as permissive
|
|
369
|
+
for select
|
|
370
|
+
to authenticated
|
|
371
|
+
using (true);
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
create policy "Enable update for authenticated users only"
|
|
375
|
+
on "public"."contacts"
|
|
376
|
+
as permissive
|
|
377
|
+
for update
|
|
378
|
+
to authenticated
|
|
379
|
+
using (true)
|
|
380
|
+
with check (true);
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
create policy "Enable insert for authenticated users only"
|
|
384
|
+
on "public"."dealNotes"
|
|
385
|
+
as permissive
|
|
386
|
+
for insert
|
|
387
|
+
to authenticated
|
|
388
|
+
with check (true);
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
create policy "Enable read access for authenticated users"
|
|
392
|
+
on "public"."dealNotes"
|
|
393
|
+
as permissive
|
|
394
|
+
for select
|
|
395
|
+
to authenticated
|
|
396
|
+
using (true);
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
create policy "Enable insert for authenticated users only"
|
|
400
|
+
on "public"."deals"
|
|
401
|
+
as permissive
|
|
402
|
+
for insert
|
|
403
|
+
to authenticated
|
|
404
|
+
with check (true);
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
create policy "Enable read access for authenticated users"
|
|
408
|
+
on "public"."deals"
|
|
409
|
+
as permissive
|
|
410
|
+
for select
|
|
411
|
+
to authenticated
|
|
412
|
+
using (true);
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
create policy "Enable update for authenticated users only"
|
|
416
|
+
on "public"."deals"
|
|
417
|
+
as permissive
|
|
418
|
+
for update
|
|
419
|
+
to authenticated
|
|
420
|
+
using (true)
|
|
421
|
+
with check (true);
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
create policy "Enable insert for authenticated users only"
|
|
425
|
+
on "public"."sales"
|
|
426
|
+
as permissive
|
|
427
|
+
for insert
|
|
428
|
+
to authenticated
|
|
429
|
+
with check (true);
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
create policy "Enable update for authenticated users only"
|
|
433
|
+
on "public"."sales"
|
|
434
|
+
as permissive
|
|
435
|
+
for update
|
|
436
|
+
to authenticated
|
|
437
|
+
using (true)
|
|
438
|
+
with check (true);
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
create policy "Enable read access for authenticated users"
|
|
442
|
+
on "public"."sales"
|
|
443
|
+
as permissive
|
|
444
|
+
for select
|
|
445
|
+
to authenticated
|
|
446
|
+
using (true);
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
create policy "Enable insert for authenticated users only"
|
|
450
|
+
on "public"."tags"
|
|
451
|
+
as permissive
|
|
452
|
+
for insert
|
|
453
|
+
to authenticated
|
|
454
|
+
with check (true);
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
create policy "Enable read access for authenticated users"
|
|
458
|
+
on "public"."tags"
|
|
459
|
+
as permissive
|
|
460
|
+
for select
|
|
461
|
+
to authenticated
|
|
462
|
+
using (true);
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
create policy "Enable insert for authenticated users only"
|
|
466
|
+
on "public"."tasks"
|
|
467
|
+
as permissive
|
|
468
|
+
for insert
|
|
469
|
+
to authenticated
|
|
470
|
+
with check (true);
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
create policy "Enable read access for authenticated users"
|
|
474
|
+
on "public"."tasks"
|
|
475
|
+
as permissive
|
|
476
|
+
for select
|
|
477
|
+
to authenticated
|
|
478
|
+
using (true);
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
create policy "Company Delete Policy"
|
|
482
|
+
on "public"."companies"
|
|
483
|
+
as permissive
|
|
484
|
+
for delete
|
|
485
|
+
to authenticated
|
|
486
|
+
using (true);
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
create policy "Contact Notes Delete Policy"
|
|
490
|
+
on "public"."contactNotes"
|
|
491
|
+
as permissive
|
|
492
|
+
for delete
|
|
493
|
+
to authenticated
|
|
494
|
+
using (true);
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
create policy "Contact Notes Update policy"
|
|
498
|
+
on "public"."contactNotes"
|
|
499
|
+
as permissive
|
|
500
|
+
for update
|
|
501
|
+
to authenticated
|
|
502
|
+
using (true);
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
create policy "Contact Delete Policy"
|
|
506
|
+
on "public"."contacts"
|
|
507
|
+
as permissive
|
|
508
|
+
for delete
|
|
509
|
+
to authenticated
|
|
510
|
+
using (true);
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
create policy "Deal Notes Delete Policy"
|
|
514
|
+
on "public"."dealNotes"
|
|
515
|
+
as permissive
|
|
516
|
+
for delete
|
|
517
|
+
to authenticated
|
|
518
|
+
using (true);
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
create policy "Deal Notes Update Policy"
|
|
522
|
+
on "public"."dealNotes"
|
|
523
|
+
as permissive
|
|
524
|
+
for update
|
|
525
|
+
to authenticated
|
|
526
|
+
using (true);
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
create policy "Deals Delete Policy"
|
|
530
|
+
on "public"."deals"
|
|
531
|
+
as permissive
|
|
532
|
+
for delete
|
|
533
|
+
to authenticated
|
|
534
|
+
using (true);
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
create policy "Task Delete Policy"
|
|
538
|
+
on "public"."tasks"
|
|
539
|
+
as permissive
|
|
540
|
+
for delete
|
|
541
|
+
to authenticated
|
|
542
|
+
using (true);
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
create policy "Task Update Policy"
|
|
546
|
+
on "public"."tasks"
|
|
547
|
+
as permissive
|
|
548
|
+
for update
|
|
549
|
+
to authenticated
|
|
550
|
+
using (true);
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
-- Use Postgres to create a bucket.
|
|
554
|
+
|
|
555
|
+
insert into storage.buckets
|
|
556
|
+
(id, name, public)
|
|
557
|
+
values
|
|
558
|
+
('attachments', 'attachments', true);
|
|
559
|
+
|
|
560
|
+
CREATE POLICY "Attachments 1mt4rzk_0" ON storage.objects FOR SELECT TO authenticated USING (bucket_id = 'attachments');
|
|
561
|
+
CREATE POLICY "Attachments 1mt4rzk_1" ON storage.objects FOR INSERT TO authenticated WITH CHECK (bucket_id = 'attachments');
|
|
562
|
+
CREATE POLICY "Attachments 1mt4rzk_3" ON storage.objects FOR DELETE TO authenticated USING (bucket_id = 'attachments');
|
|
563
|
+
|
|
564
|
+
-- Use Postgres to create views for companies.
|
|
565
|
+
|
|
566
|
+
create view "public"."companies_summary"
|
|
567
|
+
with (security_invoker=on)
|
|
568
|
+
as
|
|
569
|
+
select
|
|
570
|
+
c.*,
|
|
571
|
+
count(distinct d.id) as nb_deals,
|
|
572
|
+
count(distinct co.id) as nb_contacts
|
|
573
|
+
from
|
|
574
|
+
"public"."companies" c
|
|
575
|
+
left join
|
|
576
|
+
"public"."deals" d on c.id = d.company_id
|
|
577
|
+
left join
|
|
578
|
+
"public"."contacts" co on c.id = co.company_id
|
|
579
|
+
group by
|
|
580
|
+
c.id;
|
|
581
|
+
|
|
582
|
+
-- Use Postgres to create views for contacts.
|
|
583
|
+
|
|
584
|
+
create view "public"."contacts_summary"
|
|
585
|
+
with (security_invoker=on)
|
|
586
|
+
as
|
|
587
|
+
select
|
|
588
|
+
co.*,
|
|
589
|
+
c.name as company_name,
|
|
590
|
+
count(distinct t.id) as nb_tasks
|
|
591
|
+
from
|
|
592
|
+
"public"."contacts" co
|
|
593
|
+
left join
|
|
594
|
+
"public"."tasks" t on co.id = t.contact_id
|
|
595
|
+
left join
|
|
596
|
+
"public"."companies" c on co.company_id = c.id
|
|
597
|
+
group by
|
|
598
|
+
co.id, c.name;
|
|
599
|
+
|
|
600
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
create function public.handle_new_user()
|
|
2
|
+
returns trigger
|
|
3
|
+
language plpgsql
|
|
4
|
+
security definer set search_path = ''
|
|
5
|
+
as $$
|
|
6
|
+
declare
|
|
7
|
+
sales_count int;
|
|
8
|
+
begin
|
|
9
|
+
select count(id) into sales_count
|
|
10
|
+
from public.sales;
|
|
11
|
+
|
|
12
|
+
insert into public.sales (first_name, last_name, email, user_id, administrator)
|
|
13
|
+
values (
|
|
14
|
+
new.raw_user_meta_data ->> 'first_name',
|
|
15
|
+
new.raw_user_meta_data ->> 'last_name',
|
|
16
|
+
new.email,
|
|
17
|
+
new.id,
|
|
18
|
+
case when sales_count > 0 then FALSE else TRUE end
|
|
19
|
+
);
|
|
20
|
+
return new;
|
|
21
|
+
end;
|
|
22
|
+
$$;
|
|
23
|
+
|
|
24
|
+
create function public.handle_update_user()
|
|
25
|
+
returns trigger
|
|
26
|
+
language plpgsql
|
|
27
|
+
security definer set search_path = ''
|
|
28
|
+
as $$
|
|
29
|
+
begin
|
|
30
|
+
update public.sales
|
|
31
|
+
set
|
|
32
|
+
first_name = new.raw_user_meta_data ->> 'first_name',
|
|
33
|
+
last_name = new.raw_user_meta_data ->> 'last_name',
|
|
34
|
+
email = new.email
|
|
35
|
+
where user_id = new.id;
|
|
36
|
+
|
|
37
|
+
return new;
|
|
38
|
+
end;
|
|
39
|
+
$$;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
create unique index "uq__sales__user_id" on public.sales (user_id);
|
|
43
|
+
|
|
44
|
+
create trigger on_auth_user_created
|
|
45
|
+
after insert on auth.users
|
|
46
|
+
for each row execute procedure public.handle_new_user();
|
|
47
|
+
|
|
48
|
+
create trigger on_auth_user_updated
|
|
49
|
+
after update on auth.users
|
|
50
|
+
for each row execute procedure public.handle_update_user();
|
|
51
|
+
|
|
52
|
+
create view init_state
|
|
53
|
+
with (security_invoker=off)
|
|
54
|
+
as
|
|
55
|
+
select count(id) as is_initialized
|
|
56
|
+
from public.sales
|
|
57
|
+
limit 1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
alter table "public"."tasks" add column "sales_id" bigint;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
-- this will drop the `contacts_summary` view as well
|
|
2
|
+
ALTER TABLE "public"."contacts"
|
|
3
|
+
DROP COLUMN acquisition CASCADE;
|
|
4
|
+
|
|
5
|
+
-- We need to recreate the view with the new schema
|
|
6
|
+
|
|
7
|
+
create view "public"."contacts_summary"
|
|
8
|
+
as
|
|
9
|
+
select
|
|
10
|
+
co.*,
|
|
11
|
+
c.name as company_name,
|
|
12
|
+
count(distinct t.id) as nb_tasks
|
|
13
|
+
from
|
|
14
|
+
"public"."contacts" co
|
|
15
|
+
left join
|
|
16
|
+
"public"."tasks" t on co.id = t.contact_id
|
|
17
|
+
left join
|
|
18
|
+
"public"."companies" c on co.company_id = c.id
|
|
19
|
+
group by
|
|
20
|
+
co.id, c.name;
|