Core Service - rettersoft/rbs-docs GitHub Wiki

Rbs Core Service

User Logout

rbs.core.request.LOGOUT_USER

if you want to remove all refresh tokens, you should set true of allTokens field

Input: Item

Item {
   "allTokens": boolean // optional
   "refreshToken": string // optional when 'allTokens' field was false or undefined
   "userId": string // for service calls only - 'allTokens' must be true
}

Get Project Detail

rbs.core.request.PROJECT_DETAIL

Input: No Input

Output: {
    projectId: string
    alias: string
    createdAt: string
}

Service Manifest

  • lifeCycleEvents if you set this field to 'false' you miss the INTALL/UNINSTALL actions. default: true

  • sendActionInPath if you set this field to 'true' you get the action in path. default: false {serviceHandler}/{action}

{
    ServiceManifestModel
    {
        id: string
        name: string
        description: string
        handler ? : string
        eventHandler ? : string
        actions: IActions
        secretKey: string
        pricing: IPricing[]
        links ? : ILinkItem[]
        serviceParameters ? : string[]
        dependsOn ? : string[]
        lifeCycleEvents ? : boolean
        sendActionInPath?: boolean
        schemaList: ServiceActionSchemaModel[]
    }

    ServiceActionSchemaModel{
        actions: string[]
        description: string
        input: object // JSON-Schema Draft-07
        output: object // JSON-Schema Draft-07
    }
 
    LinkItem
    {
        title: string
        url: string
    }

    Actions
    {
        sends: string[]
        receives: string[]
    }

    Pricing
    {
        action: string
        time ? : number
        qty ? : number
        tiers: ITierItem[]
    }

    TierItem
    {
        qtyLimit ? : number
        timeLimit ? : number
        price: number
        currency: string
    }
}

Project Template Sample

projectId: 9134654c6e004ea2805a4ae9ee3c3994
readmeMd: >
  Readme md
processSchemaList:
  - processId: string
    description: string
    input: {} //JSON Schema Draft-07
    output: {} //JSON Schema Draft-07
environments:
  apiKey: $PARAM(ApiKey)
  DummyUndefinedWithDefaultValue: $PARAM(DummyUndefinedWithDefaultValue, "DummyUndefinedWithDefaultValue-default-value")
  UndefinedValue: $PARAM(UndefinedValue)
  SuperUserId: $PARAM(superUserId)
logMasks:
  - query: $.foo // $ -> request Ex: {"foo": "bar"}
    maskWith: '#' // optional default *
    unmaskEnd: 1 // optional default 0 Ex: **r
    unmaskStart: 1 // optional default 0 Ex: b** 
logMapping:
  - key: 'param1'
    query: $.request.data.test
    rules:
      - context.action:
          EQ: rbs.core.request.TEST
subscriptions: 
  - subscriptionPath: "/collection_name"
    subscriptionType: SERVICE // ENUM
    subscriberId: rbs.test
    subscriptionStartingPosition: TRIM_HORIZON | LATEST //ENUM DEFAULT: LATEST
documents:
  - path: "/collection/{documentId}"
    data:
      test: string_data
accessDefinitions:
  - path: "/collection/{docId}"
    pathRules:
      - output:
          read: true
          write: true
        rules:
          - path.docId:
              EQ: $.context.tokenPayload.identity
roles:
  - roleName: test_role
    delegatedBy:
      - rbs.test
    permissions:
      sends:
        - rbs.*
      receives:
        - rbs.*
services:
  - serviceId: rbs.one
    attachedRoles:
      - test_role
    parameters:
      testParam: $ENV(apiKey)
  - serviceId: rbs.two
    parameters:
      testParam: $ENV(DummyUndefinedWithDefaultValue)
  - serviceId: rbs.three
    parameters:
      testParam: $ENV(UndefinedValue)
  - serviceId: rbs.four
    parameters:
      testParam: $ENV(undefined_valKsjmshhb, "default-env-value-valKsjmshhb")
  - serviceId: rbs.five


Rule Contexts


enum RtbsActionMethods {
    GET = 'get',
    EVENT = 'event',
    REQUEST = 'request'
}

enum CallerEnums {
    USER = "user",
    SERVICE = "service",
    UNKNOWN = "unknown"
}

// All string value's defaults are empty string ("") 
Context {
    processId: string
    processExecutionId: string
    userId: string
    auth: string
    projectId: string
    action: string
    actionContext: {
        method: RtbsActionMethods
        companyId: string
        modelName: string
        serviceId: string
        actionStern: string
        rawAction: string
    }
    caller: CallerEnums
    acceptLanguage: string
    sourceIp: string
    requestId: string
    contentLength: number
    requestTimeEpoch: number
    tokenPayload: {
        identity: string;
        anonymous: boolean;
        projectId: string;
        userId: string;
        timestamp: number;
        claims: { [key: string]: string }
    }
    targetServiceIds: string[]
    relatedUserId: string
    culture: string
    processExecutorId: string
}

Access Definition Rule Context

{   
    path: {}, // resolved path parameters
    context: Context
}

Log Mapping Rule Context

{
    context: Context
}

Rate Limit Options Sample

RBS Console > Project Detail > Roles & Definitions > Rate Limit Options

duration: milliseconds

{
  "whiteList": ["127.0.0.1"],
  "rateLimitOptions": [
    {
        "action": "rbs.core.request.PUT_*",
        "duration": 55,
        "max": 5
    },
    {
        "action": "rbs.core.*",
        "duration": 66,
        "max": 6
    },
    {
        "action": "*",
        "duration": 77,
        "max": 7
    }
]
}

Cache Invalidation

rbs.core.request.CREATE_INVALIDATION

Input: Item

Item {
    invalidation: string; //required
    S2S:          boolean; //required
    U2S:          boolean; //required
}


Output {
    Id:                string;
    Status:            string; // Completed | InProgress
    CreateTime:        Date;
    InvalidationBatch: InvalidationBatch;
}

InvalidationBatch {
    Paths:           Paths;
    CallerReference: string;
}

Paths {
    Quantity: number;
    Items:    string[];
}

rbs.core.request.GET_INVALIDATION

Input: Item

Item {
    id: string
}

Same output with rbs.core.request.CREATE_INVALIDATION

CoDB Actions

rbs.core.request.PUT_DOCUMENT

  • path format is:

/collection-name-1/document-name-1/.../collection-name-n/document-name-n

  • Allowed max depth (max 'n' is 5)

  • ⚠️If you set document name to {auto}, CoDB will generate sortable unique id.

  • ⚠️If you set field value to null, CoDB will delete the field.

  • Reserved data keys: "data", "part", "sort", "collection", "updatedAt", "createdAt", "updateToken", "deletedAt", "projectIdCollectionIndex", "_documentKey"

Input: Item

Item {
    path: string // required
    data: object // required
    ifNotExist: boolean // optional default: false
}

Output: {
    _documentKey: string
    path: string
    collection: string
    updateToken: string
    createdAt: string // ISO
    updatedAt: string // ISO
}

rbs.core.request.DOCUMENT

Input: Item

Item {
    path: string // required
}

Output: {
    data: object
    _documentKey: string
    path: string
    collection: string
    updateToken: string
    createdAt: string // ISO
    updatedAt: string // ISO
}

rbs.core.request.CONSISTENT_DOCUMENT


rbs.core.get.DOCUMENT

Get data from cache (cache ttl should be greater then 60 seconds and less then 86400 seconds)

Input: Item

Item
{
    cacheTtlInSeconds: number // optional - default:0
    path: string // required
}

Output: rbs.core.request.PUT_DOCUMENT


rbs.core.request.LIST_DOCUMENTS

  • ⚠️If limited items data size greater than 1Mb, CoDb will set limit automatically
Input: Item

Item {
    path: string // required
    limit: number //otional
    _paginationToken: string //otional
    startFromNewest: boolean //otional
}

Output: {
    data: string[] // document paths
    _paginationToken: string | null
} 

rbs.core.request.LIST_COLLECTIONS

Input: Item

Item {
    path: string // required
}

Output: {
    data: string[] // collection paths
} 

rbs.core.request.DELETE_DOCUMENT

Input: Item

Item {
    path: string // required
}

Output: no content 

rbs.core.request.DELETE_COLLECTION

Input: Item

Item {
 collectionPath:"/collection path" 
}

Output: no content 

User Socket Connections

User socket connection endpoint(test): wss://socket-test.rtbs.io?auth=<Auth Token>

rbs.core.request.USER_CONNECT_TO_SOCKET action must add to user send permissions for user socket connections.

You can use rbs.core.request.SEND_TO_SOCKET action for send message to user socket connections.

{
    "userId":string, // required
    "connectionId":string, // optional
    "message": any // required
}

Socket Events

  • rbs.core.event.USER_SOCKET_CONNECTED event raised when user connected.
  • rbs.core.event.USER_SOCKET_DISCONNECTED event raised when user disconnected.