@wirechunk/cli 0.0.3 → 0.0.5
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 +266 -88
- package/package.json +1 -1
- package/src/commands/bootstrap.ts +18 -14
- package/src/commands/edit-admin.ts +9 -1
- package/src/commands/ext-dev/init-db.ts +2 -2
- package/src/core-api/api.ts +289 -227
- package/src/core-api/mutations/create-extension-version.generated.ts +2 -2
- package/src/users/permissions.ts +6 -7
package/build/main.js
CHANGED
|
@@ -3957,8 +3957,6 @@ const normalizeEmailAddress = (email) => {
|
|
|
3957
3957
|
};
|
|
3958
3958
|
const siteDomainKey = "siteDomain";
|
|
3959
3959
|
const submittedAtKey = "submittedAt";
|
|
3960
|
-
const defaultFormattedDataTemplate = `{{#each .}}{{@key}}: {{{.}}}
|
|
3961
|
-
{{/each}}`;
|
|
3962
3960
|
const defaultNotificationEmailBodyTemplate = `Form entry from your site {{${siteDomainKey}}}:
|
|
3963
3961
|
|
|
3964
3962
|
{{#each .}}{{@key}}: {{{.}}}
|
|
@@ -24956,17 +24954,24 @@ const bootstrap = async (opts, env2) => {
|
|
|
24956
24954
|
} else {
|
|
24957
24955
|
emailSendFrom = `site@${adminSiteDomain}`;
|
|
24958
24956
|
}
|
|
24959
|
-
const adminSiteName = `${name} Admin`;
|
|
24960
24957
|
await db.transaction(async (db2) => {
|
|
24961
24958
|
await db2.query(
|
|
24962
|
-
distExports$1.sql.type(
|
|
24963
|
-
|
|
24964
|
-
|
|
24965
|
-
|
|
24966
|
-
|
|
24967
|
-
|
|
24968
|
-
|
|
24969
|
-
|
|
24959
|
+
distExports$1.sql.type(voidSelectSchema)`
|
|
24960
|
+
insert into "Platforms" (
|
|
24961
|
+
"id",
|
|
24962
|
+
"handle",
|
|
24963
|
+
"name",
|
|
24964
|
+
"defaultFormNotificationEmailBodyTemplate",
|
|
24965
|
+
"emailSendFromAddress"
|
|
24966
|
+
)
|
|
24967
|
+
values (
|
|
24968
|
+
${platformId},
|
|
24969
|
+
${handle},
|
|
24970
|
+
${name},
|
|
24971
|
+
${defaultNotificationEmailBodyTemplate},
|
|
24972
|
+
${emailSendFrom}
|
|
24973
|
+
)
|
|
24974
|
+
`
|
|
24970
24975
|
);
|
|
24971
24976
|
});
|
|
24972
24977
|
console.log(`Created platform ${name} with handle ${handle} (ID ${platformId})`);
|
|
@@ -25119,6 +25124,7 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
25119
25124
|
return false;
|
|
25120
25125
|
} else {
|
|
25121
25126
|
if (data6.path !== void 0) {
|
|
25127
|
+
const _errs16 = errors2;
|
|
25122
25128
|
if (typeof data6.path !== "string") {
|
|
25123
25129
|
validate25.errors = [
|
|
25124
25130
|
{
|
|
@@ -25131,6 +25137,67 @@ function validate25(data, { instancePath = "", parentData, parentDataProperty, r
|
|
|
25131
25137
|
];
|
|
25132
25138
|
return false;
|
|
25133
25139
|
}
|
|
25140
|
+
var valid4 = _errs16 === errors2;
|
|
25141
|
+
} else {
|
|
25142
|
+
var valid4 = true;
|
|
25143
|
+
}
|
|
25144
|
+
if (valid4) {
|
|
25145
|
+
if (data6.description !== void 0) {
|
|
25146
|
+
const _errs18 = errors2;
|
|
25147
|
+
if (typeof data6.description !== "string") {
|
|
25148
|
+
validate25.errors = [
|
|
25149
|
+
{
|
|
25150
|
+
instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/description",
|
|
25151
|
+
schemaPath: "#/properties/components/additionalProperties/properties/description/type",
|
|
25152
|
+
keyword: "type",
|
|
25153
|
+
params: { type: "string" },
|
|
25154
|
+
message: "must be string"
|
|
25155
|
+
}
|
|
25156
|
+
];
|
|
25157
|
+
return false;
|
|
25158
|
+
}
|
|
25159
|
+
var valid4 = _errs18 === errors2;
|
|
25160
|
+
} else {
|
|
25161
|
+
var valid4 = true;
|
|
25162
|
+
}
|
|
25163
|
+
if (valid4) {
|
|
25164
|
+
if (data6.supports !== void 0) {
|
|
25165
|
+
let data9 = data6.supports;
|
|
25166
|
+
const _errs20 = errors2;
|
|
25167
|
+
{
|
|
25168
|
+
if (data9 && typeof data9 == "object" && !Array.isArray(data9)) {
|
|
25169
|
+
if (data9.children !== void 0) {
|
|
25170
|
+
if (typeof data9.children !== "boolean") {
|
|
25171
|
+
validate25.errors = [
|
|
25172
|
+
{
|
|
25173
|
+
instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/supports/children",
|
|
25174
|
+
schemaPath: "#/properties/components/additionalProperties/properties/supports/properties/children/type",
|
|
25175
|
+
keyword: "type",
|
|
25176
|
+
params: { type: "boolean" },
|
|
25177
|
+
message: "must be boolean"
|
|
25178
|
+
}
|
|
25179
|
+
];
|
|
25180
|
+
return false;
|
|
25181
|
+
}
|
|
25182
|
+
}
|
|
25183
|
+
} else {
|
|
25184
|
+
validate25.errors = [
|
|
25185
|
+
{
|
|
25186
|
+
instancePath: instancePath + "/components/" + key0.replace(/~/g, "~0").replace(/\//g, "~1") + "/supports",
|
|
25187
|
+
schemaPath: "#/properties/components/additionalProperties/properties/supports/type",
|
|
25188
|
+
keyword: "type",
|
|
25189
|
+
params: { type: "object" },
|
|
25190
|
+
message: "must be object"
|
|
25191
|
+
}
|
|
25192
|
+
];
|
|
25193
|
+
return false;
|
|
25194
|
+
}
|
|
25195
|
+
}
|
|
25196
|
+
var valid4 = _errs20 === errors2;
|
|
25197
|
+
} else {
|
|
25198
|
+
var valid4 = true;
|
|
25199
|
+
}
|
|
25200
|
+
}
|
|
25134
25201
|
}
|
|
25135
25202
|
}
|
|
25136
25203
|
} else {
|
|
@@ -25255,8 +25322,8 @@ const numberExpressionSchema = {
|
|
|
25255
25322
|
const $schema$8 = "https://json-schema.org/draft/2020-12/schema";
|
|
25256
25323
|
const $id$9 = "/expressions/string-expression.json";
|
|
25257
25324
|
const title$8 = "StringExpression";
|
|
25258
|
-
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" }];
|
|
25259
|
-
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"] } };
|
|
25325
|
+
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" }];
|
|
25326
|
+
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"] } };
|
|
25260
25327
|
const stringExpressionSchema = {
|
|
25261
25328
|
$schema: $schema$8,
|
|
25262
25329
|
$id: $id$9,
|
|
@@ -60991,82 +61058,185 @@ const createUser = async (opts, env2) => {
|
|
|
60991
61058
|
process.exit(1);
|
|
60992
61059
|
}
|
|
60993
61060
|
};
|
|
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
|
-
|
|
61061
|
+
const permissionExtensionCreate = {
|
|
61062
|
+
object: "Extension",
|
|
61063
|
+
action: "create"
|
|
61064
|
+
};
|
|
61065
|
+
const permissionExtensionCreateVersion = {
|
|
61066
|
+
object: "Extension",
|
|
61067
|
+
action: "createVersion"
|
|
61068
|
+
};
|
|
61069
|
+
const permissionSiteCreate = {
|
|
61070
|
+
object: "Site",
|
|
61071
|
+
action: "create"
|
|
61072
|
+
};
|
|
61073
|
+
const permissionTemplateCreate = {
|
|
61074
|
+
object: "Template",
|
|
61075
|
+
action: "create"
|
|
61076
|
+
};
|
|
61077
|
+
const permissionUserCreate = {
|
|
61078
|
+
object: "User",
|
|
61079
|
+
action: "create"
|
|
61080
|
+
};
|
|
61081
|
+
const permissionPlatformEdit = {
|
|
61082
|
+
object: "Platform",
|
|
61083
|
+
action: "edit"
|
|
61084
|
+
};
|
|
61085
|
+
const permissionComponentEdit = {
|
|
61086
|
+
object: "Component",
|
|
61087
|
+
action: "edit"
|
|
61088
|
+
};
|
|
61089
|
+
const permissionCourseEdit = {
|
|
61090
|
+
object: "Course",
|
|
61091
|
+
action: "edit"
|
|
61092
|
+
};
|
|
61093
|
+
const permissionCustomComponentEdit = {
|
|
61094
|
+
object: "CustomComponent",
|
|
61095
|
+
action: "edit"
|
|
61096
|
+
};
|
|
61097
|
+
const permissionCustomFieldEdit = {
|
|
61098
|
+
object: "CustomField",
|
|
61099
|
+
action: "edit"
|
|
61100
|
+
};
|
|
61101
|
+
const permissionCustomerSiteEdit = {
|
|
61102
|
+
object: "CustomerSite",
|
|
61103
|
+
action: "edit"
|
|
61104
|
+
};
|
|
61105
|
+
const permissionExtensionEdit = {
|
|
61106
|
+
object: "Extension",
|
|
61107
|
+
action: "edit"
|
|
61108
|
+
};
|
|
61109
|
+
const permissionHelpTicketEditStatus = {
|
|
61110
|
+
object: "HelpTicket",
|
|
61111
|
+
action: "editStatus"
|
|
61112
|
+
};
|
|
61113
|
+
const permissionPlatformSiteEdit = {
|
|
61114
|
+
object: "PlatformSite",
|
|
61115
|
+
action: "edit"
|
|
61116
|
+
};
|
|
61117
|
+
const permissionSequenceEdit = {
|
|
61118
|
+
object: "Sequence",
|
|
61119
|
+
action: "edit"
|
|
61120
|
+
};
|
|
61121
|
+
const permissionSequenceUserEdit = {
|
|
61122
|
+
object: "SequenceUser",
|
|
61123
|
+
action: "edit"
|
|
61124
|
+
};
|
|
61125
|
+
const permissionSiteEdit = {
|
|
61126
|
+
object: "Site",
|
|
61127
|
+
action: "edit"
|
|
61061
61128
|
};
|
|
61062
|
-
const
|
|
61129
|
+
const permissionSiteEditDomain = {
|
|
61130
|
+
object: "Site",
|
|
61131
|
+
action: "editDomain"
|
|
61132
|
+
};
|
|
61133
|
+
const permissionSiteEditTls = {
|
|
61134
|
+
object: "Site",
|
|
61135
|
+
action: "editTls"
|
|
61136
|
+
};
|
|
61137
|
+
const permissionSubscriptionEdit = {
|
|
61138
|
+
object: "Subscription",
|
|
61139
|
+
action: "edit"
|
|
61140
|
+
};
|
|
61141
|
+
const permissionTemplateEdit = {
|
|
61142
|
+
object: "Template",
|
|
61143
|
+
action: "edit"
|
|
61144
|
+
};
|
|
61145
|
+
const permissionUserEditEmail = {
|
|
61146
|
+
object: "User",
|
|
61147
|
+
action: "editEmail"
|
|
61148
|
+
};
|
|
61149
|
+
const permissionUserEditOrg = {
|
|
61150
|
+
object: "User",
|
|
61151
|
+
action: "editOrg"
|
|
61152
|
+
};
|
|
61153
|
+
const permissionUserEditStatus = {
|
|
61154
|
+
object: "User",
|
|
61155
|
+
action: "editStatus"
|
|
61156
|
+
};
|
|
61157
|
+
const permissionUserEditRole = {
|
|
61158
|
+
object: "User",
|
|
61159
|
+
action: "editRole"
|
|
61160
|
+
};
|
|
61161
|
+
const permissionUserEditProfile = {
|
|
61162
|
+
object: "User",
|
|
61163
|
+
action: "editProfile"
|
|
61164
|
+
};
|
|
61165
|
+
const permissionUserEditCustomFields = {
|
|
61166
|
+
object: "User",
|
|
61167
|
+
action: "editCustomFields"
|
|
61168
|
+
};
|
|
61169
|
+
const permissionFormTemplateSync = {
|
|
61170
|
+
object: "FormTemplate",
|
|
61171
|
+
action: "sync"
|
|
61172
|
+
};
|
|
61173
|
+
const permissionPageTemplateSync = {
|
|
61174
|
+
object: "PageTemplate",
|
|
61175
|
+
action: "sync"
|
|
61176
|
+
};
|
|
61177
|
+
const permissionPlatformView = {
|
|
61178
|
+
object: "Platform",
|
|
61179
|
+
action: "view"
|
|
61180
|
+
};
|
|
61181
|
+
const permissionCourseView = {
|
|
61182
|
+
object: "Course",
|
|
61183
|
+
action: "view"
|
|
61184
|
+
};
|
|
61185
|
+
const permissionExtensionView = {
|
|
61186
|
+
object: "Extension",
|
|
61187
|
+
action: "view"
|
|
61188
|
+
};
|
|
61189
|
+
const permissionSiteView = {
|
|
61190
|
+
object: "Site",
|
|
61191
|
+
action: "view"
|
|
61192
|
+
};
|
|
61193
|
+
const permissionTemplateView = {
|
|
61194
|
+
object: "Template",
|
|
61195
|
+
action: "view"
|
|
61196
|
+
};
|
|
61197
|
+
const allPermissions = [
|
|
61198
|
+
permissionExtensionCreate,
|
|
61199
|
+
permissionExtensionCreateVersion,
|
|
61200
|
+
permissionSiteCreate,
|
|
61201
|
+
permissionTemplateCreate,
|
|
61202
|
+
permissionUserCreate,
|
|
61203
|
+
permissionPlatformEdit,
|
|
61204
|
+
permissionComponentEdit,
|
|
61205
|
+
permissionCourseEdit,
|
|
61206
|
+
permissionCustomComponentEdit,
|
|
61207
|
+
permissionCustomFieldEdit,
|
|
61208
|
+
permissionCustomerSiteEdit,
|
|
61209
|
+
permissionExtensionEdit,
|
|
61210
|
+
permissionHelpTicketEditStatus,
|
|
61211
|
+
permissionPlatformSiteEdit,
|
|
61212
|
+
permissionSequenceEdit,
|
|
61213
|
+
permissionSequenceUserEdit,
|
|
61214
|
+
permissionSiteEdit,
|
|
61215
|
+
permissionSiteEditDomain,
|
|
61216
|
+
permissionSiteEditTls,
|
|
61217
|
+
permissionSubscriptionEdit,
|
|
61218
|
+
permissionTemplateEdit,
|
|
61219
|
+
permissionUserEditEmail,
|
|
61220
|
+
permissionUserEditOrg,
|
|
61221
|
+
permissionUserEditStatus,
|
|
61222
|
+
permissionUserEditRole,
|
|
61223
|
+
permissionUserEditProfile,
|
|
61224
|
+
permissionUserEditCustomFields,
|
|
61225
|
+
permissionFormTemplateSync,
|
|
61226
|
+
permissionPageTemplateSync,
|
|
61227
|
+
permissionPlatformView,
|
|
61228
|
+
permissionCourseView,
|
|
61229
|
+
permissionExtensionView,
|
|
61230
|
+
permissionSiteView,
|
|
61231
|
+
permissionTemplateView
|
|
61232
|
+
];
|
|
61063
61233
|
const revokeAllUserPlatformPermissions = async ({
|
|
61064
61234
|
platformAdminId
|
|
61065
61235
|
}, db) => {
|
|
61066
61236
|
await db.query(
|
|
61067
61237
|
distExports$1.sql.type(
|
|
61068
61238
|
voidSelectSchema
|
|
61069
|
-
)`delete from "
|
|
61239
|
+
)`delete from "Permissions" where "platformAdminId" = ${platformAdminId}`
|
|
61070
61240
|
);
|
|
61071
61241
|
};
|
|
61072
61242
|
const grantAllUserPlatformPermissions = async ({
|
|
@@ -61075,12 +61245,12 @@ const grantAllUserPlatformPermissions = async ({
|
|
|
61075
61245
|
await db.query(
|
|
61076
61246
|
distExports$1.sql.type(
|
|
61077
61247
|
voidSelectSchema
|
|
61078
|
-
)`insert into "
|
|
61248
|
+
)`insert into "Permissions" ("id", "platformAdminId", "object", "action") values ${distExports$1.sql.join(
|
|
61079
61249
|
allPermissions.map(
|
|
61080
|
-
(permission) => distExports$1.sql.fragment`(${cleanSmallId()}, ${platformAdminId}, ${permission})`
|
|
61250
|
+
(permission) => distExports$1.sql.fragment`(${cleanSmallId()}, ${platformAdminId}, ${permission.object}, ${permission.action})`
|
|
61081
61251
|
),
|
|
61082
61252
|
distExports$1.sql.fragment`,`
|
|
61083
|
-
)} on conflict ("platformAdminId", "
|
|
61253
|
+
)} on conflict ("platformAdminId", "object", "action") do nothing`
|
|
61084
61254
|
);
|
|
61085
61255
|
};
|
|
61086
61256
|
const findPlatformAdminSchema = z.object({
|
|
@@ -61120,10 +61290,18 @@ const editAdmin = async (opts, env2) => {
|
|
|
61120
61290
|
platformAdmin = await db2.one(
|
|
61121
61291
|
distExports$1.sql.type(findPlatformAdminSchema)`
|
|
61122
61292
|
insert into "PlatformAdmins" ("id", "platformId", "userId", "owner", "active")
|
|
61123
|
-
values (${cleanSmallId()}, ${platformId}, ${userId}, ${active ?? true}
|
|
61293
|
+
values (${cleanSmallId()}, ${platformId}, ${userId}, true, ${active ?? true})
|
|
61124
61294
|
returning "id", "platformId", "active"
|
|
61125
61295
|
`
|
|
61126
61296
|
);
|
|
61297
|
+
} else {
|
|
61298
|
+
await db2.query(
|
|
61299
|
+
distExports$1.sql.type(voidSelectSchema)`
|
|
61300
|
+
update "PlatformAdmins"
|
|
61301
|
+
set "owner" = true
|
|
61302
|
+
where "id" = ${platformAdmin.id}
|
|
61303
|
+
`
|
|
61304
|
+
);
|
|
61127
61305
|
}
|
|
61128
61306
|
await grantAllUserPlatformPermissions({ platformAdminId: platformAdmin.id }, db2);
|
|
61129
61307
|
if (opts.verbose) {
|
|
@@ -61246,13 +61424,13 @@ const initExtDb = async ({
|
|
|
61246
61424
|
create foreign table if not exists "Orgs" (
|
|
61247
61425
|
"id" text not null,
|
|
61248
61426
|
"name" text,
|
|
61249
|
-
"primaryUserId"
|
|
61427
|
+
"primaryUserId" uuid,
|
|
61250
61428
|
"createdAt" timestamptz not null
|
|
61251
61429
|
) server wirechunk options (schema_name 'public', table_name 'Orgs')
|
|
61252
61430
|
`);
|
|
61253
61431
|
await db.query(distExports$1.sql.unsafe`
|
|
61254
61432
|
create foreign table if not exists "Sites" (
|
|
61255
|
-
"id"
|
|
61433
|
+
"id" text not null,
|
|
61256
61434
|
"domain" text not null,
|
|
61257
61435
|
"orgId" text,
|
|
61258
61436
|
"name" text not null,
|
package/package.json
CHANGED
|
@@ -2,10 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { cleanTinyId } from '@wirechunk/lib/clean-small-id.ts';
|
|
3
3
|
import { normalizeDomain } from '@wirechunk/lib/domains.ts';
|
|
4
4
|
import { normalizeEmailAddress } from '@wirechunk/lib/emails.ts';
|
|
5
|
-
import {
|
|
6
|
-
defaultFormattedDataTemplate,
|
|
7
|
-
defaultNotificationEmailBodyTemplate,
|
|
8
|
-
} from '@wirechunk/lib/mixer/form-formatting-templates.ts';
|
|
5
|
+
import { defaultNotificationEmailBodyTemplate } from '@wirechunk/lib/mixer/form-formatting-templates.ts';
|
|
9
6
|
import type { DatabasePool } from 'slonik';
|
|
10
7
|
import { createPool, sql } from 'slonik';
|
|
11
8
|
import type { Env } from '../env.ts';
|
|
@@ -23,6 +20,7 @@ const randomString = () => randomUUID().replaceAll('-', '').slice(0, 10);
|
|
|
23
20
|
type BootstrapOptions = {
|
|
24
21
|
name: string;
|
|
25
22
|
handle?: string;
|
|
23
|
+
// TODO: Require this be set in the environment instead.
|
|
26
24
|
adminSiteDomain: string;
|
|
27
25
|
emailSendFrom?: string;
|
|
28
26
|
};
|
|
@@ -61,19 +59,25 @@ export const bootstrap = async (
|
|
|
61
59
|
} else {
|
|
62
60
|
emailSendFrom = `site@${adminSiteDomain}`;
|
|
63
61
|
}
|
|
64
|
-
const adminSiteName = `${name} Admin`;
|
|
65
62
|
|
|
66
63
|
await db.transaction(async (db) => {
|
|
67
64
|
await db.query(
|
|
68
|
-
sql.type(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
sql.type(voidSelectSchema)`
|
|
66
|
+
insert into "Platforms" (
|
|
67
|
+
"id",
|
|
68
|
+
"handle",
|
|
69
|
+
"name",
|
|
70
|
+
"defaultFormNotificationEmailBodyTemplate",
|
|
71
|
+
"emailSendFromAddress"
|
|
72
|
+
)
|
|
73
|
+
values (
|
|
74
|
+
${platformId},
|
|
75
|
+
${handle},
|
|
76
|
+
${name},
|
|
77
|
+
${defaultNotificationEmailBodyTemplate},
|
|
78
|
+
${emailSendFrom}
|
|
79
|
+
)
|
|
80
|
+
`,
|
|
77
81
|
);
|
|
78
82
|
});
|
|
79
83
|
|
|
@@ -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) {
|
|
@@ -59,13 +59,13 @@ const initExtDb = async ({
|
|
|
59
59
|
create foreign table if not exists "Orgs" (
|
|
60
60
|
"id" text not null,
|
|
61
61
|
"name" text,
|
|
62
|
-
"primaryUserId"
|
|
62
|
+
"primaryUserId" uuid,
|
|
63
63
|
"createdAt" timestamptz not null
|
|
64
64
|
) server wirechunk options (schema_name 'public', table_name 'Orgs')
|
|
65
65
|
`);
|
|
66
66
|
await db.query(sql.unsafe`
|
|
67
67
|
create foreign table if not exists "Sites" (
|
|
68
|
-
"id"
|
|
68
|
+
"id" text not null,
|
|
69
69
|
"domain" text not null,
|
|
70
70
|
"orgId" text,
|
|
71
71
|
"name" text not null,
|