@mitralab.io/sdk-core 0.2.15 → 0.2.17-beta.0
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/CHANGELOG.md +37 -0
- package/README.md +5 -3
- package/contracts/README.md +10 -0
- package/contracts/manifest.json +11 -1
- package/contracts/v0.2.16-beta.0/sdk-parity.json +2902 -0
- package/contracts/v0.2.17-beta.0/sdk-parity.json +2902 -0
- package/dist/index.cjs +116 -1
- package/dist/index.d.cts +118 -2
- package/dist/index.d.ts +118 -2
- package/dist/index.js +116 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -430,6 +430,14 @@ function expectAppSummary(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
|
430
430
|
if (typeof app.tenantId !== "string") invalidField(context, "tenantId", errors);
|
|
431
431
|
return app;
|
|
432
432
|
}
|
|
433
|
+
var LOGIN_THEME_FIELDS = [
|
|
434
|
+
"logoUrl",
|
|
435
|
+
"backgroundColor",
|
|
436
|
+
"colorScheme",
|
|
437
|
+
"title",
|
|
438
|
+
"subtitle",
|
|
439
|
+
"language"
|
|
440
|
+
];
|
|
433
441
|
function expectAppFields(app, context, errors) {
|
|
434
442
|
for (const field of ["id", "shortId", "subdomain", "brand", "name", "planId"]) {
|
|
435
443
|
if (typeof app[field] !== "string") invalidField(context, field, errors);
|
|
@@ -442,6 +450,15 @@ function expectAppFields(app, context, errors) {
|
|
|
442
450
|
for (const field of ["emailLoginEnabled", "passwordLoginEnabled"]) {
|
|
443
451
|
if (field in app && typeof app[field] !== "boolean") invalidField(context, field, errors);
|
|
444
452
|
}
|
|
453
|
+
if ("passwordLoginMode" in app && typeof app.passwordLoginMode !== "string") {
|
|
454
|
+
invalidField(context, "passwordLoginMode", errors);
|
|
455
|
+
}
|
|
456
|
+
if ("loginTheme" in app && app.loginTheme !== null) {
|
|
457
|
+
const theme = expectObject(app.loginTheme, `${context} loginTheme`, errors);
|
|
458
|
+
for (const field of LOGIN_THEME_FIELDS) {
|
|
459
|
+
if (!isNullableString(theme[field])) invalidField(`${context} loginTheme`, field, errors);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
445
462
|
if (typeof app.externalAccessEnabled !== "boolean") {
|
|
446
463
|
invalidField(context, "externalAccessEnabled", errors);
|
|
447
464
|
}
|
|
@@ -726,6 +743,41 @@ function expectEmailTemplatePreview(value, context, errors = defaultSdkCoreError
|
|
|
726
743
|
if (!isNullableString(preview.textBody)) invalidField(context, "textBody", errors);
|
|
727
744
|
return preview;
|
|
728
745
|
}
|
|
746
|
+
function expectEmailSender(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
747
|
+
const sender = expectObject(value, context, errors);
|
|
748
|
+
if (typeof sender.id !== "string") invalidField(context, "id", errors);
|
|
749
|
+
if (typeof sender.email !== "string") invalidField(context, "email", errors);
|
|
750
|
+
if (typeof sender.displayName !== "string") invalidField(context, "displayName", errors);
|
|
751
|
+
if (!isNonEmptyString(sender.status)) invalidField(context, "status", errors);
|
|
752
|
+
if (typeof sender.sharedWithCurrentWorkspace !== "boolean") {
|
|
753
|
+
invalidField(context, "sharedWithCurrentWorkspace", errors);
|
|
754
|
+
}
|
|
755
|
+
if (typeof sender.ownerConfirmationPending !== "boolean") {
|
|
756
|
+
invalidField(context, "ownerConfirmationPending", errors);
|
|
757
|
+
}
|
|
758
|
+
if (typeof sender.createdAt !== "string") invalidField(context, "createdAt", errors);
|
|
759
|
+
if (typeof sender.updatedAt !== "string") invalidField(context, "updatedAt", errors);
|
|
760
|
+
return sender;
|
|
761
|
+
}
|
|
762
|
+
function expectEmailSettings(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
763
|
+
const settings = expectObject(value, context, errors);
|
|
764
|
+
if (typeof settings.appId !== "string") invalidField(context, "appId", errors);
|
|
765
|
+
if (!isNullableString(settings.senderIdentityId)) {
|
|
766
|
+
invalidField(context, "senderIdentityId", errors);
|
|
767
|
+
}
|
|
768
|
+
if (!isNullableString(settings.displayName)) invalidField(context, "displayName", errors);
|
|
769
|
+
if (!isNullableString(settings.replyTo)) invalidField(context, "replyTo", errors);
|
|
770
|
+
if (typeof settings.ownTemplateSendsFromBrand !== "boolean") {
|
|
771
|
+
invalidField(context, "ownTemplateSendsFromBrand", errors);
|
|
772
|
+
}
|
|
773
|
+
const senderContext = `${context} effectiveSender`;
|
|
774
|
+
const sender = expectObject(settings.effectiveSender, senderContext, errors);
|
|
775
|
+
if (typeof sender.email !== "string") invalidField(senderContext, "email", errors);
|
|
776
|
+
if (!isNullableString(sender.displayName)) invalidField(senderContext, "displayName", errors);
|
|
777
|
+
if (!isNonEmptyString(sender.source)) invalidField(senderContext, "source", errors);
|
|
778
|
+
if (!isNullableString(sender.reason)) invalidField(senderContext, "reason", errors);
|
|
779
|
+
return settings;
|
|
780
|
+
}
|
|
729
781
|
function expectAgentDefinition(value, context, errors = defaultSdkCoreErrorFactory) {
|
|
730
782
|
const agent = expectObject(value, context, errors);
|
|
731
783
|
if (typeof agent.id !== "string") invalidField(context, "id", errors);
|
|
@@ -2899,11 +2951,13 @@ function createMembersModule(transport, errors = defaultSdkCoreErrorFactory) {
|
|
|
2899
2951
|
// src/modules/messenger.ts
|
|
2900
2952
|
function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory, getAppId) {
|
|
2901
2953
|
const templatePath = (type) => `/api/v1/email/templates/${encodePathSegment(type, "email template type", errors)}`;
|
|
2954
|
+
const senderPath = (senderId) => `/api/v1/email/identities/${encodePathSegment(senderId, "email sender id", errors)}`;
|
|
2902
2955
|
const currentAppId = () => {
|
|
2903
2956
|
const appId = getAppId?.();
|
|
2904
|
-
if (!appId) configurationError("An appId is required for email
|
|
2957
|
+
if (!appId) configurationError("An appId is required for app email calls", errors);
|
|
2905
2958
|
return appId;
|
|
2906
2959
|
};
|
|
2960
|
+
const settingsPath = () => `/api/v1/email/apps/${encodePathSegment(currentAppId(), "app id", errors)}/settings`;
|
|
2907
2961
|
const preview = async (type, appId) => expectEmailTemplatePreview(
|
|
2908
2962
|
await transport.request(`${templatePath(type)}/preview`, {
|
|
2909
2963
|
method: "GET",
|
|
@@ -2992,6 +3046,60 @@ function createMessengerModule(transport, errors = defaultSdkCoreErrorFactory, g
|
|
|
2992
3046
|
"Delete email template response",
|
|
2993
3047
|
errors
|
|
2994
3048
|
);
|
|
3049
|
+
},
|
|
3050
|
+
async listEmailSenders() {
|
|
3051
|
+
return expectObjectArray(
|
|
3052
|
+
await transport.request("/api/v1/email/identities/workspace", { method: "GET" }),
|
|
3053
|
+
"Email sender list response",
|
|
3054
|
+
errors,
|
|
3055
|
+
expectEmailSender
|
|
3056
|
+
);
|
|
3057
|
+
},
|
|
3058
|
+
async registerEmailSender(input) {
|
|
3059
|
+
return expectEmailSender(
|
|
3060
|
+
await transport.request("/api/v1/email/identities", {
|
|
3061
|
+
method: "POST",
|
|
3062
|
+
body: { email: input.email, displayName: input.displayName }
|
|
3063
|
+
}),
|
|
3064
|
+
"Register email sender response",
|
|
3065
|
+
errors
|
|
3066
|
+
);
|
|
3067
|
+
},
|
|
3068
|
+
async resendEmailSenderVerification(senderId) {
|
|
3069
|
+
return expectEmailSender(
|
|
3070
|
+
await transport.request(`${senderPath(senderId)}/resend-verification`, {
|
|
3071
|
+
method: "POST"
|
|
3072
|
+
}),
|
|
3073
|
+
"Resend email sender verification response",
|
|
3074
|
+
errors
|
|
3075
|
+
);
|
|
3076
|
+
},
|
|
3077
|
+
async confirmEmailSender(senderId, code) {
|
|
3078
|
+
return expectEmailSender(
|
|
3079
|
+
await transport.request(`${senderPath(senderId)}/confirm`, {
|
|
3080
|
+
method: "POST",
|
|
3081
|
+
body: { code }
|
|
3082
|
+
}),
|
|
3083
|
+
"Confirm email sender response",
|
|
3084
|
+
errors
|
|
3085
|
+
);
|
|
3086
|
+
},
|
|
3087
|
+
async getEmailSettings() {
|
|
3088
|
+
return expectEmailSettings(
|
|
3089
|
+
await transport.request(settingsPath(), { method: "GET" }),
|
|
3090
|
+
"Email settings response",
|
|
3091
|
+
errors
|
|
3092
|
+
);
|
|
3093
|
+
},
|
|
3094
|
+
async updateEmailSettings(input) {
|
|
3095
|
+
return expectEmailSettings(
|
|
3096
|
+
await transport.request(settingsPath(), {
|
|
3097
|
+
method: "PUT",
|
|
3098
|
+
body: settingsBody(input)
|
|
3099
|
+
}),
|
|
3100
|
+
"Update email settings response",
|
|
3101
|
+
errors
|
|
3102
|
+
);
|
|
2995
3103
|
}
|
|
2996
3104
|
};
|
|
2997
3105
|
}
|
|
@@ -3015,6 +3123,13 @@ function templateBody(appId, input) {
|
|
|
3015
3123
|
...input.textBody === void 0 ? {} : { textBody: input.textBody }
|
|
3016
3124
|
};
|
|
3017
3125
|
}
|
|
3126
|
+
function settingsBody(input) {
|
|
3127
|
+
return {
|
|
3128
|
+
...input.senderIdentityId === void 0 ? {} : { senderIdentityId: input.senderIdentityId },
|
|
3129
|
+
...input.displayName === void 0 ? {} : { displayName: input.displayName },
|
|
3130
|
+
...input.replyTo === void 0 ? {} : { replyTo: input.replyTo }
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3018
3133
|
|
|
3019
3134
|
// src/modules/publicFunctions.ts
|
|
3020
3135
|
function createPublicFunctionsModule(transport, errors = defaultSdkCoreErrorFactory) {
|