@wirechunk/cli 0.0.2 → 0.0.4
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/build/main.js +198 -98
- package/package.json +1 -1
- package/src/commands/bootstrap.ts +1 -7
- package/src/commands/create-extension-version.ts +9 -8
- package/src/commands/edit-admin.ts +9 -1
- package/src/core-api/api.ts +254 -207
- package/src/core-api/mutations/create-extension-version.generated.ts +2 -2
- package/src/users/permissions.ts +6 -7
package/build/main.js
CHANGED
|
@@ -3955,15 +3955,14 @@ const normalizeEmailAddress = (email) => {
|
|
|
3955
3955
|
}
|
|
3956
3956
|
return { ok: true, value: emailTrimmed };
|
|
3957
3957
|
};
|
|
3958
|
-
const defaultFormattedDataTemplate = `{{#each .}}{{@key}}: {{{.}}}
|
|
3959
|
-
{{/each}}`;
|
|
3960
3958
|
const siteDomainKey = "siteDomain";
|
|
3961
|
-
const formattedDataKey = "formattedData";
|
|
3962
3959
|
const submittedAtKey = "submittedAt";
|
|
3960
|
+
const defaultFormattedDataTemplate = `{{#each .}}{{@key}}: {{{.}}}
|
|
3961
|
+
{{/each}}`;
|
|
3963
3962
|
const defaultNotificationEmailBodyTemplate = `Form entry from your site {{${siteDomainKey}}}:
|
|
3964
3963
|
|
|
3965
|
-
{{{
|
|
3966
|
-
|
|
3964
|
+
{{#each .}}{{@key}}: {{{.}}}
|
|
3965
|
+
{{/each}}
|
|
3967
3966
|
|
|
3968
3967
|
Submitted {{${submittedAtKey}}}
|
|
3969
3968
|
`;
|
|
@@ -24957,22 +24956,16 @@ const bootstrap = async (opts, env2) => {
|
|
|
24957
24956
|
} else {
|
|
24958
24957
|
emailSendFrom = `site@${adminSiteDomain}`;
|
|
24959
24958
|
}
|
|
24960
|
-
const adminSiteName = `${name} Admin`;
|
|
24961
24959
|
await db.transaction(async (db2) => {
|
|
24962
24960
|
await db2.query(
|
|
24963
24961
|
distExports$1.sql.type(
|
|
24964
24962
|
voidSelectSchema
|
|
24965
24963
|
)`insert into "Platforms" ("id", "handle", "name", "defaultFormFormattedDataTemplate", "defaultFormNotificationEmailBodyTemplate", "emailSendFromAddress") values (${platformId}, ${handle}, ${name}, ${defaultFormattedDataTemplate}, ${defaultNotificationEmailBodyTemplate}, ${emailSendFrom})`
|
|
24966
24964
|
);
|
|
24967
|
-
await db2.query(
|
|
24968
|
-
distExports$1.sql.type(
|
|
24969
|
-
voidSelectSchema
|
|
24970
|
-
)`insert into "Sites" ("platformId", "domain", "name") values (${platformId}, ${adminSiteDomain}, ${adminSiteName})`
|
|
24971
|
-
);
|
|
24972
24965
|
});
|
|
24973
24966
|
console.log(`Created platform ${name} with handle ${handle} (ID ${platformId})`);
|
|
24974
24967
|
};
|
|
24975
|
-
const validateExtensionConfig
|
|
24968
|
+
const validateExtensionConfig = validate25;
|
|
24976
24969
|
function validate25(data, { instancePath = "", parentData, parentDataProperty, rootData = data, dynamicAnchors = {} } = {}) {
|
|
24977
24970
|
let vErrors = null;
|
|
24978
24971
|
let errors2 = 0;
|
|
@@ -25256,8 +25249,8 @@ const numberExpressionSchema = {
|
|
|
25256
25249
|
const $schema$8 = "https://json-schema.org/draft/2020-12/schema";
|
|
25257
25250
|
const $id$9 = "/expressions/string-expression.json";
|
|
25258
25251
|
const title$8 = "StringExpression";
|
|
25259
|
-
const oneOf$1 = [{ "$ref": "#/$defs/eventSourceComponentName" }, { "$ref": "#/$defs/eventSourceComponentType" }, { "$ref": "#/$defs/featureTag" }, { "$ref": "#/$defs/inputChangeEventStringValue" }, { "$ref": "#/$defs/inputDataString" }, { "$ref": "#/$defs/propsString" }, { "$ref": "#/$defs/stringLiteral" }, { "$ref": "#/$defs/userEmail" }, { "$ref": "#/$defs/userRole" }];
|
|
25260
|
-
const $defs$3 = { "eventSourceComponentName": { "type": "object", "properties": { "operator": { "const": "eventSourceComponentName" } }, "required": ["operator"] }, "eventSourceComponentType": { "type": "object", "properties": { "operator": { "const": "eventSourceComponentType" } }, "required": ["operator"] }, "featureTag": { "type": "object", "properties": { "operator": { "const": "featureTag" }, "tag": { "type": "string" } }, "required": ["operator", "tag"] }, "inputChangeEventStringValue": { "type": "object", "properties": { "operator": { "const": "inputChangeEventStringValue" } }, "required": ["operator"] }, "inputDataString": { "type": "object", "properties": { "operator": { "const": "inputDataString" }, "fieldKey": { "type": "string" } }, "required": ["operator", "fieldKey"] }, "propsString": { "type": "object", "properties": { "operator": { "const": "propsString" }, "prop": { "type": "string" } }, "required": ["operator", "prop"] }, "stringLiteral": { "type": "object", "properties": { "operator": { "const": "stringLiteral" }, "value": { "type": "string" } }, "required": ["operator", "value"] }, "userEmail": { "type": "object", "properties": { "operator": { "const": "userEmail" } }, "required": ["operator"] }, "userRole": { "type": "object", "properties": { "operator": { "const": "userRole" } }, "required": ["operator"] } };
|
|
25252
|
+
const oneOf$1 = [{ "$ref": "#/$defs/eventSourceComponentName" }, { "$ref": "#/$defs/eventSourceComponentType" }, { "$ref": "#/$defs/featureTag" }, { "$ref": "#/$defs/inputChangeEventStringValue" }, { "$ref": "#/$defs/inputDataString" }, { "$ref": "#/$defs/propsString" }, { "$ref": "#/$defs/stringLiteral" }, { "$ref": "#/$defs/userEmail" }, { "$ref": "#/$defs/userOrgId" }, { "$ref": "#/$defs/userRole" }];
|
|
25253
|
+
const $defs$3 = { "eventSourceComponentName": { "type": "object", "properties": { "operator": { "const": "eventSourceComponentName" } }, "required": ["operator"] }, "eventSourceComponentType": { "type": "object", "properties": { "operator": { "const": "eventSourceComponentType" } }, "required": ["operator"] }, "featureTag": { "type": "object", "properties": { "operator": { "const": "featureTag" }, "tag": { "type": "string" } }, "required": ["operator", "tag"] }, "inputChangeEventStringValue": { "type": "object", "properties": { "operator": { "const": "inputChangeEventStringValue" } }, "required": ["operator"] }, "inputDataString": { "type": "object", "properties": { "operator": { "const": "inputDataString" }, "fieldKey": { "type": "string" } }, "required": ["operator", "fieldKey"] }, "propsString": { "type": "object", "properties": { "operator": { "const": "propsString" }, "prop": { "type": "string" } }, "required": ["operator", "prop"] }, "stringLiteral": { "type": "object", "properties": { "operator": { "const": "stringLiteral" }, "value": { "type": "string" } }, "required": ["operator", "value"] }, "userEmail": { "type": "object", "properties": { "operator": { "const": "userEmail" } }, "required": ["operator"] }, "userOrgId": { "type": "object", "properties": { "operator": { "const": "userOrgId" } }, "required": ["operator"] }, "userRole": { "type": "object", "properties": { "operator": { "const": "userRole" } }, "required": ["operator"] } };
|
|
25261
25254
|
const stringExpressionSchema = {
|
|
25262
25255
|
$schema: $schema$8,
|
|
25263
25256
|
$id: $id$9,
|
|
@@ -32035,7 +32028,7 @@ const preCompiledSafeValidator = (validate2) => (value) => {
|
|
|
32035
32028
|
error: errorsText(validate2)
|
|
32036
32029
|
};
|
|
32037
32030
|
};
|
|
32038
|
-
const
|
|
32031
|
+
const validateExtensionManifest = preCompiledSafeValidator(validateExtensionConfig);
|
|
32039
32032
|
const requireValidExtensionDir = async (dir2) => {
|
|
32040
32033
|
const extConfigPath = resolve$1(dir2, "extension.json");
|
|
32041
32034
|
if (!existsSync(extConfigPath)) {
|
|
@@ -32043,7 +32036,7 @@ const requireValidExtensionDir = async (dir2) => {
|
|
|
32043
32036
|
process.exit(1);
|
|
32044
32037
|
}
|
|
32045
32038
|
const extConfig = JSON.parse(await readFile(extConfigPath, "utf8"));
|
|
32046
|
-
const validateResult =
|
|
32039
|
+
const validateResult = validateExtensionManifest(extConfig);
|
|
32047
32040
|
if (validateResult.ok) {
|
|
32048
32041
|
const config2 = validateResult.value;
|
|
32049
32042
|
if (config2.components) {
|
|
@@ -32059,7 +32052,7 @@ const requireValidExtensionDir = async (dir2) => {
|
|
|
32059
32052
|
}
|
|
32060
32053
|
}
|
|
32061
32054
|
}
|
|
32062
|
-
return {
|
|
32055
|
+
return { manifest: config2, dir: dir2 };
|
|
32063
32056
|
}
|
|
32064
32057
|
console.error(`Invalid extension config file:`, validateResult.error);
|
|
32065
32058
|
process.exit(1);
|
|
@@ -60711,20 +60704,20 @@ const createExtensionVersion = async (opts, env2) => {
|
|
|
60711
60704
|
const extensionId = requireExtensionIdOptionOrEnvVar(opts, env2);
|
|
60712
60705
|
const apiToken = requireApiToken(env2);
|
|
60713
60706
|
const cwd = process.cwd();
|
|
60714
|
-
const
|
|
60707
|
+
const { manifest } = await requireValidExtensionDir(cwd);
|
|
60715
60708
|
let enableServer;
|
|
60716
60709
|
let enableDb;
|
|
60717
|
-
if (
|
|
60718
|
-
enableServer = !!
|
|
60719
|
-
if (
|
|
60710
|
+
if (manifest.server) {
|
|
60711
|
+
enableServer = !!manifest.server.enable;
|
|
60712
|
+
if (manifest.server.database?.enable && manifest.server.enable === false) {
|
|
60720
60713
|
console.warn("WARNING: Automatically disabling database because server is disabled");
|
|
60721
60714
|
enableDb = false;
|
|
60722
|
-
} else if (
|
|
60715
|
+
} else if (manifest.server.database?.enable && !manifest.server.enable) {
|
|
60723
60716
|
console.warn("WARNING: Automatically enabling server because database is enabled");
|
|
60724
60717
|
enableServer = true;
|
|
60725
60718
|
enableDb = true;
|
|
60726
60719
|
} else {
|
|
60727
|
-
enableDb = !!
|
|
60720
|
+
enableDb = !!manifest.server.database?.enable;
|
|
60728
60721
|
}
|
|
60729
60722
|
} else {
|
|
60730
60723
|
enableServer = false;
|
|
@@ -60748,7 +60741,7 @@ const createExtensionVersion = async (opts, env2) => {
|
|
|
60748
60741
|
console.log(`Creating extension version ${versionName} (Extension ID ${extensionId})
|
|
60749
60742
|
Server: ${enableServer ? "enabled" : "disabled"}
|
|
60750
60743
|
Database: ${enableDb ? "enabled" : "disabled"}
|
|
60751
|
-
Components: ${Object.keys(
|
|
60744
|
+
Components: ${Object.keys(manifest.components ?? {}).length}`);
|
|
60752
60745
|
let extensionVersionId;
|
|
60753
60746
|
let signedUrl;
|
|
60754
60747
|
try {
|
|
@@ -60761,8 +60754,9 @@ const createExtensionVersion = async (opts, env2) => {
|
|
|
60761
60754
|
variables: {
|
|
60762
60755
|
input: {
|
|
60763
60756
|
extensionId,
|
|
60764
|
-
extensionName:
|
|
60757
|
+
extensionName: manifest.name,
|
|
60765
60758
|
versionName,
|
|
60759
|
+
manifest: JSON.stringify(manifest),
|
|
60766
60760
|
enableServer,
|
|
60767
60761
|
enableDb,
|
|
60768
60762
|
config: config2 ? JSON.stringify(config2) : void 0
|
|
@@ -60991,82 +60985,180 @@ const createUser = async (opts, env2) => {
|
|
|
60991
60985
|
process.exit(1);
|
|
60992
60986
|
}
|
|
60993
60987
|
};
|
|
60994
|
-
const
|
|
60995
|
-
|
|
60996
|
-
|
|
60997
|
-
|
|
60998
|
-
|
|
60999
|
-
|
|
61000
|
-
|
|
61001
|
-
|
|
61002
|
-
|
|
61003
|
-
|
|
61004
|
-
|
|
61005
|
-
|
|
61006
|
-
|
|
61007
|
-
|
|
61008
|
-
|
|
61009
|
-
|
|
61010
|
-
|
|
61011
|
-
|
|
61012
|
-
|
|
61013
|
-
|
|
61014
|
-
|
|
61015
|
-
|
|
61016
|
-
|
|
61017
|
-
|
|
61018
|
-
|
|
61019
|
-
|
|
61020
|
-
|
|
61021
|
-
|
|
61022
|
-
|
|
61023
|
-
|
|
61024
|
-
|
|
61025
|
-
|
|
61026
|
-
|
|
61027
|
-
|
|
61028
|
-
|
|
61029
|
-
|
|
61030
|
-
|
|
61031
|
-
|
|
61032
|
-
|
|
61033
|
-
|
|
61034
|
-
|
|
61035
|
-
|
|
61036
|
-
|
|
61037
|
-
|
|
61038
|
-
|
|
61039
|
-
|
|
61040
|
-
|
|
61041
|
-
|
|
61042
|
-
|
|
61043
|
-
|
|
61044
|
-
|
|
61045
|
-
|
|
61046
|
-
|
|
61047
|
-
|
|
61048
|
-
|
|
61049
|
-
|
|
61050
|
-
|
|
61051
|
-
|
|
61052
|
-
|
|
61053
|
-
|
|
61054
|
-
|
|
61055
|
-
|
|
61056
|
-
|
|
61057
|
-
|
|
61058
|
-
|
|
61059
|
-
|
|
61060
|
-
|
|
60988
|
+
const permissionExtensionCreate = {
|
|
60989
|
+
object: "Extension",
|
|
60990
|
+
action: "create"
|
|
60991
|
+
};
|
|
60992
|
+
const permissionExtensionCreateVersion = {
|
|
60993
|
+
object: "Extension",
|
|
60994
|
+
action: "createVersion"
|
|
60995
|
+
};
|
|
60996
|
+
const permissionSiteCreate = {
|
|
60997
|
+
object: "Site",
|
|
60998
|
+
action: "create"
|
|
60999
|
+
};
|
|
61000
|
+
const permissionTemplateCreate = {
|
|
61001
|
+
object: "Template",
|
|
61002
|
+
action: "create"
|
|
61003
|
+
};
|
|
61004
|
+
const permissionUserCreate = {
|
|
61005
|
+
object: "User",
|
|
61006
|
+
action: "create"
|
|
61007
|
+
};
|
|
61008
|
+
const permissionPlatformEdit = {
|
|
61009
|
+
object: "Platform",
|
|
61010
|
+
action: "edit"
|
|
61011
|
+
};
|
|
61012
|
+
const permissionComponentEdit = {
|
|
61013
|
+
object: "Component",
|
|
61014
|
+
action: "edit"
|
|
61015
|
+
};
|
|
61016
|
+
const permissionCourseEdit = {
|
|
61017
|
+
object: "Course",
|
|
61018
|
+
action: "edit"
|
|
61019
|
+
};
|
|
61020
|
+
const permissionCustomComponentEdit = {
|
|
61021
|
+
object: "CustomComponent",
|
|
61022
|
+
action: "edit"
|
|
61023
|
+
};
|
|
61024
|
+
const permissionCustomFieldEdit = {
|
|
61025
|
+
object: "CustomField",
|
|
61026
|
+
action: "edit"
|
|
61027
|
+
};
|
|
61028
|
+
const permissionCustomerSiteEdit = {
|
|
61029
|
+
object: "CustomerSite",
|
|
61030
|
+
action: "edit"
|
|
61031
|
+
};
|
|
61032
|
+
const permissionExtensionEdit = {
|
|
61033
|
+
object: "Extension",
|
|
61034
|
+
action: "edit"
|
|
61035
|
+
};
|
|
61036
|
+
const permissionHelpTicketEditStatus = {
|
|
61037
|
+
object: "HelpTicket",
|
|
61038
|
+
action: "editStatus"
|
|
61039
|
+
};
|
|
61040
|
+
const permissionPlatformSiteEdit = {
|
|
61041
|
+
object: "PlatformSite",
|
|
61042
|
+
action: "edit"
|
|
61043
|
+
};
|
|
61044
|
+
const permissionSequenceEdit = {
|
|
61045
|
+
object: "Sequence",
|
|
61046
|
+
action: "edit"
|
|
61047
|
+
};
|
|
61048
|
+
const permissionSequenceUserEdit = {
|
|
61049
|
+
object: "SequenceUser",
|
|
61050
|
+
action: "edit"
|
|
61051
|
+
};
|
|
61052
|
+
const permissionSiteEdit = {
|
|
61053
|
+
object: "Site",
|
|
61054
|
+
action: "edit"
|
|
61061
61055
|
};
|
|
61062
|
-
const
|
|
61056
|
+
const permissionSiteEditDomain = {
|
|
61057
|
+
object: "Site",
|
|
61058
|
+
action: "editDomain"
|
|
61059
|
+
};
|
|
61060
|
+
const permissionSiteEditTls = {
|
|
61061
|
+
object: "Site",
|
|
61062
|
+
action: "editTls"
|
|
61063
|
+
};
|
|
61064
|
+
const permissionSubscriptionEdit = {
|
|
61065
|
+
object: "Subscription",
|
|
61066
|
+
action: "edit"
|
|
61067
|
+
};
|
|
61068
|
+
const permissionTemplateEdit = {
|
|
61069
|
+
object: "Template",
|
|
61070
|
+
action: "edit"
|
|
61071
|
+
};
|
|
61072
|
+
const permissionUserEditEmail = {
|
|
61073
|
+
object: "User",
|
|
61074
|
+
action: "editEmail"
|
|
61075
|
+
};
|
|
61076
|
+
const permissionUserEditOrg = {
|
|
61077
|
+
object: "User",
|
|
61078
|
+
action: "editOrg"
|
|
61079
|
+
};
|
|
61080
|
+
const permissionUserEditStatus = {
|
|
61081
|
+
object: "User",
|
|
61082
|
+
action: "editStatus"
|
|
61083
|
+
};
|
|
61084
|
+
const permissionUserEditRole = {
|
|
61085
|
+
object: "User",
|
|
61086
|
+
action: "editRole"
|
|
61087
|
+
};
|
|
61088
|
+
const permissionUserEditProfile = {
|
|
61089
|
+
object: "User",
|
|
61090
|
+
action: "editProfile"
|
|
61091
|
+
};
|
|
61092
|
+
const permissionFormTemplateSync = {
|
|
61093
|
+
object: "FormTemplate",
|
|
61094
|
+
action: "sync"
|
|
61095
|
+
};
|
|
61096
|
+
const permissionPageTemplateSync = {
|
|
61097
|
+
object: "PageTemplate",
|
|
61098
|
+
action: "sync"
|
|
61099
|
+
};
|
|
61100
|
+
const permissionPlatformView = {
|
|
61101
|
+
object: "Platform",
|
|
61102
|
+
action: "view"
|
|
61103
|
+
};
|
|
61104
|
+
const permissionCourseView = {
|
|
61105
|
+
object: "Course",
|
|
61106
|
+
action: "view"
|
|
61107
|
+
};
|
|
61108
|
+
const permissionExtensionView = {
|
|
61109
|
+
object: "Extension",
|
|
61110
|
+
action: "view"
|
|
61111
|
+
};
|
|
61112
|
+
const permissionSiteView = {
|
|
61113
|
+
object: "Site",
|
|
61114
|
+
action: "view"
|
|
61115
|
+
};
|
|
61116
|
+
const permissionTemplateView = {
|
|
61117
|
+
object: "Template",
|
|
61118
|
+
action: "view"
|
|
61119
|
+
};
|
|
61120
|
+
const allPermissions = [
|
|
61121
|
+
permissionExtensionCreate,
|
|
61122
|
+
permissionExtensionCreateVersion,
|
|
61123
|
+
permissionSiteCreate,
|
|
61124
|
+
permissionTemplateCreate,
|
|
61125
|
+
permissionUserCreate,
|
|
61126
|
+
permissionPlatformEdit,
|
|
61127
|
+
permissionComponentEdit,
|
|
61128
|
+
permissionCourseEdit,
|
|
61129
|
+
permissionCustomComponentEdit,
|
|
61130
|
+
permissionCustomFieldEdit,
|
|
61131
|
+
permissionCustomerSiteEdit,
|
|
61132
|
+
permissionExtensionEdit,
|
|
61133
|
+
permissionHelpTicketEditStatus,
|
|
61134
|
+
permissionPlatformSiteEdit,
|
|
61135
|
+
permissionSequenceEdit,
|
|
61136
|
+
permissionSequenceUserEdit,
|
|
61137
|
+
permissionSiteEdit,
|
|
61138
|
+
permissionSiteEditDomain,
|
|
61139
|
+
permissionSiteEditTls,
|
|
61140
|
+
permissionSubscriptionEdit,
|
|
61141
|
+
permissionTemplateEdit,
|
|
61142
|
+
permissionUserEditEmail,
|
|
61143
|
+
permissionUserEditOrg,
|
|
61144
|
+
permissionUserEditStatus,
|
|
61145
|
+
permissionUserEditRole,
|
|
61146
|
+
permissionUserEditProfile,
|
|
61147
|
+
permissionFormTemplateSync,
|
|
61148
|
+
permissionPageTemplateSync,
|
|
61149
|
+
permissionPlatformView,
|
|
61150
|
+
permissionCourseView,
|
|
61151
|
+
permissionExtensionView,
|
|
61152
|
+
permissionSiteView,
|
|
61153
|
+
permissionTemplateView
|
|
61154
|
+
];
|
|
61063
61155
|
const revokeAllUserPlatformPermissions = async ({
|
|
61064
61156
|
platformAdminId
|
|
61065
61157
|
}, db) => {
|
|
61066
61158
|
await db.query(
|
|
61067
61159
|
distExports$1.sql.type(
|
|
61068
61160
|
voidSelectSchema
|
|
61069
|
-
)`delete from "
|
|
61161
|
+
)`delete from "Permissions" where "platformAdminId" = ${platformAdminId}`
|
|
61070
61162
|
);
|
|
61071
61163
|
};
|
|
61072
61164
|
const grantAllUserPlatformPermissions = async ({
|
|
@@ -61075,12 +61167,12 @@ const grantAllUserPlatformPermissions = async ({
|
|
|
61075
61167
|
await db.query(
|
|
61076
61168
|
distExports$1.sql.type(
|
|
61077
61169
|
voidSelectSchema
|
|
61078
|
-
)`insert into "
|
|
61170
|
+
)`insert into "Permissions" ("id", "platformAdminId", "object", "action") values ${distExports$1.sql.join(
|
|
61079
61171
|
allPermissions.map(
|
|
61080
|
-
(permission) => distExports$1.sql.fragment`(${cleanSmallId()}, ${platformAdminId}, ${permission})`
|
|
61172
|
+
(permission) => distExports$1.sql.fragment`(${cleanSmallId()}, ${platformAdminId}, ${permission.object}, ${permission.action})`
|
|
61081
61173
|
),
|
|
61082
61174
|
distExports$1.sql.fragment`,`
|
|
61083
|
-
)} on conflict ("platformAdminId", "
|
|
61175
|
+
)} on conflict ("platformAdminId", "object", "action") do nothing`
|
|
61084
61176
|
);
|
|
61085
61177
|
};
|
|
61086
61178
|
const findPlatformAdminSchema = z.object({
|
|
@@ -61120,10 +61212,18 @@ const editAdmin = async (opts, env2) => {
|
|
|
61120
61212
|
platformAdmin = await db2.one(
|
|
61121
61213
|
distExports$1.sql.type(findPlatformAdminSchema)`
|
|
61122
61214
|
insert into "PlatformAdmins" ("id", "platformId", "userId", "owner", "active")
|
|
61123
|
-
values (${cleanSmallId()}, ${platformId}, ${userId}, ${active ?? true}
|
|
61215
|
+
values (${cleanSmallId()}, ${platformId}, ${userId}, true, ${active ?? true})
|
|
61124
61216
|
returning "id", "platformId", "active"
|
|
61125
61217
|
`
|
|
61126
61218
|
);
|
|
61219
|
+
} else {
|
|
61220
|
+
await db2.query(
|
|
61221
|
+
distExports$1.sql.type(voidSelectSchema)`
|
|
61222
|
+
update "PlatformAdmins"
|
|
61223
|
+
set "owner" = true
|
|
61224
|
+
where "id" = ${platformAdmin.id}
|
|
61225
|
+
`
|
|
61226
|
+
);
|
|
61127
61227
|
}
|
|
61128
61228
|
await grantAllUserPlatformPermissions({ platformAdminId: platformAdmin.id }, db2);
|
|
61129
61229
|
if (opts.verbose) {
|
package/package.json
CHANGED
|
@@ -23,6 +23,7 @@ const randomString = () => randomUUID().replaceAll('-', '').slice(0, 10);
|
|
|
23
23
|
type BootstrapOptions = {
|
|
24
24
|
name: string;
|
|
25
25
|
handle?: string;
|
|
26
|
+
// TODO: Require this be set in the environment instead.
|
|
26
27
|
adminSiteDomain: string;
|
|
27
28
|
emailSendFrom?: string;
|
|
28
29
|
};
|
|
@@ -61,7 +62,6 @@ export const bootstrap = async (
|
|
|
61
62
|
} else {
|
|
62
63
|
emailSendFrom = `site@${adminSiteDomain}`;
|
|
63
64
|
}
|
|
64
|
-
const adminSiteName = `${name} Admin`;
|
|
65
65
|
|
|
66
66
|
await db.transaction(async (db) => {
|
|
67
67
|
await db.query(
|
|
@@ -69,12 +69,6 @@ export const bootstrap = async (
|
|
|
69
69
|
voidSelectSchema,
|
|
70
70
|
)`insert into "Platforms" ("id", "handle", "name", "defaultFormFormattedDataTemplate", "defaultFormNotificationEmailBodyTemplate", "emailSendFromAddress") values (${platformId}, ${handle}, ${name}, ${defaultFormattedDataTemplate}, ${defaultNotificationEmailBodyTemplate}, ${emailSendFrom})`,
|
|
71
71
|
);
|
|
72
|
-
|
|
73
|
-
await db.query(
|
|
74
|
-
sql.type(
|
|
75
|
-
voidSelectSchema,
|
|
76
|
-
)`insert into "Sites" ("platformId", "domain", "name") values (${platformId}, ${adminSiteDomain}, ${adminSiteName})`,
|
|
77
|
-
);
|
|
78
72
|
});
|
|
79
73
|
|
|
80
74
|
console.log(`Created platform ${name} with handle ${handle} (ID ${platformId})`);
|
|
@@ -44,22 +44,22 @@ export const createExtensionVersion = async (
|
|
|
44
44
|
const extensionId = requireExtensionIdOptionOrEnvVar(opts, env);
|
|
45
45
|
const apiToken = requireApiToken(env);
|
|
46
46
|
const cwd = process.cwd();
|
|
47
|
-
const
|
|
47
|
+
const { manifest } = await requireValidExtensionDir(cwd);
|
|
48
48
|
let enableServer: boolean;
|
|
49
49
|
let enableDb: boolean;
|
|
50
|
-
if (
|
|
51
|
-
enableServer = !!
|
|
52
|
-
if (
|
|
50
|
+
if (manifest.server) {
|
|
51
|
+
enableServer = !!manifest.server.enable;
|
|
52
|
+
if (manifest.server.database?.enable && manifest.server.enable === false) {
|
|
53
53
|
// Server was explicitly disabled, so don't allow database.
|
|
54
54
|
console.warn('WARNING: Automatically disabling database because server is disabled');
|
|
55
55
|
enableDb = false;
|
|
56
|
-
} else if (
|
|
56
|
+
} else if (manifest.server.database?.enable && !manifest.server.enable) {
|
|
57
57
|
// Server was unspecified, so enable it because database is enabled.
|
|
58
58
|
console.warn('WARNING: Automatically enabling server because database is enabled');
|
|
59
59
|
enableServer = true;
|
|
60
60
|
enableDb = true;
|
|
61
61
|
} else {
|
|
62
|
-
enableDb = !!
|
|
62
|
+
enableDb = !!manifest.server.database?.enable;
|
|
63
63
|
}
|
|
64
64
|
} else {
|
|
65
65
|
enableServer = false;
|
|
@@ -84,7 +84,7 @@ export const createExtensionVersion = async (
|
|
|
84
84
|
console.log(`Creating extension version ${versionName} (Extension ID ${extensionId})
|
|
85
85
|
Server: ${enableServer ? 'enabled' : 'disabled'}
|
|
86
86
|
Database: ${enableDb ? 'enabled' : 'disabled'}
|
|
87
|
-
Components: ${Object.keys(
|
|
87
|
+
Components: ${Object.keys(manifest.components ?? {}).length}`);
|
|
88
88
|
|
|
89
89
|
let extensionVersionId: string;
|
|
90
90
|
let signedUrl: string;
|
|
@@ -98,8 +98,9 @@ export const createExtensionVersion = async (
|
|
|
98
98
|
variables: {
|
|
99
99
|
input: {
|
|
100
100
|
extensionId,
|
|
101
|
-
extensionName:
|
|
101
|
+
extensionName: manifest.name,
|
|
102
102
|
versionName,
|
|
103
|
+
manifest: JSON.stringify(manifest),
|
|
103
104
|
enableServer,
|
|
104
105
|
enableDb,
|
|
105
106
|
config: config ? JSON.stringify(config) : undefined,
|
|
@@ -63,10 +63,18 @@ export const editAdmin = async (
|
|
|
63
63
|
platformAdmin = await db.one(
|
|
64
64
|
sql.type(findPlatformAdminSchema)`
|
|
65
65
|
insert into "PlatformAdmins" ("id", "platformId", "userId", "owner", "active")
|
|
66
|
-
values (${cleanSmallId()}, ${platformId}, ${userId}, ${active ?? true}
|
|
66
|
+
values (${cleanSmallId()}, ${platformId}, ${userId}, true, ${active ?? true})
|
|
67
67
|
returning "id", "platformId", "active"
|
|
68
68
|
`,
|
|
69
69
|
);
|
|
70
|
+
} else {
|
|
71
|
+
await db.query(
|
|
72
|
+
sql.type(voidSelectSchema)`
|
|
73
|
+
update "PlatformAdmins"
|
|
74
|
+
set "owner" = true
|
|
75
|
+
where "id" = ${platformAdmin.id}
|
|
76
|
+
`,
|
|
77
|
+
);
|
|
70
78
|
}
|
|
71
79
|
await grantAllUserPlatformPermissions({ platformAdminId: platformAdmin.id }, db);
|
|
72
80
|
if (opts.verbose) {
|