Skip to content

Commit 71fd1a5

Browse files
tobiceB4nan
andauthored
feat: add general access enum to consts (#507)
We plan to allow users to configure through API & clients how their storages and runs can be accessed — whether just the ID / name is sufficient to access the storage. Full context in apify/apify-core#19012. This PR adds appropriate enums that will be used both externally (in clients & API), and internally (where it will replace the [existing](https://github.com/apify/apify-core/blob/ba052eedd7490952fa1b8c1447c261a9cfd3acb3/src/packages/consts/src/iam.ts#L101) enum). Note that there are separate enums for runs and storages as only storages support access by name. So far we have been using a shared enum for both, but it's cleaner to have them separated — in run related logic & documentation we won't have to account (much) for the unsupported value. --------- Co-authored-by: Martin Adámek <banan23@gmail.com>
1 parent 780eca2 commit 71fd1a5

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

packages/consts/src/consts.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ValueOf } from './helpers';
12
import { DNS_SAFE_NAME_REGEX, EMAIL_REGEX } from './regexs';
23

34
export const FREE_SUBSCRIPTION_PLAN_CODE = 'DEV';
@@ -631,3 +632,40 @@ export const ISSUES_STATUS_TYPES = {
631632
* This is used for filtering issues. All issue types to be considered.
632633
*/
633634
export const ISSUES_STATUS_ALL = 'ALL';
635+
636+
/**
637+
* Storage setting determining how others can access the storage.
638+
*
639+
* This setting overrides the user setting of the storage owner.
640+
*/
641+
export const STORAGE_GENERAL_ACCESS = {
642+
// Empty / not populated: Follow the user setting.
643+
644+
/** Only signed-in users with explicit access can read this storage. */
645+
RESTRICTED: 'RESTRICTED',
646+
647+
/** Anyone with a link, or the unique storage ID, can read the storage. */
648+
ANYONE_WITH_ID_CAN_READ: 'ANYONE_WITH_ID_CAN_READ',
649+
650+
/** Anyone with a link, the unique storage ID, or the storage name, can read the storage. */
651+
ANYONE_WITH_NAME_CAN_READ: 'ANYONE_WITH_NAME_CAN_READ',
652+
} as const;
653+
654+
export type STORAGE_GENERAL_ACCESS = ValueOf<typeof STORAGE_GENERAL_ACCESS>
655+
656+
/**
657+
* Run setting determining how others can access the run.
658+
*
659+
* This setting overrides the user setting of the run owner.
660+
*/
661+
export const RUN_GENERAL_ACCESS = {
662+
// Empty / not populated: Follow the user setting.
663+
664+
/** Only signed-in users with explicit access can read this run. */
665+
RESTRICTED: 'RESTRICTED',
666+
667+
/** Anyone with a link, or the unique run ID, can read the run. */
668+
ANYONE_WITH_ID_CAN_READ: 'ANYONE_WITH_ID_CAN_READ',
669+
} as const;
670+
671+
export type RUN_GENERAL_ACCESS = ValueOf<typeof RUN_GENERAL_ACCESS>

packages/consts/src/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type ValueOf<T> = T[keyof T];

packages/consts/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './consts';
2+
export * from './helpers';
23
export * from './regexs';

0 commit comments

Comments
 (0)