UNPKG

23 kBJavaScriptView Raw
1/**
2 * Copyright (c) 2018, Kinvey, Inc. All rights reserved.
3 *
4 * This software is licensed to you under the Kinvey terms of service located at
5 * http://www.kinvey.com/terms-of-use. By downloading, accessing and/or using this
6 * software, you hereby accept such terms of service (and any agreement referenced
7 * therein) and agree that you have read, understand and agree to be bound by such
8 * terms of service and are of legal age to agree to such terms with Kinvey.
9 *
10 * This software contains valuable confidential and proprietary information of
11 * KINVEY, INC and is subject to applicable licensing agreements.
12 * Unauthorized reproduction, transmission or distribution of this file and its
13 * contents is a violation of applicable laws.
14 */
15
16const Constants = {};
17
18Constants.Namespace = {
19 APP: 'app',
20 COLL: 'coll',
21 ENV: 'appenv',
22 FLEX: 'flex',
23 ORG: 'org',
24 PROFILE: 'profile',
25 SERVICE: 'service',
26 SITE: 'website'
27};
28
29Constants.SubCommand = {
30 [Constants.Namespace.FLEX]: {
31 INIT: 'init',
32 DEPLOY: 'deploy',
33 JOB: 'job',
34 STATUS: 'status',
35 LIST: 'list',
36 LOGS: 'logs',
37 RECYCLE: 'recycle',
38 DELETE: 'delete',
39 CLEAR: 'clear',
40 CREATE: 'create',
41 UPDATE: 'update',
42 SHOW: 'show'
43 },
44 [Constants.Namespace.ENV]: {
45 SHOW: 'show',
46 DELETE: 'delete'
47 }
48};
49
50Constants.Command = {
51 FLEX_INIT: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].INIT}`,
52 FLEX_DEPLOY: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].DEPLOY}`,
53 FLEX_JOB: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].JOB}`,
54 FLEX_STATUS: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].STATUS}`,
55 FLEX_LIST: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].LIST}`,
56 FLEX_LOGS: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].LOGS}`,
57 FLEX_RECYCLE: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].RECYCLE}`,
58 FLEX_DELETE: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].DELETE}`,
59 FLEX_CLEAR: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].CLEAR}`,
60 FLEX_CREATE: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].CREATE}`,
61 FLEX_SHOW: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].SHOW}`,
62 FLEX_UPDATE: `${Constants.Namespace.FLEX} ${Constants.SubCommand[Constants.Namespace.FLEX].UPDATE}`,
63 ENV_SHOW: `${Constants.Namespace.ENV} ${Constants.SubCommand[Constants.Namespace.ENV].SHOW}`,
64 ENV_DELETE: `${Constants.Namespace.ENV} ${Constants.SubCommand[Constants.Namespace.ENV].DELETE}`
65};
66
67Constants.CommandRequirement = {
68 AUTH: 'auth',
69 PROFILE_AVAILABLE: 'profile'
70};
71
72Constants.EnvironmentVariables = {
73 PREFIX: 'KINVEY_CLI_'
74};
75Constants.EnvironmentVariables.USER = `${Constants.EnvironmentVariables.PREFIX}EMAIL`;
76Constants.EnvironmentVariables.PASSWORD = `${Constants.EnvironmentVariables.PREFIX}PASSWORD`;
77Constants.EnvironmentVariables.PROFILE = `${Constants.EnvironmentVariables.PREFIX}PROFILE`;
78Constants.EnvironmentVariables.HOST = `${Constants.EnvironmentVariables.PREFIX}HOST`;
79
80Constants.AllCommandsNotRequiringAuth = ['init', 'profile create', 'profile list', 'profile show', 'profile delete', 'profile use', 'profile login', 'flex clear'];
81
82Constants.CommonOptionsNames = {
83 NO_COLOR: 'no-color',
84 NO_PROMPT: 'no-prompt',
85 OUTPUT: 'output',
86 SILENT: 'silent',
87 SUPPRESS_VERSION_CHECK: 'suppress-version-check',
88 VERBOSE: 'verbose'
89};
90
91Constants.CommonOptions = {
92 [Constants.CommonOptionsNames.NO_PROMPT]: {
93 global: false,
94 alias: 'noPrompt',
95 describe: 'Do not prompt',
96 type: 'boolean',
97 default: false
98 }
99};
100
101Constants.OutputFormat = {
102 HUMAN_READABLE: 'default',
103 TEXT: 'text',
104 JSON: 'json'
105};
106
107Constants.AuthOptionsNames = {
108 BAAS_HOST: 'baas',
109 EMAIL: 'email',
110 PASSWORD: 'password',
111 TWO_FACTOR_AUTH_TOKEN: '2fa',
112 PROFILE: 'profile',
113 HOST: 'instance-id'
114};
115
116Constants.ExportOptionsNames = {
117 FILE: 'file'
118};
119
120Constants.ExportOptions = {
121 [Constants.ExportOptionsNames.FILE]: {
122 global: false,
123 describe: 'Path to file',
124 required: true,
125 type: 'string'
126 }
127};
128
129Constants.AppOptionsName = {
130 APP: 'app'
131};
132
133Constants.AppOptions = {
134 [Constants.AppOptionsName.APP]: {
135 global: false,
136 describe: 'App ID/name',
137 type: 'string'
138 }
139};
140
141Constants.CollectionOptionsName = {
142 COLL: 'coll'
143};
144
145Constants.CollectionOptions = {
146 [Constants.CollectionOptionsName.COLL]: {
147 global: false,
148 describe: 'Collection name',
149 type: 'string'
150 }
151};
152
153Constants.EnvOptionsName = {
154 ENV: 'env'
155};
156
157Constants.EnvOptions = {
158 [Constants.EnvOptionsName.ENV]: {
159 global: false,
160 describe: 'Env ID/name',
161 type: 'string'
162 }
163};
164
165Constants.FlexOptionsNames = {
166 SERVICE_ID: 'service',
167 DOMAIN_TYPE: 'domain',
168 DOMAIN_ID: 'id',
169 FROM: 'from',
170 TO: 'to',
171 PAGE: 'page',
172 NUMBER: 'number',
173 JOB_ID: 'id',
174 SERVICE_SECRET: 'secret',
175 SVC_ENV: 'env',
176 ENV_VARS_REPLACE: 'replace-vars',
177 ENV_VARS_SET: 'set-vars',
178 ENV_VARS: 'vars',
179 RUNTIME: 'runtime'
180};
181
182const flexEnvVarsSyntaxDescription = 'Specify either as comma-separated list of key-value pairs (key1=value1,key2=value2) or in JSON format.';
183
184Constants.CLIRuntime = {
185 NODE6: 'node6',
186 NODE8: 'node8',
187 NODE10: 'node10',
188 NODE12: 'node12'
189};
190
191Constants.AllowedCLIRuntimes = [
192 Constants.CLIRuntime.NODE6,
193 Constants.CLIRuntime.NODE8,
194 Constants.CLIRuntime.NODE10,
195 Constants.CLIRuntime.NODE12
196];
197
198Constants.FlexOptions = {
199 [Constants.FlexOptionsNames.SERVICE_ID]: {
200 global: false,
201 describe: 'Service ID',
202 type: 'string'
203 },
204 [Constants.FlexOptionsNames.SERVICE_SECRET]: {
205 global: false,
206 describe: 'Shared secret',
207 type: 'string'
208 },
209 [Constants.FlexOptionsNames.DOMAIN_TYPE]: {
210 global: false,
211 describe: 'Specify domain: \'app\' or \'org\'',
212 type: 'string',
213 choices: ['app', 'org']
214 },
215 [Constants.FlexOptionsNames.DOMAIN_ID]: {
216 global: false,
217 describe: 'ID of app or org',
218 type: 'string'
219 },
220 [Constants.FlexOptionsNames.SVC_ENV]: {
221 global: false,
222 describe: 'Service environment name/ID',
223 type: 'string'
224 },
225 [Constants.FlexOptionsNames.ENV_VARS_REPLACE]: {
226 global: false,
227 describe: `Environment variables (replaces all already existing). ${flexEnvVarsSyntaxDescription}`,
228 alias: 'replaceVars'
229 },
230 [Constants.FlexOptionsNames.ENV_VARS_SET]: {
231 global: false,
232 describe: `Environment variables to set. ${flexEnvVarsSyntaxDescription}`,
233 alias: 'setVars'
234 },
235 [Constants.FlexOptionsNames.ENV_VARS]: {
236 global: false,
237 describe: `Environment variables. ${flexEnvVarsSyntaxDescription}`,
238 alias: Constants.FlexOptionsNames.ENV_VARS_SET
239 },
240 [Constants.FlexOptionsNames.RUNTIME]: {
241 global: false,
242 describe: 'Runtime environment',
243 type: 'string',
244 choices: Constants.AllowedCLIRuntimes
245 }
246};
247
248Constants.APIRuntime = {
249 NODE6: 'flex-runtime-node6',
250 NODE8: 'flex-runtime-node8',
251 NODE10: 'flex-runtime-node10',
252 NODE12: 'flex-runtime-node12'
253};
254
255Constants.CLIRuntimeToAPIRuntime = {
256 [Constants.CLIRuntime.NODE6]: Constants.APIRuntime.NODE6,
257 [Constants.CLIRuntime.NODE8]: Constants.APIRuntime.NODE8,
258 [Constants.CLIRuntime.NODE10]: Constants.APIRuntime.NODE10,
259 [Constants.CLIRuntime.NODE12]: Constants.APIRuntime.NODE12
260};
261
262Constants.APIRuntimeToCLIRuntime = {
263 [Constants.APIRuntime.NODE6]: Constants.CLIRuntime.NODE6,
264 [Constants.APIRuntime.NODE8]: Constants.CLIRuntime.NODE8,
265 [Constants.APIRuntime.NODE10]: Constants.CLIRuntime.NODE10,
266 [Constants.APIRuntime.NODE12]: Constants.CLIRuntime.NODE12
267};
268
269Constants.OrgOptionsName = {
270 ORG: 'org'
271};
272
273Constants.OrgOptions = {
274 [Constants.OrgOptionsName.ORG]: {
275 global: false,
276 describe: 'Org ID/name',
277 type: 'string'
278 }
279};
280
281Constants.ServiceOptionsNames = {
282 SVC_ENV: 'svcEnv'
283};
284
285Constants.ServiceOptions = {
286 [Constants.ServiceOptionsNames.SVC_ENV]: {
287 global: false,
288 describe: 'Service environment name/ID',
289 type: 'string'
290 }
291};
292
293Constants.SitesOptionsNames = {
294 SITE: 'website',
295 DOMAIN_NAME: 'domainName',
296 INDEX_PAGE: 'indexPage',
297 ERROR_PAGE: 'errorPage',
298 ROUTING: 'historyApiRouting',
299 FORCE: 'force'
300};
301
302Constants.SitesOptions = {
303 [Constants.SitesOptionsNames.SITE]: {
304 global: false,
305 describe: 'Website ID/name',
306 type: 'string',
307 demandOption: true
308 },
309 [Constants.SitesOptionsNames.DOMAIN_NAME]: {
310 global: false,
311 describe: 'Domain name',
312 type: 'string',
313 demandOption: true
314 },
315 [Constants.SitesOptionsNames.INDEX_PAGE]: {
316 global: false,
317 describe: 'Index page',
318 type: 'string',
319 demandOption: false
320 },
321 [Constants.SitesOptionsNames.ERROR_PAGE]: {
322 global: false,
323 describe: 'Error page',
324 type: 'string',
325 demandOption: false
326 },
327 [Constants.SitesOptionsNames.ROUTING]: {
328 global: false,
329 describe: 'Enable server support for History API routing',
330 type: 'boolean',
331 demandOption: false,
332 default: false
333 },
334 [Constants.SitesOptionsNames.FORCE]: {
335 global: false,
336 describe: 'Force execution (skip client-side validation)',
337 type: 'boolean',
338 demandOption: false,
339 default: false
340 }
341};
342
343Constants.PromptTypes = {
344 CONFIRM: 'confirm',
345 INPUT: 'input',
346 LIST: 'list',
347 PASSWORD: 'password'
348};
349
350Constants.PromptMessages = {
351 INPUT_EMAIL: 'E-mail',
352 INPUT_PASSWORD: 'Password',
353 INPUT_MFA_TOKEN: 'Two-factor authentication token',
354 INPUT_HOST: 'Instance ID (optional)',
355 INPUT_PROFILE: 'Profile name (stores connection settings)',
356 INPUT_OVERRIDE_PROFILE: 'Override profile?',
357 INPUT_DOMAIN: 'Would you like to select a service from a Kinvey app or org?',
358 INPUT_APP: 'Which app would you like to use?',
359 INPUT_ORG: 'Which organization would you like to use?',
360 INPUT_SPECIFIC_SERVICE: 'Which service would you like to use?',
361 INPUT_SPECIFIC_SVC_ENV: 'Which service environment would you like to use?',
362 INVALID_MFA_TOKEN: 'Please enter a valid 2FA token (6 digits).',
363 INVALID_EMAIL_ADDRESS: 'Please enter a valid e-mail address.',
364 INVALID_STRING: 'Please provide a non-empty string.'
365};
366
367Constants.InfoMessages = {
368 APP_PROMPTING: 'Prompting for application',
369 APP_OR_ORG_PROMPTING: 'Prompting for app or organization',
370 ORG_PROMPTING: 'Prompting for organization',
371 SERVICE_PROMPTING: 'Prompting for service',
372 TWO_FACTOR_TOKEN_PROMPTING: 'Prompting for 2FA token',
373 EMAIL_PASSWORD_PROMPTING: 'Prompting for email and/or password'
374};
375
376Constants.LogErrorMessages = {
377 INVALID_TIMESTAMP: 'invalid (ISO-8601 timestamp expected)',
378 INVALID_NONZEROINT: 'invalid (non-zero integer expected)'
379};
380
381/**
382 * Defines domain types.
383 * @readonly
384 * @enum {string} DomainTypes
385 */
386Constants.DomainTypes = {
387 APP: 'app',
388 ORG: 'org'
389};
390
391Constants.JobStatus = {
392 COMPLETE: 'COMPLETE'
393};
394
395Constants.ServiceStatus = {
396 ONLINE: 'ONLINE',
397 NEW: 'NEW',
398 BUILDING: 'BUILDING',
399 DEPLOYING: 'DEPLOYING',
400 UPDATING: 'UPDATING',
401 ERROR: 'ERROR'
402};
403
404Constants.DeploymentStatus = {
405 RUNNING: 'RUNNING',
406 ERROR: 'ERROR',
407 COMPLETED: 'COMPLETED'
408};
409
410Constants.FlexProjectMaxSize = 10 * 1024 * 1024;
411
412/**
413 * Defines active item types.
414 * @readonly
415 * @enum {string} ActiveItemType
416 */
417Constants.ActiveItemType = {
418 APP: 'app',
419 ENV: 'env',
420 ORG: 'org'
421};
422
423Constants.ActiveItemTypes = [Constants.ActiveItemType.APP, Constants.ActiveItemType.ENV, Constants.ActiveItemType.ORG];
424
425Constants.Errors = {
426 ConnectionReset: {
427 NAME: 'ECONNRESET',
428 MESSAGE: 'A connection was forcibly closed by a peer.'
429 },
430 DeploymentVersionTooLow: {
431 NAME: 'DeploymentVersionTooLow'
432 },
433 InvalidEmail: {
434 NAME: 'InvalidEmail',
435 MESSAGE: 'E-mail is invalid.'
436 },
437 InvalidCredentials: {
438 NAME: 'InvalidCredentials',
439 MESSAGE: 'Credentials are invalid. Please authenticate.'
440 },
441 InvalidConfigUrl: {
442 NAME: 'InvalidConfigUrl',
443 MESSAGE: 'The configuration URL is invalid. Please use a valid Kinvey instance name or URL.'
444 },
445 InvalidProject: {
446 NAME: 'InvalidProject',
447 MESSAGE: 'This project is not valid. Please implement the kinvey-flex-sdk node module.'
448 },
449 ProfileNotFound: {
450 NAME: 'ProfileNotFound',
451 MESSAGE: 'Profile not found. Please verify profile name exists.'
452 },
453 ProfileRequired: {
454 NAME: 'ProfileRequired',
455 MESSAGE: `Profile is required. Please set active profile or use the --${Constants.AuthOptionsNames.PROFILE} option.`
456 },
457 AppRequired: {
458 NAME: 'AppRequired',
459 MESSAGE: `Application is required. Please set active app or use the --${Constants.AppOptionsName.APP} option.`
460 },
461 AppOrOrgRequired: {
462 NAME: 'AppOrOrgRequired',
463 MESSAGE: `Either '--${Constants.AppOptionsName.APP}' or '--${Constants.OrgOptionsName.ORG}' option must be set.`
464 },
465 EnvRequired: {
466 NAME: 'EnvRequired',
467 MESSAGE: `Environment is required. Please set active env or use the --${Constants.EnvOptionsName.ENV} option.`
468 },
469 ProjectNotConfigured: {
470 NAME: 'ProjectNotConfigured',
471 MESSAGE: `This project is not configured. Use 'kinvey ${Constants.Command.FLEX_INIT}' to get started.`
472 },
473 ProjectMaxFileSizeExceeded: {
474 NAME: 'ProjectMaxFileSizeExceeded',
475 MESSAGE: `This project is too big to be deployed. The max project size is ${Constants.FlexProjectMaxSize} bytes.`
476 },
477 ProjectRestoreError: {
478 NAME: 'ProjectRestoreError',
479 MESSAGE: 'This project could not be properly restored. Run `kinvey flex init` to get started.'
480 },
481 RequestError: {
482 NAME: 'RequestError',
483 MESSAGE: 'There was an error processing your request.'
484 },
485 RequestTimedOut: {
486 NAME: 'ETIMEDOUT',
487 MESSAGE: 'Request timed out.'
488 },
489 TooManyEntitiesFound: {
490 NAME: 'TooManyFound',
491 MESSAGE: 'Too many entities found.'
492 },
493 NoAppsFound: {
494 NAME: 'NoAppsFound',
495 MESSAGE: 'You have no apps yet. Head over to the console to create one.'
496 },
497 NoAppsAndOrgsFound: {
498 NAME: 'NoAppsAndOrgsFound',
499 MESSAGE: 'You have no apps and orgs yet. Head over to the console to create some.'
500 },
501 NoEntityFound: {
502 NAME: 'NotFound',
503 MESSAGE: 'Entity not found.'
504 },
505 NoFlexServicesFound: {
506 NAME: 'NoFlexServicesFound',
507 MESSAGE: 'You have no eligible Internal Flex Services yet.'
508 },
509 NoScvEnvFound: {
510 NAME: 'NoScvEnvFound',
511 MESSAGE: 'You have no service environments yet.'
512 },
513 NoSiteEnvFound: {
514 NAME: 'NoSiteEnvFound',
515 MESSAGE: 'You have no site environments yet.'
516 },
517 NoOrgsFound: {
518 NAME: 'NoOrgsFound',
519 MESSAGE: 'You have no organizations yet. Head over to the console to create one.'
520 },
521 NoOrgFound: {
522 NAME: 'OrganizationNotFound',
523 MESSAGE: 'The specified organization could not be found.'
524 },
525 NoServiceHostsFound: {
526 NAME: 'NoServiceHostsFound',
527 MESSAGE: 'There are no logs for this Internal Flex Service'
528 },
529 NoJobStored: {
530 NAME: 'NoJobStored',
531 MESSAGE: 'No previous job stored. Please provide a job ID.'
532 },
533 ItemNotSpecified: {
534 NAME: 'ItemNotSpecified',
535 MESSAGE: 'No item identifier is specified and/or active item is not set.'
536 }
537};
538
539Constants.HTTPMethod = {
540 GET: 'GET',
541 POST: 'POST',
542 PUT: 'PUT',
543 DELETE: 'DELETE'
544};
545
546Constants.HTTPConnectionErrors = ['ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'PROTOCOL_CONNECTION_LOST'];
547
548Constants.LogLevel = {
549 DATA: 'data',
550 DEBUG: 'debug',
551 ERROR: 'error',
552 INFO: 'info',
553 SILENT: 'silent',
554 WARN: 'warn'
555};
556
557Constants.StderrLogLevels = [
558 Constants.LogLevel.DEBUG,
559 Constants.LogLevel.ERROR,
560 Constants.LogLevel.INFO,
561 Constants.LogLevel.WARN
562];
563
564/**
565 * Defines operation types.
566 * @readonly
567 * @enum {string} OperationType
568 */
569Constants.OperationType = {
570 CREATE: 'create',
571 UPDATE: 'update',
572 DELETE: 'delete',
573 ACTIVATE: 'activate',
574 SAVE: 'save',
575 EXPORT: 'export'
576};
577
578Constants.OperationMessage = {
579 [Constants.OperationType.CREATE]: 'Created',
580 [Constants.OperationType.UPDATE]: 'Updated',
581 [Constants.OperationType.DELETE]: 'Deleted',
582 [Constants.OperationType.ACTIVATE]: 'Active',
583 [Constants.OperationType.SAVE]: 'Saved',
584 [Constants.OperationType.EXPORT]: 'Exported'
585};
586
587/**
588 * Defines entity types.
589 * @readonly
590 * @enum {string} EntityType
591 */
592Constants.EntityType = {
593 CONFIGURATION: 'configuration',
594 PROFILE: 'profile',
595 ORG: 'organization',
596 APP: 'application',
597 ENV: 'environment',
598 COLL: 'collection',
599 SERVICE: 'service',
600 INTERNAL_FLEX_SERVICE: 'internal flex service',
601 SCV_ENV: 'service environment',
602 SITE: 'website'
603};
604
605Constants.Mapping = {};
606Constants.Mapping[Constants.EntityType.ORG] = {
607 BASIC: { id: 'id', name: 'name' },
608 DETAILS: {
609 id: 'id',
610 name: 'name',
611 plan: 'restrictions.defaultPlanLevel',
612 requireApprovals: 'security.requireApprovals',
613 requireEmailVerification: 'security.requireEmailVerification',
614 requireTwoFactorAuth: 'security.requireTwoFactorAuth'
615 }
616};
617Constants.Mapping[Constants.EntityType.APP] = {
618 BASIC: {
619 id: 'id',
620 name: 'name',
621 organizationId: 'organizationId',
622 environments: item => (item && item.environments ? item.environments.length : 0)
623 }
624};
625Constants.Mapping[Constants.EntityType.APP].DETAILS = Object.assign(
626 {},
627 Constants.Mapping[Constants.EntityType.APP].BASIC,
628 { plan: 'plan.level' }
629);
630
631
632Constants.Mapping[Constants.EntityType.ENV] = {
633 BASIC: {
634 id: 'id',
635 name: 'name'
636 }
637};
638Constants.Mapping[Constants.EntityType.ENV].DETAILS = Object.assign(
639 {},
640 Constants.Mapping[Constants.EntityType.ENV].BASIC,
641 { appSecret: 'appSecret' }
642);
643
644Constants.CollectionHook = {
645 onPreSave: 'pre-save',
646 onPreFetch: 'pre-fetch',
647 onPreDelete: 'pre-delete',
648 onPostSave: 'post-save',
649 onPostFetch: 'post-fetch',
650 onPostDelete: 'post-delete'
651};
652
653Constants.AllowedCollectionHooks = Object.keys(Constants.CollectionHook);
654
655Constants.EndpointFieldNames = ['name', 'code', 'host', 'sdkHandlerName', 'schedule'];
656
657/**
658 * Defines types of configuration files.
659 * @readonly
660 * @enum {string} ConfigType
661 */
662Constants.ConfigType = {
663 APP: 'application',
664 ENV: 'environment',
665 ORG: 'organization',
666 SERVICE: 'service'
667};
668
669/**
670 * Defines basic permissions for a collection as defined in a config file.
671 * @readonly
672 * @enum {string} BasicCollectionPermission
673 */
674Constants.BasicCollectionPermission = {
675 PRIVATE: 'private',
676 FULL: 'full',
677 SHARED: 'shared',
678 READ_ONLY: 'read-only'
679};
680
681Constants.AllowedBasicCollPermissions = Object.keys(Constants.BasicCollectionPermission).map(x => Constants.BasicCollectionPermission[x]);
682
683Constants.AllowedRolesPermissions = ['always', 'grant', 'entity', 'never'];
684
685/**
686 * Defines a mapping from basic collection permissions as defined in a config file to backend collection permissions.
687 * @readonly
688 * @enum {string} BackendCollectionPermission
689 */
690Constants.BackendCollectionPermission = {
691 [Constants.BasicCollectionPermission.PRIVATE]: 'append-only',
692 [Constants.BasicCollectionPermission.FULL]: 'write',
693 [Constants.BasicCollectionPermission.SHARED]: 'append-read',
694 [Constants.BasicCollectionPermission.READ_ONLY]: 'read-only'
695};
696
697/**
698 * Defines permissions operations on a collection.
699 * @readonly
700 * @enum {string} PermissionsOperation
701 */
702Constants.PermissionsOperation = {
703 CREATE: 'create',
704 READ: 'read',
705 UPDATE: 'update',
706 DELETE: 'delete'
707};
708
709Constants.AllowedPermissionsOperations = [Constants.PermissionsOperation.CREATE, Constants.PermissionsOperation.READ, Constants.PermissionsOperation.UPDATE, Constants.PermissionsOperation.DELETE];
710
711Constants.ConfigFiles = {};
712
713Constants.ConfigFiles.FILE_REFERENCE_PREFIX = 'file::';
714
715Constants.ConfigFiles.CollType = {
716 INTERNAL: 'internal',
717 EXTERNAL: 'external'
718};
719
720Constants.ConfigFiles.ServiceType = {
721 FLEX_INTERNAL: 'flex-internal',
722 FLEX_EXTERNAL: 'flex-external',
723 REST: 'data-rest',
724 SP: 'data-sharepoint',
725 SF: 'data-salesforce',
726 SQL: 'data-mssql',
727 PROGRESS_DATA: 'data-progress',
728 DATA_DIRECT: 'data-direct',
729 POKIT_DOK: 'data-health'
730};
731
732Constants.BackendServiceType = {
733 FLEX_INTERNAL: 'internal',
734 FLEX_EXTERNAL: 'external',
735 REST: 'rest',
736 SP: 'sharepoint',
737 SF: 'salesforce',
738 SQL: 'mssql',
739 PROGRESS_DATA: 'progressDataObject'
740};
741
742Constants.ConfigFiles.BaseConfigType = {
743 DATA_DIRECT: 'dataDirect',
744 POKIT_DOK: 'pokitDok'
745};
746
747Constants.AllowedServiceTypesToApply = Object.keys(Constants.ConfigFiles.ServiceType).map(x => Constants.ConfigFiles.ServiceType[x]);
748Constants.AllowedServiceTypesForExport = Object.keys(Constants.BackendServiceType).map(x => Constants.BackendServiceType[x]);
749
750Constants.ConfigFiles.BackendToConfigServiceType = {
751 [Constants.BackendServiceType.FLEX_INTERNAL]: Constants.ConfigFiles.ServiceType.FLEX_INTERNAL,
752 [Constants.BackendServiceType.FLEX_EXTERNAL]: Constants.ConfigFiles.ServiceType.FLEX_EXTERNAL,
753 [Constants.BackendServiceType.REST]: Constants.ConfigFiles.ServiceType.REST,
754 [Constants.BackendServiceType.SP]: Constants.ConfigFiles.ServiceType.SP,
755 [Constants.BackendServiceType.SF]: Constants.ConfigFiles.ServiceType.SF,
756 [Constants.BackendServiceType.SQL]: Constants.ConfigFiles.ServiceType.SQL,
757 [Constants.BackendServiceType.PROGRESS_DATA]: Constants.ConfigFiles.ServiceType.PROGRESS_DATA
758};
759
760Constants.ConfigFiles.ConfigToBackendServiceType = {
761 [Constants.ConfigFiles.ServiceType.FLEX_INTERNAL]: Constants.BackendServiceType.FLEX_INTERNAL,
762 [Constants.ConfigFiles.ServiceType.FLEX_EXTERNAL]: Constants.BackendServiceType.FLEX_EXTERNAL,
763 [Constants.ConfigFiles.ServiceType.REST]: Constants.BackendServiceType.REST,
764 [Constants.ConfigFiles.ServiceType.SP]: Constants.BackendServiceType.SP,
765 [Constants.ConfigFiles.ServiceType.SF]: Constants.BackendServiceType.SF,
766 [Constants.ConfigFiles.ServiceType.SQL]: Constants.BackendServiceType.SQL,
767 [Constants.ConfigFiles.ServiceType.PROGRESS_DATA]: Constants.BackendServiceType.PROGRESS_DATA,
768 [Constants.ConfigFiles.ServiceType.DATA_DIRECT]: Constants.BackendServiceType.REST,
769 [Constants.ConfigFiles.ServiceType.POKIT_DOK]: Constants.BackendServiceType.REST
770};
771
772Constants.ConfigFiles.AllowedCollTypes = [Constants.ConfigFiles.CollType.INTERNAL, Constants.ConfigFiles.CollType.EXTERNAL];
773
774module.exports = Constants;