@agnocon/piece-brilliant-directories 0.1.7

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.MIT-AP ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) Activepieces AB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Derived helpers in this folder are adapted from Activepieces (MIT) for use
24
+ inside CX without depending on @activepieces/* packages at runtime.
@@ -0,0 +1,9 @@
1
+ export declare const brilliantDirectoriesAuth: import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ api_key: import("@agnocon/pieces-framework").SecretTextProperty<true>;
3
+ site_url: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ }>;
5
+ export declare const brilliantDirectories: import("@agnocon/pieces-framework").Piece<import("@agnocon/pieces-framework").CustomAuthProperty<{
6
+ api_key: import("@agnocon/pieces-framework").SecretTextProperty<true>;
7
+ site_url: import("@agnocon/pieces-framework").ShortTextProperty<true>;
8
+ }>>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,wBAAwB;;;EAsBnC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;GAoB/B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.brilliantDirectories = exports.brilliantDirectoriesAuth = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/brilliant-directories/src/index.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_common_1 = require("@agnocon/pieces-common");
8
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
9
+ const create_new_user_1 = require("./lib/actions/create-new-user");
10
+ exports.brilliantDirectoriesAuth = pieces_framework_1.PieceAuth.CustomAuth({
11
+ required: true,
12
+ description: `
13
+ Brilliant Directories Authentication.
14
+
15
+ Please enter your API key which can be generated from here: https://ww2.managemydirectory.com/admin/apiSettings
16
+
17
+ Then enter your brilliant directories website instance URL appended with /api like the example.
18
+ `,
19
+ props: {
20
+ api_key: pieces_framework_1.PieceAuth.SecretText({
21
+ displayName: 'API Key',
22
+ description: 'The api key of the brilliant directories account account',
23
+ required: true,
24
+ }),
25
+ site_url: pieces_framework_1.Property.ShortText({
26
+ displayName: 'Instance Url',
27
+ description: 'The url of the brilliant directories instance.',
28
+ required: true,
29
+ defaultValue: 'https://yoursitehere.com/api',
30
+ }),
31
+ },
32
+ });
33
+ exports.brilliantDirectories = (0, pieces_framework_1.createPiece)({
34
+ displayName: 'Brilliant Directories',
35
+ description: 'All-in-one membership software',
36
+ auth: exports.brilliantDirectoriesAuth,
37
+ minimumSupportedRelease: '0.30.0',
38
+ logoUrl: 'https://cdn.activepieces.com/pieces/brilliant-directories.png',
39
+ categories: [],
40
+ authors: ["ShayPunter", "dennisrongo", "kishanprmr", "MoShizzle", "abuaboud"],
41
+ actions: [
42
+ create_new_user_1.createNewUser,
43
+ (0, pieces_common_1.createCustomApiCallAction)({
44
+ baseUrl: (auth) => { var _a; return ((_a = auth === null || auth === void 0 ? void 0 : auth.props) === null || _a === void 0 ? void 0 : _a.site_url) || ''; },
45
+ auth: exports.brilliantDirectoriesAuth,
46
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
47
+ return ({
48
+ 'X-Api-Key': `${auth.props.api_key}`,
49
+ });
50
+ }),
51
+ }),
52
+ ],
53
+ triggers: [],
54
+ });
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,iGAAiG;AACjG,qEAAqE;AACrE,0DAAmE;AACnE,gEAImC;AAEnC,mEAA8D;AAEjD,QAAA,wBAAwB,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC3D,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE;;;;;;GAMZ;IACD,KAAK,EAAE;QACL,OAAO,EAAE,4BAAS,CAAC,UAAU,CAAC;YAC5B,WAAW,EAAE,SAAS;YACtB,WAAW,EAAE,0DAA0D;YACvE,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,8BAA8B;SAC7C,CAAC;KACH;CACF,CAAC,CAAC;AAEU,QAAA,oBAAoB,GAAG,IAAA,8BAAW,EAAC;IAC9C,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,gCAAgC;IAE7C,IAAI,EAAE,gCAAwB;IAC9B,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+DAA+D;IACxE,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,CAAC,YAAY,EAAC,aAAa,EAAC,YAAY,EAAC,WAAW,EAAC,UAAU,CAAC;IACzE,OAAO,EAAE;QACP,+BAAa;QACb,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAE,QAAQ,KAAI,EAAE,CAAA,EAAA;YAC9C,IAAI,EAAE,gCAAwB;YAC9B,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;iBACrC,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const createNewUser: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").CustomAuthProperty<{
2
+ api_key: import("@agnocon/pieces-framework").SecretTextProperty<true>;
3
+ site_url: import("@agnocon/pieces-framework").ShortTextProperty<true>;
4
+ }>, {
5
+ email: import("@agnocon/pieces-framework").ShortTextProperty<true>;
6
+ password: import("@agnocon/pieces-framework").ShortTextProperty<true>;
7
+ subscription: import("@agnocon/pieces-framework").ShortTextProperty<true>;
8
+ meta: import("@agnocon/pieces-framework").JsonProperty<false>;
9
+ }>;
10
+ //# sourceMappingURL=create-new-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-new-user.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-new-user.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa;;;;;;;;EA0DxB,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNewUser = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/brilliant-directories/src/lib/actions/create-new-user.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
8
+ const pieces_common_1 = require("@agnocon/pieces-common");
9
+ const __1 = require("../..");
10
+ const brilliant_directories_common_1 = require("../common/brilliant-directories-common");
11
+ exports.createNewUser = (0, pieces_framework_1.createAction)({
12
+ name: 'create_new_user',
13
+ auth: __1.brilliantDirectoriesAuth,
14
+ displayName: 'Create new User',
15
+ description: 'Creates a new user in your brilliant directories site',
16
+ audience: 'both',
17
+ aiMetadata: { description: 'Registers a new member account on a Brilliant Directories site via the v2 user/create API. Use to onboard a member when you have their email, password, and a subscription ID that maps to a membership plan; extra profile fields can be passed through the Meta object. Not idempotent — each call creates a new account, so calling twice with the same email may produce a duplicate or fail.', idempotent: false },
18
+ props: {
19
+ email: pieces_framework_1.Property.ShortText({
20
+ displayName: 'Email',
21
+ description: 'Email address for the users account',
22
+ required: true,
23
+ }),
24
+ password: pieces_framework_1.Property.ShortText({
25
+ displayName: 'Password',
26
+ description: 'Password for the new user account',
27
+ required: true,
28
+ }),
29
+ subscription: pieces_framework_1.Property.ShortText({
30
+ displayName: 'Subscription ID',
31
+ description: 'The subscription ID from your website',
32
+ required: true,
33
+ }),
34
+ meta: pieces_framework_1.Property.Json({
35
+ displayName: 'Meta',
36
+ description: 'Additional fields for the new user account',
37
+ required: false,
38
+ }),
39
+ },
40
+ run(context) {
41
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
+ const siteUrl = (0, brilliant_directories_common_1.parseDirectoryURL)(context.auth.props.site_url);
43
+ // Compile the request
44
+ const CREATE_NEW_USER_URL = siteUrl + '/v2/user/create';
45
+ const headers = {
46
+ accept: 'application/json',
47
+ 'X-Api-Key': context.auth.props.api_key,
48
+ 'Content-Type': 'application/x-www-form-urlencoded',
49
+ };
50
+ const body = Object.assign({ email: context.propsValue.email, password: context.propsValue.password, subscription_id: context.propsValue.subscription }, context.propsValue.meta);
51
+ // send the request
52
+ const request = yield pieces_common_1.httpClient.sendRequest({
53
+ method: pieces_common_1.HttpMethod.POST,
54
+ url: CREATE_NEW_USER_URL,
55
+ headers: headers,
56
+ body: body,
57
+ });
58
+ // return the request
59
+ return request;
60
+ });
61
+ },
62
+ });
63
+ //# sourceMappingURL=create-new-user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-new-user.js","sourceRoot":"","sources":["../../../src/lib/actions/create-new-user.ts"],"names":[],"mappings":";;;;AAAA,uHAAuH;AACvH,qEAAqE;AACrE,gEAAmE;AACnE,0DAAgE;AAChE,6BAAiD;AACjD,yFAA2E;AAE9D,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,4BAAwB;IAC9B,WAAW,EAAE,iBAAiB;IAC9B,WAAW,EAAE,uDAAuD;IACpE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,mYAAmY,EAAE,UAAU,EAAE,KAAK,EAAE;IACnb,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACxB,WAAW,EAAE,OAAO;YACpB,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC3B,WAAW,EAAE,UAAU;YACvB,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC/B,WAAW,EAAE,iBAAiB;YAC9B,WAAW,EAAE,uCAAuC;YACpD,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,MAAM;YACnB,WAAW,EAAE,4CAA4C;YACzD,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IAEK,GAAG,CAAC,OAAO;;YACf,MAAM,OAAO,GAAG,IAAA,gDAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAE/D,sBAAsB;YACtB,MAAM,mBAAmB,GAAG,OAAO,GAAG,iBAAiB,CAAC;YACxD,MAAM,OAAO,GAAG;gBACd,MAAM,EAAE,kBAAkB;gBAC1B,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;gBACvC,cAAc,EAAE,mCAAmC;aACpD,CAAC;YACF,MAAM,IAAI,mBACR,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,KAAK,EAC/B,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,EACrC,eAAe,EAAE,OAAO,CAAC,UAAU,CAAC,YAAY,IAC7C,OAAO,CAAC,UAAU,CAAC,IAAI,CAC3B,CAAC;YAEF,mBAAmB;YACnB,MAAM,OAAO,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAW;gBACrD,MAAM,EAAE,0BAAU,CAAC,IAAI;gBACvB,GAAG,EAAE,mBAAmB;gBACxB,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE,IAAI;aACX,CAAC,CAAC;YAEH,qBAAqB;YACrB,OAAO,OAAO,CAAC;QACjB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Process the directory URL to ensure proper formatting and requests.
3
+ *
4
+ * @param {string} url directory site url
5
+ * @returns {string} formatted url
6
+ */
7
+ export declare function parseDirectoryURL(url: string): string;
8
+ //# sourceMappingURL=brilliant-directories-common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brilliant-directories-common.d.ts","sourceRoot":"","sources":["../../../src/lib/common/brilliant-directories-common.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,UAoB5C"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDirectoryURL = parseDirectoryURL;
4
+ // Vendored from Activepieces packages/pieces/community/brilliant-directories/src/lib/common/brilliant-directories-common.ts (MIT).
5
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
6
+ /**
7
+ * Process the directory URL to ensure proper formatting and requests.
8
+ *
9
+ * @param {string} url directory site url
10
+ * @returns {string} formatted url
11
+ */
12
+ function parseDirectoryURL(url) {
13
+ let formattedUrl = url;
14
+ // Ensure the URL starts with "https://"
15
+ if (!formattedUrl.startsWith('https://')) {
16
+ // If the URL starts with "http://", replace it with "https://"
17
+ // Otherwise, prepend "https://" to the URL
18
+ formattedUrl = formattedUrl.startsWith('http://')
19
+ ? formattedUrl.replace('http://', 'https://')
20
+ : 'https://' + formattedUrl;
21
+ }
22
+ // Ensure the URL ends with "/api"
23
+ if (!formattedUrl.endsWith('/api')) {
24
+ // If the URL ends with a slash, append "api" to the URL
25
+ // Otherwise, append "/api" to the URL
26
+ formattedUrl += formattedUrl.endsWith('/') ? 'api' : '/api';
27
+ }
28
+ return formattedUrl;
29
+ }
30
+ //# sourceMappingURL=brilliant-directories-common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brilliant-directories-common.js","sourceRoot":"","sources":["../../../src/lib/common/brilliant-directories-common.ts"],"names":[],"mappings":";;AAQA,8CAoBC;AA5BD,mIAAmI;AACnI,qEAAqE;AACrE;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,GAAW;IAC3C,IAAI,YAAY,GAAG,GAAG,CAAC;IAEvB,wCAAwC;IACxC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,+DAA+D;QAC/D,2CAA2C;QAC3C,YAAY,GAAG,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC;YAC/C,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC;YAC7C,CAAC,CAAC,UAAU,GAAG,YAAY,CAAC;IAChC,CAAC;IAED,kCAAkC;IAClC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACnC,wDAAwD;QACxD,sCAAsC;QACtC,YAAY,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@agnocon/piece-brilliant-directories",
3
+ "version": "0.1.7",
4
+ "description": "AgnoCon brilliant directories connector",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src",
17
+ "LICENSE.MIT-AP"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc -p tsconfig.json",
21
+ "vendor": "node ../scripts/vendor-ap.mjs piece-brilliant-directories"
22
+ },
23
+ "dependencies": {
24
+ "@agnocon/core-utils": "0.2.0",
25
+ "@agnocon/piece-types": "0.3.1",
26
+ "@agnocon/pieces-common": "0.12.8",
27
+ "@agnocon/pieces-framework": "0.36.0",
28
+ "tslib": "2.6.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "20.17.6",
32
+ "typescript": "5.5.4"
33
+ },
34
+ "license": "MIT",
35
+ "agnocon": {
36
+ "originVersion": "0.1.7"
37
+ },
38
+ "publishConfig": {
39
+ "access": "restricted",
40
+ "tag": "latest"
41
+ },
42
+ "keywords": [
43
+ "agnocon",
44
+ "connector"
45
+ ]
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { createCustomApiCallAction } from '@agnocon/pieces-common';
2
+ import {
3
+ createPiece,
4
+ PieceAuth,
5
+ Property,
6
+ } from '@agnocon/pieces-framework';
7
+ import { PieceCategory } from '@agnocon/pieces-framework';
8
+ import { createNewUser } from './lib/actions/create-new-user';
9
+
10
+ export const brilliantDirectoriesAuth = PieceAuth.CustomAuth({
11
+ required: true,
12
+ description: `
13
+ Brilliant Directories Authentication.
14
+
15
+ Please enter your API key which can be generated from here: https://ww2.managemydirectory.com/admin/apiSettings
16
+
17
+ Then enter your brilliant directories website instance URL appended with /api like the example.
18
+ `,
19
+ props: {
20
+ api_key: PieceAuth.SecretText({
21
+ displayName: 'API Key',
22
+ description: 'The api key of the brilliant directories account account',
23
+ required: true,
24
+ }),
25
+ site_url: Property.ShortText({
26
+ displayName: 'Instance Url',
27
+ description: 'The url of the brilliant directories instance.',
28
+ required: true,
29
+ defaultValue: 'https://yoursitehere.com/api',
30
+ }),
31
+ },
32
+ });
33
+
34
+ export const brilliantDirectories = createPiece({
35
+ displayName: 'Brilliant Directories',
36
+ description: 'All-in-one membership software',
37
+
38
+ auth: brilliantDirectoriesAuth,
39
+ minimumSupportedRelease: '0.30.0',
40
+ logoUrl: 'https://cdn.activepieces.com/pieces/brilliant-directories.png',
41
+ categories: [],
42
+ authors: ["ShayPunter","dennisrongo","kishanprmr","MoShizzle","abuaboud"],
43
+ actions: [
44
+ createNewUser,
45
+ createCustomApiCallAction({
46
+ baseUrl: (auth) => auth?.props?.site_url || '',
47
+ auth: brilliantDirectoriesAuth,
48
+ authMapping: async (auth) => ({
49
+ 'X-Api-Key': `${auth.props.api_key}`,
50
+ }),
51
+ }),
52
+ ],
53
+ triggers: [],
54
+ });
@@ -0,0 +1,64 @@
1
+ import { createAction, Property } from '@agnocon/pieces-framework';
2
+ import { httpClient, HttpMethod } from '@agnocon/pieces-common';
3
+ import { brilliantDirectoriesAuth } from '../..';
4
+ import { parseDirectoryURL } from '../common/brilliant-directories-common';
5
+
6
+ export const createNewUser = createAction({
7
+ name: 'create_new_user',
8
+ auth: brilliantDirectoriesAuth,
9
+ displayName: 'Create new User',
10
+ description: 'Creates a new user in your brilliant directories site',
11
+ audience: 'both',
12
+ aiMetadata: { description: 'Registers a new member account on a Brilliant Directories site via the v2 user/create API. Use to onboard a member when you have their email, password, and a subscription ID that maps to a membership plan; extra profile fields can be passed through the Meta object. Not idempotent — each call creates a new account, so calling twice with the same email may produce a duplicate or fail.', idempotent: false },
13
+ props: {
14
+ email: Property.ShortText({
15
+ displayName: 'Email',
16
+ description: 'Email address for the users account',
17
+ required: true,
18
+ }),
19
+ password: Property.ShortText({
20
+ displayName: 'Password',
21
+ description: 'Password for the new user account',
22
+ required: true,
23
+ }),
24
+ subscription: Property.ShortText({
25
+ displayName: 'Subscription ID',
26
+ description: 'The subscription ID from your website',
27
+ required: true,
28
+ }),
29
+ meta: Property.Json({
30
+ displayName: 'Meta',
31
+ description: 'Additional fields for the new user account',
32
+ required: false,
33
+ }),
34
+ },
35
+
36
+ async run(context) {
37
+ const siteUrl = parseDirectoryURL(context.auth.props.site_url);
38
+
39
+ // Compile the request
40
+ const CREATE_NEW_USER_URL = siteUrl + '/v2/user/create';
41
+ const headers = {
42
+ accept: 'application/json',
43
+ 'X-Api-Key': context.auth.props.api_key,
44
+ 'Content-Type': 'application/x-www-form-urlencoded',
45
+ };
46
+ const body = {
47
+ email: context.propsValue.email,
48
+ password: context.propsValue.password,
49
+ subscription_id: context.propsValue.subscription,
50
+ ...context.propsValue.meta,
51
+ };
52
+
53
+ // send the request
54
+ const request = await httpClient.sendRequest<string[]>({
55
+ method: HttpMethod.POST,
56
+ url: CREATE_NEW_USER_URL,
57
+ headers: headers,
58
+ body: body,
59
+ });
60
+
61
+ // return the request
62
+ return request;
63
+ },
64
+ });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Process the directory URL to ensure proper formatting and requests.
3
+ *
4
+ * @param {string} url directory site url
5
+ * @returns {string} formatted url
6
+ */
7
+ export function parseDirectoryURL(url: string) {
8
+ let formattedUrl = url;
9
+
10
+ // Ensure the URL starts with "https://"
11
+ if (!formattedUrl.startsWith('https://')) {
12
+ // If the URL starts with "http://", replace it with "https://"
13
+ // Otherwise, prepend "https://" to the URL
14
+ formattedUrl = formattedUrl.startsWith('http://')
15
+ ? formattedUrl.replace('http://', 'https://')
16
+ : 'https://' + formattedUrl;
17
+ }
18
+
19
+ // Ensure the URL ends with "/api"
20
+ if (!formattedUrl.endsWith('/api')) {
21
+ // If the URL ends with a slash, append "api" to the URL
22
+ // Otherwise, append "/api" to the URL
23
+ formattedUrl += formattedUrl.endsWith('/') ? 'api' : '/api';
24
+ }
25
+
26
+ return formattedUrl;
27
+ }