feat: add platform capability contracts

This commit is contained in:
2026-04-28 11:17:07 +00:00
parent 251e08894a
commit 95a053d6bb
19 changed files with 340 additions and 3 deletions
+3
View File
@@ -8,6 +8,9 @@ tap.test('exports public namespaces', async () => {
if (!interfaces.requests) {
throw new Error('Missing requests namespace');
}
if (!interfaces.platform) {
throw new Error('Missing platform namespace');
}
if (!interfaces.platformservice) {
throw new Error('Missing platformservice namespace');
}
+2
View File
@@ -1,9 +1,11 @@
import * as data from './data/index.js';
import * as platform from './platform/index.js';
import * as platformservice from './platformservice/index.js';
import * as requests from './requests/index.js';
export {
data,
platform,
platformservice,
requests
}
+23
View File
@@ -0,0 +1,23 @@
import * as plugins from '../plugins.js';
export interface IChat {
systemMessage: string;
messages: {
role: 'assistant' | 'user';
content: string;
}[];
}
export interface IReq_Chat extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_Chat
> {
method: 'chat';
request: {
chat: IChat;
};
response: {
chat: IChat;
latestMessage: string;
};
}
+10
View File
@@ -0,0 +1,10 @@
export type TPlatformBackupTarget = 'volume' | 'database' | 'bucket';
export interface IPlatformBackupBindingConfig {
targets: Array<{
type: TPlatformBackupTarget;
name: string;
}>;
schedule: string;
retentionDays?: number;
}
+8
View File
@@ -0,0 +1,8 @@
export type TPlatformDatabaseEngine = 'postgres' | 'mongodb' | 'mysql' | 'redis';
export interface IPlatformDatabaseBindingConfig {
engine: TPlatformDatabaseEngine;
databaseName?: string;
version?: string;
extensions?: string[];
}
+73
View File
@@ -0,0 +1,73 @@
import * as plugins from '../plugins.js';
export type TTemplates = 'default' | 'linkaction' | 'notification';
export interface IReq_SendEmail extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_SendEmail
> {
method: 'sendEmail';
request: {
title: string;
from: string;
to: string;
body: string;
attachments?: Array<{
name: string;
binaryAttachmentString: string;
}>;
};
response: {
responseId: string;
};
}
export interface IReq_RegisterRecipient extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_RegisterRecipient
> {
method: 'registerRecipient';
request: {
emailAddress: string;
};
response: {
status: 'ok' | 'not ok';
};
}
export interface IReq_CheckEmailStatus extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_CheckEmailStatus
> {
method: 'checkEmailStatus';
request: {
emailId: string;
};
response: {
status: string;
details?: { message: string };
};
}
export interface IReq_GetEmailStats extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_GetEmailStats
> {
method: 'getEmailStats';
request: {
jwt: string;
};
response: {
totalEmailsSent: number;
totalEmailsDelivered: number;
totalEmailsBounced: number;
averageDeliveryTimeMs: number;
lastUpdated: string;
};
}
export type IReq_GetEMailStats = IReq_GetEmailStats;
export type IRequest_SendEmail = IReq_SendEmail;
export type IRequest_RegisterRecipient = IReq_RegisterRecipient;
export type IRequest_CheckEmailStatus = IReq_CheckEmailStatus;
export type IRequest_GetEMailStats = IReq_GetEmailStats;
+27
View File
@@ -0,0 +1,27 @@
import * as ai from './ai.js';
import * as backup from './backup.js';
import * as database from './database.js';
import * as email from './email.js';
import * as letter from './letter.js';
import * as logging from './logging.js';
import * as objectstorage from './objectstorage.js';
import * as pushnotification from './pushnotification.js';
import * as sip from './sip.js';
import * as sms from './sms.js';
import * as types from './types.js';
export {
ai,
backup,
database,
email,
letter,
logging,
objectstorage,
pushnotification,
sip,
sms,
types,
};
export * from './types.js';
+26
View File
@@ -0,0 +1,26 @@
import * as plugins from '../plugins.js';
export interface IReq_SendLetter extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_SendLetter
> {
method: 'sendLetter';
request: {
description: string;
needsCover: boolean;
title?: string;
from?: plugins.tsclass.business.IAddress;
to?: plugins.tsclass.business.IAddress;
coverBody?: string;
service: 'Einschreiben'[];
pdfAttachments?: Array<{
name: string;
binaryAttachmentString: string;
}>;
};
response: {
processId: string;
};
}
export type IRequest_SendLetter = IReq_SendLetter;
+5
View File
@@ -0,0 +1,5 @@
export interface IPlatformLoggingBindingConfig {
streams?: string[];
retentionDays?: number;
exposeQueryEndpoint?: boolean;
}
+6
View File
@@ -0,0 +1,6 @@
export interface IPlatformObjectStorageBindingConfig {
bucketName?: string;
region?: string;
publicRead?: boolean;
versioning?: boolean;
}
+18
View File
@@ -0,0 +1,18 @@
import * as plugins from '../plugins.js';
export interface IReq_SendPushNotification extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_SendPushNotification
> {
method: 'sendPushNotification';
request: {
deviceToken: string;
message: string;
};
response: {
ok: boolean;
status: string;
};
}
export type IRequest_SendPushNotification = IReq_SendPushNotification;
+6
View File
@@ -0,0 +1,6 @@
export interface IPlatformSipBindingConfig {
trunkId?: string;
extension?: string;
inboundNumbers?: string[];
outboundCallerId?: string;
}
+34
View File
@@ -0,0 +1,34 @@
import * as plugins from '../plugins.js';
export interface IReq_SendSms extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_SendSms
> {
method: 'sendSms';
request: {
toNumber: number;
fromName: string;
messageText: string;
};
response: {
status: 'ok' | 'not ok';
};
}
export interface IReq_SendVerificationCode extends plugins.typedrequestInterfaces.implementsTR<
plugins.typedrequestInterfaces.ITypedRequest,
IReq_SendVerificationCode
> {
method: 'sendVerificationCode';
request: {
toNumber: number;
fromName: string;
};
response: {
status: 'ok' | 'not ok';
verificationCode: string;
};
}
export type IRequest_SendSms = IReq_SendSms;
export type IRequest_SendVerificationCode = IReq_SendVerificationCode;
+82
View File
@@ -0,0 +1,82 @@
export type TPlatformCapability =
| 'email'
| 'sms'
| 'pushnotification'
| 'letter'
| 'ai'
| 'database'
| 'objectstorage'
| 'logging'
| 'backup'
| 'sip';
export type TPlatformAccessMode = 'rpc' | 'binding' | 'sidecar' | 'internal';
export type TPlatformBindingStatus = 'requested' | 'provisioning' | 'ready' | 'degraded' | 'failed' | 'disabled';
export type TPlatformDesiredState = 'enabled' | 'disabled';
export type TPlatformEndpointProtocol =
| 'typedrequest'
| 'http'
| 'tcp'
| 'udp'
| 'smtp'
| 's3'
| 'postgres'
| 'mongodb'
| 'sip';
export type TPlatformConfigValue =
| string
| number
| boolean
| null
| TPlatformConfigValue[]
| { [key: string]: TPlatformConfigValue };
export interface IPlatformCapability {
id: TPlatformCapability;
title: string;
description?: string;
accessMode: TPlatformAccessMode;
defaultProviderType?: string;
}
export interface IPlatformProviderConfig {
id: string;
capability: TPlatformCapability;
providerType: string;
name: string;
enabled: boolean;
config?: { [key: string]: TPlatformConfigValue };
secretBundleId?: string;
}
export interface IPlatformCredentialRef {
secretBundleId?: string;
secretGroupIds?: string[];
dockerSecretName?: string;
env?: { [key: string]: string };
}
export interface IPlatformServiceEndpoint {
name: string;
capability: TPlatformCapability;
protocol: TPlatformEndpointProtocol;
internalUrl?: string;
externalUrl?: string;
networkAlias?: string;
port?: number;
}
export interface IPlatformBinding {
id: string;
serviceId: string;
capability: TPlatformCapability;
desiredState: TPlatformDesiredState;
status: TPlatformBindingStatus;
providerConfigId?: string;
config?: { [key: string]: TPlatformConfigValue };
endpoints?: IPlatformServiceEndpoint[];
credentials?: IPlatformCredentialRef[];
createdAt?: number;
updatedAt?: number;
}
+3 -1
View File
@@ -20,4 +20,6 @@ export interface IReq_Chat extends plugins.typedrequestInterfaces.implementsTR<
chat: IChat;
latestMessage: string;
}
}
}
export type IRequest_Chat = IReq_Chat;
+3 -1
View File
@@ -31,4 +31,6 @@ export interface IRequest_SendLetter extends plugins.typedrequestInterfaces.impl
*/
processId: string;
};
}
}
export type IReq_SendLetter = IRequest_SendLetter;
+5
View File
@@ -68,3 +68,8 @@ export interface IReq_GetEMailStats extends plugins.typedrequestInterfaces.imple
lastUpdated: string;
};
}
export type IRequest_SendEmail = IReq_SendEmail;
export type IRequest_RegisterRecipient = IReq_RegisterRecipient;
export type IRequest_CheckEmailStatus = IReq_CheckEmailStatus;
export type IRequest_GetEMailStats = IReq_GetEMailStats;
+3 -1
View File
@@ -13,4 +13,6 @@ export interface IRequest_SendPushNotification extends plugins.typedrequestInter
ok: boolean;
status: string;
}
}
}
export type IReq_SendPushNotification = IRequest_SendPushNotification;
+3
View File
@@ -31,3 +31,6 @@ export interface IRequest_SendSms
verificationCode: string;
}
}
export type IReq_SendSms = IRequest_SendSms;
export type IReq_SendVerificationCode = IRequest_SendVerificationCode;