Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@retter/rio-generator

Package Overview
Dependencies
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@retter/rio-generator - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

dist/languages/kotlin.d.ts

665

.test.js
const generator = require('./dist/index').generator
;(async () => {
const code = await generator({
classes: {
BackofficeUser:
'preAuthorizer: auth.preAuthorizer\nmethods:\n - method: createUser\n sync: true\n steps:\n - id: default\n handler: auth.createUser\n - method: signIn\n sync: true\n readonly: true\n steps:\n - id: default\n handler: auth.signIn\n - method: updatePassword\n sync: true\n steps:\n - id: default\n handler: auth.updatePassword\n',
CDH: 'getInstanceId: index.getInstanceId\nmethods:\n - method: query\n inputModel: QueryUserInput\n outputModel: QueryUserOutput\n sync: true\n readonly: true\n steps:\n - id: default\n handler: index.query\n',
MsisdnAuthenticator:
'preAuthorizer: index.preAuthorizer\ninit: \n inputModel: GetMsisdnAuthInput\n handler: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: sendOtp\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.sendOtp\n\n - method: validateOtp\n inputModel: ValidateOtpInput\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.validateOtp\n\n - method: signup\n tag: signup\n inputModel: SignUpInput\n sync: true\n steps:\n - id: default\n handler: index.signup\n',
Places: 'getInstanceId: index.getInstanceId\nmethods:\n - method: getPlaces\n sync: true\n readonly: true\n steps:\n - id: default\n handler: index.getPlaces\n',
StoreLocator:
'preAuthorizer: index.preAuthorizer\ninit: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: upsertStore\n sync: true\n steps:\n - id: default\n handler: store.upsertStore\n - method: removeStore\n sync: true\n steps:\n - id: default\n handler: store.removeStore\n - method: locate\n sync: true\n readonly: true\n steps:\n - id: default\n handler: store.locate\n',
User: 'preAuthorizer: auth.preAuthorizer\ninit: index.init\ndependencies:\n - utils\ngetState: index.getState\nmethods:\n\n - method: updateEmail\n tag: auth\n sync: true\n steps:\n - id: default\n handler: auth.updateEmail\n\n - method: validateEmail\n tag: auth\n sync: true\n steps:\n - id: default\n handler: auth.validateEmail\n\n - method: signup\n inputModel: UserSignUpInput\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.signup\n\n\n - method: setAvatar\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.setAvatar\n\n\n - method: getAvatar\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.getAvatar\n\n\n - method: updateProfile\n inputModel : UpdateProfileInput\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.updateProfile\n\n\n - method: getProfile\n tag: profile\n sync: true\n readOnly: true\n steps:\n - id: default\n handler: profile.getProfile\n\n - method: clearAddresses\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.clearAddresses\n\n - method: isSignupComplete\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.isSignupComplete\n\n - method: upsertAddress\n tag: address\n inputModel: Address\n sync: true\n steps:\n - id: default\n handler: address.upsertAddress\n\n - method: upsertInvoiceAddress\n tag: address\n inputModel: Address\n sync: true\n steps:\n - id: default\n handler: address.upsertInvoiceAddress\n\n - method: removeAddress\n tag: address\n inputModel: RemoveAddressInput\n sync: true\n steps:\n - id: default\n handler: address.removeAddress\n',
},
models: {
Address: {
properties: {
addressId: { type: 'string' },
title: { type: 'string', minLength: 1 },
nameSurname: { type: 'string' },
alternativeRecipient: { type: 'string' },
country: { type: 'string' },
city: { type: 'string' },
district: { type: 'string' },
neighborhood: { type: 'string' },
street: { type: 'string' },
building: { type: 'string' },
door: { type: 'string' },
floor: { type: 'string' },
postalCode: { type: 'string' },
phoneNumber: { type: 'string' },
location: { $ref: '#/$defs/Location' },
invoiceType: { enum: ['NONE', 'E-ARSIV', 'INDIVIDUAL', 'CORPORATE'], type: 'string', default: 'NONE' },
identityNo: { type: 'string', minLength: 1 },
companyName: { type: 'string', minLength: 1 },
taxNo: { type: 'string', minLength: 1 },
taxOffice: { type: 'string', minLength: 1 },
text: { type: 'string' },
createdAt: { type: 'number' },
updatedAt: { type: 'number' },
const code = await generator(
{
classes: {
BackofficeUser:
'preAuthorizer: auth.preAuthorizer\nmethods:\n - method: createUser\n sync: true\n steps:\n - id: default\n handler: auth.createUser\n - method: signIn\n sync: true\n readonly: true\n steps:\n - id: default\n handler: auth.signIn\n - method: updatePassword\n sync: true\n steps:\n - id: default\n handler: auth.updatePassword\n',
CDH: 'getInstanceId: index.getInstanceId\nmethods:\n - method: query\n inputModel: QueryUserInput\n outputModel: QueryUserOutput\n sync: true\n readonly: true\n steps:\n - id: default\n handler: index.query\n',
Homepage:
'preAuthorizer: index.preAuthorizer\ninit: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n\n - method: getHome\n tag: default\n inputModel: GetHomepageInput\n outputModel: GetHomepageOutput\n sync: true\n steps:\n - id: default\n handler: index.getHome\n \n - method: upsertHomeData\n tag: default\n inputModel: UpsertHomepageInput\n sync: true\n steps:\n - id: default\n handler: index.upsertHomeData\n',
MsisdnAuthenticator:
'preAuthorizer: index.preAuthorizer\ninit: \n inputModel: GetMsisdnAuthInput\n handler: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: sendOtp\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.sendOtp\n\n - method: validateOtp\n inputModel: ValidateOtpInput\n outputModel: ValidateOtpOutput\n tag: otp\n sync: true\n steps:\n - id: default\n handler: index.validateOtp\n\n - method: signup\n tag: signup\n inputModel: SignUpInput\n sync: true\n steps:\n - id: default\n handler: index.signup\n',
Places: 'getInstanceId: index.getInstanceId\nmethods:\n - method: getPlaces\n sync: true\n readonly: true\n steps:\n - id: default\n handler: index.getPlaces\n',
Product:
'preAuthorizer: index.preAuthorizer\ninit: product.upsert\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: get\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.getProduct\n - method: update\n tag: update\n sync: true\n steps:\n - id: default\n handler: product.upsert\n - method: uploadImage\n input: UploadImageInput\n tag: test\n sync: true\n steps:\n - id: default\n handler: product.uploadImage\n inputModel: UploadImageInput\n - method: getImage\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.getImage\n',
ProductManager:
'preAuthorizer: index.preAuthorizer\ninit: index.init\ngetState: index.getState\ngetInstanceId: index.getInstanceId\nmethods:\n - method: getConfig\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: config.get\n - method: updateConfig\n inputModel: ConfigInput\n tag: test\n sync: true\n steps:\n - id: default\n handler: config.update\n - method: upsertAttribute\n tag: test\n sync: true\n steps:\n - id: default\n handler: attribute.upsert\n inputModel: AttributeInput\n - method: removeAttribute\n inputModel: RemoveAttributeInput\n tag: test\n sync: true\n steps:\n - id: default\n handler: attribute.remove\n - method: listAttributes\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: attribute.list\n - method: upsertCategory\n tag: test\n sync: true\n steps:\n - id: default\n handler: category.handler\n inputModel: UpsertCategoryInput\n - method: removeCategory\n tag: test\n sync: true\n steps:\n - id: default\n handler: category.handler\n inputModel: RemoveCategoryInput\n - method: addImageToCategory\n tag: test\n sync: true\n steps:\n - id: default\n handler: category.handler\n inputModel: AddImageToCategoryInput\n - method: listCategories\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: category.handler\n - method: getCategoryTree\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: category.handler\n - method: getCategoryImage\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: category.handler\n - method: syncProduct\n tag: test\n sync: false\n steps:\n - id: default\n handler: product.syncProduct\n - method: listProducts\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.list\n - method: importProducts\n tag: test\n sync: false\n steps:\n - id: default\n handler: product.importProducts\n - method: syncProducts\n tag: test\n sync: false\n steps:\n - id: default\n handler: product.syncProducts\n - method: search\n tag: test\n sync: true\n steps:\n - id: default\n handler: product.search\n inputModel: SearchListingProductsInput\n - method: triggerExport\n tag: test\n sync: true\n steps:\n - id: default\n handler: product.triggerExport\n - method: exporter\n tag: test\n sync: false\n steps:\n - id: default\n handler: product.exporter\n - method: getFile\n tag: test\n sync: true\n readonly: true\n steps:\n - id: default\n handler: product.getFile\n',
User: 'preAuthorizer: auth.preAuthorizer\ninit: index.init\ndependencies:\n - utils\ngetState: index.getState\nmethods:\n\n - method: updateEmail\n tag: auth\n sync: true\n steps:\n - id: default\n handler: auth.updateEmail\n\n - method: validateEmail\n tag: auth\n sync: true\n steps:\n - id: default\n handler: auth.validateEmail\n\n - method: signup\n inputModel: UserSignUpInput\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.signup\n\n\n # - method: setAvatar\n # tag: profile\n # sync: true\n # steps:\n # - id: default\n # handler: profile.setAvatar\n\n\n # - method: getAvatar\n # tag: profile\n # sync: true\n # steps:\n # - id: default\n # handler: profile.getAvatar\n\n\n - method: updateProfile\n inputModel : UpdateProfileInput\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.updateProfile\n\n\n # - method: getProfile\n # tag: profile\n # sync: true\n # readOnly: true\n # steps:\n # - id: default\n # handler: profile.getProfile\n\n # - method: clearAddresses\n # tag: profile\n # sync: true\n # steps:\n # - id: default\n # handler: profile.clearAddresses\n\n - method: isSignupComplete\n tag: profile\n sync: true\n steps:\n - id: default\n handler: profile.isSignupComplete\n\n - method: upsertAddress\n tag: address\n inputModel: Address\n sync: true\n steps:\n - id: default\n handler: address.upsertAddress\n\n - method: removeAddress\n tag: address\n inputModel: RemoveAddressInput\n sync: true\n steps:\n - id: default\n handler: address.removeAddress\n',
},
models: {
AddImageToCategoryInput: {
type: 'object',
properties: { id: { type: 'string' }, content: { type: 'string' } },
required: ['id', 'content'],
additionalProperties: false,
},
allOf: [
{
if: { properties: { invoiceType: { const: 'NONE' } } },
then: { required: ['title', 'country', 'city', 'district', 'neighborhood', 'street', 'building', 'door', 'floor'] },
Address: {
properties: {
addressId: { type: 'string' },
title: { type: 'string', minLength: 1 },
nameSurname: { type: 'string' },
alternativeRecipient: { type: 'string' },
country: { type: 'string' },
city: { type: 'string' },
district: { type: 'string' },
neighborhood: { type: 'string' },
street: { type: 'string' },
building: { type: 'string' },
door: { type: 'string' },
floor: { type: 'string' },
postalCode: { type: 'string' },
phoneNumber: { type: 'string' },
location: { $ref: '#/$defs/Location' },
invoiceType: { enum: ['NONE', 'E-ARSIV', 'INDIVIDUAL', 'CORPORATE'], type: 'string', default: 'NONE' },
identityNo: { type: 'string', minLength: 1 },
companyName: { type: 'string', minLength: 1 },
taxNo: { type: 'string', minLength: 1 },
taxOffice: { type: 'string', minLength: 1 },
text: { type: 'string' },
createdAt: { type: 'number' },
updatedAt: { type: 'number' },
},
{
if: { properties: { invoiceType: { const: 'E-ARSIV' } } },
then: {
required: ['title', 'country', 'city', 'district', 'neighborhood', 'street', 'building', 'door', 'floor', 'identityNo'],
allOf: [
{
if: { properties: { invoiceType: { const: 'NONE' } } },
then: { required: ['title', 'country', 'city', 'district', 'neighborhood', 'street', 'building', 'door', 'floor'] },
},
{
if: { properties: { invoiceType: { const: 'E-ARSIV' } } },
then: {
required: [
'title',
'country',
'city',
'district',
'neighborhood',
'street',
'building',
'door',
'floor',
'identityNo',
],
},
},
{
if: { properties: { invoiceType: { const: 'CORPORATE' } } },
then: {
required: [
'title',
'country',
'city',
'district',
'neighborhood',
'street',
'building',
'door',
'floor',
'identityNo',
'companyName',
'taxNo',
'taxOffice',
],
},
},
],
type: 'object',
},
AttributeInput: {
type: 'object',
properties: {
_createdBy: { type: 'string' },
_updatedBy: { type: 'string' },
_createdAt: { type: 'number' },
_updatedAt: { type: 'number' },
id: { type: 'string', minLength: 1 },
name: { type: 'object', additionalProperties: { type: 'string' } },
type: { type: 'string', enum: ['string', 'number', 'boolean', 'array', 'enum', 'record'] },
default: {},
isRequired: { type: 'boolean', default: false },
isLocalized: { type: 'boolean', default: false },
options: { type: 'array', items: { type: 'string' } },
listing: { type: 'boolean', default: false },
},
{
if: { properties: { invoiceType: { const: 'CORPORATE' } } },
then: {
required: [
'title',
'country',
'city',
'district',
'neighborhood',
'street',
'building',
'door',
'floor',
'identityNo',
'companyName',
'taxNo',
'taxOffice',
],
required: ['id', 'name', 'type'],
additionalProperties: false,
},
ConfigInput: {
type: 'object',
properties: {
locales: { type: 'array', items: { type: 'string', enum: ['tr_TR', 'en_US', 'ru_RU'] }, minItems: 1 },
rootCategoryId: { type: 'string', default: 'master' },
},
required: ['locales'],
additionalProperties: false,
},
FindNearestStoreInput: {
type: 'object',
description: 'User coordinate',
properties: { lat: { type: 'number' }, lng: { type: 'number' } },
required: ['lat', 'lng'],
},
GetHomepageInput: {
type: 'object',
description: "A client calls Homepage class's getHome method with this input.",
properties: {
segment: { type: 'string' },
storeId: { type: 'string' },
cacheDuration: { type: 'number' },
platform: { type: 'string', enum: ['WEB', 'IOS', 'ANDROID'] },
},
required: ['platform'],
},
GetHomepageOutput: {
type: 'object',
description: 'Home page model describing what to show on clients home page.',
properties: {
stories: { type: 'array', items: { $ref: '#/$defs/HomepageStory' } },
banners: { type: 'array', items: { $ref: '#/$defs/HomepageBanner' } },
},
required: ['stories', 'banners'],
},
GetImageInput: {
type: 'object',
properties: {
id: { type: 'string' },
width: { type: 'number', default: 128 },
height: { type: 'number', default: 128 },
quality: { type: 'number', minimum: 10, maximum: 100, default: 25 },
fit: { type: 'string', enum: ['contain', 'cover', 'fill', 'inside', 'outside'], default: 'inside' },
},
required: ['id'],
additionalProperties: false,
},
GetMsisdnAuthInput: {
properties: { msisdn: { type: 'string', minLength: 12, maxLength: 12, pattern: '^[0-9]*$' } },
required: ['msisdn'],
type: 'object',
},
HomepageBanner: {
required: ['title', 'imageUrl'],
allOf: [{ $ref: '#/$defs/HomepageBaseModel' }],
description: 'An object representing a banner in home page of the app.',
type: 'object',
properties: { imageUrl: { type: 'string' }, title: { type: 'string' } },
},
HomepageBaseModel: {
required: [],
properties: {
excludeSegments: { type: 'array', items: { type: 'string' } },
includeSegments: { type: 'array', items: { type: 'string' } },
expireDate: { type: 'number' },
excludeStores: { type: 'array', items: { type: 'string' } },
includeStores: { items: { type: 'string' }, type: 'array' },
},
description: '',
type: 'object',
},
HomepageStory: {
type: 'object',
description: 'An object representing a story in home page of the app.',
properties: { title: { type: 'string' }, imageUrl: { type: 'string' }, isStarred: { type: 'boolean' } },
allOf: [{ $ref: '#/$defs/HomepageBaseModel' }],
required: ['title', 'imageUrl', 'isStarred'],
},
IsSignUpCompleteOutput: {
properties: { isSignupComplete: { type: 'boolean' }, userId: { type: 'string' } },
required: ['userId', 'isSignupComplete'],
type: 'object',
},
Location: { properties: { lat: { type: 'number' }, lng: { type: 'number' } }, required: ['lat', 'lng'], type: 'object' },
Product: {
type: 'object',
properties: {
_createdBy: { type: 'string' },
_updatedBy: { type: 'string' },
_createdAt: { type: 'number' },
_updatedAt: { type: 'number' },
id: { type: 'string' },
isEnabled: { type: 'boolean', default: true },
hash: { type: 'string' },
images: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
tags: { type: 'array', items: { type: 'string' }, default: [] },
url: { type: 'string' },
},
required: ['id'],
additionalProperties: false,
},
default: [],
},
attributes: { type: 'object', additionalProperties: {} },
},
],
additionalProperties: false,
type: 'object',
},
GetMsisdnAuthInput: {
properties: { msisdn: { type: 'string', minLength: 12, maxLength: 12, pattern: '^[0-9]*$' } },
required: ['msisdn'],
type: 'object',
},
IsSignUpCompleteOutput: {
properties: { isSignupComplete: { type: 'boolean' }, userId: { type: 'string' } },
required: ['userId', 'isSignupComplete'],
type: 'object',
},
Location: { properties: { lat: { type: 'number' }, lng: { type: 'number' } }, required: ['lat', 'lng'], type: 'object' },
QueryUserInput: { properties: { msisdn: { type: 'string', minLength: 10, maxLength: 10 } }, required: ['msisdn'], type: 'object' },
QueryUserOutput: { properties: { customerId: { type: 'string' } }, required: ['customerId'], type: 'object' },
RemoveAddressInput: { properties: { addressId: { type: 'string', minLength: 1 } }, required: ['addressId'], type: 'object' },
SignUpInput: {
properties: {
signupToken: { type: 'string', minLength: 1 },
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
email: { type: 'string', format: 'email' },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
address: { $ref: '#/$defs/Address' },
required: ['id'],
additionalProperties: false,
},
required: ['firstName', 'lastName', 'email', 'birthdate', 'gender', 'address'],
type: 'object',
},
SigninInput: { properties: { password: { type: 'string', minLenght: 8 } }, required: ['password'], type: 'object' },
UpdateEmailInput: { properties: { email: { type: 'string', format: 'email' } }, required: ['email'], type: 'object' },
UpdatePasswordInput: {
properties: { oldPassword: { type: 'string', minLenght: 8 }, password: { type: 'string', minLenght: 8 } },
required: ['oldPassword', 'password'],
type: 'object',
},
UpdateProfileInput: {
properties: {
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
ProductInitInput: {
type: 'object',
properties: { id: { type: 'string', minLength: 1 } },
required: ['id'],
additionalProperties: true,
},
required: ['firstName', 'lastName', 'birthdate', 'gender'],
type: 'object',
},
UserSignUpInput: {
properties: {
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
email: { type: 'string', format: 'email' },
msisdn: { type: 'string', minLength: 12, maxLength: 12 },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
ProductUpdateInput: {
type: 'object',
properties: { attributes: { type: 'object' } },
required: ['attributes'],
additionalProperties: true,
},
required: ['firstName', 'lastName', 'email', 'msisdn', 'birthdate', 'gender'],
type: 'object',
QueryUserInput: {
properties: { msisdn: { type: 'string', minLength: 12, maxLength: 12, pattern: '^[0-9]*$' } },
required: ['msisdn'],
type: 'object',
},
QueryUserOutput: { properties: { customerId: { type: 'string' } }, required: ['customerId'], type: 'object' },
RemoveAddressInput: { properties: { addressId: { type: 'string', minLength: 1 } }, required: ['addressId'], type: 'object' },
RemoveAttributeInput: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'], additionalProperties: false },
RemoveCategoryInput: { type: 'object', properties: { id: { type: 'string' } }, required: ['id'], additionalProperties: false },
SayHelloInput: {
type: 'object',
properties: {
firstName: { type: 'string', description: "The person's first name." },
lastName: { type: 'string', description: "The person's last name." },
age: { description: 'Age in years which must be equal to or greater than zero.', type: 'integer', minimum: 0 },
},
},
SearchListingProductsInput: {
type: 'object',
properties: {
q: { type: 'string' },
size: { type: 'number', minimum: 0, maximum: 50, default: 10 },
from: { type: 'number', minimum: 0, default: 0 },
},
additionalProperties: false,
},
SignUpInput: {
properties: {
signupToken: { type: 'string', minLength: 1 },
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
email: { type: 'string', format: 'email' },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
},
required: ['firstName', 'lastName', 'email', 'birthdate', 'gender', 'signupToken'],
type: 'object',
},
SigninInput: { properties: { password: { type: 'string', minLength: 8 } }, required: ['password'], type: 'object' },
StoreDecreaseStockInput: { type: 'array', items: { $ref: '#/$defs/StoreIncreaseDecreaseItem' } },
StoreGetInstanceIdInput: { type: 'object', properties: { storeId: { type: 'string' } }, required: ['storeId'] },
StoreGetProductBySku: { type: 'array', items: { type: 'string' } },
StoreIncreaseDecreaseItem: {
type: 'object',
properties: { sku: { type: 'string' }, quantity: { type: 'integer', minimum: 1 } },
required: ['sku', 'quantity'],
},
StoreIncreaseStockInput: { type: 'array', items: { $ref: '#/$defs/StoreIncreaseDecreaseItem' } },
StoreInfo: {
type: 'object',
properties: {
storeId: { type: 'string' },
lat: { type: 'number' },
lng: { type: 'number' },
radiusInMeter: { type: 'integer' },
isDeleted: { type: 'boolean', default: false },
},
required: ['storeId', 'lat', 'lng', 'radiusInMeter'],
},
StoreProduct: {
type: 'object',
properties: {
stock: { type: 'integer', minimum: 0 },
isDisabled: { type: 'boolean', default: false },
prices: { $ref: '#/$defs/StoreProductPrice' },
},
},
StoreProductDeleteInput: { type: 'object', properties: { sku: { type: 'string' } }, required: ['sku'] },
StoreProductPrice: {
type: 'object',
patternProperties: {
'[a-zA-Z0-9_]': {
type: 'object',
properties: { normal: { type: 'integer', minimum: 0 }, discounted: { type: 'integer', minimum: 0 } },
required: ['normal', 'discounted'],
},
},
additionalProperties: false,
},
StoreProductPriceSyncObject: {
type: 'object',
properties: { storeId: { type: 'string' }, prices: { $ref: '#/$defs/StoreProductPrice' }, sku: { type: 'string' } },
required: ['prices', 'sku', 'storeId'],
},
StoreProductStockSyncObject: {
type: 'object',
properties: { storeId: { type: 'string' }, stock: { type: 'integer' }, sku: { type: 'string' } },
required: ['stock', 'sku', 'storeId'],
},
StoreSetProductPrice: {
type: 'object',
properties: { prices: { $ref: '#/$defs/StoreProductPrice' }, sku: { type: 'string' } },
required: ['prices', 'sku'],
},
StoreSetProductStock: {
type: 'object',
properties: { stock: { type: 'integer', minimum: 0 }, sku: { type: 'string' } },
required: ['stock', 'sku'],
},
StoreSkuInput: { type: 'object', properties: { sku: { type: 'string' } }, required: ['sku'] },
StoreUpsertFeedURLs: {
type: 'object',
properties: {
storesUrl: { type: 'string', format: 'uri' },
stocksUrl: { type: 'string', format: 'uri' },
pricesUrl: { type: 'string', format: 'uri' },
},
},
StoreUpsertOrderInput: { type: 'object', properties: { orderId: { type: 'string' }, status: { type: 'string' } } },
SyncStoresInput: {
type: 'object',
properties: { url: { description: 'Url method should be get and url response should be json string', type: 'string' } },
required: ['url'],
},
UpdateConfigInput: {
type: 'object',
properties: { locales: { type: 'array', minItems: 1, items: { type: 'string', enum: ['tr_TR', 'en_US', 'ru_RU'] } } },
required: ['locales'],
additionalProperties: false,
},
UpdateEmailInput: { properties: { email: { type: 'string', format: 'email' } }, required: ['email'], type: 'object' },
UpdatePasswordInput: {
properties: { oldPassword: { type: 'string', minLength: 8 }, password: { type: 'string', minLength: 8 } },
required: ['oldPassword', 'password'],
type: 'object',
},
UpdateProductInput: {
type: 'object',
properties: {
_createdBy: { type: 'string' },
_updatedBy: { type: 'string' },
_createdAt: { type: 'number' },
_updatedAt: { type: 'number' },
id: { type: 'string' },
isEnabled: { type: 'boolean', default: true },
_hash: { type: 'string' },
images: {
type: 'array',
items: {
type: 'object',
properties: { id: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } }, url: { type: 'string' } },
required: ['id'],
additionalProperties: false,
},
default: [],
},
attributes: { type: 'object', additionalProperties: {} },
categories: {
type: 'array',
items: {
type: 'object',
properties: { id: { type: 'string' }, name: { type: 'object', additionalProperties: { type: 'string' } } },
required: ['id', 'name'],
additionalProperties: false,
},
default: [],
},
},
required: ['id'],
additionalProperties: false,
},
UpdateProductOutput: {
type: 'object',
properties: {
_createdBy: { type: 'string' },
_updatedBy: { type: 'string' },
_createdAt: { type: 'number' },
_updatedAt: { type: 'number' },
id: { type: 'string' },
isEnabled: { type: 'boolean', default: true },
_hash: { type: 'string' },
images: {
type: 'array',
items: {
type: 'object',
properties: { id: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } }, url: { type: 'string' } },
required: ['id'],
additionalProperties: false,
},
default: [],
},
attributes: { type: 'object', additionalProperties: {} },
categories: {
type: 'array',
items: {
type: 'object',
properties: { id: { type: 'string' }, name: { type: 'object', additionalProperties: { type: 'string' } } },
required: ['id', 'name'],
additionalProperties: false,
},
default: [],
},
},
required: ['id'],
additionalProperties: false,
},
UpdateProfileInput: {
properties: {
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
},
required: ['firstName', 'lastName', 'birthdate', 'gender'],
type: 'object',
},
UploadImageInput: {
type: 'object',
properties: { content: { type: 'string' }, tags: { type: 'array', items: { type: 'string' } } },
required: ['content'],
additionalProperties: false,
},
UpsertCategoryInput: {
type: 'object',
properties: {
id: { type: 'string' },
parentId: { type: ['string', 'null'], default: null },
name: { type: 'object', additionalProperties: { type: 'string' } },
description: { type: 'object', additionalProperties: { type: 'string' } },
sortingOrder: { type: 'number', default: 0 },
images: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
tags: { type: 'array', items: { type: 'string' }, default: [] },
url: { type: 'string' },
},
required: ['id'],
additionalProperties: false,
},
default: [],
},
},
required: ['id', 'name'],
additionalProperties: false,
},
UpsertHomepageInput: {
description: "Ecom client calls Homepage class's upsertHomepage method with this input.",
type: 'object',
required: ['stories', 'platform'],
properties: {
platform: { type: 'string', enum: ['WEB', 'IOS', 'ANDROID'] },
stories: { items: { $ref: '#/$defs/HomepageStory' }, type: 'array' },
banners: { items: { $ref: '#/$defs/HomepageBanner' }, type: 'array' },
},
},
UpsertProductInput: {
type: 'object',
properties: {
_createdBy: { type: 'string' },
_updatedBy: { type: 'string' },
_createdAt: { type: 'number' },
_updatedAt: { type: 'number' },
id: { type: 'string' },
isEnabled: { type: 'boolean', default: true },
hash: { type: 'string' },
images: {
type: 'array',
items: {
type: 'object',
properties: {
id: { type: 'string' },
tags: { type: 'array', items: { type: 'string' }, default: [] },
url: { type: 'string' },
},
required: ['id'],
additionalProperties: false,
},
default: [],
},
attributes: { type: 'object', additionalProperties: {} },
},
required: ['id'],
additionalProperties: false,
},
UserSignUpInput: {
properties: {
firstName: { type: 'string', minLength: 2 },
lastName: { type: 'string', minLength: 2 },
email: { type: 'string', format: 'email' },
msisdn: { type: 'string', minLength: 12, maxLength: 12, pattern: '^[0-9]*$' },
birthdate: { type: 'string', format: 'date' },
gender: { type: 'string', enum: ['male', 'female'] },
contactCampaign: { type: 'boolean', default: false },
},
required: ['firstName', 'lastName', 'email', 'msisdn', 'birthdate', 'gender'],
type: 'object',
},
ValidateOtpInput: { properties: { otp: { type: 'string', minLength: 6, maxLength: 6 } }, required: ['otp'], type: 'object' },
ValidateOtpOutput: {
properties: {
customToken: { type: 'string' },
signupToken: { type: 'string' },
authStatus: {
enum: ['SIGNUP_REQUIRED', 'SUCCESS', 'AUTH_FAILED_INVALID_OTP', 'TOO_MANY_ATTEMPTS'],
type: 'string',
default: 'AUTH_FAILED_INVALID_OTP',
},
},
type: 'object',
required: ['authStatus'],
},
},
ValidateOtpInput: { properties: { otp: { type: 'string', minLength: 6, maxLength: 6 } }, required: ['otp'], type: 'object' },
},
})
'swift-client',
)
console.log(code)
})()
})()

11

dist/index.d.ts

@@ -0,8 +1,5 @@

import { Classes, Models, SupportedProgrammingLanguage } from './utils';
export declare function generator(params: {
classes: {
[key: string]: string;
};
models: {
[key: string]: any;
};
}): Promise<string>;
classes: Classes;
models: Models;
}, language?: SupportedProgrammingLanguage): Promise<string>;

@@ -49,54 +49,30 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generator = void 0;
var yaml_1 = __importDefault(require("yaml"));
var quicktype_core_1 = require("quicktype-core");
function quicktypeJSONSchema(typeName, jsonSchemaString) {
var utils_1 = require("./utils");
var typescript_1 = require("./languages/typescript");
var kotlin_1 = require("./languages/kotlin");
var swift_1 = require("./languages/swift");
function generator(params, language) {
if (language === void 0) { language = 'typescript'; }
return __awaiter(this, void 0, void 0, function () {
var schemaInput, inputData, ts, index;
var classes, models, lines, interfaces;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
schemaInput = new quicktype_core_1.JSONSchemaInput(new quicktype_core_1.FetchingJSONSchemaStore());
// We could add multiple schemas for multiple types,
// but here we're just making one type from JSON schema.
return [4 /*yield*/, schemaInput.addSource({ name: typeName, schema: jsonSchemaString })];
case 1:
// We could add multiple schemas for multiple types,
// but here we're just making one type from JSON schema.
_a.sent();
inputData = new quicktype_core_1.InputData();
inputData.addInput(schemaInput);
ts = new quicktype_core_1.TypeScriptTargetLanguage();
index = ts.optionDefinitions.findIndex(function (i) { return i.name === 'just-types'; });
ts.optionDefinitions[index].defaultValue = true;
return [4 /*yield*/, quicktype_core_1.quicktype({
inputData: inputData,
lang: ts,
allPropertiesOptional: false
})];
case 2: return [2 /*return*/, _a.sent()];
}
});
});
}
function generator(params) {
return __awaiter(this, void 0, void 0, function () {
var classes, models, lines, ts, blocks;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
classes = params.classes, models = params.models;
return [4 /*yield*/, quicktypeJSONSchema('RioModels', JSON.stringify({ properties: __assign({}, models), $defs: __assign({}, models) }))];
return [4 /*yield*/, utils_1.quickTypeJSONSchema('RioModels', JSON.stringify({ properties: __assign({}, models), $defs: __assign({}, models) }), language)];
case 1:
lines = (_a.sent()).lines;
ts = lines.join('\n') + '\n\n';
blocks = Object.keys(classes).map(function (classId) { return renderClass(classId, classes[classId]); });
return [2 /*return*/, "\n// This is an auto generated file!\n\nimport RDK, { KeyValueString, GetInstance, CloudObjectResponse } from '@retter/rdk'\n\ninterface RetterRequest<T> extends Omit<GetInstance, 'classId'|'body'> {\n body?: T\n}\n\ninterface RetterResponse<T> extends CloudObjectResponse {\n body?: T\n}\n\n" + ts.trim() + "\n\nexport interface RDKOptions {\n httpMethod?: string\n queryStringParams?: KeyValueString\n headers?: KeyValueString\n}\n\nexport namespace Classes {\n " + blocks.reduce(function (f, i) {
f = f + '\n\n' + i;
return f.trim();
}, '') + "\n}\n"];
interfaces = lines.join('\n');
switch (language) {
case 'kotlin-client':
return [2 /*return*/, kotlin_1.renderKotlin(classes, interfaces)];
case 'swift-client':
return [2 /*return*/, swift_1.renderSwift(classes, interfaces)];
case 'typescript':
default:
return [2 /*return*/, typescript_1.renderTypescript(classes, interfaces)];
}
return [2 /*return*/];
}

@@ -107,19 +83,2 @@ });

exports.generator = generator;
function capitalizeFirstLetter(str) {
if (!str || str === 'any')
return 'any';
return str.charAt(0).toUpperCase() + str.slice(1);
}
function renderClass(classId, template) {
template = yaml_1.default.parse(template);
var methods = [];
for (var _i = 0, _a = template.methods; _i < _a.length; _i++) {
var method = _a[_i];
var methodName = method.method;
var description = method.description || 'calls ' + methodName + ' on ' + classId;
methods.push(("\n/**\n * " + description + "\n * @param {" + capitalizeFirstLetter(method.inputModel) + "} body - payload\n * @param {RDKOptions} options - other method call parameters\n * @returns {Promise<RetterResponse<" + capitalizeFirstLetter(method.outputModel) + ">>}\n */\npublic async " + methodName + "(body: " + capitalizeFirstLetter(method.inputModel) + ", options?: RDKOptions): Promise<RetterResponse<" + capitalizeFirstLetter(method.outputModel) + "> | undefined> {\n return await this._rdk.methodCall({\n ...options,\n classId: '" + classId + "',\n instanceId: this.instanceId,\n lookupKey: this.lookupKey,\n methodName: '" + methodName + "',\n body,\n })\n}\n ").trim());
}
var getInstanceInputType = template.init && typeof template.init !== 'string' ? template.init.inputModel : 'any';
return ("\n/** " + (template.description || classId + ' Class') + " */\nexport class " + classId + " {\n private readonly _rdk: RDK\n private readonly lookupKey?: { name: string; value: string }\n public readonly instanceId?: string\n public isNewInstance?: boolean\n\n /**\n * use this constructor if you know the instance id.\n * @param {string} instanceId - instance id\n * @returns {" + classId + "}\n */\n public constructor(instanceId: string);\n /**\n * use this constructor if you know only the look up key.\n * @param {string} name - look up key name\n * @param {string} value - look up key value\n * @returns {" + classId + "}\n */\n public constructor(name: string, value: string);\n public constructor(...args: string[]) {\n this.isNewInstance = false\n this._rdk = new RDK()\n if (args.length === 0 || args.length > 2) {\n throw new Error('Invalid number of arguments.');\n }\n if (args.length === 2) this.lookupKey = { name: args[0], value: args[1] }\n else this.instanceId = args[0]\n }\n\n get rdk() { return this._rdk }\n\n /**\n * Gets a cloud object instance or creates new one\n * @param {RetterRequest<" + capitalizeFirstLetter(getInstanceInputType) + ">} options - instance options\n * @returns {Promise<" + classId + ">}\n */\n public static async getInstance(options?: RetterRequest<" + capitalizeFirstLetter(getInstanceInputType) + ">): Promise<" + classId + "> {\n const rdk = new RDK()\n const result = await rdk.getInstance({\n ...options,\n classId: '" + classId + "',\n })\n if (result && 200 <= result.statusCode && result.statusCode < 300) {\n const _instance = new " + classId + "(result.body.instanceId)\n _instance.isNewInstance = !!result.body.newInstance\n return _instance\n }\n\n throw new Error(result?.body?.message || 'failed')\n }\n\n " + methods.join('\n\n') + "\n}\n ").trim();
}
//# sourceMappingURL=index.js.map
{
"name": "@retter/rio-generator",
"version": "1.1.3",
"version": "1.2.0",
"description": "retter io proxy class helper generator",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,149 +0,19 @@

import YAML from 'yaml'
import { quicktype, InputData, TypeScriptTargetLanguage, JSONSchemaInput, FetchingJSONSchemaStore } from 'quicktype-core'
import { Classes, Models, quickTypeJSONSchema, SupportedProgrammingLanguage } from './utils'
import { renderTypescript } from './languages/typescript'
import { renderKotlin } from './languages/kotlin'
import { renderSwift } from './languages/swift'
async function quicktypeJSONSchema(typeName: string, jsonSchemaString: string) {
const schemaInput = new JSONSchemaInput(new FetchingJSONSchemaStore())
// We could add multiple schemas for multiple types,
// but here we're just making one type from JSON schema.
await schemaInput.addSource({ name: typeName, schema: jsonSchemaString })
const inputData = new InputData()
inputData.addInput(schemaInput)
const ts = new TypeScriptTargetLanguage()
const index = ts.optionDefinitions.findIndex(i => i.name === 'just-types')
ts.optionDefinitions[index].defaultValue = true
return await quicktype({
inputData,
lang: ts,
allPropertiesOptional: false
})
}
export async function generator(params: { classes: { [key: string]: string }; models: { [key: string]: any } }) {
export async function generator(params: { classes: Classes; models: Models }, language: SupportedProgrammingLanguage = 'typescript'): Promise<string> {
const { classes, models } = params
const { lines } = await quicktypeJSONSchema('RioModels', JSON.stringify({ properties: { ...models }, $defs: { ...models } }))
const ts = lines.join('\n') + '\n\n'
const blocks: any[] = Object.keys(classes).map((classId) => renderClass(classId, classes[classId]))
return `
// This is an auto generated file!
import RDK, { KeyValueString, GetInstance, CloudObjectResponse } from '@retter/rdk'
interface RetterRequest<T> extends Omit<GetInstance, 'classId'|'body'> {
body?: T
}
interface RetterResponse<T> extends CloudObjectResponse {
body?: T
}
${ts.trim()}
export interface RDKOptions {
httpMethod?: string
queryStringParams?: KeyValueString
headers?: KeyValueString
}
export namespace Classes {
${blocks.reduce((f, i) => {
f = f + '\n\n' + i
return f.trim()
}, '')}
}
`
}
function capitalizeFirstLetter(str?: string) {
if (!str || str === 'any') return 'any'
return str.charAt(0).toUpperCase() + str.slice(1)
}
function renderClass(classId: string, template: any) {
template = YAML.parse(template)
const methods: string[] = []
for (const method of template.methods) {
const methodName = method.method
const description = method.description || 'calls ' + methodName + ' on ' + classId
methods.push(
`
/**
* ${description}
* @param {${capitalizeFirstLetter(method.inputModel)}} body - payload
* @param {RDKOptions} options - other method call parameters
* @returns {Promise<RetterResponse<${capitalizeFirstLetter(method.outputModel)}>>}
*/
public async ${methodName}(body: ${capitalizeFirstLetter(method.inputModel)}, options?: RDKOptions): Promise<RetterResponse<${capitalizeFirstLetter(method.outputModel)}> | undefined> {
return await this._rdk.methodCall({
...options,
classId: '${classId}',
instanceId: this.instanceId,
lookupKey: this.lookupKey,
methodName: '${methodName}',
body,
})
}
`.trim(),
)
const { lines } = await quickTypeJSONSchema('RioModels', JSON.stringify({ properties: { ...models }, $defs: { ...models } }), language)
const interfaces = lines.join('\n')
switch (language) {
case 'kotlin-client':
return renderKotlin(classes, interfaces)
case 'swift-client':
return renderSwift(classes, interfaces)
case 'typescript':
default:
return renderTypescript(classes, interfaces)
}
const getInstanceInputType = template.init && typeof template.init !== 'string' ? template.init.inputModel : 'any'
return `
/** ${template.description || classId + ' Class'} */
export class ${classId} {
private readonly _rdk: RDK
private readonly lookupKey?: { name: string; value: string }
public readonly instanceId?: string
public isNewInstance?: boolean
/**
* use this constructor if you know the instance id.
* @param {string} instanceId - instance id
* @returns {${classId}}
*/
public constructor(instanceId: string);
/**
* use this constructor if you know only the look up key.
* @param {string} name - look up key name
* @param {string} value - look up key value
* @returns {${classId}}
*/
public constructor(name: string, value: string);
public constructor(...args: string[]) {
this.isNewInstance = false
this._rdk = new RDK()
if (args.length === 0 || args.length > 2) {
throw new Error('Invalid number of arguments.');
}
if (args.length === 2) this.lookupKey = { name: args[0], value: args[1] }
else this.instanceId = args[0]
}
get rdk() { return this._rdk }
/**
* Gets a cloud object instance or creates new one
* @param {RetterRequest<${capitalizeFirstLetter(getInstanceInputType)}>} options - instance options
* @returns {Promise<${classId}>}
*/
public static async getInstance(options?: RetterRequest<${capitalizeFirstLetter(getInstanceInputType)}>): Promise<${classId}> {
const rdk = new RDK()
const result = await rdk.getInstance({
...options,
classId: '${classId}',
})
if (result && 200 <= result.statusCode && result.statusCode < 300) {
const _instance = new ${classId}(result.body.instanceId)
_instance.isNewInstance = !!result.body.newInstance
return _instance
}
throw new Error(result?.body?.message || 'failed')
}
${methods.join('\n\n')}
}
`.trim()
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc