@erxes/api-shared 3.2.20-2 → 3.2.21-1
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/core-modules/dist/erxes-api-shared-core-modules.cjs.dev.js +1 -1
- package/core-modules/dist/erxes-api-shared-core-modules.cjs.prod.js +1 -1
- package/core-modules/dist/erxes-api-shared-core-modules.esm.js +2 -2
- package/dist/declarations/src/utils/saas/global-profile-v2.d.ts +32 -0
- package/dist/declarations/src/utils/saas/global-profile-v2.d.ts.map +1 -0
- package/dist/declarations/src/utils/saas/index.d.ts +1 -0
- package/dist/declarations/src/utils/saas/index.d.ts.map +1 -1
- package/dist/declarations/src/utils/saas/saas-mongo-connection.d.ts.map +1 -1
- package/dist/declarations/src/utils/saas/types.d.ts +2 -0
- package/dist/declarations/src/utils/saas/types.d.ts.map +1 -1
- package/dist/declarations/src/utils/service-discovery.d.ts.map +1 -1
- package/dist/{start-plugin-89fa2bd2.cjs.dev.js → start-plugin-7dc096bc.cjs.dev.js} +351 -16
- package/dist/{start-plugin-6e76556c.esm.js → start-plugin-a2f6eca9.esm.js} +350 -20
- package/dist/{start-plugin-576e707d.cjs.prod.js → start-plugin-b095acca.cjs.prod.js} +351 -16
- package/package.json +1 -1
- package/src/utils/saas/definition.ts +6 -0
- package/src/utils/saas/global-profile-v2.test.ts +81 -0
- package/src/utils/saas/global-profile-v2.ts +203 -0
- package/src/utils/saas/index.ts +1 -0
- package/src/utils/saas/saas-mongo-connection.ts +19 -1
- package/src/utils/saas/types.ts +3 -0
- package/src/utils/service-discovery.ts +15 -1
- package/utils/dist/erxes-api-shared-utils.cjs.dev.js +6 -1
- package/utils/dist/erxes-api-shared-utils.cjs.prod.js +6 -1
- package/utils/dist/erxes-api-shared-utils.esm.js +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var startPlugin = require('../../dist/start-plugin-
|
|
5
|
+
var startPlugin = require('../../dist/start-plugin-7dc096bc.cjs.dev.js');
|
|
6
6
|
var dayjs = require('dayjs');
|
|
7
7
|
require('node-fetch');
|
|
8
8
|
var nanoid = require('nanoid');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var startPlugin = require('../../dist/start-plugin-
|
|
5
|
+
var startPlugin = require('../../dist/start-plugin-b095acca.cjs.prod.js');
|
|
6
6
|
var dayjs = require('dayjs');
|
|
7
7
|
require('node-fetch');
|
|
8
8
|
var nanoid = require('nanoid');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _asyncToGenerator, a as _regeneratorRuntime, x as _toConsumableArray,
|
|
2
|
-
export {
|
|
1
|
+
import { _ as _asyncToGenerator, a as _regeneratorRuntime, x as _toConsumableArray, c9 as isSameRecordReferenceType, i as _objectSpread2, k as _createForOfIteratorHelper, ca as normalizeRecordReferenceTypes, cb as normalizeRecordReferenceExtensions, b6 as getPlugin, b1 as getPlugins, cc as propertyDataPath, cd as toPropertyRowKey, ce as getLocalRecordReferenceType, cf as getRecordReferencePluginName, cg as _typeof, h as _slicedToArray, ch as resolveRecordReferenceValue, ci as _toArray, cj as AUTOMATION_ERROR_CODES, s as sendWorkerQueue, ap as redis, p as sendTRPCMessage, ck as SEGMENT_MEMBERSHIP_FIELD, cl as parsePropertyDataKey, cm as toPropertyGroupKey, cn as walkSegmentNodes, co as segmentFieldRef, cp as segmentReferenceRef, cq as segmentRelationRef, cr as DEFAULT_SEGMENT_TIME_ZONE, cs as normalizeSegmentOperator, ct as SegmentOperator, cu as PERIOD_OPERATORS, cv as zonedPeriodRange, cw as shiftZonedDays, cx as zonedDate, cy as isAnniversary, cz as _objectWithoutProperties, w as _defineProperty, cA as compileSegmentMongoFilter, g as getEnv, cB as gatherSegmentRelations, bu as escapeRegExp, cC as mergePropertyRowConditions, cD as parsePropertyColumnKey, cE as isPropertyGroupKey, cF as propertyGroupIdFromKey, cG as toPropertyRowColumnKey, cH as PROPERTIES_DATA, cI as logActivityLogError, cJ as matchesFieldPattern$1, cK as findResolver, cL as getSnapshot, cM as detectAssignmentDelta, c2 as ExpectedError, m as _createClass, n as _classCallCheck } from '../../dist/start-plugin-a2f6eca9.esm.js';
|
|
2
|
+
export { fD as APPROVAL_APPROVER_SCOPES, fH as APPROVAL_DECISIONS, fC as APPROVAL_LOCK_STATUSES, fE as APPROVAL_MODES, fJ as APPROVAL_NOTIFICATION_ACTIONS, fI as APPROVAL_NOTIFICATION_CONTENT_TYPE, fG as APPROVAL_REQUEST_KINDS, fF as APPROVAL_REQUEST_STATUSES, dB as AUTOMATION_CORE_ACTIONS, dG as AUTOMATION_CORE_ACTION_DEFERRED, dC as AUTOMATION_CORE_TRIGGER_TYPES, dH as AUTOMATION_DEFERRED_TIMEOUT, dE as AUTOMATION_EMAIL_RECIPIENTS_TYPES, cj as AUTOMATION_ERROR_CODES, dP as AUTOMATION_EXECUTION_STATUS, dF as AUTOMATION_NON_DEFERRABLE_CORE_ACTIONS, dV as AUTOMATION_OUTPUT_ITEM_COUNT, dy as AUTOMATION_PROPERTY_OPERATORS, dA as AUTOMATION_STATUSES, gd as AUTO_MATCH_CONFIDENCE, f2 as ApplyMembershipInput, e6 as AutomationActionInput, e3 as AutomationBaseInput, e4 as AutomationExecActionInput, e5 as AutomationExecutionInput, dJ as BROADCAST_TARGET_TYPE, dI as BROADCAST_TRIGGER_TYPE, g4 as BatchSkipRowInput, d1 as COMPANY_BUSINESS_TYPES, d3 as COMPANY_INDUSTRY_TYPES, dd as CUSTOMER_SELECT_OPTIONS, eg as CheckCustomTriggerInput, e9 as CheckCustomTriggerInputData, f1 as CountSegmentMembersInput, d2 as DEFAULT_COMPANY_INDUSTRY_TYPES, d8 as DEFAULT_CONSTANT_VALUES, cr as DEFAULT_SEGMENT_TIME_ZONE, eR as DEFAULT_SEGMENT_VALUE_FIELD, d6 as DEFAULT_SEX_CHOICES, d4 as DEFAULT_SOCIAL_LINKS, fm as EMAIL_LANES, fp as EMAIL_RAMP_ID, dL as EXECUTE_WAIT_TYPES, e$ as EvaluateFieldsInput, eh as FindObjectInput, ea as FindObjectInputData, ek as GenerateAiContextInput, ed as GenerateAiContextInputData, g5 as GetExportDataInput, g3 as GetExportHeadersInput, g7 as GetImportHeadersInput, g8 as GetImportHeadersOutput, dg as INPUT_TYPE, g2 as InsertImportRowsInput, f$ as InsertImportRowsInputSchema, g6 as InsertImportRowsOutput, f0 as ListSegmentMembersInput, el as LoadAiKnowledgeDocumentBatchInput, ee as LoadAiKnowledgeDocumentBatchInputData, em as LookupAiToolInput, ef as LookupAiToolInputData, cu as PERIOD_OPERATORS, cH as PROPERTIES_DATA, f5 as PROPERTY_ANY_ROW_KEY_SEP, f3 as PROPERTY_GROUP_KEY_PREFIX, fa as PROPERTY_ROW_INDEX_SEP, f4 as PROPERTY_ROW_KEY_SEP, fd as PropertyValueUsageInput, e8 as ReceiveActionsInput, e7 as ReceiveActionsInputData, ei as ResolveOutputPathsInput, eb as ResolveOutputPathsInputData, eu as SEGMENT_BOOLEAN_OPERATORS, et as SEGMENT_DATE_OPERATORS, er as SEGMENT_ID_OPERATORS, eW as SEGMENT_IMPLICIT_OPERATORS, ck as SEGMENT_MEMBERSHIP_FIELD, es as SEGMENT_NUMBER_OPERATORS, eV as SEGMENT_OPERATOR_SPECS, ez as SEGMENT_QUEUES, eq as SEGMENT_TEXT_OPERATORS, d7 as SEX_OPTIONS, d5 as SOCIAL_LINKS, dz as STATIC_PLACEHOLDER, d0 as STATUSES, db as STRUCTURE_STATUSES, ge as SUGGEST_CONFIDENCE, e_ as SegmentBaseInput, ev as SegmentField, eZ as SegmentNodeSchema, ct as SegmentOperator, ej as SetPropertiesInput, ec as SetPropertiesInputData, fK as TApprovalChangeProducers, dN as TAutomationActionFolks, dD as TAutomationFindObjectType, dM as TAutomationProducers, g0 as TImportExportProducers, fc as TPropertyProducers, eY as TSegmentProducers, ff as UNKNOWN_VALUE_COUNTS, fe as UNKNOWN_VALUE_SAMPLES, df as USER_EXPORT_EXTENDED_FIELDS, de as USER_EXTENDED_FIELDS, dc as USER_MOVEMENT_STATUSES, da as USER_PROPERTIES_INFO, d9 as USER_ROLES, fY as USER_TYPES, fl as activityLogsSchema, dR as aiAgentSchema, eN as anniversaryRanges, dp as appSchema, fP as approvalChangeApplyInputSchema, fx as approvalChangePluginName, fL as approvalLockCheckInputSchema, fN as approvalLockCreateInputSchema, fM as approvalLockStatesInputSchema, fO as approvalRequestCreateInputSchema, dj as attachmentSchema, dQ as automationExecutionSchema, dO as automationSchema, e2 as buildRuntimeOutputsIndex, dq as buildSetPropertyModifier, cV as canGroup, cR as checkLogin, cY as checkPermissionGroup, cU as clearGroupActionsCache, fQ as clientPortalSchema, eP as collectSegmentReferences, eO as collectSegmentValueRefs, fZ as commentSchema, cA as compileSegmentMongoFilter, gi as countCsvDataRows, fR as cpNotificationConfigUserSchema, f_ as cpNotificationSchema, fT as cpNotificationSettingsSchema, fS as cpTwoFactor, fX as cpUserSchema, dl as createEventHandlers, f as createScopedEventHandlers, dh as customFieldSchema, cM as detectAssignmentDelta, fn as emailAddressSchema, fo as emailDeliverySchema, fq as emailRampSchema, fr as emailSenderSchema, fW as fcmDeviceSchema, f7 as fieldIdFromPropertyDataPath, cK as findResolver, eH as gatherSegmentEventTypes, eJ as gatherSegmentFieldSources, eK as gatherSegmentJoinPaths, eI as gatherSegmentRecordTypes, cB as gatherSegmentRelations, dn as generateEventHandlersFromRequest, d$ as getAutomationNodeType, dt as getContentType, cT as getGroupActionsMap, g9 as getImportExportJobOptions, du as getModuleName, dv as getPluginName, dr as getSetPropertySelector, cL as getSnapshot, dK as getTriggerTargetType, dU as getValueByPath, cW as hasDeclaredOAuthScopes, eQ as hasSegmentReferenceInRelation, fB as initApproval, fb as initPropertyProducers, dk as initRecordReferences, eX as initSegmentProducers, cy as isAnniversary, eM as isLeapYear, f6 as isPropertyDataPath, cE as isPropertyGroupKey, dW as isReEnrollableTrigger, dX as isReEnrollingTrigger, fz as localApprovalChangeType, cI as logActivityLogError, gb as logImportExportEvent, fk as logsSchema, dT as matchAutomationResolverKey, gg as matchImportHeaders, cJ as matchesFieldPattern, fi as measurePropertyValueCounts, fh as measurePropertyValueSamples, fj as measurePropertyValueUsage, cC as mergePropertyRowConditions, fy as normalizeApprovalChangeType, fA as normalizeApprovalConfig, e1 as normalizeAutomationConstantsForTransport, gf as normalizeHeader, cs as normalizeSegmentOperator, fs as notificationSchema, ft as notificationSettingsSchema, fu as notificationZTypeSchema, cD as parsePropertyColumnKey, cl as parsePropertyDataKey, cN as permissionGroupSchema, cP as permissionSchema, gh as processCSVStream, f8 as propertyDataExistsFilter, cc as propertyDataPath, f9 as propertyDataRegexFilter, cF as propertyGroupIdFromKey, fU as refreshTokenSchema, d_ as replaceOutputPlaceholders, cX as resolveActionOAuthScopes, dY as resolveAutomationActionInputs, dS as resolveFromSourceField, dZ as resolveOutputPathsByNodeType, ch as resolveRecordReferenceValue, eT as resolveSegmentFieldDependencies, eS as resolveSegmentFieldOperators, eU as resolveSegmentValueField, cQ as roleSchema, di as ruleSchema, gc as safeCleanup, eB as scheduleSegmentReconcile, ex as segmentDependencies, ew as segmentDependencyKey, ey as segmentDependsOnClock, co as segmentFieldRef, eG as segmentJoinChanges, eA as segmentQueueFor, cp as segmentReferenceRef, cq as segmentRelationRef, ep as sendAutomationDeferredCompletion, eo as sendAutomationRun, en as sendAutomationTrigger, fv as sendNotification, fw as sendNotificationChannels, eC as sendSegmentChanged, eF as sendSegmentForget, eE as sendSegmentRebuild, eD as sendSegmentReconcile, dm as setEventHandlerRuntimeContext, ds as setProperty, cw as shiftZonedDays, fV as socialAuthProviderSchema, dw as splitType, dx as startAutomations, g1 as startImportExportWorker, cm as toPropertyGroupKey, cG as toPropertyRowColumnKey, cd as toPropertyRowKey, ga as toTerminalImportExportError, e0 as toTransportOutput, fg as unknownValueUsage, cO as userGroupSchema, c$ as userMovemmentSchema, c_ as userSchema, cn as walkSegmentNodes, cS as wrapPermission, cZ as wrapPublicResolver, cx as zonedDate, eL as zonedDayStart, cv as zonedPeriodRange } from '../../dist/start-plugin-a2f6eca9.esm.js';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import 'node-fetch';
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IOrganization } from "./types.js";
|
|
2
|
+
export declare const GP_STATUS: {
|
|
3
|
+
readonly OLD: "old";
|
|
4
|
+
readonly NEW: "new";
|
|
5
|
+
};
|
|
6
|
+
export declare const isGlobalProfileV2: (organization?: Partial<IOrganization> | null) => boolean;
|
|
7
|
+
type StripeMetadata = Record<string, string | undefined>;
|
|
8
|
+
type StripeItem = {
|
|
9
|
+
quantity?: number;
|
|
10
|
+
metadata?: StripeMetadata;
|
|
11
|
+
price?: {
|
|
12
|
+
metadata?: StripeMetadata;
|
|
13
|
+
product?: string | {
|
|
14
|
+
metadata?: StripeMetadata;
|
|
15
|
+
deleted?: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type StripeSubscription = {
|
|
20
|
+
status: string;
|
|
21
|
+
items?: {
|
|
22
|
+
data: StripeItem[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** Plugin codes one subscription item grants right now. */
|
|
26
|
+
export declare const pluginsOfStripeItem: (item: StripeItem, nowSeconds?: number) => string[];
|
|
27
|
+
/** Plugin codes granted by a customer's free list and live subscriptions. */
|
|
28
|
+
export declare const pluginsFromStripe: (freePlugins: string | undefined, subscriptions: StripeSubscription[], nowSeconds?: number) => string[];
|
|
29
|
+
/** Plugin codes a v2 organization may use. Cached for a minute per organization. */
|
|
30
|
+
export declare const getGlobalProfileV2Plugins: (organization: Partial<IOrganization>) => Promise<string[]>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=global-profile-v2.d.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
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/utils/saas","sources":["index.ts"],"names":[],"mappings":"AAAA,2CAAwC;AACxC,2BAAwB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../../../src/utils/saas","sources":["index.ts"],"names":[],"mappings":"AAAA,2CAAwC;AACxC,2BAAwB;AACxB,uCAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saas-mongo-connection.d.ts","sourceRoot":"../../../../../src/utils/saas","sources":["saas-mongo-connection.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAchC,OAAO,EACL,aAAa,EACb,UAAU,EAEV,qBAAqB,EACrB,4BAA4B,EAC7B,mBAAgB;AAIjB,eAAO,IAAI,sBAAsB,EAAE,GAAG,CAAC;AACvC,eAAO,IAAI,eAAe,EAAE,GAAG,CAAC;AAChC,eAAO,IAAI,gBAAgB,EAAE,GAAG,CAAC;AACjC,eAAO,IAAI,sBAAsB,EAAE,GAAG,CAAC;AACvC,eAAO,IAAI,cAAc,EAAE,GAAG,CAAC;AAC/B,eAAO,IAAI,kBAAkB,EAAE,GAAG,CAAC;AACnC,eAAO,IAAI,mBAAmB,EAAE,GAAG,CAAC;AACpC,eAAO,IAAI,gBAAgB,EAAE,GAAG,CAAC;AACjC,eAAO,IAAI,oBAAoB,EAAE,GAAG,CAAC;AACrC,eAAO,IAAI,kCAAkC,EAAE,QAAQ,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;AAE5F,eAAO,MAAM,qBAAqB,QAAa,OAAO,CAAC,IAAI,CA+C1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAO,CAAC;AAErE,eAAO,MAAM,gCAAgC,GAC3C,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,CAgBhB,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,2CAIpC;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AC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,4BAA4B;IAC3C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-discovery.d.ts","sourceRoot":"../../../../src/utils","sources":["service-discovery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service-discovery.d.ts","sourceRoot":"../../../../src/utils","sources":["service-discovery.ts"],"names":[],"mappings":"AAgBA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,eAAO,MAAM,KAAK,SAA6B,CAAC;AAEhD,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,WAAkC,CAAC;AAE5E,eAAO,MAAM,UAAU,QAAa,OAAO,CAAC,MAAM,EAAE,CAUnD,CAAC;AAIF,eAAO,MAAM,gBAAgB,GAAU,SAAS,MAAM,EAAE,KAAG,OAAO,CAAC,IAAI,CAEtE,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,MAAM,EAAE,CAQzD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,EAAE,CA4ClB,CAAC;AAEF,KAAK,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC;AAIpD,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,SAWvD,CAAC;AAEF,eAAO,MAAM,SAAS,GACpB,MAAM,MAAM,KACX,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAiB/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,yCAKpC,YAAY,kBAuEd,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,kBAEjE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAU,MAAM,MAAM,qBAM3C,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,MAAM,MAAM,iBAKlD,CAAC;AAcF,eAAO,MAAM,sBAAsB,GAAU,OAAO,SAAS,MAAM,EACjE,YAAY,MAAM,EAClB,cAAc,MAAM,EACpB,QAAQ,OAAO,kBAgBhB,CAAC"}
|
|
@@ -18,7 +18,7 @@ var rateLimit = require('express-rate-limit');
|
|
|
18
18
|
var graphql = require('graphql');
|
|
19
19
|
var language = require('graphql/language');
|
|
20
20
|
var dayjs = require('dayjs');
|
|
21
|
-
var fetch = require('node-fetch');
|
|
21
|
+
var fetch$1 = require('node-fetch');
|
|
22
22
|
var nanoid = require('nanoid');
|
|
23
23
|
var Redis = require('ioredis');
|
|
24
24
|
var _loadash = require('lodash');
|
|
@@ -73,7 +73,7 @@ var http__namespace = /*#__PURE__*/_interopNamespace(http);
|
|
|
73
73
|
var path__namespace = /*#__PURE__*/_interopNamespace(path);
|
|
74
74
|
var rateLimit__default = /*#__PURE__*/_interopDefault(rateLimit);
|
|
75
75
|
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
76
|
-
var fetch__default = /*#__PURE__*/_interopDefault(fetch);
|
|
76
|
+
var fetch__default = /*#__PURE__*/_interopDefault(fetch$1);
|
|
77
77
|
var Redis__default = /*#__PURE__*/_interopDefault(Redis);
|
|
78
78
|
var _loadash__namespace = /*#__PURE__*/_interopNamespace(_loadash);
|
|
79
79
|
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
@@ -1892,6 +1892,15 @@ var saasOrganizationsSchema = new mongoose__default["default"].Schema({
|
|
|
1892
1892
|
cycleEnabled: {
|
|
1893
1893
|
type: Boolean
|
|
1894
1894
|
},
|
|
1895
|
+
// Which global profile owns the organization. Missing or 'old': the original
|
|
1896
|
+
// erxes.io profile, billed through `charge`. 'new': dashboard.erxes.io, whose
|
|
1897
|
+
// plugins come from the Stripe customer below (see global-profile-v2.ts).
|
|
1898
|
+
gpStatus: {
|
|
1899
|
+
type: String
|
|
1900
|
+
},
|
|
1901
|
+
gpStripeCustomerId: {
|
|
1902
|
+
type: String
|
|
1903
|
+
},
|
|
1895
1904
|
// Kept apart from `domain` / `dnsStatus`, which drive the white-label app
|
|
1896
1905
|
// domain, so a help center hostname never changes how the app sets cookies.
|
|
1897
1906
|
helpCenterDomain: {
|
|
@@ -3173,7 +3182,7 @@ var getSaasOrganizationIdBySubdomain = /*#__PURE__*/function () {
|
|
|
3173
3182
|
}();
|
|
3174
3183
|
var getSaasOrgsCache = /*#__PURE__*/function () {
|
|
3175
3184
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
|
|
3176
|
-
var subdomain, excludeSubdomains, domain, value, organizations;
|
|
3185
|
+
var subdomain, excludeSubdomains, domain, value, organizations, cached, organization;
|
|
3177
3186
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
3178
3187
|
while (1) switch (_context3.prev = _context3.next) {
|
|
3179
3188
|
case 0:
|
|
@@ -3194,31 +3203,54 @@ var getSaasOrgsCache = /*#__PURE__*/function () {
|
|
|
3194
3203
|
redis.set('core_organizations', JSON.stringify(organizations));
|
|
3195
3204
|
case 10:
|
|
3196
3205
|
if (!subdomain) {
|
|
3197
|
-
_context3.next =
|
|
3206
|
+
_context3.next = 23;
|
|
3198
3207
|
break;
|
|
3199
3208
|
}
|
|
3200
|
-
|
|
3209
|
+
cached = organizations.find(function (org) {
|
|
3201
3210
|
return org.subdomain === subdomain;
|
|
3202
|
-
})
|
|
3203
|
-
|
|
3204
|
-
if (!excludeSubdomains) {
|
|
3211
|
+
});
|
|
3212
|
+
if (!cached) {
|
|
3205
3213
|
_context3.next = 14;
|
|
3206
3214
|
break;
|
|
3207
3215
|
}
|
|
3216
|
+
return _context3.abrupt("return", cached);
|
|
3217
|
+
case 14:
|
|
3218
|
+
_context3.next = 16;
|
|
3219
|
+
return getSaasCoreConnection();
|
|
3220
|
+
case 16:
|
|
3221
|
+
_context3.next = 18;
|
|
3222
|
+
return exports.coreModelOrganizations.findOne({
|
|
3223
|
+
subdomain: subdomain
|
|
3224
|
+
}).lean();
|
|
3225
|
+
case 18:
|
|
3226
|
+
organization = _context3.sent;
|
|
3227
|
+
if (!organization) {
|
|
3228
|
+
_context3.next = 22;
|
|
3229
|
+
break;
|
|
3230
|
+
}
|
|
3231
|
+
_context3.next = 22;
|
|
3232
|
+
return redis.set('core_organizations', '');
|
|
3233
|
+
case 22:
|
|
3234
|
+
return _context3.abrupt("return", organization || undefined);
|
|
3235
|
+
case 23:
|
|
3236
|
+
if (!excludeSubdomains) {
|
|
3237
|
+
_context3.next = 25;
|
|
3238
|
+
break;
|
|
3239
|
+
}
|
|
3208
3240
|
return _context3.abrupt("return", organizations.filter(function (org) {
|
|
3209
3241
|
return !excludeSubdomains.includes(org.subdomain);
|
|
3210
3242
|
}));
|
|
3211
|
-
case
|
|
3243
|
+
case 25:
|
|
3212
3244
|
if (!domain) {
|
|
3213
|
-
_context3.next =
|
|
3245
|
+
_context3.next = 27;
|
|
3214
3246
|
break;
|
|
3215
3247
|
}
|
|
3216
3248
|
return _context3.abrupt("return", organizations.find(function (org) {
|
|
3217
3249
|
return org.domain === domain;
|
|
3218
3250
|
}));
|
|
3219
|
-
case
|
|
3251
|
+
case 27:
|
|
3220
3252
|
return _context3.abrupt("return", organizations);
|
|
3221
|
-
case
|
|
3253
|
+
case 28:
|
|
3222
3254
|
case "end":
|
|
3223
3255
|
return _context3.stop();
|
|
3224
3256
|
}
|
|
@@ -4076,6 +4108,291 @@ var getSaasOrgPromoCodes = /*#__PURE__*/function () {
|
|
|
4076
4108
|
};
|
|
4077
4109
|
}();
|
|
4078
4110
|
|
|
4111
|
+
/*
|
|
4112
|
+
* Organizations created on dashboard.erxes.io (the v2 global profile) carry
|
|
4113
|
+
* gpStatus 'new'. Their plugins come from Stripe, not from `charge`:
|
|
4114
|
+
* - every item on the organization's subscriptions while it is active, trialing
|
|
4115
|
+
* or past due. A removed item drops to quantity 0 but stays until the period
|
|
4116
|
+
* ends; the v2 profile stamps that date on the item as `ends_at` metadata.
|
|
4117
|
+
* - every plugin inside a bundle item (`plugins` in the price metadata).
|
|
4118
|
+
* - plugins the organization has without a Stripe item (free plans, always-free
|
|
4119
|
+
* plugins, admin gifts), kept in the customer's `free_plugins` metadata.
|
|
4120
|
+
* Organizations without gpStatus, or with 'old', are untouched.
|
|
4121
|
+
*/
|
|
4122
|
+
|
|
4123
|
+
var GP_STATUS = {
|
|
4124
|
+
OLD: 'old',
|
|
4125
|
+
NEW: 'new'
|
|
4126
|
+
};
|
|
4127
|
+
var isGlobalProfileV2 = function isGlobalProfileV2(organization) {
|
|
4128
|
+
return (organization === null || organization === void 0 ? void 0 : organization.gpStatus) === GP_STATUS.NEW;
|
|
4129
|
+
};
|
|
4130
|
+
var STRIPE_API = 'https://api.stripe.com/v1';
|
|
4131
|
+
var LIVE_STATUSES = ['active', 'trialing', 'past_due'];
|
|
4132
|
+
var FRESH_SECONDS = 60;
|
|
4133
|
+
// Served when Stripe can't be reached, so a short outage doesn't empty workspaces.
|
|
4134
|
+
var STALE_SECONDS = 24 * 60 * 60;
|
|
4135
|
+
var list = function list(value) {
|
|
4136
|
+
return (value || '').split(',').map(function (code) {
|
|
4137
|
+
return code.trim();
|
|
4138
|
+
}).filter(Boolean);
|
|
4139
|
+
};
|
|
4140
|
+
var stripeGet = /*#__PURE__*/function () {
|
|
4141
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(path) {
|
|
4142
|
+
var key, response;
|
|
4143
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4144
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4145
|
+
case 0:
|
|
4146
|
+
key = getEnv({
|
|
4147
|
+
name: 'GP2_STRIPE_SECRET_KEY'
|
|
4148
|
+
});
|
|
4149
|
+
if (key) {
|
|
4150
|
+
_context.next = 3;
|
|
4151
|
+
break;
|
|
4152
|
+
}
|
|
4153
|
+
throw new Error('GP2_STRIPE_SECRET_KEY is not configured');
|
|
4154
|
+
case 3:
|
|
4155
|
+
_context.next = 5;
|
|
4156
|
+
return fetch("".concat(STRIPE_API).concat(path), {
|
|
4157
|
+
headers: {
|
|
4158
|
+
Authorization: "Bearer ".concat(key)
|
|
4159
|
+
},
|
|
4160
|
+
signal: AbortSignal.timeout(8000)
|
|
4161
|
+
});
|
|
4162
|
+
case 5:
|
|
4163
|
+
response = _context.sent;
|
|
4164
|
+
if (response.ok) {
|
|
4165
|
+
_context.next = 8;
|
|
4166
|
+
break;
|
|
4167
|
+
}
|
|
4168
|
+
throw new Error("Stripe ".concat(path.split('?')[0], ": ").concat(response.status));
|
|
4169
|
+
case 8:
|
|
4170
|
+
return _context.abrupt("return", response.json());
|
|
4171
|
+
case 9:
|
|
4172
|
+
case "end":
|
|
4173
|
+
return _context.stop();
|
|
4174
|
+
}
|
|
4175
|
+
}, _callee);
|
|
4176
|
+
}));
|
|
4177
|
+
return function stripeGet(_x) {
|
|
4178
|
+
return _ref.apply(this, arguments);
|
|
4179
|
+
};
|
|
4180
|
+
}();
|
|
4181
|
+
|
|
4182
|
+
/** Plugin codes one subscription item grants right now. */
|
|
4183
|
+
var pluginsOfStripeItem = function pluginsOfStripeItem(item) {
|
|
4184
|
+
var _item$metadata, _item$quantity, _item$price, _item$price2;
|
|
4185
|
+
var nowSeconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now() / 1000;
|
|
4186
|
+
var endsAt = Number(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.ends_at) || 0);
|
|
4187
|
+
var entitled = ((_item$quantity = item.quantity) !== null && _item$quantity !== void 0 ? _item$quantity : 0) > 0 || endsAt > nowSeconds;
|
|
4188
|
+
if (!entitled) {
|
|
4189
|
+
return [];
|
|
4190
|
+
}
|
|
4191
|
+
var product = _typeof((_item$price = item.price) === null || _item$price === void 0 ? void 0 : _item$price.product) === 'object' ? item.price.product : undefined;
|
|
4192
|
+
var metadata = _objectSpread2(_objectSpread2({}, (product === null || product === void 0 ? void 0 : product.metadata) || {}), ((_item$price2 = item.price) === null || _item$price2 === void 0 ? void 0 : _item$price2.metadata) || {});
|
|
4193
|
+
if (metadata.kind === 'bundle') {
|
|
4194
|
+
return list(metadata.plugins);
|
|
4195
|
+
}
|
|
4196
|
+
return metadata.plugin_code ? [metadata.plugin_code] : [];
|
|
4197
|
+
};
|
|
4198
|
+
|
|
4199
|
+
/** Plugin codes granted by a customer's free list and live subscriptions. */
|
|
4200
|
+
var pluginsFromStripe = function pluginsFromStripe(freePlugins, subscriptions) {
|
|
4201
|
+
var nowSeconds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Date.now() / 1000;
|
|
4202
|
+
var plugins = new Set(list(freePlugins));
|
|
4203
|
+
var _iterator = _createForOfIteratorHelper(subscriptions),
|
|
4204
|
+
_step;
|
|
4205
|
+
try {
|
|
4206
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4207
|
+
var _subscription$items;
|
|
4208
|
+
var subscription = _step.value;
|
|
4209
|
+
if (!LIVE_STATUSES.includes(subscription.status)) {
|
|
4210
|
+
continue;
|
|
4211
|
+
}
|
|
4212
|
+
var _iterator2 = _createForOfIteratorHelper(((_subscription$items = subscription.items) === null || _subscription$items === void 0 ? void 0 : _subscription$items.data) || []),
|
|
4213
|
+
_step2;
|
|
4214
|
+
try {
|
|
4215
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4216
|
+
var item = _step2.value;
|
|
4217
|
+
pluginsOfStripeItem(item, nowSeconds).forEach(function (code) {
|
|
4218
|
+
return plugins.add(code);
|
|
4219
|
+
});
|
|
4220
|
+
}
|
|
4221
|
+
} catch (err) {
|
|
4222
|
+
_iterator2.e(err);
|
|
4223
|
+
} finally {
|
|
4224
|
+
_iterator2.f();
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
} catch (err) {
|
|
4228
|
+
_iterator.e(err);
|
|
4229
|
+
} finally {
|
|
4230
|
+
_iterator.f();
|
|
4231
|
+
}
|
|
4232
|
+
return _toConsumableArray(plugins);
|
|
4233
|
+
};
|
|
4234
|
+
var fetchPlugins = /*#__PURE__*/function () {
|
|
4235
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(customerId) {
|
|
4236
|
+
var _customer$metadata;
|
|
4237
|
+
var customer, subscriptions, products, _iterator3, _step3, _subscription$items2, subscription, _iterator4, _step4, _price$metadata, item, price, product;
|
|
4238
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4239
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4240
|
+
case 0:
|
|
4241
|
+
_context2.next = 2;
|
|
4242
|
+
return stripeGet("/customers/".concat(encodeURIComponent(customerId)));
|
|
4243
|
+
case 2:
|
|
4244
|
+
customer = _context2.sent;
|
|
4245
|
+
if (!customer.deleted) {
|
|
4246
|
+
_context2.next = 5;
|
|
4247
|
+
break;
|
|
4248
|
+
}
|
|
4249
|
+
return _context2.abrupt("return", []);
|
|
4250
|
+
case 5:
|
|
4251
|
+
_context2.next = 7;
|
|
4252
|
+
return stripeGet("/subscriptions?customer=".concat(encodeURIComponent(customerId), "&status=all&limit=100"));
|
|
4253
|
+
case 7:
|
|
4254
|
+
subscriptions = _context2.sent;
|
|
4255
|
+
products = new Map();
|
|
4256
|
+
_iterator3 = _createForOfIteratorHelper(subscriptions.data);
|
|
4257
|
+
_context2.prev = 10;
|
|
4258
|
+
_iterator3.s();
|
|
4259
|
+
case 12:
|
|
4260
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
4261
|
+
_context2.next = 42;
|
|
4262
|
+
break;
|
|
4263
|
+
}
|
|
4264
|
+
subscription = _step3.value;
|
|
4265
|
+
_iterator4 = _createForOfIteratorHelper(((_subscription$items2 = subscription.items) === null || _subscription$items2 === void 0 ? void 0 : _subscription$items2.data) || []);
|
|
4266
|
+
_context2.prev = 15;
|
|
4267
|
+
_iterator4.s();
|
|
4268
|
+
case 17:
|
|
4269
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
4270
|
+
_context2.next = 32;
|
|
4271
|
+
break;
|
|
4272
|
+
}
|
|
4273
|
+
item = _step4.value;
|
|
4274
|
+
price = item.price;
|
|
4275
|
+
product = price === null || price === void 0 ? void 0 : price.product;
|
|
4276
|
+
if (!(price && !((_price$metadata = price.metadata) !== null && _price$metadata !== void 0 && _price$metadata.kind) && typeof product === 'string')) {
|
|
4277
|
+
_context2.next = 30;
|
|
4278
|
+
break;
|
|
4279
|
+
}
|
|
4280
|
+
if (products.has(product)) {
|
|
4281
|
+
_context2.next = 29;
|
|
4282
|
+
break;
|
|
4283
|
+
}
|
|
4284
|
+
_context2.t0 = products;
|
|
4285
|
+
_context2.t1 = product;
|
|
4286
|
+
_context2.next = 27;
|
|
4287
|
+
return stripeGet("/products/".concat(encodeURIComponent(product)));
|
|
4288
|
+
case 27:
|
|
4289
|
+
_context2.t2 = _context2.sent;
|
|
4290
|
+
_context2.t0.set.call(_context2.t0, _context2.t1, _context2.t2);
|
|
4291
|
+
case 29:
|
|
4292
|
+
price.product = products.get(product);
|
|
4293
|
+
case 30:
|
|
4294
|
+
_context2.next = 17;
|
|
4295
|
+
break;
|
|
4296
|
+
case 32:
|
|
4297
|
+
_context2.next = 37;
|
|
4298
|
+
break;
|
|
4299
|
+
case 34:
|
|
4300
|
+
_context2.prev = 34;
|
|
4301
|
+
_context2.t3 = _context2["catch"](15);
|
|
4302
|
+
_iterator4.e(_context2.t3);
|
|
4303
|
+
case 37:
|
|
4304
|
+
_context2.prev = 37;
|
|
4305
|
+
_iterator4.f();
|
|
4306
|
+
return _context2.finish(37);
|
|
4307
|
+
case 40:
|
|
4308
|
+
_context2.next = 12;
|
|
4309
|
+
break;
|
|
4310
|
+
case 42:
|
|
4311
|
+
_context2.next = 47;
|
|
4312
|
+
break;
|
|
4313
|
+
case 44:
|
|
4314
|
+
_context2.prev = 44;
|
|
4315
|
+
_context2.t4 = _context2["catch"](10);
|
|
4316
|
+
_iterator3.e(_context2.t4);
|
|
4317
|
+
case 47:
|
|
4318
|
+
_context2.prev = 47;
|
|
4319
|
+
_iterator3.f();
|
|
4320
|
+
return _context2.finish(47);
|
|
4321
|
+
case 50:
|
|
4322
|
+
return _context2.abrupt("return", pluginsFromStripe((_customer$metadata = customer.metadata) === null || _customer$metadata === void 0 ? void 0 : _customer$metadata.free_plugins, subscriptions.data));
|
|
4323
|
+
case 51:
|
|
4324
|
+
case "end":
|
|
4325
|
+
return _context2.stop();
|
|
4326
|
+
}
|
|
4327
|
+
}, _callee2, null, [[10, 44, 47, 50], [15, 34, 37, 40]]);
|
|
4328
|
+
}));
|
|
4329
|
+
return function fetchPlugins(_x2) {
|
|
4330
|
+
return _ref2.apply(this, arguments);
|
|
4331
|
+
};
|
|
4332
|
+
}();
|
|
4333
|
+
|
|
4334
|
+
/** Plugin codes a v2 organization may use. Cached for a minute per organization. */
|
|
4335
|
+
var getGlobalProfileV2Plugins = /*#__PURE__*/function () {
|
|
4336
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(organization) {
|
|
4337
|
+
var customerId, freshKey, staleKey, cached, plugins, value, stale;
|
|
4338
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4339
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4340
|
+
case 0:
|
|
4341
|
+
customerId = organization.gpStripeCustomerId;
|
|
4342
|
+
if (customerId) {
|
|
4343
|
+
_context3.next = 3;
|
|
4344
|
+
break;
|
|
4345
|
+
}
|
|
4346
|
+
return _context3.abrupt("return", []);
|
|
4347
|
+
case 3:
|
|
4348
|
+
freshKey = "gp2_plugins:".concat(customerId);
|
|
4349
|
+
staleKey = "gp2_plugins_stale:".concat(customerId);
|
|
4350
|
+
_context3.next = 7;
|
|
4351
|
+
return redis.get(freshKey)["catch"](function () {
|
|
4352
|
+
return null;
|
|
4353
|
+
});
|
|
4354
|
+
case 7:
|
|
4355
|
+
cached = _context3.sent;
|
|
4356
|
+
if (!cached) {
|
|
4357
|
+
_context3.next = 10;
|
|
4358
|
+
break;
|
|
4359
|
+
}
|
|
4360
|
+
return _context3.abrupt("return", JSON.parse(cached));
|
|
4361
|
+
case 10:
|
|
4362
|
+
_context3.prev = 10;
|
|
4363
|
+
_context3.next = 13;
|
|
4364
|
+
return fetchPlugins(customerId);
|
|
4365
|
+
case 13:
|
|
4366
|
+
plugins = _context3.sent;
|
|
4367
|
+
value = JSON.stringify(plugins);
|
|
4368
|
+
_context3.next = 17;
|
|
4369
|
+
return Promise.all([redis.set(freshKey, value, 'EX', FRESH_SECONDS), redis.set(staleKey, value, 'EX', STALE_SECONDS)])["catch"](function () {
|
|
4370
|
+
return undefined;
|
|
4371
|
+
});
|
|
4372
|
+
case 17:
|
|
4373
|
+
return _context3.abrupt("return", plugins);
|
|
4374
|
+
case 20:
|
|
4375
|
+
_context3.prev = 20;
|
|
4376
|
+
_context3.t0 = _context3["catch"](10);
|
|
4377
|
+
console.error("[gp2] plugins for ".concat(organization.subdomain, ": ").concat(_context3.t0.message));
|
|
4378
|
+
_context3.next = 25;
|
|
4379
|
+
return redis.get(staleKey)["catch"](function () {
|
|
4380
|
+
return null;
|
|
4381
|
+
});
|
|
4382
|
+
case 25:
|
|
4383
|
+
stale = _context3.sent;
|
|
4384
|
+
return _context3.abrupt("return", stale ? JSON.parse(stale) : []);
|
|
4385
|
+
case 27:
|
|
4386
|
+
case "end":
|
|
4387
|
+
return _context3.stop();
|
|
4388
|
+
}
|
|
4389
|
+
}, _callee3, null, [[10, 20]]);
|
|
4390
|
+
}));
|
|
4391
|
+
return function getGlobalProfileV2Plugins(_x3) {
|
|
4392
|
+
return _ref3.apply(this, arguments);
|
|
4393
|
+
};
|
|
4394
|
+
}();
|
|
4395
|
+
|
|
4079
4396
|
dotenv__namespace.config();
|
|
4080
4397
|
var _process$env$1 = process.env,
|
|
4081
4398
|
NODE_ENV = _process$env$1.NODE_ENV,
|
|
@@ -4157,7 +4474,7 @@ var getActivePlugins = /*#__PURE__*/function () {
|
|
|
4157
4474
|
}();
|
|
4158
4475
|
var getAvailablePlugins = /*#__PURE__*/function () {
|
|
4159
4476
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(subdomain) {
|
|
4160
|
-
var ENABLED_PLUGINS, ENABLED_API_PLUGINS, VERSION, organizationInfo, charges, plugins;
|
|
4477
|
+
var ENABLED_PLUGINS, ENABLED_API_PLUGINS, VERSION, organizationInfo, enabled, _plugins, charges, plugins;
|
|
4161
4478
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4162
4479
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4163
4480
|
case 0:
|
|
@@ -4172,7 +4489,7 @@ var getAvailablePlugins = /*#__PURE__*/function () {
|
|
|
4172
4489
|
defaultValue: 'os'
|
|
4173
4490
|
});
|
|
4174
4491
|
if (!(VERSION && VERSION === 'saas')) {
|
|
4175
|
-
_context4.next =
|
|
4492
|
+
_context4.next = 19;
|
|
4176
4493
|
break;
|
|
4177
4494
|
}
|
|
4178
4495
|
_context4.next = 6;
|
|
@@ -4181,6 +4498,19 @@ var getAvailablePlugins = /*#__PURE__*/function () {
|
|
|
4181
4498
|
});
|
|
4182
4499
|
case 6:
|
|
4183
4500
|
organizationInfo = _context4.sent;
|
|
4501
|
+
if (!isGlobalProfileV2(organizationInfo)) {
|
|
4502
|
+
_context4.next = 13;
|
|
4503
|
+
break;
|
|
4504
|
+
}
|
|
4505
|
+
enabled = [].concat(_toConsumableArray(ENABLED_PLUGINS.split(',')), _toConsumableArray(ENABLED_API_PLUGINS.split(',')));
|
|
4506
|
+
_context4.next = 11;
|
|
4507
|
+
return getGlobalProfileV2Plugins(organizationInfo);
|
|
4508
|
+
case 11:
|
|
4509
|
+
_plugins = _context4.sent;
|
|
4510
|
+
return _context4.abrupt("return", ['core'].concat(_toConsumableArray(_plugins.filter(function (plugin) {
|
|
4511
|
+
return enabled.includes(plugin);
|
|
4512
|
+
}))));
|
|
4513
|
+
case 13:
|
|
4184
4514
|
charges = organizationInfo.charge;
|
|
4185
4515
|
plugins = [];
|
|
4186
4516
|
Object.keys(charges).forEach(function (key) {
|
|
@@ -4194,9 +4524,9 @@ var getAvailablePlugins = /*#__PURE__*/function () {
|
|
|
4194
4524
|
}
|
|
4195
4525
|
});
|
|
4196
4526
|
return _context4.abrupt("return", ['core'].concat(plugins));
|
|
4197
|
-
case
|
|
4527
|
+
case 19:
|
|
4198
4528
|
return _context4.abrupt("return", getPlugins());
|
|
4199
|
-
case
|
|
4529
|
+
case 20:
|
|
4200
4530
|
case "end":
|
|
4201
4531
|
return _context4.stop();
|
|
4202
4532
|
}
|
|
@@ -22832,6 +23162,7 @@ exports.EvaluateFieldsInput = EvaluateFieldsInput;
|
|
|
22832
23162
|
exports.ExpectedError = ExpectedError;
|
|
22833
23163
|
exports.FindObjectInput = FindObjectInput;
|
|
22834
23164
|
exports.FindObjectInputData = FindObjectInputData;
|
|
23165
|
+
exports.GP_STATUS = GP_STATUS;
|
|
22835
23166
|
exports.GenerateAiContextInput = GenerateAiContextInput;
|
|
22836
23167
|
exports.GenerateAiContextInputData = GenerateAiContextInputData;
|
|
22837
23168
|
exports.GetExportDataInput = GetExportDataInput;
|
|
@@ -23022,6 +23353,7 @@ exports.getDate = getDate;
|
|
|
23022
23353
|
exports.getDiffObjects = getDiffObjects;
|
|
23023
23354
|
exports.getEnv = getEnv;
|
|
23024
23355
|
exports.getFullDate = getFullDate;
|
|
23356
|
+
exports.getGlobalProfileV2Plugins = getGlobalProfileV2Plugins;
|
|
23025
23357
|
exports.getGroupActionsMap = getGroupActionsMap;
|
|
23026
23358
|
exports.getImportExportJobOptions = getImportExportJobOptions;
|
|
23027
23359
|
exports.getLocalRecordReferenceType = getLocalRecordReferenceType;
|
|
@@ -23072,6 +23404,7 @@ exports.isAnniversary = isAnniversary;
|
|
|
23072
23404
|
exports.isDev = isDev;
|
|
23073
23405
|
exports.isEnabled = isEnabled;
|
|
23074
23406
|
exports.isExpectedError = isExpectedError;
|
|
23407
|
+
exports.isGlobalProfileV2 = isGlobalProfileV2;
|
|
23075
23408
|
exports.isImage = isImage;
|
|
23076
23409
|
exports.isLeapYear = isLeapYear;
|
|
23077
23410
|
exports.isPropertyDataPath = isPropertyDataPath;
|
|
@@ -23121,6 +23454,8 @@ exports.parsePropertyColumnKey = parsePropertyColumnKey;
|
|
|
23121
23454
|
exports.parsePropertyDataKey = parsePropertyDataKey;
|
|
23122
23455
|
exports.permissionGroupSchema = permissionGroupSchema;
|
|
23123
23456
|
exports.permissionSchema = permissionSchema;
|
|
23457
|
+
exports.pluginsFromStripe = pluginsFromStripe;
|
|
23458
|
+
exports.pluginsOfStripeItem = pluginsOfStripeItem;
|
|
23124
23459
|
exports.pluralFormation = pluralFormation;
|
|
23125
23460
|
exports.processCSVStream = processCSVStream;
|
|
23126
23461
|
exports.propertyDataExistsFilter = propertyDataExistsFilter;
|